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.
141 lines
5.1 KiB
Java
141 lines
5.1 KiB
Java
11 months ago
|
package com.glxp.api.controller.ud;
|
||
|
|
||
|
|
||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||
|
import com.github.pagehelper.Page;
|
||
|
import com.github.pagehelper.PageHelper;
|
||
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
||
|
import com.glxp.api.annotation.Log;
|
||
|
import com.glxp.api.common.enums.ResultEnum;
|
||
|
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.anno.AnncmntDevEntity;
|
||
|
import com.glxp.api.entity.auth.AuthAdmin;
|
||
|
import com.glxp.api.entity.ud.UdInfoEntity;
|
||
|
import com.glxp.api.entity.ud.UdProducePlanEntity;
|
||
|
import com.glxp.api.req.anno.AnncmntDevEntityRequest;
|
||
|
import com.glxp.api.req.system.DeleteRequest;
|
||
|
import com.glxp.api.req.ud.UdInfoEntityRequest;
|
||
|
import com.glxp.api.res.PageSimpleResponse;
|
||
|
import com.glxp.api.service.anno.AnncmntDevService;
|
||
|
import com.glxp.api.service.ud.UdInfoService;
|
||
|
import com.glxp.api.util.BeanCopyUtils;
|
||
|
import com.glxp.api.util.StringUtils;
|
||
|
import lombok.RequiredArgsConstructor;
|
||
|
import org.springframework.validation.BindingResult;
|
||
|
import org.springframework.validation.annotation.Validated;
|
||
|
import org.springframework.web.bind.annotation.*;
|
||
|
import springfox.documentation.annotations.ApiIgnore;
|
||
|
|
||
|
import javax.validation.Valid;
|
||
|
import java.util.Date;
|
||
|
import java.util.List;
|
||
|
|
||
|
/**
|
||
|
* 用户信息
|
||
|
*
|
||
|
*/
|
||
|
@ApiIgnore
|
||
|
@Validated
|
||
|
@RequiredArgsConstructor
|
||
|
@RestController
|
||
|
@RequestMapping("/ud/info")
|
||
|
public class UdInfoController extends BaseController {
|
||
|
|
||
|
private final UdInfoService udInfoService;
|
||
|
|
||
|
|
||
|
@GetMapping("/list")
|
||
|
public BaseResponse list(UdInfoEntityRequest request, BindingResult bindingResult) {
|
||
|
if (bindingResult.hasErrors()) {
|
||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||
|
}
|
||
|
int offset = (request.getPage() - 1) * request.getLimit();
|
||
|
Page<UdInfoEntity> pages = PageHelper.offsetPage(offset, request.getLimit());
|
||
|
List<UdInfoEntity> list = udInfoService.list(getQueryWrapper(request));
|
||
|
PageSimpleResponse<UdInfoEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
||
|
pageSimpleResponse.setTotal(pages.getTotal());
|
||
|
pageSimpleResponse.setList(list);
|
||
|
|
||
|
return ResultVOUtils.success(pageSimpleResponse);
|
||
|
}
|
||
|
|
||
|
@AuthRuleAnnotation("")
|
||
|
@PostMapping("/save")
|
||
|
@Log(title = "U盾管理", businessType = BusinessType.INSERT)
|
||
|
public BaseResponse save(@RequestBody UdInfoEntity entity,
|
||
|
BindingResult bindingResult) {
|
||
|
|
||
|
if (bindingResult.hasErrors()) {
|
||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||
|
}
|
||
|
AuthAdmin authAdmin = getUser();
|
||
|
entity.setStatus("2");
|
||
|
entity.setCheckStatus("2");
|
||
|
entity.setCreateTime(new Date());
|
||
|
entity.setCreateUser(authAdmin.getId()+"");
|
||
|
entity.setUpdateTime(new Date());
|
||
|
entity.setUpdateUser( authAdmin.getId()+"");
|
||
|
boolean b = udInfoService.save(entity);
|
||
|
if (!b) {
|
||
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
||
|
}
|
||
|
return ResultVOUtils.success("添加成功!");
|
||
|
}
|
||
|
|
||
|
@AuthRuleAnnotation("")
|
||
|
@PostMapping("/edit")
|
||
|
@Log(title = "U盾管理", businessType = BusinessType.UPDATE)
|
||
|
public BaseResponse edit(@RequestBody @Valid UdInfoEntity entity,
|
||
|
BindingResult bindingResult) {
|
||
|
|
||
|
if (bindingResult.hasErrors()) {
|
||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||
|
}
|
||
|
if (entity.getId() == null) {
|
||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||
|
}
|
||
|
UdInfoEntity originEntity = udInfoService.getById(entity.getId());
|
||
|
if (originEntity == null) {
|
||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||
|
}
|
||
|
AuthAdmin authAdmin = getUser();
|
||
|
entity.setUpdateTime(new Date());
|
||
|
entity.setUpdateUser( authAdmin.getId()+"");
|
||
|
boolean b = udInfoService.updateById(entity);
|
||
|
if (!b) {
|
||
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
||
|
}
|
||
|
|
||
|
return ResultVOUtils.success("修改成功!");
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
@AuthRuleAnnotation("")
|
||
|
@PostMapping("/delete")
|
||
|
@Log(title = "U盾管理", businessType = BusinessType.DELETE)
|
||
|
public BaseResponse delete(@RequestBody DeleteRequest deleteRequest) {
|
||
|
|
||
|
if (StringUtils.isEmpty(deleteRequest.getId())) {
|
||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||
|
}
|
||
|
boolean b = udInfoService.removeById(deleteRequest.getId());
|
||
|
|
||
|
if (!b) {
|
||
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
||
|
}
|
||
|
return ResultVOUtils.success();
|
||
|
}
|
||
|
|
||
|
public static QueryWrapper<UdInfoEntity> getQueryWrapper(UdInfoEntityRequest request) {
|
||
|
UdInfoEntity entity = new UdInfoEntity();
|
||
|
BeanCopyUtils.copy(request, entity);
|
||
|
QueryWrapper queryWrapper = new QueryWrapper(entity);
|
||
|
return queryWrapper;
|
||
|
}
|
||
|
|
||
|
}
|