添加合同权限限制

This commit is contained in:
梁琦涛
2021-10-20 09:25:25 +08:00
parent e20efff3c8
commit 849ca76ad1
8 changed files with 66 additions and 17 deletions
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.AutoLog;
import com.jero.common.common.RoleCommon;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.api.ISysBaseAPI;
import com.jero.common.system.base.controller.JeroController;
@@ -113,6 +114,10 @@ public class PayIncomeContractController extends JeroController<PayIncomeContrac
if(!StringUtils.isBlank(projectName)){
projectName = oConvertUtils.replaceAllPercent(projectName);
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
payIncomeContract.setPrincipalId(sysUser.getId());
}
Page<PayIncomeContract> page = new Page<>(pageNo, pageSize);
IPage<PayIncomeContract> pageList = payIncomeContractService.queryPageList(page, payIncomeContract,chargeStatus,projectName,startTime,endTime);
return Result.OK(pageList);
@@ -16,10 +16,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.AutoLog;
import com.jero.common.common.RoleCommon;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.api.ISysBaseAPI;
import com.jero.common.system.base.controller.JeroController;
import com.jero.common.system.query.QueryGenerator;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.DateUtils;
import com.jero.common.util.oConvertUtils;
import com.jero.contract.common.PayIncomeContractCommon;
@@ -30,6 +32,7 @@ import com.jero.contract.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecgframework.poi.excel.def.MapExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -95,9 +98,12 @@ public class PaySpendingContractController extends JeroController<PaySpendingCon
if(!StringUtils.isBlank(paySpendingContract.getContractNum())){
paySpendingContract.setContractNum(oConvertUtils.replaceAllPercent(paySpendingContract.getContractNum()));
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
paySpendingContract.setPrincipalId(sysUser.getId());
}
Page<PaySpendingContract> page = new Page<>(pageNo, pageSize);
IPage<PaySpendingContract> pageList = paySpendingContractService.queryPageList(page, paySpendingContract.getContractNum(),
paySpendingContract.getContractName(),startTime,endTime);
IPage<PaySpendingContract> pageList = paySpendingContractService.queryPageList(page, paySpendingContract,startTime,endTime);
return Result.OK(pageList);
}
@@ -25,9 +25,8 @@ public interface PaySpendingContractMapper extends BaseMapper<PaySpendingContrac
* @Return
* @Exception
*/
IPage<PaySpendingContract> queryPageList(Page<PaySpendingContract> page, @Param("contractNum") String contractNum,
@Param("contractName") String contractName,@Param("startTime") String startTime,
@Param("endTime") String endTime);
IPage<PaySpendingContract> queryPageList(Page<PaySpendingContract> page, @Param("paySpendingContract") PaySpendingContract paySpendingContract
,@Param("startTime") String startTime, @Param("endTime") String endTime);
/**
* @Description excel导出
@@ -90,6 +90,9 @@
<if test="projectName != null and projectName != ''">
AND aa.associatedProject LIKE CONCAT('%',CONCAT(#{projectName},'%'))
</if>
<if test="payIncomeContract.principalId != null and payIncomeContract.principalId != ''">
AND aa.principal_id = #{payIncomeContract.principalId}
</if>
</where>
ORDER BY aa.chargeStatus desc,aa.statusOrder desc, aa.createTime desc
</select>
@@ -40,11 +40,11 @@
) AS chargeStatus
FROM pay_spending_contract psc
<where>
<if test="contractNum != null and contractNum != ''">
AND contract_num LIKE CONCAT('%',CONCAT(#{contractNum},'%'))
<if test="paySpendingContract.contractNum != null and paySpendingContract.contractNum != ''">
AND contract_num LIKE CONCAT('%',CONCAT(#{paySpendingContract.contractNum},'%'))
</if>
<if test="contractName != null and contractName != ''">
AND contract_name LIKE CONCAT('%',CONCAT(#{contractName},'%'))
<if test="paySpendingContract.contractName != null and paySpendingContract.contractName != ''">
AND contract_name LIKE CONCAT('%',CONCAT(#{paySpendingContract.contractName},'%'))
</if>
<if test="startTime != null and startTime != ''">
AND DATE_FORMAT(create_time,'%Y-%m-%d') >= #{startTime}
@@ -52,6 +52,9 @@
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(create_time,'%Y-%m-%d') &lt;= #{endTime}
</if>
<if test="paySpendingContract.principalId != null and paySpendingContract.principalId != ''">
AND principal_id = #{paySpendingContract.principalId}
</if>
</where>
ORDER BY chargeStatus desc,create_time desc
</select>
@@ -24,7 +24,7 @@ public interface IPaySpendingContractService extends IService<PaySpendingContrac
* @Return
* @Exception
*/
IPage<PaySpendingContract> queryPageList(Page<PaySpendingContract> page,String contractNum,String contractName,String startTime,String endTime);
IPage<PaySpendingContract> queryPageList(Page<PaySpendingContract> page,PaySpendingContract paySpendingContract,String startTime,String endTime);
/**
* @Description 添加
@@ -249,6 +249,12 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
if(Objects.isNull(payIncomeContractStatus)){
throw new JeroBootException("收入合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
if(!Objects.equals(sysUser.getId(),payIncomeContract.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
}
// 项目已打包
if(Objects.equals(payIncomeContractStatus.getPack(),PayIncomeContractCommon.PACK1)){
if(!Objects.equals(payIncomeContract.getPack(),PayIncomeContractCommon.PACK1)){
@@ -308,7 +314,16 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
if(CollectionUtils.isEmpty(listPayIncomeContractAssociated)){
throw new JeroBootException("关联项目不能为空!");
}
PayIncomeContract payIncomeContract = payIncomeContractService.getById(listPayIncomeContractAssociated.get(0).getContractId());
if(Objects.isNull(payIncomeContract)){
throw new JeroBootException("合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
if(!Objects.equals(sysUser.getId(),payIncomeContract.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
}
listPayIncomeContractAssociated.forEach(p->{
String projectName = "";
String principalId = "";
@@ -317,10 +332,6 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
if(!StringUtils.isBlank(msgPayIncomeContractAssociated)){
throw new JeroBootException(msgPayIncomeContractAssociated.toString());
}
PayIncomeContract payIncomeContract = payIncomeContractService.getById(p.getContractId());
if(Objects.isNull(payIncomeContract)){
throw new JeroBootException("合同不存在!");
}
// 查看项目类型
switch (String.valueOf(p.getProjectType())){
case PayIncomeContractCommon.PROJECT_TYPE1:
@@ -579,6 +590,11 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
throw new JeroBootException("合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
if(!Objects.equals(sysUser.getId(),payIncomeContract.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
}
// 查看项目类型
switch (String.valueOf(payIncomeContractAssociated.getProjectType())){
case PayIncomeContractCommon.PROJECT_TYPE1:
@@ -718,7 +734,6 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
@Override
@Transactional
public void submitAudit(PayIncomeContract payIncomeContract) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(StringUtils.isBlank(payIncomeContract.getId())){
throw new JeroBootException("合同id不能为空!");
}
@@ -726,6 +741,12 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
if(Objects.isNull(payIncomeContractNew)){
throw new JeroBootException("合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
if(!Objects.equals(sysUser.getId(),payIncomeContract.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
}
// 验证合同状态是否为草稿或者未通过
if(!Objects.equals(payIncomeContract.getStatus(),PayIncomeContractCommon.STATUS2)
|| (!Objects.equals(payIncomeContractNew.getStatus(),PayIncomeContractCommon.STATUS1)
@@ -980,6 +1001,12 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
if(Objects.isNull(payIncomeContractStatus)){
throw new JeroBootException("收入合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
if(!Objects.equals(sysUser.getId(),payIncomeContractStatus.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
}
if(!Objects.equals(payIncomeContractStatus.getStatus(),PayIncomeContractCommon.STATUS1)
&& !Objects.equals(payIncomeContractStatus.getStatus(),PayIncomeContractCommon.STATUS4)){
throw new JeroBootException("收入合同不可删除!");
@@ -1005,11 +1032,17 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
if(CollectionUtils.isEmpty(listPayIncomeContractStatus)){
throw new JeroBootException("收入合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
listPayIncomeContractStatus.forEach(p->{
if(!Objects.equals(p.getStatus(),PayIncomeContractCommon.STATUS1)
&& !Objects.equals(p.getStatus(),PayIncomeContractCommon.STATUS4)){
throw new JeroBootException("收入合同不可删除!");
}
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
if(!Objects.equals(sysUser.getId(),p.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
}
});
payIncomeContractService.removeByIds(ids);
@@ -64,8 +64,8 @@ public class PaySpendingContractServiceImpl extends ServiceImpl<PaySpendingContr
@Override
public IPage<PaySpendingContract> queryPageList(Page<PaySpendingContract> page, String contractNum, String contractName, String startTime, String endTime) {
return paySpendingContractMapper.queryPageList(page,contractNum,contractName,startTime,endTime);
public IPage<PaySpendingContract> queryPageList(Page<PaySpendingContract> page, PaySpendingContract paySpendingContract, String startTime, String endTime) {
return paySpendingContractMapper.queryPageList(page,paySpendingContract,startTime,endTime);
}
@Override