You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-spms-java/src/main/java/com/glxp/api/controller/dev/DevicePlanDetailController....

131 lines
4.3 KiB
Java

package com.glxp.api.controller.dev;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.auth.AuthAdmin;
import com.glxp.api.entity.dev.DevicePlanDetailEntity;
import com.glxp.api.entity.dev.DevicePlanEntity;
import com.glxp.api.req.dev.DevicePlanDetailGroupQuery;
import com.glxp.api.req.dev.DevicePlanDetailParam;
import com.glxp.api.req.dev.DevicePlanDetailQuery;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.service.dev.DeviceInfoService;
import com.glxp.api.service.dev.DevicePlanDetailService;
import com.glxp.api.service.dev.DevicePlanService;
import com.glxp.api.vo.dev.DevicePlanDetailVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
*
* data: 2023/11/12
*/
@RestController
@RequestMapping
@RequiredArgsConstructor
@Slf4j
public class DevicePlanDetailController extends BaseController {
private final DeviceInfoService deviceInfoService;
private final DevicePlanService devicePlanService;
private final DevicePlanDetailService devicePlanDetailService;
/**
*
*
* @param query
* @return
*/
@AuthRuleAnnotation("")
@PostMapping("/udi/device/plan/detailGroup/page")
public BaseResponse pageGroup(@RequestBody @Valid DevicePlanDetailGroupQuery query) {
List<DevicePlanDetailVo> list = devicePlanDetailService.pageGroupVo(query);
PageInfo pageInfo = new PageInfo<>(list);
PageSimpleResponse page = new PageSimpleResponse();
page.setTotal(pageInfo.getTotal());
page.setList(pageInfo.getList());
return ResultVOUtils.success(page);
}
/**
*
*
* @param query
* @return
*/
@AuthRuleAnnotation("")
@PostMapping("/udi/device/plan/detail/page")
public BaseResponse pageGroup(@RequestBody @Valid DevicePlanDetailQuery query) {
List<DevicePlanDetailVo> list = devicePlanDetailService.pageVo(query);
PageInfo pageInfo = new PageInfo<>(list);
PageSimpleResponse page = new PageSimpleResponse();
page.setTotal(pageInfo.getTotal());
page.setList(pageInfo.getList());
return ResultVOUtils.success(page);
}
/**
*
*
* @param param
* @return id
*/
@AuthRuleAnnotation("")
@PostMapping("/udi/device/plan/detail/add")
public BaseResponse add(@RequestBody @Valid DevicePlanDetailParam param) {
DevicePlanEntity entity = null;
if (!param.valid(devicePlanService)) {
AuthAdmin user = super.getUser();
entity = param.getDevicePlanParam().getEntity(user);
devicePlanService.save(entity);
param.getDevicePlanParam().setPlanId(entity.getPlanId());
param.setPlanId(entity.getPlanId());
} else {
entity = devicePlanService.getById(param.getPlanId());
}
param.valid(devicePlanService);
List<DevicePlanDetailEntity> list = param.getEntity(deviceInfoService);
devicePlanDetailService.replaceBatch(list);
return ResultVOUtils.success(entity);
}
/**
*
*
* @param planId id
* @param productId id
*/
@AuthRuleAnnotation("")
@DeleteMapping("/udi/device/plan/detail/delByProductId/{planId}/{productId}")
public BaseResponse delByProductId(@PathVariable Long planId, @PathVariable Long productId) {
devicePlanDetailService.delByProductId(planId, productId);
return ResultVOUtils.successMsg("删除成功");
}
/**
*
*
* @param planId id
* @param deviceCode
*/
@AuthRuleAnnotation("")
@DeleteMapping("/udi/device/plan/detail/delByDeviceCode/{planId}/{deviceCode}")
public BaseResponse delByDeviceCode(@PathVariable Long planId, @PathVariable String deviceCode) {
devicePlanDetailService.delByDeviceCode(planId, deviceCode);
return ResultVOUtils.successMsg("删除成功");
}
}