|
@@ -3,6 +3,7 @@ package com.management.platform.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.management.platform.entity.*;
|
|
|
import com.management.platform.entity.vo.ContractPageVO;
|
|
|
+import com.management.platform.entity.vo.SysRichFunction;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.ContractDocumentService;
|
|
|
import com.management.platform.service.ContractService;
|
|
@@ -58,6 +59,8 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
private WxCorpInfoMapper wxCorpInfoMapper;
|
|
|
@Resource
|
|
|
private ContractDocumentMapper contractDocumentMapper;
|
|
|
+ @Resource
|
|
|
+ private SysFunctionMapper sysFunctionMapper;
|
|
|
@Value(value = "${upload.path}")
|
|
|
private String path;
|
|
|
|
|
@@ -80,6 +83,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
try {
|
|
|
String token = request.getHeader("token");
|
|
|
User user = userMapper.selectById(token);
|
|
|
+ List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看合同");
|
|
|
+ if(functionContractList.size() <= 0){
|
|
|
+ httpRespMsg.setError(MessageUtils.message("access.viewError"));
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
List<ContractType> types = contractTypeMapper.selectList(new QueryWrapper<ContractType>().eq("company_id", user.getCompanyId()));
|
|
|
if (types.size() == 0){
|
|
|
//String[] typeNames = {"买卖合同","赠与合同","租赁合同","借款合同","仓储合同","委托合同"};
|
|
@@ -241,6 +249,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
public HttpRespMsg addContract(HttpServletRequest request, Contract contract) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "编辑合同");
|
|
|
+ if(functionContractList.size() <= 0){
|
|
|
+ httpRespMsg.setError(MessageUtils.message("access.operationError"));
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
List<Contract> contracts = contractMapper.selectList(new QueryWrapper<Contract>().eq("company_id", user.getCompanyId()));
|
|
|
if (StringUtils.isBlank(contract.getName())){
|
|
|
//名称不可为空
|
|
@@ -283,6 +296,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
public HttpRespMsg editContract(HttpServletRequest request, Contract contract) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "编辑合同");
|
|
|
+ if(functionContractList.size() <= 0){
|
|
|
+ httpRespMsg.setError(MessageUtils.message("access.operationError"));
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
try {
|
|
|
if (StringUtils.isBlank(contract.getName())){
|
|
|
//名称不可为空
|
|
@@ -323,6 +341,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
|
+ List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "编辑合同");
|
|
|
+ if(functionContractList.size() <= 0){
|
|
|
+ msg.setError(MessageUtils.message("access.operationError"));
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
Integer companyId = user.getCompanyId();
|
|
|
//然后处理文件
|
|
@@ -514,6 +537,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
|
+ List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "审核合同");
|
|
|
+ if(functionContractList.size() <= 0){
|
|
|
+ msg.setError(MessageUtils.message("access.operationError"));
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
Contract contract = new Contract();
|
|
|
contract.setId(id);
|
|
|
contract.setCheckerId(user.getId());
|
|
@@ -533,6 +561,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
|
+ List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看合同");
|
|
|
+ if(functionContractList.size() <= 0){
|
|
|
+ msg.setError(MessageUtils.message("access.viewError"));
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
List<ContractDocument> fileUrl = contractDocumentMapper.selectList(new QueryWrapper<ContractDocument>().eq("contract_id", id).eq("is_deleted",0));
|
|
|
List<User> users = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
@@ -560,22 +593,21 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
|
- //只有创建者才可以删除
|
|
|
- Contract contract = contractMapper.selectById(id);
|
|
|
- if (user.getId().equals(contract.getCreatorId())){
|
|
|
- contractMapper.deleteById(id);
|
|
|
- //删除附件
|
|
|
- List<ContractDocument> contractFile = contractDocumentMapper.selectList(new QueryWrapper<ContractDocument>().eq("contract_id", id));
|
|
|
- for (ContractDocument contractDocument : contractFile) {
|
|
|
- contractDocument.setIsDeleted(1);
|
|
|
- }
|
|
|
- for (ContractDocument contractDocument : contractFile) {
|
|
|
- contractDocumentMapper.updateById(contractDocument);
|
|
|
- }
|
|
|
- msg.msg = MessageUtils.message("other.deleteScu");
|
|
|
- }else {
|
|
|
- msg.msg = MessageUtils.message("access.createDelete");
|
|
|
+ List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "编辑合同");
|
|
|
+ if(functionContractList.size() <= 0){
|
|
|
+ msg.setError(MessageUtils.message("access.deleteError"));
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ contractMapper.deleteById(id);
|
|
|
+ //删除附件
|
|
|
+ List<ContractDocument> contractFile = contractDocumentMapper.selectList(new QueryWrapper<ContractDocument>().eq("contract_id", id));
|
|
|
+ for (ContractDocument contractDocument : contractFile) {
|
|
|
+ contractDocument.setIsDeleted(1);
|
|
|
+ }
|
|
|
+ for (ContractDocument contractDocument : contractFile) {
|
|
|
+ contractDocumentMapper.updateById(contractDocument);
|
|
|
}
|
|
|
+ msg.msg = MessageUtils.message("other.deleteScu");
|
|
|
return msg;
|
|
|
}
|
|
|
|