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.
136 lines
5.0 KiB
Java
136 lines
5.0 KiB
Java
package com.glxp.api.controller.anno;
|
|
|
|
|
|
import cn.hutool.core.lang.func.Func;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.github.pagehelper.PageInfo;
|
|
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.SysCustomConfigDetailEntity;
|
|
import com.glxp.api.req.anno.AnncmntDevEntityRequest;
|
|
import com.glxp.api.req.auth.SysCustomConfigDetailRequest;
|
|
import com.glxp.api.req.system.DeleteRequest;
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
import com.glxp.api.service.anno.AnncmntDevService;
|
|
import com.glxp.api.util.BeanCopyUtils;
|
|
import com.glxp.api.util.StringUtils;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
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.List;
|
|
|
|
/**
|
|
* 用户信息
|
|
*
|
|
*/
|
|
@ApiIgnore
|
|
@Validated
|
|
@RequiredArgsConstructor
|
|
@RestController
|
|
@RequestMapping("/anno/anncmnt/dev")
|
|
public class AnncmntDevController extends BaseController {
|
|
|
|
private final AnncmntDevService anncmntDevService;
|
|
|
|
|
|
@GetMapping("/list")
|
|
public BaseResponse list(AnncmntDevEntityRequest request, BindingResult bindingResult) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
IPage page = new Page(request.getPage(),request.getLimit());
|
|
IPage<AnncmntDevEntity> pages = anncmntDevService.page(page, getQueryWrapper(request));
|
|
PageSimpleResponse<AnncmntDevEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
pageSimpleResponse.setTotal(pages.getTotal());
|
|
pageSimpleResponse.setList(pages.getRecords());
|
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/save")
|
|
@Log(title = "器械公告管理", businessType = BusinessType.INSERT)
|
|
public BaseResponse save(@RequestBody AnncmntDevEntity entity,
|
|
BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
|
|
boolean b = anncmntDevService.save(entity);
|
|
if (!b) {
|
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
|
}
|
|
return ResultVOUtils.success("添加成功!");
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/edit")
|
|
@Log(title = "器械公告管理", businessType = BusinessType.UPDATE)
|
|
public BaseResponse edit(@RequestBody @Valid AnncmntDevEntity 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);
|
|
}
|
|
AnncmntDevEntity originEntity = anncmntDevService.getById(entity.getId());
|
|
if (originEntity == null) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
|
}
|
|
boolean b = anncmntDevService.updateById(entity);
|
|
if (!b) {
|
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
|
}
|
|
|
|
return ResultVOUtils.success("修改成功!");
|
|
|
|
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/delete")
|
|
@Log(title = "器械公告管理", businessType = BusinessType.DELETE)
|
|
public BaseResponse delete(@RequestBody DeleteRequest deleteRequest) {
|
|
|
|
if (StringUtils.isEmpty(deleteRequest.getId())) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
|
}
|
|
boolean b = anncmntDevService.removeById(deleteRequest.getId());
|
|
|
|
if (!b) {
|
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
|
}
|
|
return ResultVOUtils.success();
|
|
}
|
|
|
|
public static QueryWrapper<AnncmntDevEntity> getQueryWrapper(AnncmntDevEntityRequest request) {
|
|
AnncmntDevEntity entity = new AnncmntDevEntity();
|
|
BeanCopyUtils.copy(request, entity);
|
|
QueryWrapper queryWrapper = new QueryWrapper(entity);
|
|
if(StringUtils.isNotBlank(request.getEndTime())){
|
|
queryWrapper.le("publicTime",request.getEndTime());
|
|
}
|
|
if(StringUtils.isNotBlank(request.getStartTime())){
|
|
queryWrapper.ge("publicTime",request.getStartTime());
|
|
}
|
|
return queryWrapper;
|
|
}
|
|
|
|
}
|