Commit b9b4e623 authored by hongguangwu's avatar hongguangwu

权限优化-同一个人不能重复加

parent 92bffdfd
......@@ -3,10 +3,12 @@ package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TCutsomerDataPermisson;
import com.yifu.cloud.plus.v1.yifu.archives.service.TCutsomerDataPermissonService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TSettleDomainService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
......@@ -82,10 +84,9 @@ public class TCutsomerDataPermissonController {
**/
@Operation(description = "权限复制 权限同项目分配客服(wxhr:tsettledomain_assign_customerservice)")
@GetMapping("/copy")
//@PreAuthorize("@pms.hasPermission('tsettledomain_assign_customerservice')")
public R<String> insertForCopyCutsomerDataPermisson(String[] srcUser, String[] beUser) {
YifuUser user = SecurityUtils.getUser();
R result = tCutsomerDataPermissonService.insertForCopyCutsomerDataPermisson(srcUser, beUser, user);
R<String> result = tCutsomerDataPermissonService.insertForCopyCutsomerDataPermisson(srcUser, beUser, user);
if(CommonConstants.SUCCESS.equals(result.getCode())){//权限刷新
settleDomainService.removeSettleCache(user, Arrays.asList(beUser));
}
......@@ -111,11 +112,22 @@ public class TCutsomerDataPermissonController {
@Operation(description = "新增")
@SysLog("新增客户数据权限表")
@PostMapping
//@PreAuthorize("@pms.hasPermission('tcutsomerdatapermisson_add')")
public R<Boolean> save(@RequestBody TCutsomerDataPermisson tCutsomerDataPermisson){
public R<String> save(@RequestBody TCutsomerDataPermisson tCutsomerDataPermisson){
YifuUser user = SecurityUtils.getUser();
settleDomainService.removeSettleCache(user, Arrays.asList(tCutsomerDataPermisson.getUserId()));
return new R<>(tCutsomerDataPermissonService.save(tCutsomerDataPermisson));
if (Common.isNotNull(tCutsomerDataPermisson.getUserId()) && Common.isNotNull(tCutsomerDataPermisson.getSettleDomainId())) {
List<TCutsomerDataPermisson> list = tCutsomerDataPermissonService.list(Wrappers.<TCutsomerDataPermisson>query().lambda()
.eq(TCutsomerDataPermisson::getUserId, tCutsomerDataPermisson.getUserId())
.eq(TCutsomerDataPermisson::getSettleDomainId, tCutsomerDataPermisson.getSettleDomainId())
);
if (list != null && !list.isEmpty()) {
return R.failed("该用户已存在该项目");
}
tCutsomerDataPermissonService.save(tCutsomerDataPermisson);
return R.ok();
} else {
return R.failed("用户id与项目id必填");
}
}
/**
......@@ -126,7 +138,6 @@ public class TCutsomerDataPermissonController {
@Operation(description = "修改")
@SysLog("修改客户数据权限表")
@PutMapping
//@PreAuthorize("@pms.hasPermission('tcutsomerdatapermisson_edit')")
public R<Boolean> update(@RequestBody TCutsomerDataPermisson tCutsomerDataPermisson) {
YifuUser user = SecurityUtils.getUser();
settleDomainService.removeSettleCache(user, Arrays.asList(tCutsomerDataPermisson.getUserId()));
......@@ -141,7 +152,6 @@ public class TCutsomerDataPermissonController {
@Operation(description = "删除(tcutsomerdatapermisson_del)")
@SysLog("删除客户数据权限表")
@DeleteMapping("/{id}")
//@PreAuthorize("@pms.hasPermission('tcutsomerdatapermisson_del')")
public R<Boolean> removeById(@PathVariable String id){
YifuUser user = SecurityUtils.getUser();
TCutsomerDataPermisson tdp = tCutsomerDataPermissonService.getById(id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment