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/DeviceAssetUserController.java

92 lines
3.7 KiB
Java

package com.glxp.api.controller.dev;
import cn.hutool.core.util.IdUtil;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.annotation.Log;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BusinessType;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.dev.DeviceAssetUserEntity;
import com.glxp.api.req.inv.FilterInvUserRequest;
import com.glxp.api.req.system.DeleteDeviceFileRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.service.auth.CustomerService;
import com.glxp.api.service.dev.DeviceAssetUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* 设备相关人员
*/
@Slf4j
@RestController
public class DeviceAssetUserController extends BaseController {
@Resource
private DeviceAssetUserService deviceAssetUserService;
@Resource
private CustomerService customerService;
@AuthRuleAnnotation("")
@GetMapping("/inv/device/user/filter")
public BaseResponse filterDeviceUser(FilterInvUserRequest filterInvUserRequest) {
List<DeviceAssetUserEntity> deviceAssetUserEntityList
= deviceAssetUserService.filterDeviceUser(filterInvUserRequest);
PageInfo<DeviceAssetUserEntity> pageInfo;
pageInfo = new PageInfo<>(deviceAssetUserEntityList);
PageSimpleResponse<DeviceAssetUserEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(deviceAssetUserEntityList);
return ResultVOUtils.success(pageSimpleResponse);
}
@AuthRuleAnnotation("")
@PostMapping("/inv/info/insertDeviceUser")
@Log(title = "相关人员", businessType = BusinessType.INSERT)
public BaseResponse insertDeviceUser(@RequestBody DeviceAssetUserEntity deviceAssetUserEntity) {
String userId = customerService.getUserId()+ "";
Date now = new Date();
deviceAssetUserEntity.setCreateTime(now);
deviceAssetUserEntity.setUpdateTime(now);
deviceAssetUserEntity.setCreateUser(userId);
deviceAssetUserEntity.setUpdateUser(userId);
deviceAssetUserEntity.setId(IdUtil.getSnowflakeNextId());
boolean b = deviceAssetUserService.insertDeviceUser(deviceAssetUserEntity);
return ResultVOUtils.success("成功");
}
@AuthRuleAnnotation("")
@PostMapping("/inv/info/deleteDeviceUser")
public BaseResponse deleteDeviceUser(@RequestBody DeleteDeviceFileRequest deleteDeviceFileRequest) {
boolean b = deviceAssetUserService.deleteById(deleteDeviceFileRequest.getId());
return ResultVOUtils.success("成功");
}
@AuthRuleAnnotation("")
@PostMapping("/inv/info/updateDeviceUser")
@Log(title = "相关人员", businessType = BusinessType.UPDATE)
public BaseResponse updateDeviceUser(@RequestBody DeviceAssetUserEntity deviceAssetUserEntity) {
String userId = customerService.getUserId()+ "";
Date now = new Date();
deviceAssetUserEntity.setUpdateTime(now);
deviceAssetUserEntity.setUpdateUser(userId);
boolean b = deviceAssetUserService.updateDeviceUser(deviceAssetUserEntity);
if (b){
return ResultVOUtils.success("修改成功");
}else {
return ResultVOUtils.error("修改失败!");
}
}
}