Commit 879409b1 authored by huyuchen's avatar huyuchen

Merge remote-tracking branch 'origin/MVP1.7.7' into MVP1.7.7

parents 0254a835 3110d6b7
apiVersion: apps/v1
kind: Deployment
metadata:
name: yifu-prd-webcsp
namespace: prd-mvp
spec:
selector:
matchLabels:
app: yifu-prd-webcsp
replicas: 1
template: # 模版
metadata: # 模版
labels: # 设定资源的标签
app: yifu-prd-webcsp
annotations:
dapr.io/enabled: "true" #设定此参数为 true 注入Dapr sidecar到pod
dapr.io/app-id: "yifu-prd-webcsp" #应用程序唯一 ID。 用于服务发现、状态封装 和 发布/订阅 消费者ID
dapr.io/app-port: "8889" #这个参数告诉Dapr你的应用程序正在监听哪个端口。
#dapr.io/log-level: "debug" #为 Dapr sidecar设置日志级别。 允许的值是debug,info,warn,error。 默认是 info
#dapr.io/log-as-json: "false" #将此参数设置为true以JSON格式输出日志。 默认值为 false.
#dapr.io/config: file #告诉 Dapr 要使用哪个配置 CRD
dapr.io/app-protocol: "http" #告诉 Dapr 你的应用程序正在使用哪种协议。 有效选项是 http and grpc。 Default is http
#dapr.io/app-max-concurrency: "20" #限制应用程序的并发量。 有效的数值是大于 0
#dapr.io/app-ssl: "false" #告诉Dapr通过不安全的SSL连接调用应用程序。 同时适用于HTTP和gRPC。 Traffic between your app and the Dapr sidecar is encrypted with a certificate issued by a non-trusted certificate authority, which is considered insecure. 默认值为 false.
dapr.io/metrics-port: "9090" #设置 sidecar 度量服务器的端口。 默认值为 9090
#dapr.io/sidecar-cpu-limit: 2 #Dapr sidecar可以使用的最大CPU数量。 默认情况下未设置
#dapr.io/sidecar-memory-limit: "800Mi" #Dapr sidecar可以使用的最大内存量。默认情况下未设置 请参阅 https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/ 的有效值。
#dapr.io/sidecar-cpu-request: 1 #Dapr sidecar要求的 CPU 数量
#dapr.io/sidecar-memory-request #Dapr sidecar 请求的内存数量
dapr.io/http-max-request-size: "100" #增加http和grpc服务器请求正文参数的最大大小,单位为MB,以处理大文件的上传。 默认值为 4 MB
dapr.io/http-read-buffer-size: "16" #Dapr has a default limit of 4KB for the http header read buffer size. When sending http headers that are bigger than the default 4KB, you can increase this value. Otherwise, you may encounter a Too big request header
#dapr.io/sidecar-listen-addresses: "0.0.0.0"
# 更多dapr配置请参考 https://www.bookstack.cn/read/dapr-1.5-zh/cc77b74e2cc2f4d4.md
spec:
nodeSelector:
node-type: worker
containers:
- name: yifu-prd-webcsp
image: hub.worfu.com/prd-mvp/yifu-prd-webcsp:1.0.0
imagePullPolicy: Always
ports:
- containerPort: 8889
env:
- name: TZ
value: Asia/Shanghai
resources:
requests:
memory: "100Mi"
limits:
memory: "200Mi"
imagePullSecrets:
- name: login
apiVersion: v1
kind: Service
metadata:
name: yifu-prd-webcsp
namespace: prd-mvp
labels:
k8s-app: yifu-prd-webcsp
spec:
ports:
- name: yifu-prd-webcsp
port: 80
protocol: TCP
targetPort: 8889
selector:
app: yifu-prd-webcsp
...@@ -89,7 +89,7 @@ public class FileUploadServiceImpl implements FileUploadService { ...@@ -89,7 +89,7 @@ public class FileUploadServiceImpl implements FileUploadService {
true, true,
"1", authorities, "1", "1", authorities, "1",
null, null, null, null,
null); null,null);
attaInfo.setCreateBy(user.getId()); attaInfo.setCreateBy(user.getId());
attaInfo.setCreateName(user.getNickname()); attaInfo.setCreateName(user.getNickname());
attaInfo = tAttaInfoService.add(attaInfo); attaInfo = tAttaInfoService.add(attaInfo);
......
...@@ -1719,7 +1719,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE ...@@ -1719,7 +1719,7 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
true, true,
"1", authorities, "1", "1", authorities, "1",
null, null, null, null,
null); null,null);
} }
/** /**
......
...@@ -117,7 +117,7 @@ public class YifuTokenEndpoint { ...@@ -117,7 +117,7 @@ public class YifuTokenEndpoint {
CommonConstants.STATUS_NORMAL.equals(user.getLockFlag()), CommonConstants.STATUS_NORMAL.equals(user.getLockFlag()),
user.getUserGroup(),authorities, user.getLdapDn(), user.getUserGroup(),authorities, user.getLdapDn(),
info.getClientRoleMap(),info.getSettleIdList(), info.getClientRoleMap(),info.getSettleIdList(),
user.getType()); user.getType(),info.getCspPermMap());
thisUser.setClientRoleMap(info.getClientRoleMap()); thisUser.setClientRoleMap(info.getClientRoleMap());
return thisUser; return thisUser;
} }
......
...@@ -5,6 +5,8 @@ import cn.hutool.core.util.CharsetUtil; ...@@ -5,6 +5,8 @@ import cn.hutool.core.util.CharsetUtil;
import cn.hutool.http.HttpStatus; import cn.hutool.http.HttpStatus;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.yifu.cloud.plus.v1.yifu.auth.constants.SecurityConstants; import com.yifu.cloud.plus.v1.yifu.auth.constants.SecurityConstants;
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.Common;
......
...@@ -597,7 +597,7 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh ...@@ -597,7 +597,7 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh
true, true,
"1", authorities, "1", "1", authorities, "1",
null, null, null, null,
null); null,null);
// 调用以前的批量校验 // 调用以前的批量校验
R<List<TCheckIdCard>> returnR = this.checkSalaryIdCard(list, user); R<List<TCheckIdCard>> returnR = this.checkSalaryIdCard(list, user);
if (returnR != null) { if (returnR != null) {
......
package com.yifu.cloud.plus.v1.yifu.admin.api.vo; package com.yifu.cloud.plus.v1.yifu.common.core.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
...@@ -33,7 +32,13 @@ public class UserPermissionVo implements Serializable { ...@@ -33,7 +32,13 @@ public class UserPermissionVo implements Serializable {
* 用户ID * 用户ID
*/ */
private String userId; private String userId;
/**
* 关联项目编码 fxj 2025-02-25
*/
private String projectNo;
/**
private Map<String,UserPermissionVo> permissionVoMap; * 关联项目名称 fxj 2025-02-25
*/
private String projectName;
} }
...@@ -92,9 +92,18 @@ public class YifuUser extends User { ...@@ -92,9 +92,18 @@ public class YifuUser extends User {
@Getter @Getter
@Setter @Setter
private List<String> settleIdList; private List<String> settleIdList;
/**
* @Author fxj
* @Description 客户服务平台 项目权限及项目对应的数据权限
* @Date 14:48 2025/2/25
**/
@Getter
@Setter
private List<UserPermissionVo> cspPermMap;
/** /**
* @Author fxj * @Author fxj
* @Description 员工类型 * @Description 员工类型 0 系统用户 1 LDAP用户 2 B端用户 3.微信用户 默认系统用户 4.甲方客户端
**/ **/
@Getter @Getter
private String type; private String type;
...@@ -104,7 +113,8 @@ public class YifuUser extends User { ...@@ -104,7 +113,8 @@ public class YifuUser extends User {
boolean credentialsNonExpired, boolean accountNonLocked, boolean credentialsNonExpired, boolean accountNonLocked,
String userGroup, Collection<? extends GrantedAuthority> authorities, String ldapDn, String userGroup, Collection<? extends GrantedAuthority> authorities, String ldapDn,
Map<String, List<Long>> clientRoleMap, Map<String, List<Long>> clientRoleMap,
List<String> settleIdList,String type) { List<String> settleIdList,String type,
List<UserPermissionVo> cspPermMap) {
super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities); super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
this.id = id; this.id = id;
this.deptId = deptId; this.deptId = deptId;
...@@ -117,5 +127,6 @@ public class YifuUser extends User { ...@@ -117,5 +127,6 @@ public class YifuUser extends User {
this.clientRoleMap=clientRoleMap; this.clientRoleMap=clientRoleMap;
this.settleIdList=settleIdList; this.settleIdList=settleIdList;
this.type=type; this.type=type;
this.cspPermMap=cspPermMap;
} }
} }
...@@ -94,6 +94,6 @@ public class WxUserDetailService implements UserDetailsService { ...@@ -94,6 +94,6 @@ public class WxUserDetailService implements UserDetailsService {
user.getPhone(), true, true, true, user.getPhone(), true, true, true,
StrUtil.equals(user.getLockFlag(), CommonConstants.STATUS_NORMAL), StrUtil.equals(user.getLockFlag(), CommonConstants.STATUS_NORMAL),
user.getUserGroup(),authorities, user.getLdapDn(),info.getClientRoleMap(), user.getUserGroup(),authorities, user.getLdapDn(),info.getClientRoleMap(),
info.getSettleIdList(),user.getType()); info.getSettleIdList(),user.getType(),null);
} }
} }
...@@ -72,7 +72,7 @@ public interface YifuUserDetailsService extends UserDetailsService, Ordered { ...@@ -72,7 +72,7 @@ public interface YifuUserDetailsService extends UserDetailsService, Ordered {
user.getPhone(), true, true, true, user.getPhone(), true, true, true,
StrUtil.equals(user.getLockFlag(), CommonConstants.STATUS_NORMAL), StrUtil.equals(user.getLockFlag(), CommonConstants.STATUS_NORMAL),
user.getUserGroup(),authorities, user.getLdapDn(),info.getClientRoleMap(), user.getUserGroup(),authorities, user.getLdapDn(),info.getClientRoleMap(),
info.getSettleIdList(),user.getType()); info.getSettleIdList(),user.getType(),info.getCspPermMap());
} }
/** /**
......
...@@ -53,10 +53,6 @@ ...@@ -53,10 +53,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId> <artifactId>spring-boot-starter-undertow</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-core</artifactId>
</dependency>
</dependencies> </dependencies>
......
...@@ -51,4 +51,11 @@ public class UserDTO extends SysUser { ...@@ -51,4 +51,11 @@ public class UserDTO extends SysUser {
*/ */
private String newpassword1; private String newpassword1;
/**
* 姓名或者手机号搜索
* chenyuxi
* @since 1.9.7
*/
private String nameOrPhone;
} }
...@@ -19,6 +19,7 @@ package com.yifu.cloud.plus.v1.yifu.admin.api.dto; ...@@ -19,6 +19,7 @@ package com.yifu.cloud.plus.v1.yifu.admin.api.dto;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysPost; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysPost;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole;
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.common.core.vo.UserPermissionVo;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
...@@ -76,4 +77,11 @@ public class UserInfo implements Serializable { ...@@ -76,4 +77,11 @@ public class UserInfo implements Serializable {
* @Date 13:53 2023/1/3 * @Date 13:53 2023/1/3
**/ **/
private List<String> settleIdList; private List<String> settleIdList;
/**
* @Author fxj
* @Description 客户服务平台 项目权限及项目对应的数据权限
* @Date 14:48 2025/2/25
**/
private List<UserPermissionVo> cspPermMap;
} }
...@@ -23,6 +23,8 @@ import io.swagger.v3.oas.annotations.media.Schema; ...@@ -23,6 +23,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
/** /**
* 项目下用户部门及权限 * 项目下用户部门及权限
* *
...@@ -35,22 +37,30 @@ public class SysUserDeptPermission extends Model<SysUserDeptPermission> { ...@@ -35,22 +37,30 @@ public class SysUserDeptPermission extends Model<SysUserDeptPermission> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableId(value = "user_id", type = IdType.ASSIGN_ID) @TableId(value = "id", type = IdType.ASSIGN_ID)
@Schema(description = "主键id") @Schema(description = "主键id")
private String id; private String id;
@NotBlank(message = "用户id 不能为空")
@Schema(description = "用户id") @Schema(description = "用户id")
private String userId; private String userId;
@NotBlank(message = "部门id 不能为空")
@Schema(description = "部门id") @Schema(description = "部门id")
private Long deptId; private Long deptId;
@NotBlank(message = "关联项目编码 不能为空")
@Schema(description = "关联项目编码") @Schema(description = "关联项目编码")
private String projectNo; private String projectNo;
@Schema(description = "归属系统 0 mvp 1 甲方客户端") @NotBlank(message = "关联项目名称 不能为空")
@Schema(description = "关联项目名称")
private String projectName;
@Schema(description = "归属系统 yifu-mvp、yifu-csp")
private String client; private String client;
@NotBlank(message = "账号类型 不能为空")
@Schema(description = "账号类型:0 管理员, 1 普通成员") @Schema(description = "账号类型:0 管理员, 1 普通成员")
private String userType; private String userType;
......
package com.yifu.cloud.plus.v1.yifu.admin.api.vo;
import lombok.Data;
import javax.sql.rowset.serial.SerialArray;
import java.io.Serializable;
/**
* @Author fxj
* @Date 2025/2/26
* @Description 部门排序树
* @Version 1.0
*/
@Data
public class DeptSortVo implements Serializable {
/**
* @Author fxj
* @Description 部门ID
* @Date 17:27 2025/2/26
**/
private String id;
/**
* @Author fxj
* @Description 部门排序
* @Date 17:27 2025/2/26
**/
private String sort;
}
package com.yifu.cloud.plus.v1.yifu.admin.api.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
/**
* 客户服务平台——部门树
*
* @author chenyuxi
* @since 1.9.7
*/
@Data
public class DeptTreeSelectVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 部门ID
*/
private Long deptId;
/**
* 父部门ID
*/
private Long parentId;
/**
* 祖级列表
*/
private String ancestors;
/**
* 部门名称
*/
private String name;
/**
* 父部门名称
*/
private String parentName;
/**
* 部门总人数
*/
private String peopleNum;
private Integer sortOrder;
private List<DeptTreeSelectVO> children;
public DeptTreeSelectVO(SysDeptVo dept) {
this.deptId = dept.getDeptId();
this.parentId = dept.getParentId();
this.ancestors = dept.getAncestors();
this.name = dept.getName();
this.sortOrder = dept.getSortOrder();
this.parentName = dept.getParentName();
this.peopleNum =dept.getPeopleNum();
if(dept.getChildren() != null){
this.children = dept.getChildren().stream().map(DeptTreeSelectVO::new).collect(Collectors.toList());
}
}
}
package com.yifu.cloud.plus.v1.yifu.admin.api.vo;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 客户服务平台——部门包装类
*
* @author chenyuxi
* @since 1.9.7
*/
@Data
public class SysDeptMoveVo implements Serializable {
/**
* @Author fxj
* @Description 部门ID
* @Date 17:29 2025/2/26
**/
private String sysDeptId;
/**
* @Author fxj
* @Description 部门父级ID
* @Date 17:29 2025/2/26
**/
private String parentId;
/**
* @Author fxj
* @Description 部门排序信息
* @Date 17:29 2025/2/26
**/
private List<DeptSortVo> deptSortList;
}
package com.yifu.cloud.plus.v1.yifu.admin.api.vo;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 客户服务平台——部门包装类
*
* @author chenyuxi
* @since 1.9.7
*/
@Data
public class SysDeptVo extends SysDept {
/** 子部门 */
private List<SysDeptVo> children;
/**
* 父部门名称
*/
private String parentName;
/**
* 部门人数
*/
private String peopleNum;
}
/*
* Copyright (c) 2020 yifu4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yifu.cloud.plus.v1.yifu.admin.api.vo;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysPost;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author lengleng
* @date 2019/2/1
*/
@Data
public class UserCspVO extends SysUser implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用户Id
*/
private String userId;
/**
* 用户名
*/
@NotBlank(message = "用户名 不能为空")
private String username;
/**
* 用户昵称
*/
@NotBlank(message = "用户昵称 不能为空")
private String nickname;
/**
* 手机号码
*/
@NotBlank(message = "手机号码 不能为空")
private String phone;
/**
* 部门ID
*/
@NotBlank(message = "部门ID 不能为空")
private Long deptId;
//关系表数据开始
@NotBlank(message = "关联项目编码 不能为空")
@Schema(description = "关联项目编码")
private String projectNo;
@NotBlank(message = "关联项目名称 不能为空")
@Schema(description = "关联项目名称")
private String projectName;
@Schema(description = "归属系统 0 yifu-mvp 1 yifu-csp")
private String client;
@NotBlank(message = "账号类型 不能为空")
@Schema(description = "账号类型:0 管理员, 1 普通成员")
private String userType;
}
package com.yifu.cloud.plus.v1.yifu.admin.constants;
/**
* @Author fxj
* @Description 客户服务平台相关常量
* @Date 16:45 2025/2/26
* @Param
* @return
**/
public class UserDeptPermConstants {
// 社保补缴配置有误!
public static final String PERMISSION_SAVE_ERROR = "客户服务平台用户更新异常!";
public static final String ADMIN_DISABLE_ERROR = "管理员账号禁止收回,如需操作请先修改用户为普通用户!";
public static final String USER_EXITS_ERROR = "已存在对应用户数据,请勿重复配置!";
public static final String CUSTOMER_SERVICE_PLATFORM = "客户服务平台用户";
public static final String DEFAULT_PASSWORD = "123456";
public static final String ERROR_TEMPLATE = "模板中已存在对应员工";
public static final String YL = "养老";
public static final String DB = "大病";
public static final String SY = "失业";
public static final String BIR = "生育";
public static final String GS = "工伤";
public static final String YB = "医保";
public static final String BJ = "补缴";
public static final String YEAR_1970 = "1970-02";
public static final String NOT_EXIT_SETTLEiNFO = "未找到该人员对应的项目信息,请核实";
public static final String ERROR_PRI = "该人员归属的";
public static final String ERROR_END = "信息缺失,将导致后续无法结算,请联系卢名旭处理";
}
...@@ -18,7 +18,12 @@ package com.yifu.cloud.plus.v1.yifu.admin.controller; ...@@ -18,7 +18,12 @@ package com.yifu.cloud.plus.v1.yifu.admin.controller;
import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.DeptTreeSelectVO;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysDeptMoveVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysDeptVo;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptService;
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.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner; import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
...@@ -154,4 +159,103 @@ public class DeptController { ...@@ -154,4 +159,103 @@ public class DeptController {
public R innerUpdateDeptByLdap() { public R innerUpdateDeptByLdap() {
return R.ok(sysDeptService.updateDeptByLdap()); return R.ok(sysDeptService.updateDeptByLdap());
} }
/**
* 客户服务平台——获取部门树(用于下拉选择)
* @return 树形菜单
*/
@GetMapping(value = "/csp/list")
public R<List<DeptTreeSelectVO>> cspList(SysDeptVo dept) {
if(Common.isEmpty(dept.getProjectNo())){
R.failed("项目编码不能为空");
}
return R.ok(sysDeptService.cspDeptTreeSelect(dept));
}
/**
* 客户服务平台——获取部门树(带部门下人数)
* @return 树形菜单
*/
@GetMapping(value = "/csp/tree")
public R<List<DeptTreeSelectVO>> cspTree(SysDeptVo dept) {
if(Common.isEmpty(dept.getProjectNo())){
R.failed("项目编码不能为空");
}
return R.ok(sysDeptService.cspDeptTree(dept));
}
/**
* 客户服务平台——添加部门
* @param sysDept 实体
* @return success/false
*/
@SysLog("客户服务平台——添加部门")
@PostMapping("/csp")
public R<String> saveCspDept(@RequestBody SysDept sysDept) {
if(Common.isEmpty(sysDept.getProjectNo())){
R.failed("项目编码不能为空");
}
// todo 名字长度
if(Common.isEmpty(sysDept.getName())){
R.failed("部门名称不能为空");
}
// 父级不传,默认增顶级部门
if (Common.isEmpty(sysDept.getParentId())){
sysDept.setParentId(0L);
}
return sysDeptService.saveCspDept(sysDept);
}
/**
* 客户服务平台——编辑部门
* @param sysDept 实体
* @return success/false
*/
@SysLog("客户服务平台——编辑部门")
@PutMapping("/csp")
public R<String> updateCspDept(@RequestBody SysDept sysDept) {
if(Common.isEmpty(sysDept.getDeptId())){
R.failed("ID不能为空");
}
if(Common.isEmpty(sysDept.getName())){
R.failed("部门名称不能为空");
}
return sysDeptService.updateCspDept(sysDept);
}
/**
* 删除
* @param id ID
* @return success/false
*/
@SysLog("客户服务平台——删除部门")
@DeleteMapping("/csp/{id:\\d+}")
public R<String> removeCspDeptById(@PathVariable Long id) {
if(Common.isEmpty(id)){
R.failed("项目Id不能为空");
}
return sysDeptService.removeCspDeptById(id);
}
/**
* 客户服务平台——获取项目下部门总数
* @return R<Integer> 部门总数
*/
@GetMapping(value = "/csp/getDeptCount")
public R<Integer> cspDeptCount(SysDeptVo dept) {
if(Common.isEmpty(dept.getProjectNo())){
R.failed("项目编码不能为空");
}
return R.ok(sysDeptService.cspDeptCount(dept.getProjectNo()));
}
/**
* @Author fxj
* @Description 获取
* @Date 17:27 2025/2/26
**/
@PostMapping(value = "/cspUpdateDept")
public R<Boolean> cspUpdateDept(SysDeptMoveVo dept) {
return sysDeptService.cspUpdateDept(dept);
}
} }
/*
* Copyright (c) 2020 yifu4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yifu.cloud.plus.v1.yifu.admin.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.icbc.api.request.ErrorHandlingProRequestV1;
import com.pig4cloud.plugin.excel.annotation.RequestExcel;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUserDeptPermission;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.HcmRoleInfoVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.RoleExcelVO;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.RoleVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserCspVO;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysRoleMenuService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysRoleService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysUserDeptPermissionService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysUserService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ClientNameConstants;
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.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* @Author fxj
* @Description 客户服务平台 账号 部门 项目 关系表
* @Date 18:38 2025/2/25
* @Param
* @return
**/
@RestController
@RequiredArgsConstructor
@RequestMapping("/userDeprtPermission")
@Tag(name = "客户服务平台账号授权")
public class SysUserDeptPermissionController {
private final SysUserDeptPermissionService sysUserDeptPermissionService;
private final SysUserService sysUserService;
/**
* 新增
* @Description 新增用户
* @return success、false
*/
@SysLog("新增用户")
@PostMapping("add")
public R<Boolean> save(@Valid @RequestBody UserCspVO entity) {
return sysUserDeptPermissionService.saveAsso(entity);
}
/**
* 修改用户
* @param entity 修改用户
* @return success/false
*/
@SysLog("修改用户")
@PostMapping("/update")
public R<Boolean> update(@Valid @RequestBody UserCspVO entity) {
return sysUserDeptPermissionService.updateByIdAsso(entity);
}
/**
* 收回用户
* @param userId
* @return
*/
@SysLog("收回用户")
@DeleteMapping("/disable")
public R<Boolean> removeById(@RequestParam(required = true,value = "userId") String userId,
@RequestParam(required = true,value = "projectNo") String projectNo) {
return sysUserDeptPermissionService.removeUserDeptPermissionById(userId,projectNo);
}
}
...@@ -597,7 +597,7 @@ public class UserController { ...@@ -597,7 +597,7 @@ public class UserController {
* @param userByApprovalRole * @param userByApprovalRole
* @author chenyuxi * @author chenyuxi
* @date 2025-01-10 17:47:32 * @date 2025-01-10 17:47:32
* @since 1.7.5 * @since 1.9.5
**/ **/
@Inner @Inner
@PostMapping("/inner/getUser/getUserByRoleIdForCrm") @PostMapping("/inner/getUser/getUserByRoleIdForCrm")
...@@ -623,4 +623,34 @@ public class UserController { ...@@ -623,4 +623,34 @@ public class UserController {
public Boolean selectExitDeptCompany(@RequestBody String deptId) { public Boolean selectExitDeptCompany(@RequestBody String deptId) {
return userService.selectExitDeptCompany(deptId); return userService.selectExitDeptCompany(deptId);
} }
/**
* 分页查询系统里所有用户
*
* @param page 参数集
* @param userDTO 查询参数列表
* @return 用户集合
*
* @author chenyuxi
* @since 1.9.7
*/
@GetMapping("/allUserPage")
public R<IPage<SysUser>> getAllUserPage(Page page, UserDTO userDTO) {
return R.ok(userService.getAllUserPage(page, userDTO));
}
/**
* @Author fxj
* @Description 按项目对应部门查询客户服务平台的用户信息
* @Date 14:27 2025/2/26
* @Param
* @return
**/
@GetMapping("/cspUserPage")
public R<IPage<SysUser>> cspUserPage(Page page, @RequestParam(required = true,value = "deptId") String deptId,
@RequestParam(required = false,value = "userName") String userName,
@RequestParam(required = false,value = "nickName") String nickName) {
return userService.cspUserPage(page, deptId,userName,nickName);
}
} }
/*
* Copyright (c) 2020 yifu4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yifu.cloud.plus.v1.yifu.admin.controller;
import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUserDeptPermission;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.DeptTreeSelectVO;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysDeptVo;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysUserDeptPermissionService;
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.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* 项目下用户部门及权限
*
* @author chenyuxi
* @since 1.9.7
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/userDeptPermission")
@Tag(name = "项目下用户部门及权限")
public class UserDeptPermissionController {
private final SysUserDeptPermissionService sysUserDeptPermissionService;
/**
* 客户服务平台——获取用户权限
* @param sysUserDeptPermission 实体
* @return success/false
*/
@GetMapping("/info")
public R<SysUserDeptPermission> getInfo(SysUserDeptPermission sysUserDeptPermission) {
if(Common.isEmpty(sysUserDeptPermission.getProjectNo())){
R.failed("项目编码不能为空");
}
if(Common.isEmpty(sysUserDeptPermission.getUserId())){
R.failed("用户ID不能为空");
}
return R.ok(sysUserDeptPermissionService.getInfo(sysUserDeptPermission.getProjectNo(),sysUserDeptPermission.getUserId()));
}
/**
* 客户服务平台——用户权限控制
* @param sysUserDeptPermission 实体
* @return success/false
*/
@SysLog("客户服务平台——用户权限控制")
@PostMapping("/permission")
public R<String> saveUserPermission(@RequestBody SysUserDeptPermission sysUserDeptPermission) {
if(Common.isEmpty(sysUserDeptPermission.getProjectNo())){
R.failed("项目编码不能为空");
}
if(Common.isEmpty(sysUserDeptPermission.getUserId())){
R.failed("用户ID不能为空");
}
if (Common.isEmpty(sysUserDeptPermission.getPermissionsType())){
R.failed("数据权限不能为空");
}
if (CommonConstants.THREE_STRING.equals(sysUserDeptPermission.getPermissionsType())
&& Common.isEmpty(sysUserDeptPermission.getAppointDeptScope())
){
R.failed("指定部门时,部门范围不能为空");
}
return sysUserDeptPermissionService.saveUserPermission(sysUserDeptPermission);
}
/**
* 客户服务平台——绑定项目
* @param sysUserDeptPermission 实体
* @return success/false
*/
@SysLog("客户服务平台——绑定项目")
@PostMapping("/relation")
public R<String> relationUser(@RequestBody SysUserDeptPermission sysUserDeptPermission) {
if(Common.isEmpty(sysUserDeptPermission.getProjectNo())){
R.failed("项目编码不能为空");
}
if(Common.isEmpty(sysUserDeptPermission.getProjectName())){
R.failed("项目名称不能为空");
}
if(Common.isEmpty(sysUserDeptPermission.getUserId())){
R.failed("用户ID不能为空");
}
if (Common.isEmpty(sysUserDeptPermission.getDeptId())){
R.failed("部门ID不能为空");
}
return sysUserDeptPermissionService.relationUser(sysUserDeptPermission);
}
}
...@@ -18,6 +18,8 @@ package com.yifu.cloud.plus.v1.yifu.admin.mapper; ...@@ -18,6 +18,8 @@ package com.yifu.cloud.plus.v1.yifu.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.DeptSortVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysDeptVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -47,4 +49,44 @@ public interface SysDeptMapper extends BaseMapper<SysDept> { ...@@ -47,4 +49,44 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
SysDept selectDeptDn(@Param("deptDn")String deptDn); SysDept selectDeptDn(@Param("deptDn")String deptDn);
List<SysDept> getDeptListByDeptId(@Param("deptIdSplit") String deptIdSplit, @Param("deptId") Long deptId); List<SysDept> getDeptListByDeptId(@Param("deptIdSplit") String deptIdSplit, @Param("deptId") Long deptId);
/**
* 客户服务平台——查询部门管理数据
*
* @param dept 部门信息
*/
List<SysDeptVo> cspDeptList(@Param("dept") SysDeptVo dept);
/**
* 客户服务平台——查询部门管理数据(带部门下人数)
*
*/
List<SysDeptVo> cspDeptUserList(@Param("dept") SysDeptVo dept);
/**
* 客户服务平台——查询同项目下同级部门
*
*/
SysDept checkDeptNameUnique(@Param("projectNo") String projectNo, @Param("deptName") String deptName, @Param("parentId") Long parentId);
/**
* 客户服务平台——是否存在子节点
*
* @param deptId 部门ID
* @return 结果
*/
int hasChildByDeptId(@Param("deptId") Long deptId);
/**
* 客户服务平台——查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果
*/
int checkDeptExistUser(@Param("deptId") Long deptId);
int cspDeptCount(@Param("projectNo") String projectNo);
void batchUpdateSort(@Param("moveVos")List<DeptSortVo> moveVos);
} }
...@@ -83,4 +83,22 @@ public interface SysUserMapper extends BaseMapper<SysUser> { ...@@ -83,4 +83,22 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
List<SysUser> getUserManagerByUpDepartIdUp(@Param("departId") Integer departId, @Param("roleId")String roleId); List<SysUser> getUserManagerByUpDepartIdUp(@Param("departId") Integer departId, @Param("roleId")String roleId);
String selectExitDeptCompany(@Param("deptId") String deptId); String selectExitDeptCompany(@Param("deptId") String deptId);
/**
* 分页查询系统里所有用户
* @param page 分页
* @param userDTO 查询参数
* @return list
*/
IPage<SysUser> getAllUserPage(Page page, @Param("query") UserDTO userDTO);
/**
* 分页查询系统里所有用户(带或查询的条件)
* @param page 分页
* @param userDTO 查询参数
* @return list
*/
IPage<SysUser> getAllUserPageWhere(Page page, @Param("query") UserDTO userDTO);
IPage<SysUser> cspUserPage(Page page, @Param("deptId")String deptId, @Param("userName")String userName, @Param("nickName")String nickName);
} }
...@@ -19,6 +19,9 @@ package com.yifu.cloud.plus.v1.yifu.admin.service; ...@@ -19,6 +19,9 @@ package com.yifu.cloud.plus.v1.yifu.admin.service;
import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.DeptTreeSelectVO;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysDeptMoveVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysDeptVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import java.util.List; import java.util.List;
...@@ -79,4 +82,56 @@ public interface SysDeptService extends IService<SysDept> { ...@@ -79,4 +82,56 @@ public interface SysDeptService extends IService<SysDept> {
* @return R * @return R
*/ */
R updateDeptByLdap(); R updateDeptByLdap();
/**
* 客户服务平台——获取部门树(用于下拉选择)
*
* @param dept 部门信息
* @return 下拉树结构列表
*/
List<DeptTreeSelectVO> cspDeptTreeSelect(SysDeptVo dept);
/**
* 客户服务平台——获取部门树(带部门下人数)
*
* @param dept 部门信息
* @return 部门树列表
*/
List<DeptTreeSelectVO> cspDeptTree(SysDeptVo dept);
/**
* 客户服务平台——添加部门
*
* @param dept 部门信息
* @return 结果
*/
R<String> saveCspDept(SysDept dept);
/**
* 客户服务平台——编辑部门
*
* @param dept 部门信息
* @return 结果
*/
R<String> updateCspDept(SysDept dept);
/**
* 客户服务平台——删除部门
*
* @param id 部门id
* @return 结果
*/
R<String> removeCspDeptById(Long id);
/**
* 客户服务平台——获取项目下部门总数
*
* @param projectNo 项目编码
* @return R<Integer> 部门总数
*/
Integer cspDeptCount(String projectNo);
R<Boolean> cspUpdateDept(SysDeptMoveVo dept);
} }
...@@ -18,10 +18,14 @@ package com.yifu.cloud.plus.v1.yifu.admin.service; ...@@ -18,10 +18,14 @@ package com.yifu.cloud.plus.v1.yifu.admin.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUserDeptPermission; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUserDeptPermission;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserPermissionVo; import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserCspVO;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.UserPermissionVo;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* 项目下用户部门及权限 * 项目下用户部门及权限
* *
...@@ -30,6 +34,16 @@ import java.util.Map; ...@@ -30,6 +34,16 @@ import java.util.Map;
*/ */
public interface SysUserDeptPermissionService extends IService<SysUserDeptPermission> { public interface SysUserDeptPermissionService extends IService<SysUserDeptPermission> {
/**
* 项目下用户数据权限
* @param projectNo 项目编号
* @param userId 用户ID
*
* @return UserPermissionVo 用户在指定项目下的权限
*/
SysUserDeptPermission getInfo(String projectNo, String userId);
/** /**
* 项目下用户数据权限 * 项目下用户数据权限
* @param projectNo 项目编号 * @param projectNo 项目编号
...@@ -47,4 +61,25 @@ public interface SysUserDeptPermissionService extends IService<SysUserDeptPermis ...@@ -47,4 +61,25 @@ public interface SysUserDeptPermissionService extends IService<SysUserDeptPermis
*/ */
Map<String, UserPermissionVo> getUserPermissionFlush(String userId); Map<String, UserPermissionVo> getUserPermissionFlush(String userId);
/**
* 客户服务平台——用户权限控制
* @param sysUserDeptPermission 实体
* @return success/false
*/
R<String> saveUserPermission(SysUserDeptPermission sysUserDeptPermission);
/**
* 客户服务平台——绑定项目
* @param sysUserDeptPermission 实体
* @return success/false
*/
R<String> relationUser(SysUserDeptPermission sysUserDeptPermission);
List<UserPermissionVo> getUserPermission(String userId);
R<Boolean> saveAsso(UserCspVO entity);
R<Boolean> updateByIdAsso(UserCspVO entity);
R<Boolean> removeUserDeptPermissionById(String userId, String projectNo);
} }
...@@ -192,4 +192,18 @@ public interface SysUserService extends IService<SysUser> { ...@@ -192,4 +192,18 @@ public interface SysUserService extends IService<SysUser> {
Boolean selectExitDeptCompany(String deptId); Boolean selectExitDeptCompany(String deptId);
/**
* 分页查询系统里所有用户
*
* @param page 参数集
* @param userDTO 查询参数列表
* @return 用户集合
*
* @author chenyuxi
* @since 1.9.7
*/
IPage<SysUser> getAllUserPage(Page page, UserDTO userDTO);
R<IPage<SysUser>> cspUserPage(Page page, String deptId, String userName, String nickName);
} }
...@@ -20,26 +20,36 @@ import cn.hutool.core.collection.CollUtil; ...@@ -20,26 +20,36 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode; import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeUtil; import cn.hutool.core.lang.tree.TreeUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.unboundid.ldap.sdk.SearchResultEntry; import com.unboundid.ldap.sdk.SearchResultEntry;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDeptRelation; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDeptRelation;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.DeptSortVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.DeptTreeSelectVO;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysDeptMoveVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysDeptVo;
import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDeptMapper; import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDeptMapper;
import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysUserMapper; import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysUserMapper;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptRelationService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptRelationService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptService;
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.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.ldap.util.LdapUtil; import com.yifu.cloud.plus.v1.yifu.common.ldap.util.LdapUtil;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils; import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -269,4 +279,273 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl ...@@ -269,4 +279,273 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
} }
return R.ok(); return R.ok();
} }
/**
* 客户服务平台——获取部门树(用于下拉选择)
*
* @param dept 部门信息
* @return 下拉树结构列表
*/
@Override
public List<DeptTreeSelectVO> cspDeptTreeSelect(SysDeptVo dept) {
List<DeptTreeSelectVO> cspDeptTree = new ArrayList<>();
// 获取部门列表
List<SysDeptVo> sysDeptList = baseMapper.cspDeptList(dept);
if(Common.isNotNull(sysDeptList)){
// 组装部门树
List<SysDeptVo> deptTrees = buildDeptTree(sysDeptList);
if(Common.isNotNull(deptTrees)){
// 数据库查到的对象到视图对象的映射
cspDeptTree = deptTrees.stream().map(DeptTreeSelectVO::new).collect(Collectors.toList());
}
}
return cspDeptTree;
}
/**
* 客户服务平台——获取部门树(带部门下人数)
*
* @return 部门树列表
*/
@Override
public List<DeptTreeSelectVO> cspDeptTree(SysDeptVo dept) {
List<DeptTreeSelectVO> cspDeptTree = new ArrayList<>();
// 获取部门列表带用户数量
List<SysDeptVo> sysDeptList = baseMapper.cspDeptUserList(dept);
if(Common.isNotNull(sysDeptList)){
// 组装部门树
List<SysDeptVo> deptTrees = buildDeptTree(sysDeptList);
if(Common.isNotNull(sysDeptList)){
// 数据库查到的对象到视图对象的映射
cspDeptTree = deptTrees.stream().map(DeptTreeSelectVO::new).collect(Collectors.toList());
}
}
return cspDeptTree;
}
/**
* 客户服务平台——组装部门树
*
* @param sysDeptList 部门列表
* @return 下拉树结构列表
*/
private List<SysDeptVo> buildDeptTree(List<SysDeptVo> sysDeptList) {
List<SysDeptVo> returnList = new ArrayList<>();
List<Long> tempDeptIdList = new ArrayList<>();
for (SysDeptVo dept : sysDeptList) {
tempDeptIdList.add(dept.getDeptId());
}
for (Iterator<SysDeptVo> iterator = sysDeptList.iterator(); iterator.hasNext();) {
SysDeptVo dept = (SysDeptVo) iterator.next();
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempDeptIdList.contains(dept.getParentId())) {
// 遍历该父节点的所有子节点
recursionFn(sysDeptList, dept);
returnList.add(dept);
}
}
if (Common.isEmpty(returnList)) {
returnList = sysDeptList;
}
return returnList;
}
/**
* 递归列表
*/
private void recursionFn(List<SysDeptVo> list, SysDeptVo t) {
// 得到子节点列表
List<SysDeptVo> childList = getChildList(list, t);
t.setChildren(childList);
for (SysDeptVo tChild : childList) {
if (hasChild(list, tChild))
{
recursionFn(list, tChild);
}
int i = 0;
int i1= 0;
if(Common.isNotNull(tChild.getPeopleNum())){
i =Integer.parseInt(tChild.getPeopleNum());
}
if(Common.isNotNull(t.getPeopleNum())){
i1=Integer.parseInt(t.getPeopleNum());
}
int i2=i+i1;
String i3=String.valueOf(i2);
t.setPeopleNum(i3);
}
}
/**
* 得到子节点列表
*/
private List<SysDeptVo> getChildList(List<SysDeptVo> list, SysDeptVo t)
{
List<SysDeptVo> tlist = new ArrayList<>();
Iterator<SysDeptVo> it = list.iterator();
while (it.hasNext())
{
SysDeptVo n = (SysDeptVo) it.next();
if (Common.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
{
tlist.add(n);
}
}
return tlist;
}
/**
* 判断是否有子节点
*/
private boolean hasChild(List<SysDeptVo> list, SysDeptVo t)
{
return getChildList(list, t).size() > 0 ? true : false;
}
/**
* 客户服务平台——添加部门
*
* @param dept 部门信息
* @return 结果
*/
@Override
public R<String> saveCspDept(SysDept dept) {
if (Common.isEmpty(dept.getParentId())){
dept.setParentId(0L);
}
SysDept nameInfo = baseMapper.checkDeptNameUnique(dept.getProjectNo(),dept.getName(), dept.getParentId());
if (Common.isNotNull(nameInfo)) {
return R.failed("已存在同级同名部门");
}
if(0L == dept.getParentId()){
LambdaQueryWrapper<SysDept> deptQuery = Wrappers.<SysDept>lambdaQuery()
.eq(SysDept::getParentId, 0L)
.eq(SysDept::getProjectNo, dept.getProjectNo())
.eq(SysDept::getDelFlag, CommonConstants.ZERO_STRING)
.last(" limit 1 ");
SysDept firstInfo = baseMapper.selectOne(deptQuery);
if (Common.isNotNull(firstInfo)) {
return R.failed("一个项目下只能有一个顶级部门");
}
}
// 新增部门
if(0L == dept.getParentId()){
dept.setAncestors(CommonConstants.ZERO_STRING);
} else {
if(Common.isNotNull(dept.getParentId())){
SysDept info = baseMapper.selectById(dept.getParentId());
if (Common.isEmpty(info)) {
return R.failed("父级部门未找到");
}
if (Common.isNotNull(info.getAncestors())){
// todo 商量是否加这个限制
String[] split = info.getAncestors().split(",");
if (split.length >= 6){
return R.failed("添加部门的层级超出限制,最多支持5级");
}
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
}
}
// todo 去常量
dept.setClient("yifu-csp");
this.save(dept);
return R.ok("创建成功");
}
/**
* 客户服务平台——编辑部门
*
* @param dept 部门信息
* @return 结果
*/
@Override
public R<String> updateCspDept(SysDept dept) {
SysDept findInfo = baseMapper.selectById(dept.getDeptId());
if (Common.isEmpty(findInfo)) {
return R.failed("部门未找到");
}
SysDept nameInfo = baseMapper.checkDeptNameUnique(findInfo.getProjectNo(),dept.getName(), findInfo.getParentId());
if (Common.isNotNull(nameInfo) && nameInfo.getDeptId().longValue() != dept.getDeptId().longValue()) {
return R.failed("已存在同级同名部门");
}
LambdaUpdateWrapper<SysDept> updateInfoWrapper = new LambdaUpdateWrapper<>();
updateInfoWrapper.eq(SysDept::getDeptId, dept.getDeptId())
.set(SysDept::getName, dept.getName())
.set(SysDept::getUpdateTime, LocalDateTime.now());
this.update(null, updateInfoWrapper);
return R.ok("更新成功");
}
/**
* 客户服务平台——删除部门
*
* @param deptId 部门id
* @return 结果
*/
@Override
public R<String> removeCspDeptById(Long deptId) {
int hasChild = baseMapper.hasChildByDeptId(deptId);
if (hasChild > 0) {
return R.failed("存在下级部门,不允许删除");
}
int existUser = baseMapper.checkDeptExistUser(deptId);
if (existUser > 0) {
return R.failed("部门下仍然有员工,请调出所有员工后,删除部门");
}
this.removeById(deptId);
return R.ok("删除成功");
}
/**
* 客户服务平台——获取项目下部门总数
*
* @param projectNo 项目编码
* @return R<Integer> 部门总数
*/
@Override
public Integer cspDeptCount(String projectNo) {
return baseMapper.cspDeptCount(projectNo);
}
/**
* @Author fxj
* @Description 按项目对应部门查询客户服务平台的用户信息
* @Date 14:27 2025/2/26
* @Param
* @return
**/
@Override
public R<Boolean> cspUpdateDept(SysDeptMoveVo dept) {
try {
if(Common.isEmpty(dept)
|| Common.isEmpty(dept.getSysDeptId())
|| Common.isEmpty(dept.getParentId())
|| Common.isEmpty(dept.getDeptSortList())){
R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
SysDept parentDept = baseMapper.selectById(dept.getParentId());
if (Common.isEmpty(parentDept)){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
SysDept updateEntity = baseMapper.selectById(dept.getSysDeptId());
if (Common.isEmpty(updateEntity)){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
updateEntity.setParentId(parentDept.getDeptId());
updateEntity.setAncestors(parentDept.getAncestors());
baseMapper.updateById(updateEntity);
List<DeptSortVo> moveVos = dept.getDeptSortList();
baseMapper.batchUpdateSort(moveVos);
}catch (Exception e){
log.error("客户服务平台机构变更异常",e);
return R.failed(CommonConstants.UPDATE_DATA_FAIL);
}
return R.ok();
}
} }
...@@ -16,21 +16,32 @@ ...@@ -16,21 +16,32 @@
package com.yifu.cloud.plus.v1.yifu.admin.service.impl; package com.yifu.cloud.plus.v1.yifu.admin.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
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.SysDept; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUserDeptPermission; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUserDeptPermission;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserPermissionVo; import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserCspVO;
import com.yifu.cloud.plus.v1.yifu.admin.constants.UserDeptPermConstants;
import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDeptMapper; import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDeptMapper;
import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysUserDeptPermissionMapper; import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysUserDeptPermissionMapper;
import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysUserMapper;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysUserDeptPermissionService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysUserDeptPermissionService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
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.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil; import com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.UserPermissionVo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -49,6 +60,19 @@ public class SysUserDeptPermissionServiceImpl extends ServiceImpl<SysUserDeptPer ...@@ -49,6 +60,19 @@ public class SysUserDeptPermissionServiceImpl extends ServiceImpl<SysUserDeptPer
private final SysDeptMapper sysDeptMapper; private final SysDeptMapper sysDeptMapper;
private final SysUserMapper sysUserMapper;
private static final PasswordEncoder ENCODER = new BCryptPasswordEncoder();
@Override
public SysUserDeptPermission getInfo(String projectNo, String userId) {
LambdaQueryWrapper<SysUserDeptPermission> permissionQuery = Wrappers.<SysUserDeptPermission>lambdaQuery()
.eq(SysUserDeptPermission::getUserId, userId)
.eq(SysUserDeptPermission::getProjectNo, projectNo)
.last(" limit 1 ");
return baseMapper.selectOne(permissionQuery);
}
@Override @Override
public UserPermissionVo getUserPermissionVo(String projectNo, String userId) { public UserPermissionVo getUserPermissionVo(String projectNo, String userId) {
UserPermissionVo authority = new UserPermissionVo(); UserPermissionVo authority = new UserPermissionVo();
...@@ -71,8 +95,7 @@ public class SysUserDeptPermissionServiceImpl extends ServiceImpl<SysUserDeptPer ...@@ -71,8 +95,7 @@ public class SysUserDeptPermissionServiceImpl extends ServiceImpl<SysUserDeptPer
@Override @Override
public Map<String, UserPermissionVo> getUserPermissionFlush(String userId) { public Map<String, UserPermissionVo> getUserPermissionFlush(String userId) {
UserPermissionVo authority; UserPermissionVo authority;
Map<String, UserPermissionVo> tPermissionMapByProject = new HashMap<>(); Map<String, UserPermissionVo> tPermissionMapByProject = new HashMap<>();if (Common.isEmpty(userId)) {
if (Common.isEmpty(userId)) {
log.error("获取用户权限失败,缺少用户信息"); log.error("获取用户权限失败,缺少用户信息");
return tPermissionMapByProject; return tPermissionMapByProject;
} }
...@@ -80,7 +103,6 @@ public class SysUserDeptPermissionServiceImpl extends ServiceImpl<SysUserDeptPer ...@@ -80,7 +103,6 @@ public class SysUserDeptPermissionServiceImpl extends ServiceImpl<SysUserDeptPer
String deptIdSplit = ""; String deptIdSplit = "";
Long deptId = 0L; Long deptId = 0L;
Set<String> permissionDbSet = null; Set<String> permissionDbSet = null;
List<SysUserDeptPermission> tPermissionInfoList = baseMapper.getUserDeptPermissionList(userId); List<SysUserDeptPermission> tPermissionInfoList = baseMapper.getUserDeptPermissionList(userId);
if (Common.isEmpty(tPermissionInfoList)) { if (Common.isEmpty(tPermissionInfoList)) {
log.error("获取用户权限失败,未获取到用户在项目下的权限信息>>用户"+userId); log.error("获取用户权限失败,未获取到用户在项目下的权限信息>>用户"+userId);
...@@ -100,6 +122,9 @@ public class SysUserDeptPermissionServiceImpl extends ServiceImpl<SysUserDeptPer ...@@ -100,6 +122,9 @@ public class SysUserDeptPermissionServiceImpl extends ServiceImpl<SysUserDeptPer
continue; continue;
}else { }else {
authority = new UserPermissionVo(); authority = new UserPermissionVo();
authority.setProjectNo(projectNoStr);
authority.setProjectName(tPermissionInfo.getProjectName());
authority.setUserType(tPermissionInfo.getUserType());
if (CommonConstants.ZERO_STRING.equals(tPermissionInfo.getPermissionsType())) { if (CommonConstants.ZERO_STRING.equals(tPermissionInfo.getPermissionsType())) {
// 全部数据 // 全部数据
authority.setHaveAll(true); authority.setHaveAll(true);
...@@ -181,4 +206,316 @@ public class SysUserDeptPermissionServiceImpl extends ServiceImpl<SysUserDeptPer ...@@ -181,4 +206,316 @@ public class SysUserDeptPermissionServiceImpl extends ServiceImpl<SysUserDeptPer
return tPermissionMapByProject; return tPermissionMapByProject;
} }
/**
* 客户服务平台——用户权限控制
*
* @param sysUserDeptPermission 实体
* @return success/false
*/
@Override
public R<String> saveUserPermission(SysUserDeptPermission sysUserDeptPermission) {
LambdaQueryWrapper<SysUser> userQuery = Wrappers.<SysUser>lambdaQuery()
.eq(SysUser::getUserId, sysUserDeptPermission.getUserId())
.eq(SysUser::getDelFlag, CommonConstants.ZERO_STRING)
.last(" limit 1 ");
SysUser userInfo = sysUserMapper.selectOne(userQuery);
if (Common.isEmpty(userInfo)) {
return R.failed("未找到对应用户信息");
}
LambdaQueryWrapper<SysUserDeptPermission> permissionQuery = Wrappers.<SysUserDeptPermission>lambdaQuery()
.eq(SysUserDeptPermission::getUserId, sysUserDeptPermission.getUserId())
.eq(SysUserDeptPermission::getProjectNo, sysUserDeptPermission.getProjectNo())
.last(" limit 1 ");
SysUserDeptPermission permissionInfo = baseMapper.selectOne(permissionQuery);
if (Common.isEmpty(permissionInfo)) {
return R.failed("未找到对应用户部门信息");
}
LambdaQueryWrapper<SysDept> deptQuery = Wrappers.<SysDept>lambdaQuery()
.eq(SysDept::getDeptId, permissionInfo.getDeptId())
.eq(SysDept::getDelFlag, CommonConstants.ZERO_STRING)
.last(" limit 1 ");
SysDept deptInfo = sysDeptMapper.selectOne(deptQuery);
if (Common.isEmpty(deptInfo)) {
return R.failed("异常数据,对应用户部门不存在");
}
String ancestors = deptInfo.getAncestors();
if (Common.isEmpty(ancestors)) {
return R.failed("异常数据,该用户所属部门关系为空");
}
String[] ancestorsSplit = ancestors.split(CommonConstants.COMMA_STRING);
if (ancestorsSplit.length < 2 && CommonConstants.ONE_STRING.equals(sysUserDeptPermission.getPermissionsType())) {
return R.failed("当前用户所在部门为顶级部门,不能使用该权限");
}
// 更新用户数据权限
permissionInfo.setPermissionsType(sysUserDeptPermission.getPermissionsType());
if(!CommonConstants.THREE_STRING.equals(sysUserDeptPermission.getPermissionsType())){
sysUserDeptPermission.setAppointDeptScope("");
}
permissionInfo.setAppointDeptScope(sysUserDeptPermission.getAppointDeptScope());
baseMapper.updateById(permissionInfo);
redisUtil.remove(CacheConstants.USER_DETAILS +"::"+ userInfo.getUsername());
return R.ok("更新成功");
}
/**
* 客户服务平台——绑定项目
*
* @param sysUserDeptPermission 实体
* @return success/false
*/
@Override
public R<String> relationUser(SysUserDeptPermission sysUserDeptPermission) {
LambdaQueryWrapper<SysUser> userQuery = Wrappers.<SysUser>lambdaQuery()
.eq(SysUser::getUserId, sysUserDeptPermission.getUserId())
.eq(SysUser::getDelFlag, CommonConstants.ZERO_STRING)
.last(" limit 1 ");
SysUser userInfo = sysUserMapper.selectOne(userQuery);
if (Common.isEmpty(userInfo)) {
return R.failed("未找到对应用户信息");
}
LambdaQueryWrapper<SysUserDeptPermission> permissionQuery = Wrappers.<SysUserDeptPermission>lambdaQuery()
.eq(SysUserDeptPermission::getUserId, sysUserDeptPermission.getUserId())
.eq(SysUserDeptPermission::getProjectNo, sysUserDeptPermission.getProjectNo())
.last(" limit 1 ");
SysUserDeptPermission permissionInfo = baseMapper.selectOne(permissionQuery);
if (Common.isNotNull(permissionInfo)) {
return R.failed("该用户已绑定到项目下了,请勿重复绑定");
}
// 更新用户数据权限
// todo 去常量
sysUserDeptPermission.setClient("yifu-csp");
sysUserDeptPermission.setPermissionsType(CommonConstants.TWO_STRING);
baseMapper.insert(sysUserDeptPermission);
redisUtil.remove(CacheConstants.USER_DETAILS +"::"+ userInfo.getUsername());
return R.ok("用户绑定项目成功");
}
/**
* @Author fxj
* @Description 既有接口‘通过用户ID获取用户的权限相关信息返回数组’
* @Date 11:26 2025/2/26
**/
@Override
public List<UserPermissionVo> getUserPermission(String userId) {
UserPermissionVo authority;
List permissionMapByProject = new ArrayList<>();
if (Common.isEmpty(userId)) {
log.error("获取用户权限失败,缺少用户信息");
return permissionMapByProject;
}
String deptIdSplit = "";
Long deptId = 0L;
Set<String> permissionDbSet = null;
List<SysUserDeptPermission> tPermissionInfoList = baseMapper.getUserDeptPermissionList(userId);
if (Common.isEmpty(tPermissionInfoList)) {
log.error("获取用户权限失败,未获取到用户在项目下的权限信息>>用户"+userId);
return permissionMapByProject;
}
Set<String> projectNoSet = tPermissionInfoList.stream().map(SysUserDeptPermission::getProjectNo).collect(Collectors.toSet());
Map<String, SysUserDeptPermission> tPermissionMap = tPermissionInfoList.stream().collect(Collectors.toMap(SysUserDeptPermission::getProjectNo, v -> v, (v1, v2) -> v1));
SysUserDeptPermission tPermissionInfo;
SysDept sysDept;
List<SysDept> sysDeptList;
String[] ancestorsSplit;
for (String projectNoStr : projectNoSet) {
tPermissionInfo = tPermissionMap.get(projectNoStr);
// 没有配置部门
if(Common.isEmpty(tPermissionInfo)){
authority = new UserPermissionVo();
log.error("获取用户权限失败,该用户指定项目权限{}", userId);
authority.setHaveAll(false);
continue;
}else {
authority = new UserPermissionVo();
authority.setProjectNo(projectNoStr);
authority.setProjectName(tPermissionInfo.getProjectName());
authority.setUserType(tPermissionInfo.getUserType());
if (CommonConstants.ZERO_STRING.equals(tPermissionInfo.getPermissionsType())) {
// 全部数据
authority.setHaveAll(true);
// redisUtil.set(CacheConstants.PROJECT_USER_PERMISSION + projectNoStr +"_"+ userId, authority);
} else if (CommonConstants.THREE_STRING.equals(tPermissionInfo.getPermissionsType())) {
// 指定部门权限
if (Common.isNotKong(tPermissionInfo.getAppointDeptScope())) {
authority.setHaveAll(false);
String[] appointDeptIdArr = tPermissionInfo.getAppointDeptScope().split(CommonConstants.COMMA_STRING);
Set<String> appointDeptIdSet = Arrays.stream(appointDeptIdArr).collect(Collectors.toSet());
authority.setDepartIdSet(appointDeptIdSet);
authority.setUserId(userId);
// redisUtil.set(CacheConstants.PROJECT_USER_PERMISSION + projectNoStr +"_"+ userId, authority);
} else {
log.error("获取用户权限失败,该用户指定部门权限为空{}", userId);
authority.setHaveAll(false);
continue;
}
} else {
sysDept = sysDeptMapper.selectById(tPermissionInfo.getDeptId());
if (Common.isNotKong(sysDept)) {
String ancestors = sysDept.getAncestors();
if (Common.isEmpty(ancestors)) {
log.error("获取用户权限失败,该用户所属部门关系为空{}", sysDept);
authority.setHaveAll(false);
continue;
}
ancestorsSplit = ancestors.split(CommonConstants.COMMA_STRING);
if (CommonConstants.ONE_STRING.equals(tPermissionInfo.getPermissionsType())) {
// 二级部门及以下
if (ancestorsSplit.length == 2) {
deptIdSplit = ancestorsSplit[0] + CommonConstants.COMMA_STRING + ancestorsSplit[1] + CommonConstants.COMMA_STRING + sysDept.getDeptId();
deptId = sysDept.getDeptId();
} else if (ancestorsSplit.length > 2) {
deptIdSplit = ancestorsSplit[0] + CommonConstants.COMMA_STRING + ancestorsSplit[1] + CommonConstants.COMMA_STRING + ancestorsSplit[2];
deptId = Long.valueOf(ancestorsSplit[2]);
} else {
log.error("获取用户权限失败,该用户所在部门为顶级部门,未查到权限{}", sysDept);
authority.setHaveAll(false);
continue;
}
} else if (CommonConstants.TWO_STRING.equals(tPermissionInfo.getPermissionsType())) {
// 本级部门及以下
deptIdSplit = ancestors + CommonConstants.COMMA_STRING + sysDept.getDeptId();
deptId = sysDept.getDeptId();
}
// 获取指定部门及下级部门的数据
sysDeptList = sysDeptMapper.getDeptListByDeptId(deptIdSplit, deptId);
if (Common.isNotKong(sysDeptList)) {
permissionDbSet = new HashSet<>();
for(SysDept deptOne : sysDeptList){
permissionDbSet.add(String.valueOf(deptOne.getDeptId()));
}
authority.setHaveAll(false);
authority.setDepartIdSet(permissionDbSet);
authority.setUserId(userId);
//redisUtil.set(CacheConstants.PROJECT_USER_PERMISSION + projectNoStr +"_"+ userId, authority);
} else {
log.error("获取用户权限失败,该用户部门及以下权限为空{}", userId);
authority.setHaveAll(false);
continue;
}
} else {
log.error("获取用户权限失败,该用户所属部门不存在{}", userId);
authority.setHaveAll(false);
continue;
}
}
}
// 赋值用户在不同项目下的权限
permissionMapByProject.add(authority);
}
return permissionMapByProject;
}
/**
* @Author fxj
* @Description 新增客户服务平台用户 及 用户权限关系表
* @Date 11:24 2025/2/26
**/
@Override
public R<Boolean> saveAsso(UserCspVO entity) {
long count = sysUserMapper.selectCount(Wrappers.<SysUser>query().lambda()
.eq(SysUser::getUsername,entity.getUsername())
.eq(SysUser::getDelFlag, CommonConstants.ZERO_STRING));
if ( count > CommonConstants.ZERO_INT) {
return R.failed(UserDeptPermConstants.USER_EXITS_ERROR);
}
SysUser user = new SysUser();
user.setUserGroup("0");
user.setDeptId(entity.getDeptId());
user.setDeptName(entity.getDeptName());
user.setType(CommonConstants.FOUR_STRING);
user.setDelFlag(CommonConstants.STATUS_NORMAL);
user.setSystemFlag(CommonConstants.ONE_STRING);
user.setUsername(entity.getUsername());
user.setNickname(entity.getNickname());
user.setPhone(entity.getPhone());
user.setLockFlag(CommonConstants.STATUS_NORMAL);
if (Common.isNotNull(user.getPassword())){
user.setPassword(ENCODER.encode(UserDeptPermConstants.DEFAULT_PASSWORD));
}
user.setPost(UserDeptPermConstants.CUSTOMER_SERVICE_PLATFORM);
user.setLockFlag(CommonConstants.STATUS_NORMAL);
user.setDelFlag(CommonConstants.STATUS_NORMAL);
user.setCreateTime(LocalDateTime.now());
sysUserMapper.insert(user);
if (Common.isNotNull(user) && Common.isNotNull(user.getUserId())){
SysUserDeptPermission permission = new SysUserDeptPermission();
permission.setDeptId(entity.getDeptId());
permission.setUserId(user.getUserId());
permission.setClient("yifu-csp");
permission.setProjectName(entity.getProjectName());
permission.setProjectNo(entity.getProjectNo());
permission.setUserType(entity.getUserType());
baseMapper.insert(permission);
if (Common.isNotNull(permission) && Common.isNotNull(permission.getUserId())){
return R.ok(Boolean.TRUE,CommonConstants.SAVE_SUCCESS);
}
}
return R.failed(Boolean.FALSE,CommonConstants.SAVE_FAILED);
}
/**
* @Author fxj
* @Description 更新客服服务平台用户信息
* @Date 11:26 2025/2/26
**/
@Override
public R<Boolean> updateByIdAsso(UserCspVO entity) {
try {
if (Common.isEmpty(entity) || Common.isEmpty(entity.getUserId())){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
SysUser user = sysUserMapper.selectById(entity.getUserId());
if (Common.isEmpty(user)){
return R.failed(CommonConstants.NO_DATA_TO_HANDLE);
}
SysUserDeptPermission permission = baseMapper.selectOne(Wrappers.<SysUserDeptPermission>query().lambda()
.eq(SysUserDeptPermission::getUserId,user.getUserId())
.eq(SysUserDeptPermission::getProjectNo,entity.getProjectNo()).last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(permission)){
return R.failed(CommonConstants.NO_DATA_TO_HANDLE);
}
user.setNickname(entity.getNickname());
user.setPhone(entity.getPhone());
user.setDeptName(entity.getDeptName());
user.setDeptId(entity.getDeptId());
LambdaUpdateWrapper<SysUser> updateWrappers = new LambdaUpdateWrapper<>();
updateWrappers.set(SysUser::getUserId,user.getUserId());
sysUserMapper.update(entity,updateWrappers);
permission.setDeptId(entity.getDeptId());
permission.setUserType(entity.getUserType());
baseMapper.updateById(permission);
}catch (Exception e){
log.error(UserDeptPermConstants.PERMISSION_SAVE_ERROR,e);
return R.failed(UserDeptPermConstants.PERMISSION_SAVE_ERROR);
}
return R.ok(null,CommonConstants.SAVE_SUCCESS);
}
/**
* @Author fxj
* @Description 收回账号
* @Date 11:24 2025/2/26
* @Param
* @return
**/
@Override
public R<Boolean> removeUserDeptPermissionById(String userId, String projectNo) {
SysUserDeptPermission permission = baseMapper.selectOne(Wrappers.<SysUserDeptPermission>query().lambda()
.eq(SysUserDeptPermission::getUserId,userId)
.eq(SysUserDeptPermission::getProjectNo,projectNo)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(permission) && CommonConstants.ZERO_STRING.equals(permission.getUserType())){
return R.failed(UserDeptPermConstants.ADMIN_DISABLE_ERROR);
}
if (baseMapper.deleteById(permission.getId()) > CommonConstants.ZERO_INT){
return R.ok(Boolean.TRUE,CommonConstants.RESULT_DATA_SUCESS);
}
return R.failed(Boolean.FALSE,CommonConstants.RESULT_DATA_FAIL);
}
} }
...@@ -36,6 +36,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.util.ParamResolver; ...@@ -36,6 +36,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.util.ParamResolver;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.*; import com.yifu.cloud.plus.v1.yifu.admin.api.vo.*;
import com.yifu.cloud.plus.v1.yifu.admin.mapper.*; import com.yifu.cloud.plus.v1.yifu.admin.mapper.*;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysMenuService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysMenuService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysUserDeptPermissionService;
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.archives.vo.TSettleDomainListVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainListVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
...@@ -100,6 +101,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -100,6 +101,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
private final PermissionDaprUtil permissionDaprUtil; private final PermissionDaprUtil permissionDaprUtil;
private final SysUserDeptPermissionService userDeptPermissionService;
@Value("${hrms.id}") @Value("${hrms.id}")
private String hcmId; private String hcmId;
...@@ -186,6 +189,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -186,6 +189,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
userInfo.setSettleIdList(sdRes.getData().getDeptIds()); userInfo.setSettleIdList(sdRes.getData().getDeptIds());
} }
userInfo.setClientRoleMap(clientRoleMap); userInfo.setClientRoleMap(clientRoleMap);
// 客户服务平台的项目权限及对应项目的数据权限
userInfo.setCspPermMap(userDeptPermissionService.getUserPermission(sysUser.getUserId()));
return userInfo; return userInfo;
} }
/** /**
...@@ -962,4 +967,30 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -962,4 +967,30 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return deptList.stream().anyMatch(dn::contains); return deptList.stream().anyMatch(dn::contains);
} }
/**
* 分页查询系统里所有用户
*
* @param page 参数集
* @param userDTO 查询参数列表
* @return 用户集合
*
* @author chenyuxi
* @since 1.9.7
*/
@Override
public IPage<SysUser> getAllUserPage(Page page, UserDTO userDTO) {
if(Common.isEmpty(userDTO.getNameOrPhone())){
return baseMapper.getAllUserPage(page, userDTO);
}
return baseMapper.getAllUserPageWhere(page, userDTO);
}
@Override
public R<IPage<SysUser>> cspUserPage(Page page, String deptId, String userName, String nickName) {
if (Common.isEmpty(deptId)){
return R.failed(null,CommonConstants.PARAM_IS_NOT_ERROR);
}
return R.ok(baseMapper.cspUserPage(page,deptId,userName,nickName));
}
} }
...@@ -6,8 +6,8 @@ spring: ...@@ -6,8 +6,8 @@ spring:
activate: activate:
on-profile: test on-profile: test
redis: redis:
host: 192.168.1.65 host: 127.0.0.1
port: 22379 port: 6379
password: '@yf_2017' password: '@yf_2017'
datasource: datasource:
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
......
...@@ -63,6 +63,53 @@ ...@@ -63,6 +63,53 @@
and (dept_id = #{deptId} or ancestors like concat(#{deptIdSplit}, '%')) and (dept_id = #{deptId} or ancestors like concat(#{deptIdSplit}, '%'))
</select> </select>
<select id="cspDeptList" resultType="com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysDeptVo">
select d.dept_id, d.name, d.parent_id,d.ancestors,sort_order
from sys_dept d
where d.del_flag = '0'
<if test="dept.projectNo != null and dept.projectNo != ''">
AND d.project_no = #{dept.projectNo}
</if>
<if test="dept.deptId != null and dept.deptId != 0">
AND d.dept_id = #{dept.deptId}
</if>
<if test="dept.parentId != null and dept.parentId != 0">
AND d.parent_id = #{dept.parentId}
</if>
<if test="dept.name != null and dept.name != ''">
AND d.name like concat('%', #{dept.name}, '%')
</if>
order by d.create_time desc,d.sort_order asc
</select>
<select id="cspDeptUserList" resultType="com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysDeptVo">
select d.dept_id, d.name, d.parent_id,d.ancestors,sort_order,
(select count(*) from sys_user_dept_permission where dept_id = d.dept_id) as peoplenum
from sys_dept d
where d.del_flag = '0'
<if test="dept.projectNo != null and dept.projectNo != ''">
AND d.project_no = #{dept.projectNo}
</if>
order by d.create_time desc,d.sort_order asc
</select>
<select id="checkDeptNameUnique" resultMap="BaseResultMap">
select dept_id,name from sys_dept
where project_no = #{projectNo} and name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
</select>
<select id="checkDeptExistUser" resultType="int">
select count(1) from sys_user_dept_permission where dept_id = #{deptId}
</select>
<select id="hasChildByDeptId" resultType="int">
select count(1) from sys_dept where del_flag = '0' and parent_id = #{deptId}
</select>
<select id="cspDeptCount" resultType="int">
select count(1) from sys_dept where del_flag = '0' and project_no = #{projectNo}
</select>
<update id="updateDeptById"> <update id="updateDeptById">
update sys_dept update sys_dept
<trim prefix="set" suffixOverrides=","> <trim prefix="set" suffixOverrides=",">
...@@ -74,4 +121,21 @@ ...@@ -74,4 +121,21 @@
</trim> </trim>
WHERE dept_id=#{dept.deptId} WHERE dept_id=#{dept.deptId}
</update> </update>
<update id="batchUpdateSort">
UPDATE sys_dept
<trim prefix="SET" suffixOverrides=",">
<trim prefix="sort_order = CASE" suffix="END,">
<foreach collection="moveVos" item="m">
WHEN dept_id = #{m.id} THEN #{m.sort}
</foreach>
</trim>
</trim>
WHERE dept_id IN
<foreach collection="moveVos" item="m" open="(" separator="," close=")">
#{m.id}
</foreach>
</update>
</mapper> </mapper>
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
<result column="user_id" property="userId"/> <result column="user_id" property="userId"/>
<result column="dept_id" property="deptId"/> <result column="dept_id" property="deptId"/>
<result column="project_no" property="projectNo"/> <result column="project_no" property="projectNo"/>
<result column="project_name" property="projectName"/>
<result column="client" property="client"/> <result column="client" property="client"/>
<result column="user_type" property="userType"/> <result column="user_type" property="userType"/>
<result column="permissions_type" property="permissionsType"/> <result column="permissions_type" property="permissionsType"/>
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
a.user_id, a.user_id,
a.dept_id, a.dept_id,
a.project_no, a.project_no,
a.project_name,
a.client, a.client,
a.user_type, a.user_type,
a.permissions_type, a.permissions_type,
......
...@@ -386,4 +386,48 @@ ...@@ -386,4 +386,48 @@
from from
sys_dept where dept_id = #{deptId} limit 1 sys_dept where dept_id = #{deptId} limit 1
</select> </select>
<select id="getAllUserPage" resultType="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser">
SELECT user_id,nickname,phone,create_time,username FROM sys_user
where del_flag = '0' and lock_flag = '0'
ORDER BY create_time DESC
</select>
<select id="getAllUserPageWhere" resultType="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser">
select u.* from
(SELECT user_id,nickname,phone,create_time,username FROM sys_user
where del_flag = '0' and lock_flag = '0'
<if test="query.nameOrPhone != null and query.nameOrPhone != ''">
<bind name="usernameLike" value="'%' + query.nameOrPhone + '%'"/>
and nickname LIKE #{usernameLike}
</if>
union
SELECT user_id,nickname,phone,create_time,username FROM sys_user
where del_flag = '0' and lock_flag = '0'
<if test="query.nameOrPhone != null and query.nameOrPhone != ''">
and phone = #{query.nameOrPhone}
</if>
) u
ORDER BY u.create_time DESC
</select>
<select id="cspUserPage" resultType="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser">
select u.user_id,u.nickname,u.phone,u.create_time,u.username from sys_user u
LEFT JOIN sys_user_dept_permission p on u.user_id=p.user_id
where
1=1
<if test="nickName != null and nickName != ''">
and u.nickname LIKE CONCAT('%',#{nickName},'%')
</if>
<if test="userName != null and username != ''">
and u.username LIKE CONCAT('%',#{userName,'%')
</if>
<if test="null != deptId and deptId != ''">
p.dept_id in (
select d.dept_id from sys_dept d where d.ancestors like CONCAT("0","%",#{deptId},"%")
)
</if>
ORDER BY u.create_time DESC
</select>
</mapper> </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