Commit 5170cc4d authored by hongguangwu's avatar hongguangwu

授权

parent a017dd5e
package com.yifu.cloud.plus.v1.yifu.archives.entity; package com.yifu.cloud.plus.v1.yifu.archives.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.alibaba.excel.annotation.ExcelIgnore;
import com.baomidou.mybatisplus.annotation.TableId; import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableName; import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import com.baomidou.mybatisplus.extension.activerecord.Model; import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute; import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
...@@ -21,106 +21,77 @@ import java.time.LocalDateTime; ...@@ -21,106 +21,77 @@ import java.time.LocalDateTime;
* @date 2019-07-19 16:22:22 * @date 2019-07-19 16:22:22
*/ */
@Data @Data
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("t_cutsomer_data_permisson") @TableName("t_cutsomer_data_permisson")
@Schema(description = "客户数据权限表") @Schema(description = "客户数据权限表")
public class TCutsomerDataPermisson extends Model<TCutsomerDataPermisson> { public class TCutsomerDataPermisson implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键", name = "id") @Schema(description = "主键", name = "id")
private String id; private String id;
/**
* 是否是数据所有者(0是1否) @Length(max = 1, message = "状态不能超过1个字符")
*/ @ExcelAttribute(name = "状态", maxLength = 1)
@NotBlank(message = "是否是数据所有者(0是1否)不能为空") @Schema(description = "状态0启用1禁用")
@Length(max = 1, message = "是否是数据所有者(0是1否)不能超过1个字符") private String status;
@ExcelAttribute(name = "是否是数据所有者(0是1否)", isNotEmpty = true, errorInfo = "是否是数据所有者(0是1否)不能为空", maxLength = 1)
@Schema(description = "是否是数据所有者(0是1否)", name = "isOwner") @Length(max = 32, message = "备注不能超过32个字符")
private String isOwner; @ExcelAttribute(name = "备注", maxLength = 32)
/** @Schema(description = "备注")
* 客户id private String remark;
*/
@Length(max = 32, message = "客户id不能超过32个字符") @Length(max = 32, message = "项目id不能超过32个字符")
@ExcelAttribute(name = "客户id", maxLength = 32) @ExcelAttribute(name = "项目id", maxLength = 32)
@Schema(description = "客户id", name = "customerId") @Schema(description = "项目id")
private String customerId; private String settleDomainId;
/**
* 合同主体id @Length(max = 50, message = "项目名称不能超过50个字符")
*/ @ExcelAttribute(name = "项目名称", maxLength = 50)
@Length(max = 32, message = "合同主体id不能超过32个字符") @Schema(description = "项目名称")
@ExcelAttribute(name = "合同主体id", maxLength = 32) private String settleDomainName;
@Schema(description = "合同主体id", name = "contractId")
private String contractId; @Length(max = 32, message = "项目编码不能超过32个字符")
/** @ExcelAttribute(name = "项目编码", maxLength = 32)
* 项目id @Schema(description = "项目编码")
*/ private String settleDomainNo;
@Length(max = 32, message = "项目id不能超过32个字符")
@ExcelAttribute(name = "项目id", maxLength = 32) @Schema(description = "创建人-姓名")
@Schema(description = "项目id", name = "settleDomainId") @TableField(fill = FieldFill.INSERT)
private String settleDomainId; @HeadFontStyle(fontHeightInPoints = 11)
/** @ExcelProperty("创建人")
* 授权来源 private String createName;
*/
@NotBlank(message = "授权来源不能为空") @Schema(description = "创建人")
@Length(max = 50, message = "授权来源不能超过50个字符") @TableField(fill = FieldFill.INSERT)
@ExcelAttribute(name = "授权来源", isNotEmpty = true, errorInfo = "授权来源不能为空", maxLength = 50) @ExcelIgnore
@Schema(description = "授权来源", name = "permissonSrc") private String createBy;
private String permissonSrc;
/** @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
* 授权等级 @Schema(description = "创建时间")
*/ @TableField(fill = FieldFill.INSERT)
@NotBlank(message = "授权等级不能为空") @HeadFontStyle(fontHeightInPoints = 11)
@ExcelAttribute(name = "授权等级", isNotEmpty = true, errorInfo = "授权等级不能为空") @ExcelProperty("创建时间")
@Schema(description = "授权等级", name = "permissonLevel") private LocalDateTime createTime;
private Integer permissonLevel;
/**
* 授权人
*/
@NotBlank(message = "授权人不能为空")
@Length(max = 32, message = "授权人不能超过32个字符")
@Schema(description = "授权人", name = "permissionUser")
private String permissionUser;
/**
* 被授权人
*/
@NotBlank(message = "被授权人不能为空") @NotBlank(message = "被授权人不能为空")
@Length(max = 32, message = "被授权人不能超过32个字符") @Length(max = 32, message = "被授权人不能超过32个字符")
@ExcelAttribute(name = "被授权人", isNotEmpty = true, errorInfo = "被授权人不能为空", maxLength = 32) @ExcelAttribute(name = "被授权人", isNotEmpty = true, errorInfo = "被授权人不能为空", maxLength = 32)
@Schema(description = "被授权人", name = "bePermissonUser") @Schema(description = "被授权人")
private String bePermissonUser; private String userId;
/**
* 被授权时间 @ExcelAttribute(name = "登录名", maxLength = 50)
*/ @Schema(description = "登录名")
@NotBlank(message = "被授权时间不能为空") private String userLoginName;
@ExcelAttribute(name = "被授权时间", isNotEmpty = true, errorInfo = "被授权时间不能为空")
@Schema(description = "被授权时间", name = "bePermissionTime") @ExcelAttribute(name = "用户名称", maxLength = 50)
private LocalDateTime bePermissionTime; @Schema(description = "用户名称(汉字)")
/** private String userNickName;
* 备注
*/
@Length(max = 50, message = "备注不能超过50个字符")
@ExcelAttribute(name = "备注", maxLength = 50)
@Schema(description = "备注", name = "remark")
private String remark;
@Length(max = 1, message = "是否是客服不能超过1个字符") @ExcelAttribute(name = "所在部门", maxLength = 50)
@Schema(description = "是否是客服(0是1否)", name = "isCustomerService") @Schema(description = "所在部门")
private String isCustomerService; private String userDeptName;
@Schema(description = "类型0:客户1:合同2:项目", name = "type") @ExcelIgnore
@Schema(description = "授权来源0ekp,1mvp,2mvp复制", name = "type")
private String type; private String type;
/**
* 无参构造方法
* @Author pwang
* @Date 2019-11-15 12:12
* @param
* @return
**/
public TCutsomerDataPermisson(){
}
} }
...@@ -6,9 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -6,9 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TCutsomerDataPermisson; 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.TCutsomerDataPermissonService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TSettleDomainService; import com.yifu.cloud.plus.v1.yifu.archives.service.TSettleDomainService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TCutsomerDataPermissonVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; 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.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
...@@ -20,6 +18,7 @@ import org.springframework.security.access.prepost.PreAuthorize; ...@@ -20,6 +18,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
/** /**
...@@ -45,9 +44,21 @@ public class TCutsomerDataPermissonController { ...@@ -45,9 +44,21 @@ public class TCutsomerDataPermissonController {
*/ */
@Operation(description = "简单分页查询") @Operation(description = "简单分页查询")
@GetMapping("/page") @GetMapping("/page")
public R<IPage<TCutsomerDataPermissonVo>> getTCutsomerDataPermissonPage(Page<TCutsomerDataPermissonVo> page, TCutsomerDataPermissonVo tCutsomerDataPermisson) { public R<IPage<TCutsomerDataPermisson>> getTCutsomerDataPermissonPage(Page<TCutsomerDataPermisson> page, TCutsomerDataPermisson tCutsomerDataPermisson) {
return new R<>(tCutsomerDataPermissonService.getTCutsomerDataPermissonPage(page,tCutsomerDataPermisson)); return new R<>(tCutsomerDataPermissonService.getTCutsomerDataPermissonPage(page,tCutsomerDataPermisson));
} }
/**
* 导出list
* @param tCutsomerDataPermisson 客户数据权限表
* @return
*/
@Operation(description = "导出的list")
@GetMapping("/getList")
public R<List<TCutsomerDataPermisson>> getTCutsomerDataPermissonList(TCutsomerDataPermisson tCutsomerDataPermisson) {
return new R<>(tCutsomerDataPermissonService.getTCutsomerDataPermissonList(tCutsomerDataPermisson));
}
/** /**
* @Author fxj * @Author fxj
* @Description 获取实体的权限: type-类型0:客户1:合同2:项目(不传默认2项目) * @Description 获取实体的权限: type-类型0:客户1:合同2:项目(不传默认2项目)
...@@ -55,21 +66,11 @@ public class TCutsomerDataPermissonController { ...@@ -55,21 +66,11 @@ public class TCutsomerDataPermissonController {
* @Param * @Param
* @return * @return
**/ **/
@Operation(description = "获取实体的权限: type-类型0:客户1:合同2:项目(不传默认2项目)") @Operation(description = "获取实体的权限:默认项目")
@GetMapping("/getPermissonByTypeAndId") @GetMapping("/getPermissonByTypeAndId")
public R<IPage<TCutsomerDataPermisson>> getTCutsomerDataPermissonByTypeAndId(String id, String type) { public R<IPage<TCutsomerDataPermisson>> getTCutsomerDataPermissonByTypeAndId(@RequestParam String settleDomainId) {
if(Common.isEmpty(id)){
return R.failed("实体id");
}
TCutsomerDataPermisson tp = new TCutsomerDataPermisson(); TCutsomerDataPermisson tp = new TCutsomerDataPermisson();
tp.setSettleDomainId(settleDomainId);
if(CommonConstants.dingleDigitStrArray[0].equals(type)){
tp.setCustomerId(id);
}else if(CommonConstants.dingleDigitStrArray[1].equals(type)){
tp.setContractId(id);
}else{
tp.setSettleDomainId(id);
}
return new R(tCutsomerDataPermissonService.list(Wrappers.lambdaQuery(tp))); return new R(tCutsomerDataPermissonService.list(Wrappers.lambdaQuery(tp)));
} }
...@@ -83,7 +84,7 @@ public class TCutsomerDataPermissonController { ...@@ -83,7 +84,7 @@ public class TCutsomerDataPermissonController {
@Operation(description = "权限复制 权限同项目分配客服(wxhr:tsettledomain_assign_customerservice)") @Operation(description = "权限复制 权限同项目分配客服(wxhr:tsettledomain_assign_customerservice)")
@GetMapping("/copy") @GetMapping("/copy")
@PreAuthorize("@pms.hasPermission('wxhr:tsettledomain_assign_customerservice')") @PreAuthorize("@pms.hasPermission('wxhr:tsettledomain_assign_customerservice')")
public R insertForCopyCutsomerDataPermisson(String[] srcUser, String[] beUser) { public R<String> insertForCopyCutsomerDataPermisson(String[] srcUser, String[] beUser) {
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
R result = tCutsomerDataPermissonService.insertForCopyCutsomerDataPermisson(srcUser, beUser, user); R result = tCutsomerDataPermissonService.insertForCopyCutsomerDataPermisson(srcUser, beUser, user);
if(CommonConstants.SUCCESS.equals(result.getCode())){//权限刷新 if(CommonConstants.SUCCESS.equals(result.getCode())){//权限刷新
...@@ -112,7 +113,9 @@ public class TCutsomerDataPermissonController { ...@@ -112,7 +113,9 @@ public class TCutsomerDataPermissonController {
@SysLog("新增客户数据权限表") @SysLog("新增客户数据权限表")
@PostMapping @PostMapping
@PreAuthorize("@pms.hasPermission('wxhr:tcutsomerdatapermisson_add')") @PreAuthorize("@pms.hasPermission('wxhr:tcutsomerdatapermisson_add')")
public R save(@RequestBody TCutsomerDataPermisson tCutsomerDataPermisson){ public R<Boolean> save(@RequestBody TCutsomerDataPermisson tCutsomerDataPermisson){
YifuUser user = SecurityUtils.getUser();
settleDomainService.removeSettleCache(user, Arrays.asList(tCutsomerDataPermisson.getUserId()));
return new R<>(tCutsomerDataPermissonService.save(tCutsomerDataPermisson)); return new R<>(tCutsomerDataPermissonService.save(tCutsomerDataPermisson));
} }
...@@ -125,7 +128,9 @@ public class TCutsomerDataPermissonController { ...@@ -125,7 +128,9 @@ public class TCutsomerDataPermissonController {
@SysLog("修改客户数据权限表") @SysLog("修改客户数据权限表")
@PutMapping @PutMapping
@PreAuthorize("@pms.hasPermission('wxhr:tcutsomerdatapermisson_edit')") @PreAuthorize("@pms.hasPermission('wxhr:tcutsomerdatapermisson_edit')")
public R update(@RequestBody TCutsomerDataPermisson tCutsomerDataPermisson){ public R<Boolean> update(@RequestBody TCutsomerDataPermisson tCutsomerDataPermisson) {
YifuUser user = SecurityUtils.getUser();
settleDomainService.removeSettleCache(user, Arrays.asList(tCutsomerDataPermisson.getUserId()));
return new R<>(tCutsomerDataPermissonService.updateById(tCutsomerDataPermisson)); return new R<>(tCutsomerDataPermissonService.updateById(tCutsomerDataPermisson));
} }
...@@ -138,14 +143,14 @@ public class TCutsomerDataPermissonController { ...@@ -138,14 +143,14 @@ public class TCutsomerDataPermissonController {
@SysLog("删除客户数据权限表") @SysLog("删除客户数据权限表")
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('wxhr:tcutsomerdatapermisson_del')") @PreAuthorize("@pms.hasPermission('wxhr:tcutsomerdatapermisson_del')")
public R removeById(@PathVariable String id){ public R<Boolean> removeById(@PathVariable String id){
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
TCutsomerDataPermisson tdp = tCutsomerDataPermissonService.getById(id); TCutsomerDataPermisson tdp = tCutsomerDataPermissonService.getById(id);
if(null == tdp){ if(null == tdp){
return new R<>("权限已删除!"); return new R<>(true);
} }
//刷新缓存 //刷新缓存
settleDomainService.removeSettleCache(user, Arrays.asList(tdp.getBePermissonUser())); settleDomainService.removeSettleCache(user, Arrays.asList(tdp.getUserId()));
return new R<>(tCutsomerDataPermissonService.removeById(id)); return new R<>(tCutsomerDataPermissonService.removeById(id));
} }
......
package com.yifu.cloud.plus.v1.yifu.archives.mapper; package com.yifu.cloud.plus.v1.yifu.archives.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TCutsomerDataPermisson; import com.yifu.cloud.plus.v1.yifu.archives.entity.TCutsomerDataPermisson;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TCutsomerDataPermissonVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.TCutsomerDataPermissonVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -16,24 +18,16 @@ import java.util.List; ...@@ -16,24 +18,16 @@ import java.util.List;
*/ */
@Mapper @Mapper
public interface TCutsomerDataPermissonMapper extends BaseMapper<TCutsomerDataPermisson> { public interface TCutsomerDataPermissonMapper extends BaseMapper<TCutsomerDataPermisson> {
/**
* 分页count
* @Author pwang
* @Date 2020-06-28 15:25
* @param tCutsomerDataPermisson
* @return
**/
long getTCutsomerDataPermissonPageCount( @Param("tCutsomerDataPermisson")TCutsomerDataPermisson tCutsomerDataPermisson);
/** /**
* 客户数据权限表简单分页查询 * 客户数据权限表简单分页查询
* @param tCutsomerDataPermisson 客户数据权限表 * @param tCutsomerDataPermisson 客户数据权限表
* @return * @return
*/ */
List<TCutsomerDataPermissonVo> getTCutsomerDataPermissonPage(@Param("tCutsomerDataPermisson") TCutsomerDataPermissonVo tCutsomerDataPermisson, @Param("page")Long page, @Param("size")Long size); IPage<TCutsomerDataPermisson> getTCutsomerDataPermissonPage(
Page<TCutsomerDataPermisson> page, @Param("tCutsomerDataPermisson") TCutsomerDataPermisson tCutsomerDataPermisson);
String getOwnerIdByIdAndType(@Param("domainId")String domainId, @Param("type")int type); List<TCutsomerDataPermisson> getTCutsomerDataPermissonPage(@Param("tCutsomerDataPermisson") TCutsomerDataPermisson tCutsomerDataPermisson);
/** /**
* 获取当前登录人拥有的所有项目权限 * 获取当前登录人拥有的所有项目权限
...@@ -43,8 +37,4 @@ public interface TCutsomerDataPermissonMapper extends BaseMapper<TCutsomerDataPe ...@@ -43,8 +37,4 @@ public interface TCutsomerDataPermissonMapper extends BaseMapper<TCutsomerDataPe
* @return * @return
**/ **/
List<TCutsomerDataPermisson> selectAllSettleDomainPermissionByUserId(@Param("userId")String userId); List<TCutsomerDataPermisson> selectAllSettleDomainPermissionByUserId(@Param("userId")String userId);
String getCustomerServiceByid(@Param("id")String id);
String getUserByid(@Param("settleId")String settleId);
} }
...@@ -8,6 +8,8 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.TCutsomerDataPermissonVo; ...@@ -8,6 +8,8 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.TCutsomerDataPermissonVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; 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.core.vo.YifuUser;
import java.util.List;
/** /**
* 客户数据权限表 * 客户数据权限表
* *
...@@ -21,44 +23,17 @@ public interface TCutsomerDataPermissonService extends IService<TCutsomerDataPer ...@@ -21,44 +23,17 @@ public interface TCutsomerDataPermissonService extends IService<TCutsomerDataPer
* @param tCutsomerDataPermisson 客户数据权限表 * @param tCutsomerDataPermisson 客户数据权限表
* @return * @return
*/ */
IPage<TCutsomerDataPermissonVo> getTCutsomerDataPermissonPage(Page<TCutsomerDataPermissonVo> page, TCutsomerDataPermissonVo tCutsomerDataPermisson); IPage<TCutsomerDataPermisson> getTCutsomerDataPermissonPage(Page<TCutsomerDataPermisson> page, TCutsomerDataPermisson tCutsomerDataPermisson);
/**
* 查询数据所有者id
* @Author pwang
* @Date 2019-07-24 15:31
* @param domainId 实体id
* @param type 实体类型0:单位1:部门2:项目
* @return 返回数据所有者的id串
**/
String findOwnerIdByIdAndType(String domainId,int type);
/**
* 查询数据所有者
* @Author pwang
* @Date 2019-07-24 15:31
* @param domainId 实体id
* @param type 实体类型0:单位1:部门2:项目
* @return 返回数据所有者
**/
YifuUser findOwnerByIdAndType(String domainId, int type);
// /**
// * 获取当前登录人拥有的所有项目权限
// * @Author fxj
// * @Date 2019-08-26
// * @param userId
// * @return
// **/
// List<TCutsomerDataPermisson> selectAllSettleDomainPermissionByUserId(int userId);
String getCustomerServiceByid(String id);
/** /**
* 获取所有有权限的用户 * @param tCutsomerDataPermisson
* @Author pwang * @Description: 导出获取list
* @Date 2019-11-28 14:54 * @Author: hgw
* @param settleId * @Date: 2022/10/26 17:23
* @return * @return: java.util.List<com.yifu.cloud.plus.v1.yifu.archives.entity.TCutsomerDataPermisson>
**/ **/
String getUserByid(String settleId); List<TCutsomerDataPermisson> getTCutsomerDataPermissonList(TCutsomerDataPermisson tCutsomerDataPermisson);
/** /**
* 权限复制 将srcUserList里面的所有用户权限(表)赋给 beUser 所有人 * 权限复制 将srcUserList里面的所有用户权限(表)赋给 beUser 所有人
* @Author pwang * @Author pwang
...@@ -68,15 +43,5 @@ public interface TCutsomerDataPermissonService extends IService<TCutsomerDataPer ...@@ -68,15 +43,5 @@ public interface TCutsomerDataPermissonService extends IService<TCutsomerDataPer
* @param user user授权人 * @param user user授权人
* @return * @return
**/ **/
R insertForCopyCutsomerDataPermisson(String[] srcUserList, String[] beUser, YifuUser user); R<String> insertForCopyCutsomerDataPermisson(String[] srcUserList, String[] beUser, YifuUser user);
/**
* 专用方法 不建议调用 存在sql注入风险
* @Author pwang
* @Date 2020-07-02 19:00
* @param sql
* @param beUser
* @param user
* @return
**/
R insertCutsomerDataPermissonBySql(String sql, String beUser, YifuUser user);
} }
...@@ -21,8 +21,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; ...@@ -21,8 +21,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysArea; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysArea;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AllUserNaVo; import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AllUserNaVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AreaVo; import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AreaVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysUserListVo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TCutsomerDataPermisson; import com.yifu.cloud.plus.v1.yifu.archives.entity.TCutsomerDataPermisson;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain; import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TCutsomerDataPermissonMapper; import com.yifu.cloud.plus.v1.yifu.archives.mapper.TCutsomerDataPermissonMapper;
...@@ -169,11 +171,11 @@ public class TSettleDomainServiceImpl extends ServiceImpl<TSettleDomainMapper, T ...@@ -169,11 +171,11 @@ public class TSettleDomainServiceImpl extends ServiceImpl<TSettleDomainMapper, T
} }
// 处理服务团队数据权限 2022-09-19 fxj // 处理服务团队数据权限 2022-09-19 fxj
if (Common.isNotNull(tSettleDomain.getServiceTeam())){ if (Common.isNotNull(tSettleDomain.getServiceTeam())){
R<AllUserNaVo> res = upmsDaprUtils.getUserIdsByUserNames(tSettleDomain.getServiceTeam()); R<SysUserListVo> res = upmsDaprUtils.getUserIdsByUserNames(tSettleDomain.getServiceTeam());
if (Common.isNotNull(res) && Common.isNotNull(res.getData()) && Common.isNotNull(res.getData().getUserIds())){ if (Common.isNotNull(res) && Common.isNotNull(res.getData()) && Common.isNotNull(res.getData().getUserList())){
// 先清理缓存 // 先清理缓存
this.removeSettleCache(null,res.getData().getUserIds()); this.removeSettleCache(null,res.getData().getUserIds());
saveForEkp(res.getData().getUserIds(),tSettleDomain.getId()); saveForEkp(res.getData().getUserList(), tSettleDomain);
} }
} }
tSettleDomain.setDeleteFlag(CommonConstants.ZERO_STRING); tSettleDomain.setDeleteFlag(CommonConstants.ZERO_STRING);
...@@ -206,25 +208,28 @@ public class TSettleDomainServiceImpl extends ServiceImpl<TSettleDomainMapper, T ...@@ -206,25 +208,28 @@ public class TSettleDomainServiceImpl extends ServiceImpl<TSettleDomainMapper, T
* @Param * @Param
* @return * @return
**/ **/
public boolean saveForEkp(List<String> userIds, String domainId){ public boolean saveForEkp(List<SysUser> userIds, TSettleDomain domain){
// 1. 先清除现有的这些的项目权限 // 1. 先清除现有的这些的项目权限
permissonMapper.delete(Wrappers.<TCutsomerDataPermisson>query().lambda() permissonMapper.delete(Wrappers.<TCutsomerDataPermisson>query().lambda()
.in(TCutsomerDataPermisson::getBePermissonUser,userIds) .in(TCutsomerDataPermisson::getUserId,userIds)
.eq(TCutsomerDataPermisson::getSettleDomainId,domainId)); .eq(TCutsomerDataPermisson::getSettleDomainId,domain.getId()));
// 2.新增新的项目人员权限 // 2.新增新的项目人员权限
TCutsomerDataPermisson pm; TCutsomerDataPermisson pm;
if (Common.isNotNull(userIds)){ if (Common.isNotNull(userIds)) {
for (String uId:userIds){ for (SysUser user : userIds){
pm = new TCutsomerDataPermisson(); pm = new TCutsomerDataPermisson();
pm.setIsCustomerService(CommonConstants.ZERO_STRING); pm.setStatus(CommonConstants.ZERO_STRING);
pm.setIsOwner(CommonConstants.ONE_STRING); pm.setUserId(user.getUserId());
pm.setPermissonSrc("EKP服务团队"); pm.setUserLoginName(user.getUsername());
pm.setPermissonLevel(CommonConstants.ONE_INT); pm.setUserNickName(user.getNickname());
pm.setBePermissonUser(uId); pm.setUserDeptName(user.getDeptName());
pm.setBePermissionTime(LocalDateTime.now()); pm.setCreateTime(LocalDateTime.now());
pm.setSettleDomainId(domainId); pm.setSettleDomainId(domain.getId());
pm.setPermissionUser(CommonConstants.ONE_STRING); pm.setSettleDomainName(domain.getDepartName());
pm.setType(CommonConstants.TWO_STRING); pm.setSettleDomainNo(domain.getDepartNo());
pm.setCreateBy(CommonConstants.ONE_STRING);
pm.setCreateName("EKP同步");
pm.setType(CommonConstants.ZERO_STRING);
permissonMapper.insert(pm); permissonMapper.insert(pm);
} }
} }
......
...@@ -6,145 +6,72 @@ ...@@ -6,145 +6,72 @@
<resultMap id="tCutsomerDataPermissonMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TCutsomerDataPermisson"> <resultMap id="tCutsomerDataPermissonMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TCutsomerDataPermisson">
<id property="id" column="ID"/> <id property="id" column="ID"/>
<result property="isOwner" column="IS_OWNER"/> <result property="status" column="STATUS"/>
<result property="contractId" column="CONTRACT_ID"/> <result property="createBy" column="CREATE_BY"/>
<result property="customerId" column="CUSTOMER_ID"/> <result property="createName" column="CREATE_NAME"/>
<result property="permissonSrc" column="PERMISSON_SRC"/> <result property="createTime" column="CREATE_TIME"/>
<result property="permissonLevel" column="PERMISSON_LEVEL"/> <result property="userId" column="USER_ID"/>
<result property="permissionUser" column="PERMISSION_USER"/> <result property="userLoginName" column="USER_LOGIN_NAME"/>
<result property="bePermissonUser" column="BE_PERMISSON_USER"/> <result property="userNickName" column="USER_NICK_NAME"/>
<result property="bePermissionTime" column="BE_PERMISSION_TIME"/> <result property="userDeptName" column="USER_DEPT_NAME"/>
<result property="remark" column="REMARK"/> <result property="remark" column="REMARK"/>
<result property="type" column="type"/> <result property="type" column="type"/>
<result property="settleDomainId" column="SETTLE_DOMAIN_ID"/> <result property="settleDomainId" column="SETTLE_DOMAIN_ID"/>
</resultMap> <result property="settleDomainName" column="SETTLE_DOMAIN_NAME"/>
<resultMap id="tCutsomerDataPermissonMapVo" type="com.yifu.cloud.plus.v1.yifu.archives.vo.TCutsomerDataPermissonVo"> <result property="settleDomainNo" column="SETTLE_DOMAIN_NO"/>
<id property="id" column="ID"/>
<result property="isOwner" column="IS_OWNER"/>
<result property="contractId" column="CONTRACT_ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="permissonSrc" column="PERMISSON_SRC"/>
<result property="permissonLevel" column="PERMISSON_LEVEL"/>
<result property="permissionUser" column="PERMISSION_USER"/>
<result property="bePermissonUser" column="BE_PERMISSON_USER"/>
<result property="bePermissionTime" column="BE_PERMISSION_TIME"/>
<result property="remark" column="REMARK"/>
<result property="settleDomainId" column="SETTLE_DOMAIN_ID"/>
<result property="type" column="type"/>
<result property="name" column="name"/>
<result property="permissionUserName" column="nickname"/>
</resultMap> </resultMap>
<sql id="base_column_list"> <sql id="base_column_list">
a.ID, a.ID
a.IS_OWNER, ,a.STATUS
a.CONTRACT_ID, ,a.REMARK
a.CUSTOMER_ID, ,a.SETTLE_DOMAIN_ID
a.PERMISSON_SRC, ,a.CREATE_BY
a.PERMISSON_LEVEL, ,a.CREATE_NAME
a.PERMISSION_USER, ,a.CREATE_TIME
a.BE_PERMISSON_USER, ,a.USER_ID
a.BE_PERMISSION_TIME, ,a.USER_LOGIN_NAME
a.REMARK, ,a.USER_NICK_NAME
a.SETTLE_DOMAIN_ID, ,a.USER_DEPT_NAME
a.type ,a.TYPE
</sql> ,a.SETTLE_DOMAIN_NAME
,a.SETTLE_DOMAIN_NO
</sql>
<sql id="where_getTCutsomerDataPermissonPage"> <sql id="where_getTCutsomerDataPermissonPage">
<if test="tCutsomerDataPermisson.bePermissonUser != null and tCutsomerDataPermisson.bePermissonUser.trim() != ''"> <if test="tCutsomerDataPermisson != null">
AND a.BE_PERMISSON_USER = #{tCutsomerDataPermisson.bePermissonUser} <if test="tCutsomerDataPermisson.userNickName != null and tCutsomerDataPermisson.userNickName.trim() != ''">
</if> AND a.USER_NICK_NAME like concat('%',#{tCutsomerDataPermisson.userNickName},'%')
<if test="tCutsomerDataPermisson.type != null and tCutsomerDataPermisson.type.trim() != ''"> </if>
AND a.type = #{tCutsomerDataPermisson.type} <if test="tCutsomerDataPermisson.userLoginName != null and tCutsomerDataPermisson.userLoginName.trim() != ''">
</if> AND a.USER_LOGIN_NAME like concat('%',#{tCutsomerDataPermisson.userLoginName},'%')
<if test="tCutsomerDataPermisson.name != null and tCutsomerDataPermisson.name.trim() != ''"> </if>
AND a.name like '%${tCutsomerDataPermisson.name}%' <if test="tCutsomerDataPermisson.userDeptName != null and tCutsomerDataPermisson.userDeptName.trim() != ''">
</if> AND a.USER_DEPT_NAME like concat('%',#{tCutsomerDataPermisson.userDeptName},'%')
<if test="tCutsomerDataPermisson.id != null and tCutsomerDataPermisson.id.trim() != ''"> </if>
AND a.ID = #{tCutsomerDataPermisson.id} <if test="tCutsomerDataPermisson.status != null and tCutsomerDataPermisson.status.trim() != ''">
</if> AND a.STATUS = #{tCutsomerDataPermisson.status}
<if test="tCutsomerDataPermisson.isOwner != null and tCutsomerDataPermisson.isOwner.trim() != ''"> </if>
AND a.IS_OWNER = #{tCutsomerDataPermisson.isOwner} <if test="tCutsomerDataPermisson.settleDomainName != null and tCutsomerDataPermisson.settleDomainName.trim() != ''">
</if> AND a.SETTLE_DOMAIN_NAME like '%${tCutsomerDataPermisson.settleDomainName}%'
<if test="tCutsomerDataPermisson.permissonSrc != null and tCutsomerDataPermisson.permissonSrc.trim() != ''"> </if>
AND a.PERMISSON_SRC = #{tCutsomerDataPermisson.permissonSrc} <if test="tCutsomerDataPermisson.settleDomainNo != null and tCutsomerDataPermisson.settleDomainNo.trim() != ''">
</if> AND a.SETTLE_DOMAIN_NO like '%${tCutsomerDataPermisson.settleDomainNo}%'
<if test="tCutsomerDataPermisson.permissonLevel != null and tCutsomerDataPermisson.permissonLevel.trim() != ''"> </if>
AND a.PERMISSON_LEVEL = #{tCutsomerDataPermisson.permissonLevel} </if>
</if>
<if test="tCutsomerDataPermisson.permissionUser != null and tCutsomerDataPermisson.permissionUser.trim() != ''">
AND a.PERMISSION_USER = #{tCutsomerDataPermisson.permissionUser}
</if>
<if test="tCutsomerDataPermisson.bePermissionTime != null and tCutsomerDataPermisson.bePermissionTime.trim() != ''">
AND a.BE_PERMISSION_TIME = #{tCutsomerDataPermisson.bePermissionTime}
</if>
<if test="tCutsomerDataPermisson.remark != null and tCutsomerDataPermisson.remark.trim() != ''">
AND a.REMARK = #{tCutsomerDataPermisson.remark}
</if>
</sql> </sql>
<select id="getTCutsomerDataPermissonPageCount" resultType="java.lang.Long"> <!--分页查询-->
SELECT <select id="getTCutsomerDataPermissonPage" resultMap="tCutsomerDataPermissonMap">
count(1)
FROM view_cutsomer_permisson a
where 1=1
<include refid="where_getTCutsomerDataPermissonPage"/>
</select>
<!--查询-->
<select id="getTCutsomerDataPermissonPage" resultMap="tCutsomerDataPermissonMapVo">
SELECT SELECT
<include refid="base_column_list"/> <include refid="base_column_list"/>
,a.name from t_cutsomer_data_permisson a
,u.nickname
from view_cutsomer_permisson a
left join yifu_cloud.sys_user u on a.PERMISSION_USER = u.user_id
where 1=1 where 1=1
<include refid="where_getTCutsomerDataPermissonPage"/> <include refid="where_getTCutsomerDataPermissonPage"/>
ORDER BY a.BE_PERMISSION_TIME DESC ORDER BY a.CREATE_TIME DESC
<if test="null != page and null != size">
limit #{page},#{size}
</if>
</select>
<select id="getOwnerIdByIdAndType" resultType="java.lang.String">
SELECT BE_PERMISSON_USER FROM t_cutsomer_data_permisson
WHERE IS_OWNER = '0'
<if test="0==type">
AND CUSTOMER_ID = '${domainId}'
</if>
<if test="1==type">
AND CONTRACT_ID = '${domainId}'
</if>
<if test="2==type">
AND SETTLE_DOMAIN_ID = '${domainId}'
</if>
ORDER BY BE_PERMISSION_TIME ASC
limit 1
</select> </select>
<!-- 获取当前登录人拥有的所有项目权限 --> <!-- 获取当前登录人拥有的所有项目权限 -->
<select id="selectAllSettleDomainPermissionByUserId" resultMap="tCutsomerDataPermissonMap"> <select id="selectAllSettleDomainPermissionByUserId" resultMap="tCutsomerDataPermissonMap">
SELECT SELECT
<include refid="base_column_list"/> <include refid="base_column_list"/>
FROM t_cutsomer_data_permisson a FROM t_cutsomer_data_permisson a
WHERE 1=1 WHERE a.STATUS = '0' and a.USER_ID = #{userId}
AND SETTLE_DOMAIN_ID IS NOT NULL
AND BE_PERMISSON_USER = '${userId}'
</select>
<select id="getCustomerServiceByid" resultType="java.lang.String">
SELECT
GROUP_CONCAT(distinct BE_PERMISSON_USER )
FROM
t_cutsomer_data_permisson
WHERE
IS_CUSTOMER_SERVICE = '0'
AND SETTLE_DOMAIN_ID = '${id}'
</select> </select>
<select id="getUserByid" resultType="java.lang.String">
SELECT
GROUP_CONCAT(distinct BE_PERMISSON_USER )
FROM
t_cutsomer_data_permisson
WHERE
SETTLE_DOMAIN_ID = '${settleId}'
</select>
</mapper> </mapper>
...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.common.dapr.util; ...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.common.dapr.util;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AllUserNaVo; import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AllUserNaVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AreaVo; import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AreaVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysUserListVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; 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.util.R;
...@@ -59,8 +60,8 @@ public class UpmsDaprUtils { ...@@ -59,8 +60,8 @@ public class UpmsDaprUtils {
* @Param * @Param
* @return * @return
**/ **/
public R<AllUserNaVo> getUserIdsByUserNames(String usernames) { public R<SysUserListVo> getUserIdsByUserNames(String usernames) {
R<AllUserNaVo> allUserVoR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(),daprUpmsProperties.getAppId(),"/user/inner/getUserIdsByUserNames", usernames, AllUserNaVo.class, SecurityConstants.FROM_IN); R<SysUserListVo> allUserVoR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(),daprUpmsProperties.getAppId(),"/user/inner/getUserIdsByUserNames", usernames, SysUserListVo.class, SecurityConstants.FROM_IN);
if (Common.isEmpty(allUserVoR)){ if (Common.isEmpty(allUserVoR)){
return R.failed("获取指定用户名对应用户IDs失败!"); return R.failed("获取指定用户名对应用户IDs失败!");
} }
......
package com.yifu.cloud.plus.v1.yifu.admin.api.vo;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Author Hgw
* @Date 2022-10-26 17:09:09
* @Description
* @Version 1.0
*/
@Data
public class SysUserListVo implements Serializable {
private List<SysUser> userList;
private List<String> userIds;
}
...@@ -25,10 +25,7 @@ import com.pig4cloud.plugin.excel.annotation.ResponseExcel; ...@@ -25,10 +25,7 @@ import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserDTO; import com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserDTO;
import com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserInfo; import com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserInfo;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AllUserNaVo; import com.yifu.cloud.plus.v1.yifu.admin.api.vo.*;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserExcelVO;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserInfoVO;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserVO;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysUserService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysUserService;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes; import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
...@@ -304,8 +301,8 @@ public class UserController { ...@@ -304,8 +301,8 @@ public class UserController {
**/ **/
@Inner @Inner
@PostMapping(value = {"/inner/getUserIdsByUserNames"}) @PostMapping(value = {"/inner/getUserIdsByUserNames"})
public AllUserNaVo getUserIdsByUserNames(@RequestBody String usernames) { public SysUserListVo getUserIdsByUserNames(@RequestBody String usernames) {
AllUserNaVo naVo = new AllUserNaVo(); SysUserListVo naVo = new SysUserListVo();
if (Common.isEmpty(usernames)){ if (Common.isEmpty(usernames)){
return naVo; return naVo;
} }
...@@ -315,9 +312,9 @@ public class UserController { ...@@ -315,9 +312,9 @@ public class UserController {
List<String> userIds = new ArrayList<>(); List<String> userIds = new ArrayList<>();
for (SysUser u:sysUsers){ for (SysUser u:sysUsers){
userIds.add(u.getUserId()); userIds.add(u.getUserId());
} }
naVo.setUserIds(userIds); naVo.setUserIds(userIds);
naVo.setUserList(sysUsers);
} }
return naVo; return naVo;
} }
......
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