mirror of
https://github.com/1Panel-dev/CordysCRM.git
synced 2026-05-14 11:22:10 +08:00
feat: user batch edit
This commit is contained in:
@@ -94,5 +94,10 @@ public class OrganizationUserController {
|
||||
organizationUserService.syncUser(type, SessionUtils.getUserId(), OrganizationContext.getOrganizationId());
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/batch/edit")
|
||||
@Operation(summary = "用户(员工)-批量编辑")
|
||||
@RequiresPermissions(PermissionConstants.SYS_DEPARTMENT_UPDATE)
|
||||
public void batchEditFunctionalCase(@Validated @RequestBody UserBatchEditRequest request) {
|
||||
organizationUserService.batchEditUser(request, SessionUtils.getUserId(), OrganizationContext.getOrganizationId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package io.cordys.crm.system.dto.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserBatchEditRequest extends UserBatchRequest{
|
||||
|
||||
private String departmentId;
|
||||
|
||||
private String supervisorId;
|
||||
|
||||
private String workCity;
|
||||
}
|
||||
@@ -9,13 +9,12 @@ import io.cordys.common.dto.OptionDTO;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jianxing
|
||||
* @date 2025-01-09 16:11:37
|
||||
*/
|
||||
public interface ExtOrganizationUserMapper {
|
||||
|
||||
int countUserByDepartmentId(@Param("departmentId") String departmentId,@Param("orgId")String orgId);
|
||||
int countUserByDepartmentId(@Param("departmentId") String departmentId, @Param("orgId") String orgId);
|
||||
|
||||
List<UserPageResponse> list(@Param("request") UserPageRequest request);
|
||||
|
||||
@@ -26,4 +25,6 @@ public interface ExtOrganizationUserMapper {
|
||||
void deleteUserByOrgId(@Param("orgId") String orgId);
|
||||
|
||||
List<OptionDTO> selectEnableOrgUser(@Param("ids") List<String> ids, @Param("enable") boolean enable);
|
||||
|
||||
void updateUserByIds(@Param("request") UserBatchEditRequest request, @Param("operatorId") String operatorId, @Param("orgId") String orgId);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<update id="enable">
|
||||
update sys_organization_user
|
||||
set `enable` = #{request.enable},
|
||||
update_time = #{time},
|
||||
update_time = UNIX_TIMESTAMP() * 1000,
|
||||
update_user = #{operatorId}
|
||||
where id in
|
||||
<foreach collection="request.ids" item="id" open="(" separator="," close=")">
|
||||
@@ -79,8 +79,31 @@
|
||||
from sys_user su
|
||||
inner join sys_organization_user sou on su.id = sou.user_id
|
||||
where sou.id in
|
||||
<foreach collection="request.ids" item="id" open="(" separator="," close=")">
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<update id="updateUserByIds">
|
||||
update sys_organization_user
|
||||
<set>
|
||||
<if test="request.departmentId != null">
|
||||
department_id = #{request.departmentId},
|
||||
</if>
|
||||
<if test="request.supervisorId != null">
|
||||
supervisor_id = #{request.supervisorId},
|
||||
</if>
|
||||
<if test="request.workCity != null">
|
||||
work_city = #{request.workCity},
|
||||
</if>
|
||||
update_time = UNIX_TIMESTAMP() * 1000,
|
||||
update_user = #{operatorId}
|
||||
</set>
|
||||
<where>
|
||||
id in
|
||||
<foreach collection="request.ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</where>
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -19,9 +19,9 @@ import io.cordys.crm.system.dto.request.*;
|
||||
import io.cordys.crm.system.dto.response.UserPageResponse;
|
||||
import io.cordys.crm.system.dto.response.UserResponse;
|
||||
import io.cordys.crm.system.mapper.*;
|
||||
import io.cordys.mybatis.BaseMapper;
|
||||
import io.cordys.integration.wecom.dto.WeComDepartment;
|
||||
import io.cordys.integration.wecom.dto.WeComUser;
|
||||
import io.cordys.mybatis.BaseMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@@ -512,4 +512,17 @@ public class OrganizationUserService {
|
||||
organizationUserMapper.batchInsert(organizationUsers);
|
||||
departmentCommanderMapper.batchInsert(departmentCommanders);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量编辑用户
|
||||
*
|
||||
* @param request
|
||||
* @param operatorId
|
||||
* @param organizationId
|
||||
*/
|
||||
public void batchEditUser(UserBatchEditRequest request, String operatorId, String organizationId) {
|
||||
extOrganizationUserMapper.updateUserByIds(request, operatorId, organizationId);
|
||||
//todo 日志
|
||||
}
|
||||
}
|
||||
@@ -173,4 +173,6 @@ permission.role.remove_user=Remove user
|
||||
customer_pool_not_exist=公海池不存在!
|
||||
customer_pool_access_fail=访问失败, 非公海池管理员!
|
||||
customer_pool_related=公海池存在未分配的线索, 禁止删除!
|
||||
customer_capacity_not_exist=Customer capacity does not exist!
|
||||
customer_capacity_not_exist=Customer capacity does not exist!
|
||||
|
||||
password_is_incorrect=Password is incorrect
|
||||
@@ -175,4 +175,6 @@ permission.role.remove_user=移除用户
|
||||
customer_pool_not_exist=公海池不存在!
|
||||
customer_pool_access_fail=访问失败, 非公海池管理员!
|
||||
customer_pool_related=公海池存在未分配的线索, 禁止删除!
|
||||
customer_capacity_not_exist=客户库容规则不存在!
|
||||
customer_capacity_not_exist=客户库容规则不存在!
|
||||
|
||||
password_is_incorrect=密码不正确
|
||||
@@ -28,6 +28,8 @@ public class OrganizationUserControllerTests extends BaseTest {
|
||||
public static final String USER_BATCH_ENABLE = "/user/batch-enable";
|
||||
public static final String USER_BATCH_RESET_PASSWORD = "/user/batch/reset-password";
|
||||
public static final String USER_SYNC = "/user/sync/";
|
||||
public static final String USER_BATCH_EDIT = "/user/batch/edit";
|
||||
|
||||
|
||||
@Sql(scripts = {"/dml/init_user_test.sql"},
|
||||
config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED),
|
||||
@@ -82,7 +84,7 @@ public class OrganizationUserControllerTests extends BaseTest {
|
||||
request.setGender(true);
|
||||
request.setEnable(true);
|
||||
request.setEmail("221@Cordys.com");
|
||||
request.setDepartmentId("8");
|
||||
request.setDepartmentId("9");
|
||||
request.setRoleIds(List.of("1", "2", "3"));
|
||||
request.setId("u_1");
|
||||
this.requestPost(USER_UPDATE, request).andExpect(status().isOk());
|
||||
@@ -118,4 +120,13 @@ public class OrganizationUserControllerTests extends BaseTest {
|
||||
public void syncUser() throws Exception {
|
||||
this.requestGet(USER_SYNC + "WECOM");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
public void batchEdit() throws Exception {
|
||||
UserBatchEditRequest request = new UserBatchEditRequest();
|
||||
request.setIds(List.of("u_1", "u_2"));
|
||||
request.setWorkCity("深圳");
|
||||
this.requestPost(USER_BATCH_EDIT,request).andExpect(status().isOk());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ VALUES
|
||||
|
||||
INSERT INTO `sys_organization_user`(`id`, `organization_id`, `department_id`, `resource_user_id`, `user_id`, `enable`, `employee_id`, `position`, `employee_type`, `supervisor_id`, `work_city`, `create_user`, `update_user`, `create_time`, `update_time`)
|
||||
VALUES
|
||||
('u_1', '100001', '8', '', '1', true, '', '', '', '', '', 'admin', 'admin', 1716175907000, 1716175907000),
|
||||
('u_2', '100001', '8', '', '2', true, '', '', '', '', '', 'admin', 'admin', 1716175907000, 1716175907000),
|
||||
('u_3', '100001', '8', '', '3', true, '', '', '', '', '', 'admin', 'admin', 1716175907000, 1716175907000),
|
||||
('u_4', '100001', '8', '', '4', true, '', '', '', '', '', 'admin', 'admin', 1716175907000, 1716175907000),
|
||||
('u_5', '100001', '8', '', '5', true, '', '', '', '', '', 'admin', 'admin', 1716175907000, 1716175907000);
|
||||
('u_1', '100001', '9', '', '1', true, '', '', '', '', '', 'admin', 'admin', 1716175907000, 1716175907000),
|
||||
('u_2', '100001', '9', '', '2', true, '', '', '', '', '', 'admin', 'admin', 1716175907000, 1716175907000),
|
||||
('u_3', '100001', '9', '', '3', true, '', '', '', '', '', 'admin', 'admin', 1716175907000, 1716175907000),
|
||||
('u_4', '100001', '9', '', '4', true, '', '', '', '', '', 'admin', 'admin', 1716175907000, 1716175907000),
|
||||
('u_5', '100001', '9', '', '5', true, '', '', '', '', '', 'admin', 'admin', 1716175907000, 1716175907000);
|
||||
|
||||
|
||||
INSERT INTO `sys_role`(`id`, `name`, `internal`, `data_scope`, `create_time`, `update_time`, `create_user`, `update_user`, `description`, `organization_id`)
|
||||
@@ -24,3 +24,8 @@ VALUES ('r_1', '测试角色', 0, '1', 1716175907000, 1716175907000, 'admin', 'a
|
||||
|
||||
INSERT INTO `sys_user_role`(`id`, `role_id`, `user_id`, `create_time`, `update_time`, `create_user`, `update_user`)
|
||||
VALUES ('sur_1', 'r_1', '1', 1716175907000, 1716175907000, 'admin', 'admin');
|
||||
|
||||
|
||||
INSERT INTO `sys_department`(`id`, `name`, `organization_id`, `parent_id`, `num`, `create_time`, `update_time`, `create_user`, `update_user`, `resource`, `resource_id`)
|
||||
VALUES
|
||||
('9', '部门9', '100001', '4', 6, 1736240043609, 1736240043609, 'admin', 'admin', 'INTERNAL', NULL);
|
||||
@@ -155,7 +155,7 @@ public class RsaUtils {
|
||||
* @throws Exception 如果解密失败
|
||||
*/
|
||||
private static String privateDecrypt(String cipherText, RSAPrivateKey privateKey) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance(RSA_CIPHER_TRANSFORMATION_OAEP);
|
||||
Cipher cipher = Cipher.getInstance(RSA_ALGORITHM);
|
||||
cipher.init(Cipher.DECRYPT_MODE, privateKey);
|
||||
|
||||
byte[] decryptedData = rsaSplitCodec(cipher, Cipher.DECRYPT_MODE, Base64.getDecoder().decode(cipherText), privateKey.getModulus().bitLength());
|
||||
|
||||
Reference in New Issue
Block a user