Commit eca6d68d authored by hongguangwu's avatar hongguangwu

EKP1.7.1-hgw-权限

parent b7dfe220
package com.yifu.cloud.plus.v1.yifu.permission.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* @Author hgw
* @Date 2023-9-21 17:03:57
* @Description
* @Version 1.0
*/
@Data
public class IdTypeEkpVo implements Serializable {
/**
* 主键
*/
@Schema(description = "主键")
private String fdId;
/**
* 类型
*/
@Schema(description = "类型")
private String type;
}
package com.yifu.cloud.plus.v1.permission.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.permission.service.SysUserPermissionService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserPermission;
import com.yifu.cloud.plus.v1.yifu.permission.vo.IdTypeEkpVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysDictVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserDeptVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionSearchVo;
......@@ -19,6 +22,8 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
/**
......@@ -157,4 +162,26 @@ public class SysUserPermissionController {
public R<List<SysDictVo>> selectDictByType(@RequestParam String type) {
return new R<>(sysUserPermissionService.selectDictByType(type));
}
/**
* 修改项目表--EKP调用接口
* @author hyc
* @param jsonStr 项目表
* @return R
*/
@Operation(summary = "自动同步权限--EKP调用接口", description = "自动同步权限--EKP调用接口")
@SysLog("自动同步权限--EKP调用接口")
@PostMapping("/autoCreateAuth")
public R<String> autoCreateAuth(@RequestBody String jsonStr) {
try {
jsonStr = URLDecoder.decode(jsonStr, CommonConstants.UTF8).replace("=", "");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
List<IdTypeEkpVo> list= JSONObject.parseArray(jsonStr, IdTypeEkpVo.class);
if (list != null && !list.isEmpty()) {
return sysUserPermissionService.autoCreateAuth(list.get(0));
}
return R.failed("自动同步权限错误-无参数");
}
}
......@@ -190,5 +190,19 @@ public interface SysUserPermissionMapper extends BaseMapper<SysUserPermission> {
**/
List<SysUserPermission> getUserPermissionByUserId(@Param("userId") String userId);
List<SysUserPermission> getUserPermissionByAutoCreateKH(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateSJ(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateBJD(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateHT(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateXM(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateKHCX(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateSJCX(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateBJDCX(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateHTCX(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateXMCX(@Param("fdId") String fdId);
void deleteUserPermissionByIdAndType(@Param("domainId") String domainId, @Param("permissionType") String permissionType);
}
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserPermission;
import com.yifu.cloud.plus.v1.yifu.permission.vo.IdTypeEkpVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysDictVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserDeptVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionSearchVo;
......@@ -46,4 +47,6 @@ public interface SysUserPermissionService extends IService<SysUserPermission> {
IPage<SysUserDeptVo> getNameCodePage(Page<SysUserDeptVo> page, SysUserDeptVo searchVo);
List<SysDictVo> selectDictByType(String type);
R<String> autoCreateAuth(IdTypeEkpVo vo);
}
......@@ -424,4 +424,55 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
return baseMapper.selectSettleCount(name);
}
}
@Override
public R<String> autoCreateAuth(IdTypeEkpVo vo) {
String fdId = vo.getFdId();
String type = vo.getType();
// 先找到表(客户、项目、项目立项等),找到创建人、服务团队;
// 组装实体类,查重,新增或更新
List<SysUserPermission> list;
// 1客户;2商机;3报价单;4合同;5项目;
String[] deleteType = {"0","1","2","3","4","5"};
log.error("EKP传过来的类型是啥0?" + type);
switch (type) {
case "客户":
baseMapper.deleteUserPermissionByIdAndType(fdId, deleteType[1]);
list = baseMapper.getUserPermissionByAutoCreateKH(fdId); break;
case "商机":
baseMapper.deleteUserPermissionByIdAndType(fdId, deleteType[2]);
list = baseMapper.getUserPermissionByAutoCreateSJ(fdId); break;
case "报价单":
baseMapper.deleteUserPermissionByIdAndType(fdId, deleteType[3]);
list = baseMapper.getUserPermissionByAutoCreateBJD(fdId); break;
case "合同":
baseMapper.deleteUserPermissionByIdAndType(fdId, deleteType[4]);
list = baseMapper.getUserPermissionByAutoCreateHT(fdId); break;
case "项目":
baseMapper.deleteUserPermissionByIdAndType(fdId, deleteType[5]);
list = baseMapper.getUserPermissionByAutoCreateXM(fdId); break;
default:
log.error("EKP传过来的类型是啥1?" + type);
// 后面改为这个:
// list = new ArrayList<>()
list = baseMapper.getUserPermissionByAutoCreateKH(fdId);
baseMapper.deleteUserPermissionByIdAndType(fdId, deleteType[1]);
}
if (list != null && !list.isEmpty()) {
for (SysUserPermission sysUserPermission : list) {
SysUserPermission permission = this.getOne(Wrappers.<SysUserPermission>query().lambda()
.eq(SysUserPermission::getDeleteFlag, CommonConstants.ONE_STRING)
.eq(SysUserPermission::getEmpLoginName, sysUserPermission.getEmpLoginName())
.eq(SysUserPermission::getPermissionType, sysUserPermission.getPermissionType())
.eq(SysUserPermission::getCode, sysUserPermission.getCode()).last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(permission) && Common.isEmpty(permission.getId())) {
this.save(sysUserPermission);
}
}
}
return R.ok();
}
}
......@@ -291,4 +291,128 @@
ORDER BY p.PERMISSION_TYPE
</select>
<!-- 查找权限,用来新建 - 客户 -->
<select id="getUserPermissionByAutoCreateKH" resultMap="sysUserPermissionMap">
select
e.fd_name EMP_NAME ,p.fd_login_name EMP_LOGIN_NAME ,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'1' PERMISSION_TYPE ,d.fd_3a9d1d4caeeeb8 NAME ,d.fd_3a9d1d4d438bfc CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS ,'0' PERMISSION_STATUS ,'1' DELETE_FLAG ,e.fd_id USER_ID ,d.fd_id DOMAIN_ID
from ekp_fa3e25a1b6c472683e96 d
LEFT JOIN ekp_c472683e96_8b4d79b2c8 f on f.fd_parent_id = d.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.fd_3b118b5e5d1024
JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId} GROUP BY e.fd_id
</select>
<!-- 查找权限,用来新建 - 商机 -->
<select id="getUserPermissionByAutoCreateSJ" resultMap="sysUserPermissionMap">
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'2' PERMISSION_TYPE,d.fd_3b04b95268f19c NAME,d.fd_3b107f1084fd96 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_24385b8cc934eb8a9231 d
LEFT JOIN ekp_34eb8a9231_8c4fb81d42 f on f.fd_parent_id = d.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.fd_3b0e8c7f169ed2
JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId} GROUP BY e.fd_id
</select>
<!-- 查找权限,用来新建 - 报价单 -->
<select id="getUserPermissionByAutoCreateBJD" resultMap="sysUserPermissionMap">
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'3' PERMISSION_TYPE,d.fd_3b04b9d8688cfa NAME,d.fd_3b04b9dc64a9f4 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_fd06fd1251d4bac8cc91 d
LEFT JOIN ekp_d4bac8cc91_8aad2804b4 f1 on f1.fd_parent_id = d.fd_id
LEFT JOIN ekporg_18308def06b6c534b70e f on f.fd_parent_id = f1.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.sys_org_person_id JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId} GROUP BY e.fd_id
</select>
<!-- 查找权限,用来新建 - 合同 -->
<select id="getUserPermissionByAutoCreateHT" resultMap="sysUserPermissionMap">
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'4' PERMISSION_TYPE,d.fd_3ad97ed761c75c NAME,d.fd_3ade319226ed52 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_4834ce2ea964f1a8cfdb d
LEFT JOIN ekporg_183823dc7ae199aa37e9 f on f.fd_parent_id = d.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.sys_org_person_id JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId} GROUP BY e.fd_id
</select>
<!-- 查找权限,用来新建 - 项目 -->
<select id="getUserPermissionByAutoCreateXM" resultMap="sysUserPermissionMap">
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'5' PERMISSION_TYPE,d.fd_3a829ae9bab760 NAME,d.fd_3a829aea0b84a4 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_fb3b8d0c8f148639b8e2 d
LEFT JOIN ekporg_1832fea7d722404c1e92 f on f.fd_parent_id = d.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.sys_org_person_id JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId} GROUP BY e.fd_id
</select>
<!-- 查找权限,用来新建 - 客户查询 -->
<select id="getUserPermissionByAutoCreateKHCX" resultMap="sysUserPermissionMap">
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'1' PERMISSION_TYPE ,d.fd_3a9d1d4caeeeb8 NAME ,d.fd_3a9d1d4d438bfc CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_05b7485fd444f95a6177 d
LEFT JOIN ekp_44f95a6177_14e68ce19e f1 on f1.fd_parent_id = d.fd_id
LEFT JOIN ekporg_1845a78746d15965cc5c f on f.fd_parent_id = f1.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.sys_org_person_id JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId} GROUP BY e.fd_id
</select>
<!-- 查找权限,用来新建 - 商机查询 -->
<select id="getUserPermissionByAutoCreateSJCX" resultMap="sysUserPermissionMap">
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'2' PERMISSION_TYPE,d.fd_3b04b95268f19c NAME,d.fd_3b107f1084fd96 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_2f8e08660c542d8a169f d
LEFT JOIN ekp_542d8a169f_8c4fb81d42 f1 on f1.fd_parent_id = d.fd_id
LEFT JOIN ekporg_183ea651979d3c384f1f f on f.fd_parent_id = f1.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.sys_org_person_id JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId} GROUP BY e.fd_id
</select>
<!-- 查找权限,用来新建 - 报价单查询 -->
<select id="getUserPermissionByAutoCreateBJDCX" resultMap="sysUserPermissionMap">
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'3' PERMISSION_TYPE,d.fd_3b04b9d8688cfa NAME,d.fd_3b04b9dc64a9f4 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_fd1449d265845e087bf2 d
LEFT JOIN ekp_845e087bf2_8aad2804b4 f1 on f1.fd_parent_id = d.fd_id
LEFT JOIN ekporg_18316f3cee7e12c284ff f on f.fd_parent_id = f1.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.sys_org_person_id JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId} GROUP BY e.fd_id
</select>
<!-- 查找权限,用来新建 - 合同查询 -->
<select id="getUserPermissionByAutoCreateHTCX" resultMap="sysUserPermissionMap">
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'4' PERMISSION_TYPE,d.fd_3ade334bac0016 NAME,d.fd_3ade33763baa0e CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_0103c453b2848c3bb31c d
LEFT JOIN ekporg_18382406ad7dbdebcf33 f on f.fd_parent_id = d.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.sys_org_person_id JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId} GROUP BY e.fd_id
</select>
<!-- 查找权限,用来新建 - 项目查询 -->
<select id="getUserPermissionByAutoCreateXMCX" resultMap="sysUserPermissionMap">
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'5' PERMISSION_TYPE,d.fd_3a2b38c61ef9aa NAME,d.fd_3a37fe508071fe CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_24a8e6a7fc143bb8c48a d
LEFT JOIN ekporg_183300291c3846bd9057 f on f.fd_parent_id = d.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.sys_org_person_id JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId} GROUP BY e.fd_id
</select>
<!-- 删除EKP新建的 -->
<delete id="deleteUserPermissionByIdAndType">
delete from sys_user_permission p
where SOURCE_TYPE = 0 and DOMAIN_ID = #{domainId} and PERMISSION_TYPE = #{permissionType}
</delete>
</mapper>
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