代码备份
parent
c6e71bdc61
commit
b7cd7cd3e0
@ -0,0 +1,109 @@
|
|||||||
|
package com.glxp.api.controller.auth;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
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.entity.sup.UserCertEntity;
|
||||||
|
import com.glxp.api.entity.sup.UserCertSetEntity;
|
||||||
|
import com.glxp.api.req.purchase.certRequest;
|
||||||
|
import com.glxp.api.req.system.DeleteCompanyFileRequest;
|
||||||
|
import com.glxp.api.res.PageSimpleResponse;
|
||||||
|
import com.glxp.api.service.sup.UserCertService;
|
||||||
|
import com.glxp.api.service.sup.UserCertSetService;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
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 springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : zhangsan
|
||||||
|
* @date : 2023/5/18 9:38
|
||||||
|
* @modyified By :
|
||||||
|
*/
|
||||||
|
@ApiIgnore
|
||||||
|
@RestController
|
||||||
|
public class ResgitserCertController {
|
||||||
|
@Resource
|
||||||
|
private UserCertService userCertService;
|
||||||
|
@Value("${file_path}")
|
||||||
|
private String filePath;
|
||||||
|
@Resource
|
||||||
|
private UserCertSetService userCertSetService;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/reg/company/cert/filterList")
|
||||||
|
public BaseResponse filterCompanyCert(certRequest certRequest, BindingResult bindingResult) {
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||||
|
}
|
||||||
|
List<UserCertEntity> userCertEntities = userCertService.selectBybId(certRequest);
|
||||||
|
PageInfo<UserCertEntity> pageInfo;
|
||||||
|
pageInfo = new PageInfo<>(userCertEntities);
|
||||||
|
PageSimpleResponse<UserCertEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
||||||
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
||||||
|
pageSimpleResponse.setList(userCertEntities);
|
||||||
|
return ResultVOUtils.success(pageSimpleResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//资质证书添加
|
||||||
|
@PostMapping("/reg/company/cert/isertCert")
|
||||||
|
public BaseResponse isertCert(@RequestBody UserCertEntity userCert) {
|
||||||
|
userCert.setCreateTime(new Date());
|
||||||
|
userCert.setUpdateTime(new Date());
|
||||||
|
userCert.setStatus(1 + "");
|
||||||
|
userCert.setCheckStatus(0 + "");
|
||||||
|
userCert.setId(IdUtil.getSnowflakeNextId());
|
||||||
|
userCertService.insertCert(userCert);
|
||||||
|
return ResultVOUtils.success("成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除
|
||||||
|
@PostMapping("/reg/company/cert/deleteCert")
|
||||||
|
public BaseResponse deleteCert(@RequestBody DeleteCompanyFileRequest deleteCompanyFileRequest) {
|
||||||
|
boolean b = userCertService.deleteById(deleteCompanyFileRequest.getId());
|
||||||
|
String URL = filePath + "/register/file/image2/" + deleteCompanyFileRequest.getFilePath();
|
||||||
|
File file = new File(URL);
|
||||||
|
if (file.exists() && file.isFile()) {
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
return ResultVOUtils.success("成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改
|
||||||
|
@PostMapping("/reg/info/updateCert")
|
||||||
|
public BaseResponse updateCert(@RequestBody UserCertEntity userCert) {
|
||||||
|
|
||||||
|
if (userCert.getValidDate() != null && userCert.getExpireDate() != null) {
|
||||||
|
if (userCert.getValidDate().getTime() > userCert.getExpireDate().getTime()) {
|
||||||
|
return ResultVOUtils.error(999, "生效期不能小于失效期!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
userCertService.updateCert(userCert);
|
||||||
|
|
||||||
|
if ("key".equals(userCert.getKey())) {
|
||||||
|
//插入记录表中
|
||||||
|
UserCertSetEntity userCertSetEntity = new UserCertSetEntity();
|
||||||
|
userCertSetEntity.setId(IdUtil.getSnowflakeNextId());
|
||||||
|
userCertSetEntity.setCreateTime(new Date());
|
||||||
|
userCertSetEntity.setCreateUser(userCert.getCreateUser());
|
||||||
|
userCertSetEntity.setName(userCert.getName());
|
||||||
|
userCertSetService.insert(userCertSetEntity);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultVOUtils.success("修改成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue