feat(developer): 完善开发者选项CRUD与SN查询逻辑
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
package com.youlai.boot.device.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.youlai.boot.common.enums.ActionTypeEnum;
|
||||
import com.youlai.boot.common.enums.LogModuleEnum;
|
||||
import com.youlai.boot.common.result.PageResult;
|
||||
import com.youlai.boot.common.result.Result;
|
||||
import com.youlai.boot.device.model.form.DeveloperForm;
|
||||
import com.youlai.boot.device.model.query.DeveloperQuery;
|
||||
import com.youlai.boot.device.model.vo.DeveloperVO;
|
||||
import com.youlai.boot.device.service.DeveloperService;
|
||||
import com.youlai.boot.device.service.DeviceService;
|
||||
import com.youlai.boot.framework.annotation.Log;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 设备开发者选项前端控制层
|
||||
*
|
||||
* @author TTSTD
|
||||
* @since 2026-04-27
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "17.设备开发者选项")
|
||||
@RequestMapping("/api/v1/developers")
|
||||
public class DeveloperController {
|
||||
|
||||
private final DeveloperService developerService;
|
||||
|
||||
private final DeviceService deviceService;
|
||||
|
||||
@Operation(summary = "开发者选项分页列表")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasPerm('device:developer:list')")
|
||||
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.LIST)
|
||||
public PageResult<DeveloperVO> page(@ParameterObject DeveloperQuery queryParams) {
|
||||
IPage<DeveloperVO> result = developerService.page(queryParams);
|
||||
return PageResult.success(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取开发者选项表单数据")
|
||||
@GetMapping("/{id}/form")
|
||||
@PreAuthorize("@ss.hasPerm('device:developer:list')")
|
||||
public Result<DeveloperForm> getDeveloperForm(
|
||||
@Parameter(description = "开发者选项配置ID") @PathVariable Long id
|
||||
) {
|
||||
return Result.success(developerService.getDeveloperFormData(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "新增开发者选项配置")
|
||||
@PostMapping
|
||||
@PreAuthorize("@ss.hasPerm('device:developer:create')")
|
||||
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.INSERT)
|
||||
public Result<?> save(@RequestBody @Valid DeveloperForm developerForm) {
|
||||
return Result.judge(developerService.saveDeveloper(developerForm));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改开发者选项配置")
|
||||
@PutMapping("/{id}")
|
||||
@PreAuthorize("@ss.hasPerm('device:developer:update')")
|
||||
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.UPDATE)
|
||||
public Result<?> update(
|
||||
@Parameter(description = "开发者选项配置ID") @PathVariable Long id,
|
||||
@RequestBody @Valid DeveloperForm developerForm
|
||||
) {
|
||||
return Result.judge(developerService.updateDeveloper(id, developerForm));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除开发者选项配置")
|
||||
@DeleteMapping("/{ids}")
|
||||
@PreAuthorize("@ss.hasPerm('device:developer:delete')")
|
||||
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.DELETE)
|
||||
public Result<?> delete(
|
||||
@Parameter(description = "开发者选项配置ID,多个以英文逗号(,)分隔") @PathVariable String ids
|
||||
) {
|
||||
return Result.judge(developerService.deleteDevelopers(ids));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据设备序列号获取开发者选项开关")
|
||||
@GetMapping("/sn/{sn}")
|
||||
@PreAuthorize("@ss.hasPerm('device:developer:list')")
|
||||
public Result<Integer> getBySn(
|
||||
@Parameter(description = "设备序列号") @PathVariable String sn
|
||||
) {
|
||||
return Result.success(developerService.getDeveloperOptionsBySn(sn));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据设备序列号保存或更新开发者选项配置")
|
||||
@PutMapping("/sn/{sn}")
|
||||
@PreAuthorize("@ss.hasPerm('device:developer:update')")
|
||||
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.UPDATE)
|
||||
public Result<?> saveOrUpdateBySn(
|
||||
@Parameter(description = "设备序列号") @PathVariable String sn,
|
||||
@Parameter(description = "开发者选项开关(0关闭,1开启)") @RequestParam Integer developerOptions
|
||||
) {
|
||||
return Result.judge(developerService.saveOrUpdateBySn(sn, developerOptions));
|
||||
}
|
||||
|
||||
@Operation(summary = "推送开发者模式指令到设备")
|
||||
@PostMapping("/sn/{sn}/push")
|
||||
@PreAuthorize("@ss.hasPerm('device:developer:push')")
|
||||
@Log(module = LogModuleEnum.DEVICE, value = ActionTypeEnum.DEVELOPER)
|
||||
public Result<?> push(
|
||||
@Parameter(description = "设备序列号") @PathVariable String sn
|
||||
) {
|
||||
return Result.judge(deviceService.setDeviceDeveloper(sn));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user