Commit 883be243 by 李小龙

角色

parent 1c2ff4c0
Showing with 1580 additions and 258 deletions
...@@ -6,7 +6,7 @@ CREATE TABLE `plat_user` ( ...@@ -6,7 +6,7 @@ CREATE TABLE `plat_user` (
`account` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '账户', `account` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '账户',
`password` varchar(64) NOT NULL COMMENT '密码', `password` varchar(64) NOT NULL COMMENT '密码',
`mobile` varchar(11) NOT NULL COMMENT '手机号', `mobile` varchar(11) NOT NULL COMMENT '手机号',
`email` varchar(64) NOT NULL COMMENT '邮箱', `email` varchar(64) DEFAULT NULL COMMENT '邮箱',
`status` char(1) NOT NULL COMMENT '状态 0禁用 1启用', `status` char(1) NOT NULL COMMENT '状态 0禁用 1启用',
`avatar` varchar(256) DEFAULT NULL COMMENT '头像', `avatar` varchar(256) DEFAULT NULL COMMENT '头像',
`is_tenant` char(1) DEFAULT NULL COMMENT '是否租户账户/租户管理员 0否 1是', `is_tenant` char(1) DEFAULT NULL COMMENT '是否租户账户/租户管理员 0否 1是',
...@@ -28,7 +28,7 @@ CREATE TABLE `plat_user` ( ...@@ -28,7 +28,7 @@ CREATE TABLE `plat_user` (
CREATE TABLE `plat_role` ( CREATE TABLE `plat_role` (
`id` varchar(64) NOT NULL COLLATE utf8mb4_general_ci COMMENT 'id', `id` varchar(64) NOT NULL COLLATE utf8mb4_general_ci COMMENT 'id',
`tenant_id` varchar(64) NOT NULL COMMENT '租户id', `tenant_id` varchar(64) NOT NULL COMMENT '租户id',
`role_name` varchar(100) NOT NULL COMMENT '名称', `name` varchar(100) NOT NULL COMMENT '名称',
`remark` varchar(255) DEFAULT NULL COMMENT '备注', `remark` varchar(255) DEFAULT NULL COMMENT '备注',
`data_scope` varchar(600) DEFAULT NULL COMMENT '数据权限 子公司id 上级可看到下级', `data_scope` varchar(600) DEFAULT NULL COMMENT '数据权限 子公司id 上级可看到下级',
`create_date` datetime NOT NULL COMMENT '创建时间', `create_date` datetime NOT NULL COMMENT '创建时间',
...@@ -36,6 +36,7 @@ CREATE TABLE `plat_role` ( ...@@ -36,6 +36,7 @@ CREATE TABLE `plat_role` (
`del_flag` CHAR(1) DEFAULT NULL COMMENT '删除标识', `del_flag` CHAR(1) DEFAULT NULL COMMENT '删除标识',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新人', `update_by` varchar(64) DEFAULT NULL COMMENT '更新人',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人', `create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
`org_id` varchar(64) DEFAULT NULL COMMENT '所属组织',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='租户端角色'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='租户端角色';
......
INSERT INTO `sys_dictionary_category` ( `id`, `code`, `name`, `create_date`, `update_date`, `del_flag` )
VALUES
( '10000', 'menu.type', '菜单类型', '2022-05-16 16:33:28', '2022-05-16 16:33:33', 0 );
INSERT INTO `sys_dictionary` ( `id`, `code`, `name`, `value`, `sort`, `description`, `category_id`, `create_date`, `update_date`, `del_flag` )
VALUES
( '10001', 'menu.type.catalogue', '目录', '1', 1, '', '10000', '2022-05-16 16:34:57', '2022-05-16 16:35:10', 0 );
INSERT INTO `sys_dictionary` ( `id`, `code`, `name`, `value`, `sort`, `description`, `category_id`, `create_date`, `update_date`, `del_flag` )
VALUES
( '10002', 'menu.type.menu', '菜单', '2', 2, '', '10000', '2022-05-16 16:35:44', '2022-05-16 16:35:50', 0 );
INSERT INTO `sys_dictionary` ( `id`, `code`, `name`, `value`, `sort`, `description`, `category_id`, `create_date`, `update_date`, `del_flag` )
VALUES
( '10003', 'menu.type.button', '按钮', '3', 3, '', '10000', '2022-05-16 16:36:28', '2022-05-16 16:36:33', 0 );
select * from sys_dictionary_category t order by t.id asc;
select * from sys_dictionary t order by t.id asc;
\ No newline at end of file
...@@ -144,7 +144,7 @@ CREATE TABLE `plat_tenant` ( ...@@ -144,7 +144,7 @@ CREATE TABLE `plat_tenant` (
`create_date` datetime NOT NULL COMMENT '创建时间', `create_date` datetime NOT NULL COMMENT '创建时间',
`update_date` datetime NOT NULL COMMENT '更新时间', `update_date` datetime NOT NULL COMMENT '更新时间',
`del_flag` CHAR(1) DEFAULT NULL COMMENT '删除标识', `del_flag` CHAR(1) DEFAULT NULL COMMENT '删除标识',
`create_by_` varchar(64) NOT NULL COMMENT '创建人', `create_by` varchar(64) NOT NULL COMMENT '创建人',
`update_by` varchar(64) NOT NULL COMMENT '更新人', `update_by` varchar(64) NOT NULL COMMENT '更新人',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 STATS_AUTO_RECALC=0 ROW_FORMAT=COMPACT COMMENT='租户管理'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 STATS_AUTO_RECALC=0 ROW_FORMAT=COMPACT COMMENT='租户管理';
...@@ -156,6 +156,8 @@ CREATE TABLE `plat_tenant_menu` ( ...@@ -156,6 +156,8 @@ CREATE TABLE `plat_tenant_menu` (
`create_date` datetime NOT NULL COMMENT '创建时间', `create_date` datetime NOT NULL COMMENT '创建时间',
`update_date` datetime NOT NULL COMMENT '更新时间', `update_date` datetime NOT NULL COMMENT '更新时间',
`del_flag` CHAR(1) DEFAULT NULL COMMENT '删除标识', `del_flag` CHAR(1) DEFAULT NULL COMMENT '删除标识',
`create_by` varchar(64) NOT NULL COMMENT '创建人',
`update_by` varchar(64) NOT NULL COMMENT '更新人',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `tnt_tenant_menu_menu_id_index` (`menu_id`), KEY `tnt_tenant_menu_menu_id_index` (`menu_id`),
KEY `tnt_tenant_menu_tenant_id_index` (`tenant_id`) KEY `tnt_tenant_menu_tenant_id_index` (`tenant_id`)
......
...@@ -40,6 +40,28 @@ public class SwaggerSaasConfig { ...@@ -40,6 +40,28 @@ public class SwaggerSaasConfig {
return config; return config;
} }
@Bean
public SwaggerModuleConfig platModule() {
SwaggerModuleConfig config = new SwaggerModuleConfig();
config.setPackageList(Arrays.asList("com.makeit.controller.plat"));
config.setModuleName("平台端");
return config;
}
@Bean
public Docket platApi() {
Docket docket = new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("03-平台端");
ApiSelectorBuilder builder = docket.select();
//api过滤
builder = builder.apis(
RequestHandlerSelectors.basePackage("com.makeit.controller.plat")
);
return builder.build();
}
@Bean @Bean
public Docket saasApi() { public Docket saasApi() {
......
package com.makeit.controller.plat;
import com.makeit.common.dto.LoginDTO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.module.admin.vo.plat.PlatUserLoginVO;
import com.makeit.service.platform.auth.PlatUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "平台端-登录")
@RestController
@RequestMapping("/plat/login")
public class PlatLoginController {
@Autowired
private PlatUserService platUserService;
@ApiOperation("登录")
@PostMapping("login")
public ApiResponseEntity<PlatUserLoginVO> login(@RequestBody LoginDTO loginDTO) {
return ApiResponseUtils.success(platUserService.login(loginDTO));
}
@ApiOperation("退出登录")
@PostMapping("logout")
public ApiResponseEntity<?> logout() {
platUserService.logout();
return ApiResponseUtils.success();
}
}
package com.makeit.controller.plat;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.dto.BaseOrgDTO;
import com.makeit.common.dto.StatusDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.auth.PlatRoleDeptDTOVO;
import com.makeit.dto.platform.auth.PlatRoleMenuDTO;
import com.makeit.dto.platform.auth.PlatUserRoleDTO;
import com.makeit.entity.platform.auth.PlatRoleMenu;
import com.makeit.entity.platform.auth.PlatRoleOrg;
import com.makeit.global.annotation.Action;
import com.makeit.module.admin.dto.plat.PlatRoleDTOVO;
import com.makeit.service.platform.auth.PlatRoleService;
import com.makeit.service.platform.auth.PlatUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 租户端角色 前端控制器
* </p>
*
* @author eugene young
* @since 2022-05-10
*/
@Api(tags = "平台端-角色")
@RestController
@RequestMapping("/plat/role")
public class PlatRoleController {
@Autowired
private PlatRoleService platRoleService;
@Autowired
private PlatUserService platUserService;
@Action(module = "平台端-角色", name = "分页列表", code = "tnt:role:page")
@ApiOperation("分页列表")
@PostMapping("page")
public ApiResponseEntity<PageVO<PlatRoleDTOVO>> page(@RequestBody PageReqDTO<PlatRoleDTOVO> page) {
return ApiResponseUtils.success(platRoleService.page(page));
}
@Action(module = "平台端-角色", name = "列表", code = "tnt:role:list")
@ApiOperation("列表")
@PostMapping("list")
public ApiResponseEntity<List<PlatRoleDTOVO>> list(@RequestBody PlatRoleDTOVO dto) {
return ApiResponseUtils.success(platRoleService.list(dto));
}
@ApiOperation("分页列表(AuthIgnore)")
@PostMapping("pageAuthIgnore")
public ApiResponseEntity<PageVO<PlatRoleDTOVO>> pageAuthIgnore(@RequestBody PageReqDTO<PlatRoleDTOVO> page) {
return ApiResponseUtils.success(platRoleService.page(page));
}
@ApiOperation("列表(AuthIgnore)")
@PostMapping("listAuthIgnore")
public ApiResponseEntity<List<PlatRoleDTOVO>> listAuthIgnore(@RequestBody PlatRoleDTOVO dto) {
return ApiResponseUtils.success(platRoleService.list(dto));
}
@Action(module = "平台端-角色", name = "新增", code = "tnt:role:add")
@ApiOperation("新增")
@PostMapping("add")
public ApiResponseEntity<?> add(@Validated @RequestBody PlatRoleDTOVO dto) {
platRoleService.add(dto);
return ApiResponseUtils.success();
}
@Action(module = "平台端-角色", name = "编辑", code = "tnt:role:edit")
@ApiOperation("编辑")
@PostMapping("edit")
public ApiResponseEntity<?> edit(@Validated @RequestBody PlatRoleDTOVO dto) {
platRoleService.edit(dto);
return ApiResponseUtils.success();
}
@Action(module = "平台端-角色", name = "详情", code = "tnt:role:view")
@ApiOperation("详情")
@PostMapping("view")
public ApiResponseEntity<PlatRoleDTOVO> view(@RequestBody BaseIdDTO dto) {
return ApiResponseUtils.success(platRoleService.view(dto.getId()));
}
@Action(module = "平台端-角色", name = "删除", code = "tnt:role:del")
@ApiOperation("删除")
@PostMapping("del")
public ApiResponseEntity<?> del(@RequestBody BaseIdDTO dto) {
platRoleService.del(dto.getId());
return ApiResponseUtils.success();
}
@Action(module = "平台端-角色", name = "改变状态", code = "tnt:role:changeStatus")
@ApiOperation("改变状态")
@PostMapping("changeStatus")
public ApiResponseEntity<?> changeStatus(@RequestBody StatusDTO dto) {
platRoleService.changeStatus(dto);
return ApiResponseUtils.success();
}
@Action(module = "平台端-角色", name = "分配用户", code = "tnt:role:assignUserList")
@ApiOperation("分配用户")
@PostMapping("assignUserList")
public ApiResponseEntity<?> assignUserList(@RequestBody List<PlatUserRoleDTO> userRoleDTOList) {//参数要不要是一个对象里 有一个数组
platRoleService.assignUserList(userRoleDTOList);
return ApiResponseUtils.success();
}
@Action(module = "平台端-角色", name = "删除分配用户", code = "tnt:role:removeAssignUserList")
@ApiOperation("删除分配用户")
@PostMapping("removeAssignUserList")
public ApiResponseEntity<?> removeAssignUserList(@RequestBody List<PlatUserRoleDTO> userRoleDTOList) {
platRoleService.removeAssignUserList(userRoleDTOList);
return ApiResponseUtils.success();
}
@Action(module = "平台端-角色", name = "分配菜单", code = "tnt:role:assignMenuList")
@ApiOperation("分配菜单")
@PostMapping("assignMenuList")
public ApiResponseEntity<?> assignMenuList(@RequestBody PlatRoleMenuDTO roleMenuDTO) {
platRoleService.assignMenuList(roleMenuDTO);
return ApiResponseUtils.success();
}
@Action(module = "平台端-角色", name = "获取分配菜单", code = "tnt:role:getAssignMenuList")
@ApiOperation("获取分配菜单")
@PostMapping("getAssignMenuList")
public ApiResponseEntity<List<PlatRoleMenu>> getAssignMenuList(@RequestBody BaseIdDTO baseIdDTO) {
return ApiResponseUtils.success(platRoleService.getAssignMenuList(baseIdDTO.getId()));
}
// @Action(module = "平台端-角色", name = "分配微信菜单", code = "tnt:role:assignWechatMenuList")
// @ApiOperation("分配微信菜单")
// @PostMapping("assignWechatMenuList")
// public ApiResponseEntity<?> assignWechatMenuList(@RequestBody PlatRoleMenuDTO roleMenuDTO) {
// platRoleService.assignWechatMenuList(roleMenuDTO);
// return ApiResponseUtils.success();
// }
//
// @Action(module = "平台端-角色", name = "获取分配微信菜单", code = "tnt:role:getWechatMenuListByRoleId")
// @ApiOperation("获取分配微信菜单")
// @PostMapping("getWechatMenuListByRoleId")
// public ApiResponseEntity<List<PlatRoleWechatMenu>> getWechatMenuListByRoleId(@RequestBody BaseIdDTO baseIdDTO) {
// return ApiResponseUtils.success(platRoleService.getWechatMenuListByRoleId(baseIdDTO.getId()));
// }
//@Action(module = "平台端-角色", name = "管理范围可选值", code = "tnt:role:getCandidateDeptList")
@ApiOperation("管理范围可选值")
@PostMapping("getCandidateOrgList")
public ApiResponseEntity<?> getCandidateDeptList(@RequestBody BaseOrgDTO deptDTO) {
return ApiResponseUtils.success(platUserService.getHotelList(deptDTO.getOrgId()));
}
@ApiOperation("管理范围可选值2")
@PostMapping("getCandidateDeptList2")
public ApiResponseEntity<?> getCandidateDeptList2(@RequestBody BaseOrgDTO deptDTO) {
return ApiResponseUtils.success(platUserService.getCandidateDeptList());
}
@Action(module = "平台端-角色", name = "分配管理权限", code = "tnt:role:assignDeptList")
@ApiOperation("分配管理权限")
@PostMapping("assignDeptList")
public ApiResponseEntity<?> assignDeptList(@RequestBody PlatRoleDeptDTOVO roleDeptDTO) {
platRoleService.assignDeptList(roleDeptDTO);
return ApiResponseUtils.success();
}
@Action(module = "平台端-角色", name = "获取分配管理权限", code = "tnt:role:getDeptListByRoleId")
@ApiOperation("获取分配管理权限")
@PostMapping("getDeptListByRoleId")
public ApiResponseEntity<List<PlatRoleOrg>> getDeptListByRoleId(@RequestBody BaseIdDTO baseIdDTO) {
return ApiResponseUtils.success(platRoleService.getDeptListByRoleId(baseIdDTO.getId()));
}
@Action(module = "平台端-角色", name = "复制角色及关联", code = "tnt:role:copyRole")
@ApiOperation("复制角色及关联")
@PostMapping("copyRole")
public ApiResponseEntity<?> copyRole(@RequestBody BaseIdDTO baseIdDTO) {
platRoleService.copyRole(baseIdDTO.getId());
return ApiResponseUtils.success();
}
@ApiOperation("列表(AuthIgnore)")
@PostMapping("getAuthIgnore")
public ApiResponseEntity<List<PlatRoleDTOVO>> getAuthIgnore(@RequestBody PlatRoleDTOVO dto) {
return ApiResponseUtils.success(platRoleService.getList(dto));
}
// @ApiOperation(value = "导出模板", notes = "")
// @PostMapping("/exportTemplate")
// public void exportTemplate(HttpServletResponse response) {
// platRoleService.exportTemplate(response);
// }
//
// @ApiOperation(value = "人员角色关联-导入", notes = "tnt.userLabel.importExcel")
// @PostMapping("/importExcel")
// @Action(name = "人员角色关联-导入", code = "tnt:role:copyRole.userRole.importExcel")
// public ApiResponseEntity<ExcelImportVo> importExcel(@RequestParam(value = "deptId", required = true) String deptId,
// @RequestParam(value = "hotelId", required = true) String hotelId,
// @RequestParam(value = "excelFile", required = true) MultipartFile excelFile) throws Exception {
// return ApiResponseUtils.success(platRoleService.importExcel(deptId, hotelId, excelFile));
// }
}
package com.makeit.controller.saas; package com.makeit.controller.plat;
import com.makeit.common.dto.BaseIdDTO; import com.makeit.common.dto.BaseIdDTO;
...@@ -10,7 +10,6 @@ import com.makeit.common.response.ApiResponseUtils; ...@@ -10,7 +10,6 @@ import com.makeit.common.response.ApiResponseUtils;
import com.makeit.global.annotation.Action; import com.makeit.global.annotation.Action;
import com.makeit.module.admin.dto.plat.PlatUserDTOVO; import com.makeit.module.admin.dto.plat.PlatUserDTOVO;
import com.makeit.module.admin.dto.plat.PlatUserQueryDTO; import com.makeit.module.admin.dto.plat.PlatUserQueryDTO;
import com.makeit.module.admin.vo.plat.PlatUserLoginVO;
import com.makeit.service.platform.auth.PlatUserService; import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.vo.platform.auth.PlatPersonDTOVO; import com.makeit.vo.platform.auth.PlatPersonDTOVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -32,29 +31,29 @@ import java.util.List; ...@@ -32,29 +31,29 @@ import java.util.List;
* @author eugene young * @author eugene young
* @since 2022-05-10 * @since 2022-05-10
*/ */
@Api(tags = "租户管理-租户账号管理") @Api(tags = "平台端-人员管理")
@RestController @RestController
@RequestMapping("/saas/plat/user") @RequestMapping("/plat/user")
public class PlatUserController { public class PlatUserController {
@Autowired @Autowired
private PlatUserService platUserService; private PlatUserService platUserService;
@Action(module = "租户端-人员", name = "分页列表", code = "saas:plat:user:page") @Action(module = "平台端-人员", name = "分页列表", code = "plat:user:page")
@ApiOperation("分页列表") @ApiOperation("分页列表")
@PostMapping("page") @PostMapping("page")
public ApiResponseEntity<PageVO<PlatPersonDTOVO>> page(@RequestBody PageReqDTO<PlatUserQueryDTO> page) { public ApiResponseEntity<PageVO<PlatPersonDTOVO>> page(@RequestBody PageReqDTO<PlatUserQueryDTO> page) {
return ApiResponseUtils.success(platUserService.page(page)); return ApiResponseUtils.success(platUserService.page(page));
} }
@Action(module = "租户端-人员", name = "列表", code = "saas:plat:user:list") @Action(module = "平台端-人员", name = "列表", code = "plat:user:list")
@ApiOperation("列表") @ApiOperation("列表")
@PostMapping("list") @PostMapping("list")
public ApiResponseEntity<List<PlatPersonDTOVO>> list(@RequestBody PlatUserQueryDTO dto) { public ApiResponseEntity<List<PlatPersonDTOVO>> list(@RequestBody PlatUserQueryDTO dto) {
return ApiResponseUtils.success(platUserService.list(dto)); return ApiResponseUtils.success(platUserService.list(dto));
} }
@Action(module = "租户端-人员", name = "未分配部门用户分页列表", code = "saas:plat:user:pageNoDeptUser") @Action(module = "平台端-人员", name = "未分配部门用户分页列表", code = "plat:user:pageNoDeptUser")
@ApiOperation("未分配部门用户分页列表") @ApiOperation("未分配部门用户分页列表")
@PostMapping("pageNoDeptUser") @PostMapping("pageNoDeptUser")
public ApiResponseEntity<PageVO<PlatPersonDTOVO>> pageNoDeptUser(@RequestBody PageReqDTO<PlatUserQueryDTO> page) { public ApiResponseEntity<PageVO<PlatPersonDTOVO>> pageNoDeptUser(@RequestBody PageReqDTO<PlatUserQueryDTO> page) {
...@@ -73,7 +72,7 @@ public class PlatUserController { ...@@ -73,7 +72,7 @@ public class PlatUserController {
return ApiResponseUtils.success(platUserService.list(dto)); return ApiResponseUtils.success(platUserService.list(dto));
} }
@Action(module = "租户端-人员", name = "新增", code = "saas:plat:user:add") @Action(module = "平台端-人员", name = "新增", code = "plat:user:add")
@ApiOperation("新增") @ApiOperation("新增")
@PostMapping("add") @PostMapping("add")
public ApiResponseEntity<?> add(@Validated @RequestBody PlatPersonDTOVO dto) { public ApiResponseEntity<?> add(@Validated @RequestBody PlatPersonDTOVO dto) {
...@@ -81,7 +80,7 @@ public class PlatUserController { ...@@ -81,7 +80,7 @@ public class PlatUserController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@Action(module = "租户端-人员", name = "编辑", code = "saas:plat:user:edit") @Action(module = "平台端-人员", name = "编辑", code = "plat:user:edit")
@ApiOperation("编辑") @ApiOperation("编辑")
@PostMapping("edit") @PostMapping("edit")
public ApiResponseEntity<?> edit(@Validated @RequestBody PlatPersonDTOVO dto) { public ApiResponseEntity<?> edit(@Validated @RequestBody PlatPersonDTOVO dto) {
...@@ -89,7 +88,7 @@ public class PlatUserController { ...@@ -89,7 +88,7 @@ public class PlatUserController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@Action(module = "租户端-人员", name = "改变密码", code = "saas:plat:user:changePassword") @Action(module = "平台端-人员", name = "改变密码", code = "plat:user:changePassword")
@ApiOperation("改变密码") @ApiOperation("改变密码")
@PostMapping("changePassword") @PostMapping("changePassword")
public ApiResponseEntity<?> changePassword(@RequestBody PlatUserDTOVO dto) { public ApiResponseEntity<?> changePassword(@RequestBody PlatUserDTOVO dto) {
...@@ -97,14 +96,14 @@ public class PlatUserController { ...@@ -97,14 +96,14 @@ public class PlatUserController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@Action(module = "租户端-人员", name = "详情", code = "saas:plat:user:view") @Action(module = "平台端-人员", name = "详情", code = "plat:user:view")
@ApiOperation("详情") @ApiOperation("详情")
@PostMapping("view") @PostMapping("view")
public ApiResponseEntity<PlatPersonDTOVO> view(@RequestBody BaseIdDTO dto) { public ApiResponseEntity<PlatPersonDTOVO> view(@RequestBody BaseIdDTO dto) {
return ApiResponseUtils.success(platUserService.viewPerson(dto.getId())); return ApiResponseUtils.success(platUserService.viewPerson(dto.getId()));
} }
@Action(module = "租户端-人员", name = "删除", code = "saas:plat:user:del") @Action(module = "平台端-人员", name = "删除", code = "plat:user:del")
@ApiOperation("删除") @ApiOperation("删除")
@PostMapping("del") @PostMapping("del")
public ApiResponseEntity<?> del(@RequestBody BaseIdDTO dto) { public ApiResponseEntity<?> del(@RequestBody BaseIdDTO dto) {
...@@ -112,7 +111,7 @@ public class PlatUserController { ...@@ -112,7 +111,7 @@ public class PlatUserController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@Action(module = "租户端-人员", name = "改变状态", code = "saas:plat:user:changeStatus") @Action(module = "平台端-人员", name = "改变状态", code = "plat:user:changeStatus")
@ApiOperation("改变状态") @ApiOperation("改变状态")
@PostMapping("changeStatus") @PostMapping("changeStatus")
public ApiResponseEntity<?> changeStatus(@RequestBody StatusDTO dto) { public ApiResponseEntity<?> changeStatus(@RequestBody StatusDTO dto) {
...@@ -120,36 +119,36 @@ public class PlatUserController { ...@@ -120,36 +119,36 @@ public class PlatUserController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@ApiOperation("获取当前登录用户角色菜单") // @ApiOperation("获取当前登录用户角色菜单")
@PostMapping("getRoleMenu") // @PostMapping("getRoleMenu")
public ApiResponseEntity<PlatUserLoginVO> getRoleAndMenuList() { // public ApiResponseEntity<PlatUserLoginVO> getRoleAndMenuList() {
return ApiResponseUtils.success(platUserService.getRoleAndMenuList()); // return ApiResponseUtils.success(platUserService.getRoleAndMenuList());
} // }
//
@ApiOperation("获取当前登录用户角色菜单2") // @ApiOperation("获取当前登录用户角色菜单2")
@PostMapping("getRoleMenu2") // @PostMapping("getRoleMenu2")
public ApiResponseEntity<PlatUserLoginVO> getRoleAndMenuList2() { // public ApiResponseEntity<PlatUserLoginVO> getRoleAndMenuList2() {
return ApiResponseUtils.success(platUserService.getRoleAndMenuList2()); // return ApiResponseUtils.success(platUserService.getRoleAndMenuList2());
} // }
// //@Action(module = "租户端-人员", name = "获取当前登录用户企业微信菜单", code = "tnt:user:getWechatMenuList") // //@Action(module = "平台端-人员", name = "获取当前登录用户企业微信菜单", code = "tnt:user:getWechatMenuList")
// @ApiOperation("获取当前登录用户企业微信菜单") // @ApiOperation("获取当前登录用户企业微信菜单")
// @PostMapping("getWechatMenuList") // @PostMapping("getWechatMenuList")
// public ApiResponseEntity<PlatUserLoginVO> getWechatMenuList() { // public ApiResponseEntity<PlatUserLoginVO> getWechatMenuList() {
// return ApiResponseUtils.success(platUserService.getWechatMenuList()); // return ApiResponseUtils.success(platUserService.getWechatMenuList());
// } // }
@ApiOperation("获取当前登录用户信息") // @ApiOperation("获取当前登录用户信息")
@PostMapping("getUserVO") // @PostMapping("getUserVO")
public ApiResponseEntity<PlatUserLoginVO> getUserInfo() { // public ApiResponseEntity<PlatUserLoginVO> getUserInfo() {
return ApiResponseUtils.success(platUserService.getUserVO()); // return ApiResponseUtils.success(platUserService.getUserVO());
} // }
//
@ApiOperation("获取当前登录用户详细信息") // @ApiOperation("获取当前登录用户详细信息")
@PostMapping("getUserDetail") // @PostMapping("getUserDetail")
public ApiResponseEntity<PlatPersonDTOVO> getUserDetail() { // public ApiResponseEntity<PlatPersonDTOVO> getUserDetail() {
return ApiResponseUtils.success(platUserService.getUserDetail()); // return ApiResponseUtils.success(platUserService.getUserDetail());
} // }
} }
package com.makeit.controller.saas;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.entity.saas.PlatMenu;
import com.makeit.global.annotation.Action;
import com.makeit.module.admin.dto.plat.PlatMenuDTOVO;
import com.makeit.module.admin.dto.plat.PlatMenuQueryDTO;
import com.makeit.service.saas.PlatMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 租户端菜单 前端控制器
* </p>
*
* @author eugene young
* @since 2022-05-10
*/
@Api(tags = "系统管理-租户资源管理(菜单)")
@RestController
@RequestMapping("/saas/plat/menu")
public class SaasPlatMenuController {
@Autowired
private PlatMenuService platMenuService;
@Action(module = "saas端-租户资源管理(菜单)", name = "列表", code = "saas:plat:menu:list")
@ApiOperation("列表")
@PostMapping("list")
public ApiResponseEntity<List<PlatMenuDTOVO>> list(@RequestBody PlatMenuQueryDTO dto){
return ApiResponseUtils.success(platMenuService.list(dto));
}
@Action(module = "saas端-租户资源管理(菜单)", name = "树形列表", code = "saas:plat:menu:tree")
@ApiOperation("树形列表")
@PostMapping("tree")
public ApiResponseEntity<List<PlatMenuDTOVO>> tree(@RequestBody PlatMenuQueryDTO dto){
return ApiResponseUtils.success(platMenuService.tree(dto));
}
@ApiOperation("列表(AuthIgnore)")
@PostMapping("listAuthIgnore")
public ApiResponseEntity<List<PlatMenuDTOVO>> listAuthIgnore(@RequestBody PlatMenuQueryDTO dto){
return ApiResponseUtils.success(platMenuService.list(dto));
}
@ApiOperation("树形列表(AuthIgnore)")
@PostMapping("treeAuthIgnore")
public ApiResponseEntity<List<PlatMenuDTOVO>> treeAuthIgnore(@RequestBody PlatMenuQueryDTO dto){
return ApiResponseUtils.success(platMenuService.tree(dto));
}
@Action(module = "saas端-租户资源管理(菜单)", name = "新增", code = "saas:plat:menu:add")
@ApiOperation("新增")
@PostMapping("add")
public ApiResponseEntity<?> add(@Validated @RequestBody PlatMenuDTOVO dto){
platMenuService.add(dto);
return ApiResponseUtils.success();
}
@Action(module = "saas端-租户资源管理(菜单)", name = "编辑", code = "saas:plat:menu:edit")
@ApiOperation("编辑")
@PostMapping("edit")
public ApiResponseEntity<?> edit(@Validated @RequestBody PlatMenuDTOVO dto){
platMenuService.edit(dto);
return ApiResponseUtils.success();
}
//@Action(module = "saas端-租户资源管理(菜单)", name = "详情", code = "saas:plat:menu:view")
@ApiOperation("详情")
@PostMapping("view")
public ApiResponseEntity<PlatMenuDTOVO> view(@RequestBody BaseIdDTO dto){
return ApiResponseUtils.success(platMenuService.view(dto.getId()));
}
@Action(module = "saas端-租户资源管理(菜单)", name = "删除", code = "saas:plat:menu:del")
@ApiOperation("删除")
@PostMapping("del")
public ApiResponseEntity<?> del(@RequestBody BaseIdDTO dto){
platMenuService.del(dto.getId());
return ApiResponseUtils.success();
}
@ApiOperation("同步")
@PostMapping("sync")
public ApiResponseEntity<?> sync() {
platMenuService.sync();
return ApiResponseUtils.success();
}
@ApiOperation("获取菜单code")
@PostMapping("loadMenuCodeList")
public ApiResponseEntity<List<PlatMenu>> loadMenuCodeLis() {
return ApiResponseUtils.success(platMenuService.loadMenuCodeList());
}
}
package com.makeit.controller.saas;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.dto.StatusDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.global.annotation.Action;
import com.makeit.module.admin.dto.plat.PlatUserDTOVO;
import com.makeit.module.admin.dto.plat.PlatUserQueryDTO;
import com.makeit.service.platform.auth.PlatUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 租户端用户 前端控制器
* </p>
*
* @author eugene young
* @since 2022-05-10
*/
@Api(tags = "系统管理-租户账号")
@RestController
@RequestMapping("/saas/plat/user")
public class SaasPlatUserController {
@Autowired
private PlatUserService platUserService;
@Action(module = "saas端-租户账号", name = "分页列表", code = "saas.plat.user.pageTenant")
//@PlatOperationLogger
@ApiOperation("分页列表")
@PostMapping("pageTenant")
public ApiResponseEntity<PageVO<PlatUserDTOVO>> pageTenant(@RequestBody PageReqDTO<PlatUserQueryDTO> page){
return ApiResponseUtils.success(platUserService.pageTenant(page));
}
@Action(module = "saas端-租户账号", name = "列表", code = "saas.plat.user.listTenant")
@ApiOperation("列表")
@PostMapping("listTenant")
public ApiResponseEntity<List<PlatUserDTOVO>> listTenant(@RequestBody PlatUserQueryDTO dto){
return ApiResponseUtils.success(platUserService.listTenant(dto));
}
@ApiOperation("分页列表(AuthIgnore)")
@PostMapping("pageTenantAuthIgnore")
public ApiResponseEntity<PageVO<PlatUserDTOVO>> pageTenantAuthIgnore(@RequestBody PageReqDTO<PlatUserQueryDTO> page){
return ApiResponseUtils.success(platUserService.pageTenant(page));
}
@ApiOperation("列表(AuthIgnore)")
@PostMapping("listTenantAuthIgnore")
public ApiResponseEntity<List<PlatUserDTOVO>> listTenantAuthIgnore(@RequestBody PlatUserQueryDTO dto){
return ApiResponseUtils.success(platUserService.listTenant(dto));
}
@Action(module = "saas端-租户账号", name = "新增", code = "saas.plat.user.add")
@ApiOperation("新增")
@PostMapping("add")
public ApiResponseEntity<?> add(@Validated @RequestBody PlatUserDTOVO dto){
platUserService.add(dto);
return ApiResponseUtils.success();
}
@Action(module = "saas端-租户账号", name = "编辑", code = "saas.plat.user.edit")
@ApiOperation("编辑")
@PostMapping("edit")
public ApiResponseEntity<?> edit(@Validated @RequestBody PlatUserDTOVO dto){
platUserService.edit(dto);
return ApiResponseUtils.success();
}
@Action(module = "saas端-租户账号", name = "改变密码", code = "saas.plat.user.changePassword")
@ApiOperation("改变密码")
@PostMapping("changePasword")
public ApiResponseEntity<?> changePassword(@RequestBody PlatUserDTOVO dto){
platUserService.changePassword(dto);
return ApiResponseUtils.success();
}
//@Action(module = "saas端-租户账号", name = "详情", code = "saas.plat.user.view")
@ApiOperation("详情")
@PostMapping("view")
public ApiResponseEntity<PlatUserDTOVO> view(@RequestBody BaseIdDTO dto){
return ApiResponseUtils.success(platUserService.view(dto.getId()));
}
@Action(module = "saas端-租户账号", name = "删除", code = "saas.plat.user.del")
@ApiOperation("删除")
@PostMapping("del")
public ApiResponseEntity<?> del(@RequestBody BaseIdDTO dto){
platUserService.del(dto.getId());
return ApiResponseUtils.success();
}
@Action(module = "saas端-租户账号", name = "改变状态", code = "saas.plat.user.changeStatus")
@ApiOperation("改变状态")
@PostMapping("changeStatus")
public ApiResponseEntity<?> changeStatus(@RequestBody StatusDTO dto){
platUserService.changeStatus(dto);
return ApiResponseUtils.success();
}
}
...@@ -13,7 +13,7 @@ import java.io.Serializable; ...@@ -13,7 +13,7 @@ import java.io.Serializable;
public class BaseOrgDTO extends BaseTenantDTO implements Serializable { public class BaseOrgDTO extends BaseTenantDTO implements Serializable {
@ApiModelProperty(value = "部门树 id", required = true) @ApiModelProperty(value = "部门树 id", required = true)
private String deptId; private String orgId;
@ApiModelProperty(value = "部门树冗余 id") @ApiModelProperty(value = "部门树冗余 id")
private String path; private String path;
......
...@@ -48,7 +48,7 @@ public class BaseEntity implements Serializable { ...@@ -48,7 +48,7 @@ public class BaseEntity implements Serializable {
private LocalDateTime updateDate; private LocalDateTime updateDate;
@TableLogic @TableLogic(value = "0",delval = "1")
@TableField(select = false, fill = FieldFill.INSERT) @TableField(select = false, fill = FieldFill.INSERT)
private String delFlag; private String delFlag;
......
...@@ -7,6 +7,7 @@ import com.makeit.exception.BusinessException; ...@@ -7,6 +7,7 @@ import com.makeit.exception.BusinessException;
import com.makeit.global.annotation.Action; import com.makeit.global.annotation.Action;
import com.makeit.module.admin.vo.plat.PlatUserRoleMenuRedisVO; import com.makeit.module.admin.vo.plat.PlatUserRoleMenuRedisVO;
import com.makeit.utils.user.plat.PlatUserUtil; import com.makeit.utils.user.plat.PlatUserUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
...@@ -38,16 +39,18 @@ public class PlatAuthorizationInterceptor implements HandlerInterceptor { ...@@ -38,16 +39,18 @@ public class PlatAuthorizationInterceptor implements HandlerInterceptor {
} }
PlatUserRoleMenuRedisVO userLoginVO = PlatUserUtil.getTntUserRoleMenu(); PlatUserRoleMenuRedisVO userLoginVO = PlatUserUtil.getTntUserRoleMenu();
if (userLoginVO == null) {
// if (IsFactoryAccountEnum.YES.getValue().equals(userLoginVO.getIsFactory())) { return true;
// return true; }
// }
if (PlatUserUtil.isSuper()) { if (PlatUserUtil.isSuper()) {
return true; return true;
} }
Set<String> codeSet = new HashSet<>(userLoginVO.getButtonCodeList()); Set<String> codeSet = new HashSet<>();
if(userLoginVO!= null && CollectionUtils.isNotEmpty(userLoginVO.getButtonCodeList())) {
codeSet = new HashSet<>(userLoginVO.getButtonCodeList());
}
for (String e : annotation.code()) { for (String e : annotation.code()) {
if (codeSet.contains(e)) { if (codeSet.contains(e)) {
......
...@@ -7,6 +7,7 @@ import com.makeit.exception.BusinessException; ...@@ -7,6 +7,7 @@ import com.makeit.exception.BusinessException;
import com.makeit.global.annotation.Action; import com.makeit.global.annotation.Action;
import com.makeit.module.admin.vo.saas.SaasUserRoleMenuRedisVO; import com.makeit.module.admin.vo.saas.SaasUserRoleMenuRedisVO;
import com.makeit.utils.user.saas.SaasUserUtil; import com.makeit.utils.user.saas.SaasUserUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
...@@ -44,7 +45,11 @@ public class SaasAuthorizationInterceptor implements HandlerInterceptor { ...@@ -44,7 +45,11 @@ public class SaasAuthorizationInterceptor implements HandlerInterceptor {
return true; return true;
} }
Set<String> codeSet = new HashSet<>(userLoginVO.getButtonCodeList()); Set<String> codeSet = new HashSet<>();
if(userLoginVO!= null && CollectionUtils.isNotEmpty(userLoginVO.getButtonCodeList())) {
codeSet = new HashSet<>(userLoginVO.getButtonCodeList());
}
for (String e : annotation.code()) { for (String e : annotation.code()) {
if (codeSet.contains(e)) { if (codeSet.contains(e)) {
return true; return true;
......
...@@ -24,9 +24,6 @@ public class PlatMenuDTOVO extends BaseIdDTO { ...@@ -24,9 +24,6 @@ public class PlatMenuDTOVO extends BaseIdDTO {
@ApiModelProperty(value = "名称") @ApiModelProperty(value = "名称")
private String name; private String name;
//@ApiModelProperty(value = "模块+类名+方法")
//private String code;
@ApiModelProperty(value = "图标") @ApiModelProperty(value = "图标")
private String icon; private String icon;
...@@ -41,7 +38,7 @@ public class PlatMenuDTOVO extends BaseIdDTO { ...@@ -41,7 +38,7 @@ public class PlatMenuDTOVO extends BaseIdDTO {
@NotBlank(message = "类型不能为空") @NotBlank(message = "类型不能为空")
@Pattern(regexp = "1|2|3", message = "类型可选值 1目录 2菜单 3按钮") @Pattern(regexp = "1|2|3", message = "类型可选值 1目录 2菜单 3按钮")
@ApiModelProperty(value = "类型 1目录 2菜单 3按钮") @ApiModelProperty(value = "类型 1目录 2菜单 3按钮")
private String category; private String resourceType;
@ApiModelProperty(value = "前端路径") @ApiModelProperty(value = "前端路径")
private String requestPath; private String requestPath;
...@@ -60,7 +57,7 @@ public class PlatMenuDTOVO extends BaseIdDTO { ...@@ -60,7 +57,7 @@ public class PlatMenuDTOVO extends BaseIdDTO {
*/ */
@ApiModelProperty(value = "创建时间", required = false) @ApiModelProperty(value = "创建时间", required = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createdAt; private LocalDateTime createDate;
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty(value = "子集") @ApiModelProperty(value = "子集")
......
...@@ -29,10 +29,10 @@ public class PlatRoleDTOVO extends BaseOrgDTO implements Serializable { ...@@ -29,10 +29,10 @@ public class PlatRoleDTOVO extends BaseOrgDTO implements Serializable {
@ApiModelProperty(value = "编码") @ApiModelProperty(value = "编码")
private String code; private String code;
@NotBlank(message = "状态不能为空") // @NotBlank(message = "状态不能为空")
@Pattern(regexp = "0|1", message = "状态可选值为 0禁用 1启用") // @Pattern(regexp = "0|1", message = "状态可选值为 0禁用 1启用")
@ApiModelProperty(value = "状态 0禁用 1启用") // @ApiModelProperty(value = "状态 0禁用 1启用")
private String status; // private String status;
@Size(max = 512, message = "备注最长512字符") @Size(max = 512, message = "备注最长512字符")
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
......
...@@ -18,10 +18,10 @@ import java.util.List; ...@@ -18,10 +18,10 @@ import java.util.List;
@Data @Data
public class PlatUserDTOVO extends BaseIdDTO { public class PlatUserDTOVO extends BaseIdDTO {
// @NotBlank(message = "用户名不能为空") @NotBlank(message = "用户名不能为空")
// @Size(max = 64, message = "用户名最长为64字符") @Size(max = 64, message = "用户名最长为64字符")
// @ApiModelProperty(value = "用户名") @ApiModelProperty(value = "用户名")
// private String username; private String username;
@NotBlank(message = "名称不能为空") @NotBlank(message = "名称不能为空")
@Size(max = 64, message = "名称最长为64字符") @Size(max = 64, message = "名称最长为64字符")
...@@ -29,20 +29,11 @@ public class PlatUserDTOVO extends BaseIdDTO { ...@@ -29,20 +29,11 @@ public class PlatUserDTOVO extends BaseIdDTO {
@ApiModelProperty(value = "账户") @ApiModelProperty(value = "账户")
private String account; private String account;
//@NotBlank(message = "密码不能为空")
@Size(max = 32, message = "密码最长为64字符") @Size(max = 32, message = "密码最长为64字符")
@ApiModelProperty(value = "密码") @ApiModelProperty(value = "密码")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY) @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String password; private String password;
// @ApiModelProperty(value = "姓名")
// private String name;
@NotBlank(message = "姓名不能为空")
@Size(max = 64, message = "用户名最长为64字符")
@ApiModelProperty(value = "姓名")
private String name;
@NotBlank(message = "手机号不能为空") @NotBlank(message = "手机号不能为空")
@Pattern(regexp = "1[0-9]{10}", message = "手机号格式不对") @Pattern(regexp = "1[0-9]{10}", message = "手机号格式不对")
//@Size(max = 11, message = "手机号最长为64字符") //@Size(max = 11, message = "手机号最长为64字符")
...@@ -63,7 +54,7 @@ public class PlatUserDTOVO extends BaseIdDTO { ...@@ -63,7 +54,7 @@ public class PlatUserDTOVO extends BaseIdDTO {
*/ */
@ApiModelProperty(value = "创建时间", required = false) @ApiModelProperty(value = "创建时间", required = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createdAt; private LocalDateTime createDate;
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty(value = "角色集合") @ApiModelProperty(value = "角色集合")
......
...@@ -18,7 +18,7 @@ public class PlatUserLoginVO implements Serializable { ...@@ -18,7 +18,7 @@ public class PlatUserLoginVO implements Serializable {
private String account; private String account;
@ApiModelProperty("姓名") @ApiModelProperty("姓名")
private String name; private String username;
// @ApiModelProperty("用户名") // @ApiModelProperty("用户名")
// private String username; // private String username;
......
...@@ -297,7 +297,7 @@ public class TokenUtil { ...@@ -297,7 +297,7 @@ public class TokenUtil {
public static SaasUserRoleMenuRedisVO getPlatUserRoleMenu() { public static SaasUserRoleMenuRedisVO getPlatUserRoleMenu() {
String token = RequestUtil.getHeader(HeaderConst.PLATFORM_TOKEN); String token = RequestUtil.getHeader(HeaderConst.PLATFORM_TOKEN);
if (StringUtils.isNotBlank(token)) { if (StringUtils.isNotBlank(token)) {
SaasUserRoleMenuRedisVO userLoginVO = RedisUtil.get(RedisConst.PLATFORM_TOKEN_ROLE_MENU_PREFIX + token); SaasUserRoleMenuRedisVO userLoginVO = RedisTemplateUtil.get(RedisConst.PLATFORM_TOKEN_ROLE_MENU_PREFIX + token,SaasUserRoleMenuRedisVO.class);
return userLoginVO; return userLoginVO;
} }
return null; return null;
......
...@@ -16,7 +16,7 @@ public class CommonUserUtil { ...@@ -16,7 +16,7 @@ public class CommonUserUtil {
PlatUserLoginVO sysUserLoginVO = ThreadLocalUserUtil.getTntUser(); PlatUserLoginVO sysUserLoginVO = ThreadLocalUserUtil.getTntUser();
if (sysUserLoginVO != null) { if (sysUserLoginVO != null) {
return new CommonUserVO(sysUserLoginVO.getId(), sysUserLoginVO.getName()); return new CommonUserVO(sysUserLoginVO.getId(), sysUserLoginVO.getUsername());
} }
WechatUserInfo wechatUserInfo = ThreadLocalUserUtil.getWechatUser(); WechatUserInfo wechatUserInfo = ThreadLocalUserUtil.getWechatUser();
......
//package com.makeit.dto.platform.auth;
//
//import io.swagger.annotations.ApiModel;
//import io.swagger.annotations.ApiModelProperty;
//import lombok.Data;
//
//@ApiModel("租户端部门 查询")
//@Data
//public class TntDeptQueryDTO extends BaseDeptDTO {
//
// @ApiModelProperty(value = "名称")
// private String name;
//
// @ApiModelProperty(value = "状态 0禁用 1启用")
// private String status;
//
// @ApiModelProperty(value = "是否从酒店开始 0否 1是")
// private String fromHotel;
//
//}
package com.makeit.dto.platform.auth;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.module.admin.dto.plat.PlatRoleDTOVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.List;
@ApiModel("租户账号 新增 编辑 详情")
@Data
public class PlatPersonDTOVO extends BaseIdDTO {
// @NotBlank(message = "用户名不能为空")
// @Size(max = 64, message = "用户名最长为64字符")
// @ApiModelProperty(value = "用户名")
// private String username;
@NotBlank(message = "名称不能为空")
@Size(max = 64, message = "名称最长为64字符")
@Pattern(regexp = "[a-zA-Z0-9]{0,64}", message = "工号只能为大小写英文字符和数字")
@ApiModelProperty(value = "账户")
private String account;
//@NotBlank(message = "密码不能为空")
@Size(max = 32, message = "密码最长为64字符")
@ApiModelProperty(value = "密码")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String password;
// @ApiModelProperty(value = "姓名")
// private String name;
@NotBlank(message = "姓名不能为空")
@Size(max = 64, message = "用户名最长为64字符")
@ApiModelProperty(value = "姓名")
private String name;
@NotBlank(message = "手机号不能为空")
@Pattern(regexp = "1[0-9]{10}", message = "手机号格式不对")
//@Size(max = 11, message = "手机号最长为64字符")
@ApiModelProperty(value = "手机号")
private String mobile;
@NotBlank(message = "状态不能为空")
@Pattern(regexp = "0|1", message = "状态可选值为 0禁用 1启用")
@ApiModelProperty(value = "状态 0禁用 1启用")
private String status;
@NotBlank(message = "部门不能为空")
@ApiModelProperty(value = "部门树id")
private String deptId;
@ApiModelProperty(value = "分管部门id")
private String chargeDeptId;
@NotBlank(message = "性别不能为空")
@Pattern(regexp = "1|2", message = "性别可选值为 1男 2女")
@ApiModelProperty(value = "性别 1男 2女")
private String sex;
@ApiModelProperty(value = "职位")
private String post;
//@NotNull(message = "职级不能为空")
@ApiModelProperty(value = "职级")
private Integer postLevel;
@ApiModelProperty(value = "职级描述")
private String postLevelDesc;
@NotBlank(message = "类型不能为空")
@Pattern(regexp = "1|2", message = "类型可选值为 1默认 2自建")
@ApiModelProperty(value = "类型 1默认 2自建")
private String type;
@ApiModelProperty(value = "企业微信id")
private String wechatId;
@Size(max = 512, message = "备注最长512字符")
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "在职状态 0离职 1在职")
private String empStatus;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间", required = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createdAt;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间",required = false)
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime updatedAt;
@ApiModelProperty(value = "部门名称")
private String deptName;
@ApiModelProperty(value = "分管部门名称")
private String chargeDeptName;
@ApiModelProperty(value = "头像")
private String avatar;
@TableField(exist = false)
@ApiModelProperty(value = "角色集合")
private List<PlatRoleDTOVO> roleList;
@ApiModelProperty("是否常用 0否 1是")
private String isFrequent;
}
package com.makeit.dto.platform.auth;
import com.makeit.common.dto.BaseTenantDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("租户端角色分配管理权限")
public class PlatRoleDeptDTOVO extends BaseTenantDTO {
@ApiModelProperty(value = "角色id")
private String roleId;
// @ApiModelProperty(value = "部门树id")
// private String deptId;
//
// @ApiModelProperty(value = "部门树冗余id")
// private String hotelId;
@ApiModelProperty(value = "部门树id集合")
private List<String> deptIdList;
}
package com.makeit.dto.platform.auth;
import com.makeit.common.dto.BaseTenantDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@ApiModel("租户端角色分配菜单")
@Data
public class PlatRoleMenuDTO extends BaseTenantDTO implements Serializable {
// @ApiModelProperty(value = "菜单id")
// private String menuId;
@ApiModelProperty(value = "角色id")
private String roleId;
@ApiModelProperty(value = "菜单集合id")
private List<String> menuIdList;
}
package com.makeit.dto.platform.auth;
import lombok.Data;
import lombok.experimental.FieldNameConstants;
@FieldNameConstants
@Data
public class PlatUserCountVO {
//private String id;
private String deptId;
private Integer count;
}
package com.makeit.dto.platform.auth;
import com.makeit.common.dto.BaseTenantDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@ApiModel("租户端角色分配用户")
@Data
public class PlatUserRoleDTO extends BaseTenantDTO implements Serializable {
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "角色id")
private String roleId;
}
//package com.makeit.dto.platform.auth;
//
//import lombok.Data;
//
//@Data
//public class TntUserRoleImportDTO {
//
// @Excel(name = "用户工号")
// private String userAccount;
//
// @Excel(name = "角色名称")
// private String roleName;
//
//}
...@@ -20,7 +20,7 @@ public class PlatRole extends BaseBusEntity { ...@@ -20,7 +20,7 @@ public class PlatRole extends BaseBusEntity {
/** /**
* 名称 * 名称
*/ */
private String roleName; private String name;
/** /**
* 备注 * 备注
...@@ -31,4 +31,6 @@ public class PlatRole extends BaseBusEntity { ...@@ -31,4 +31,6 @@ public class PlatRole extends BaseBusEntity {
* 数据权限 子公司id 上级可看到下级 * 数据权限 子公司id 上级可看到下级
*/ */
private String dataScope; private String dataScope;
private String orgId;
} }
\ No newline at end of file
package com.makeit.entity.platform.auth; package com.makeit.entity.platform.auth;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.makeit.common.entity.BaseBusEntity; import com.makeit.common.entity.BaseBusEntity;
...@@ -32,4 +33,7 @@ public class PlatRoleMenu extends BaseBusEntity { ...@@ -32,4 +33,7 @@ public class PlatRoleMenu extends BaseBusEntity {
* 菜单id * 菜单id
*/ */
private String menuId; private String menuId;
@TableField(exist = false)
private String menuName;
} }
\ No newline at end of file
...@@ -2,7 +2,18 @@ package com.makeit.service.platform.auth; ...@@ -2,7 +2,18 @@ package com.makeit.service.platform.auth;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.common.dto.StatusDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.auth.PlatRoleDeptDTOVO;
import com.makeit.dto.platform.auth.PlatRoleMenuDTO;
import com.makeit.dto.platform.auth.PlatUserRoleDTO;
import com.makeit.entity.platform.auth.PlatRole; import com.makeit.entity.platform.auth.PlatRole;
import com.makeit.entity.platform.auth.PlatRoleMenu;
import com.makeit.entity.platform.auth.PlatRoleOrg;
import com.makeit.module.admin.dto.plat.PlatRoleDTOVO;
import java.util.List;
/** /**
* @author lixl * @author lixl
...@@ -10,5 +21,53 @@ import com.makeit.entity.platform.auth.PlatRole; ...@@ -10,5 +21,53 @@ import com.makeit.entity.platform.auth.PlatRole;
* @createDate 2023-08-30 20:10:25 * @createDate 2023-08-30 20:10:25
*/ */
public interface PlatRoleService extends IService<PlatRole> { public interface PlatRoleService extends IService<PlatRole> {
List<PlatRoleDTOVO> list(PlatRoleDTOVO dto);
PageVO<PlatRoleDTOVO> page(PageReqDTO<PlatRoleDTOVO> page);
void add(PlatRoleDTOVO dto);
void edit(PlatRoleDTOVO dto);
PlatRoleDTOVO view(String id);
void del(String id);
void changeStatus(StatusDTO dto);
void assignUserList(List<PlatUserRoleDTO> userRoleDTOList);
void removeAssignUserList(List<PlatUserRoleDTO> userRoleDTOList);
// void exportTemplate(HttpServletResponse response);
//
// ExcelImportVo importExcel(String deptId, String hotelId, MultipartFile excelFile) throws Exception;
void assignMenuList(PlatRoleMenuDTO roleMenuDTO);
List<PlatRoleMenu> getAssignMenuList(String id);
// void assignWechatMenuList(PlatRoleMenuDTO roleMenuDTO);
// List<PlatRoleWechatMenu> getWechatMenuListByRoleId(String roleId);
void assignDeptList(PlatRoleDeptDTOVO tntRoleDeptDTO);
List<PlatRoleOrg> getDeptListByRoleId(String roleId);
void copyRole(String roleId);
/**
* Lzy
*
* @param dto
* @return
*/
List<PlatRoleDTOVO> getList(PlatRoleDTOVO dto);
} }
...@@ -90,9 +90,9 @@ public interface PlatUserService extends IService<PlatUser> { ...@@ -90,9 +90,9 @@ public interface PlatUserService extends IService<PlatUser> {
//void leaveMessage(PlatUser tntUser); //void leaveMessage(PlatUser tntUser);
// List<PlatRole> getRoleListWithTag(String userId); List<PlatRole> getRoleListWithTag(String userId);
// PlatRole getMaxRole(String userId); PlatRole getMaxRole(String userId);
List<PlatOrg> getDeptTreeList(); List<PlatOrg> getDeptTreeList();
...@@ -110,7 +110,7 @@ public interface PlatUserService extends IService<PlatUser> { ...@@ -110,7 +110,7 @@ public interface PlatUserService extends IService<PlatUser> {
List<PlatOrg> getDeptSelfAndChildrenCanTap(String deptId); List<PlatOrg> getDeptSelfAndChildrenCanTap(String deptId);
// List<PlatOrg> getHotelList(String deptId); List<PlatOrg> getHotelList(String deptId);
List<PlatOrg> getCandidateDeptList(); List<PlatOrg> getCandidateDeptList();
...@@ -130,4 +130,11 @@ public interface PlatUserService extends IService<PlatUser> { ...@@ -130,4 +130,11 @@ public interface PlatUserService extends IService<PlatUser> {
PageVO<PlatPersonDTOVO> indexPage(PageReqDTO<PlatUserQueryDTO> page); PageVO<PlatPersonDTOVO> indexPage(PageReqDTO<PlatUserQueryDTO> page);
List<PlatOrg> getDeptList(); List<PlatOrg> getDeptList();
/**
* 更新用户的tenantId
* @param tenantId
* @param platUserId
*/
void updatePlatUserTenantId(String tenantId,String platUserId);
} }
...@@ -87,15 +87,15 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg> ...@@ -87,15 +87,15 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
// e.setCanTap(CommonEnum.YES.getValue()); // e.setCanTap(CommonEnum.YES.getValue());
}); });
List<PlatOrg> tntDeptList = this.getDeptSelfAndChildren(dto.getDeptId()); List<PlatOrg> tntDeptList = this.getDeptSelfAndChildren(dto.getOrgId());
// if (CommonEnum.YES.getValue().equals(dto.getFromHotel())) { // if (CommonEnum.YES.getValue().equals(dto.getFromHotel())) {
// tntDeptList = StreamUtil.filter(tntDeptList, e -> DeptEnum.DeptTagEnum.HOTEL.getValue().equals(e.getTag())); // tntDeptList = StreamUtil.filter(tntDeptList, e -> DeptEnum.DeptTagEnum.HOTEL.getValue().equals(e.getTag()));
// } // }
List<String> idList = StreamUtil.map(tntDeptList, PlatOrg::getId); List<String> idList = StreamUtil.map(tntDeptList, PlatOrg::getId);
if (StringUtils.isNotBlank(dto.getDeptId())) {//左上方可点击的 和 左下方中的任意 if (StringUtils.isNotBlank(dto.getOrgId())) {//左上方可点击的 和 左下方中的任意
idList.add(dto.getDeptId()); idList.add(dto.getOrgId());
} }
tntDeptList.addAll(deptList); tntDeptList.addAll(deptList);
......
package com.makeit.service.platform.auth.impl; package com.makeit.server.platform.auth.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.common.dto.StatusDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.auth.PlatRoleDeptDTOVO;
import com.makeit.dto.platform.auth.PlatRoleMenuDTO;
import com.makeit.dto.platform.auth.PlatUserRoleDTO;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatRole; import com.makeit.entity.platform.auth.PlatRole;
import com.makeit.entity.platform.auth.PlatRoleMenu;
import com.makeit.entity.platform.auth.PlatRoleOrg;
import com.makeit.entity.platform.auth.PlatUserRole;
import com.makeit.entity.saas.PlatMenu;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.IsTenantAccountEnum;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.auth.PlatRoleMapper; import com.makeit.mapper.platform.auth.PlatRoleMapper;
import com.makeit.module.admin.dto.plat.PlatRoleDTOVO;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.auth.PlatRoleMenuService;
import com.makeit.service.platform.auth.PlatRoleOrgService;
import com.makeit.service.platform.auth.PlatRoleService; import com.makeit.service.platform.auth.PlatRoleService;
import com.makeit.service.platform.auth.PlatUserRoleService;
import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.service.saas.PlatMenuService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.sql.WrapperUtil;
import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.utils.user.plat.PlatUserUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/** /**
* @author lixl * @author lixl
...@@ -13,6 +52,506 @@ import org.springframework.stereotype.Service; ...@@ -13,6 +52,506 @@ import org.springframework.stereotype.Service;
*/ */
@Service @Service
public class PlatRoleServiceImpl extends ServiceImpl<PlatRoleMapper, PlatRole> public class PlatRoleServiceImpl extends ServiceImpl<PlatRoleMapper, PlatRole>
implements PlatRoleService{ implements PlatRoleService {
@Autowired
private PlatUserService tntUserService;
@Autowired
private PlatUserRoleService tntUserRoleService;
@Autowired
private PlatRoleMenuService tntRoleMenuService;
@Autowired
private PlatMenuService tntMenuService;
// @Autowired
// private PlatRoleWechatMenuService tntRoleWechatMenuService;
@Autowired
private PlatRoleOrgService tntRoleDeptService;
@Autowired
private PlatOrgService tntDeptService;
private LambdaQueryWrapper<PlatRole> listWrapper(PlatRoleDTOVO dto) {
return new QueryWrapper<PlatRole>().lambda()
.like(StringUtils.isNotBlank(dto.getName()), PlatRole::getName, dto.getName())
.in(dto.getNameList() != null, PlatRole::getName, dto.getNameList())
.and(StringUtils.isNotBlank(dto.getKeyword()), qw -> {
qw.like(StringUtils.isNotBlank(dto.getKeyword()), PlatRole::getName, dto.getKeyword())
.or()
.like(StringUtils.isNotBlank(dto.getKeyword()), PlatRole::getName, dto.getKeyword());
})
.eq(StringUtils.isNotBlank(dto.getOrgId()), PlatRole::getOrgId, dto.getOrgId())
.orderByDesc(PlatRole::getCreateDate);
}
@Override
public List<PlatRoleDTOVO> list(PlatRoleDTOVO dto) {
List<PlatRole> tntRoleList = list(listWrapper(dto));
List<PlatRoleDTOVO> rolVOList = BeanDtoVoUtils.listVo(tntRoleList, PlatRoleDTOVO.class);
JoinUtil.join(rolVOList, tntDeptService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> {
r.setDeptName(e.getName());
});
return BeanDtoVoUtils.listVo(tntRoleList, PlatRoleDTOVO.class);
}
@Override
public PageVO<PlatRoleDTOVO> page(PageReqDTO<PlatRoleDTOVO> page) {
PlatRoleDTOVO dto = page.getData();
Page<PlatRole> p = PageUtil.toMpPage(page);
Page<PlatRole> pageList = page(p, listWrapper(dto));
List<PlatRoleDTOVO> tntUserVOList = BeanDtoVoUtils.listVo(pageList.getRecords(), PlatRoleDTOVO.class);
JoinUtil.join(tntUserVOList, tntDeptService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> {
r.setDeptName(e.getName());
});
return PageUtil.toPageVO(tntUserVOList, pageList);
}
private void check(PlatRoleDTOVO dto) {
if (checkLevel(dto)) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_ROLE_ADMIN_CANT_ADD);
}
PlatRole old = WrapperUtil.getOne(this, new QueryWrapper<PlatRole>().lambda()
.eq(PlatRole::getOrgId, dto.getOrgId())
.eq(PlatRole::getName, dto.getName()));
if (old != null && !old.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_NAME_DUPLICATE);
}
old = WrapperUtil.getOne(this, new QueryWrapper<PlatRole>().lambda()
.eq(PlatRole::getOrgId, dto.getOrgId()))
;
if (old != null && !old.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_CODE_DUPLICATE);
}
}
private boolean checkLevel(PlatRoleDTOVO dto) {
if (!IsTenantAccountEnum.YES.getValue().equals(PlatUserUtil.getUserVO().getIsTenant())) {
PlatRole tntRole = tntUserService.getMaxRole(PlatUserUtil.getUserId());
//todo 2023年9月4日
// PlatDept tntDept = tntDeptService.getById(dto.getOrgId());
// if (DeptEnum.tagLevelMap.get(tntDept.getTag()).compareTo(DeptEnum.tagLevelMap.get(tntRole.getTag())) < 0
// ||
// (
// DeptEnum.tagLevelMap.get(tntDept.getTag()).compareTo(DeptEnum.tagLevelMap.get(tntRole.getTag())) == 0
// && !CommonEnum.NO.getValue().equals(dto.getIsAdmin())
// )
// ) {
// return true;
// }
}
return false;
}
private void adminRoleCantDo(String roleId) {
if (checkLevel(BeanDtoVoUtils.convert(getById(roleId), PlatRoleDTOVO.class))) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_ROLE_ADMIN_CANT_EDIT);
}
}
@Transactional
@Override
public void add(PlatRoleDTOVO dto) {
check(dto);
save(BeanDtoVoUtils.convert(dto, PlatRole.class));
}
@Transactional
@Override
public void edit(PlatRoleDTOVO dto) {
adminRoleCantDo(dto.getId());
check(dto);
updateById(BeanDtoVoUtils.convert(dto, PlatRole.class));
}
@Override
public PlatRoleDTOVO view(String id) {
PlatRoleDTOVO vo = BeanDtoVoUtils.convert(getById(id), PlatRoleDTOVO.class);
JoinUtil.join(Arrays.asList(vo), tntDeptService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> {
r.setDeptName(e.getName());
});
return vo;
}
@Transactional
@Override
public void del(String id) {
adminRoleCantDo(id);
removeById(id);
}
@Transactional
@Override
public void changeStatus(StatusDTO dto) {
adminRoleCantDo(dto.getId());
if (Arrays.stream(CommonEnum.values()).noneMatch(e -> e.getValue().equals(dto.getStatus()))) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR);
}
PlatRole role = getById(dto.getId());
updateById(role);
}
@Transactional
@Override
public void assignUserList(List<PlatUserRoleDTO> userRoleDTOList) {//目前只给一个角色 分配人人员使用
removeAssignUserList(userRoleDTOList);
List<PlatUserRole> userRoleList = BeanDtoVoUtils.listVo(userRoleDTOList, PlatUserRole.class);
tntUserRoleService.saveBatch(userRoleList);
}
@Transactional
@Override
public void removeAssignUserList(List<PlatUserRoleDTO> userRoleDTOList) {
Map<String, List<PlatUserRoleDTO>> roleUserMap = StreamUtil.groupBy(userRoleDTOList, PlatUserRoleDTO::getRoleId);
roleUserMap.forEach((k, v) -> {
adminRoleCantDo(k);
List<String> userIdList = StreamUtil.map(v, PlatUserRoleDTO::getUserId);
userIdList.add(-1 + "");
tntUserRoleService.remove(new QueryWrapper<PlatUserRole>().lambda()
.eq(PlatUserRole::getRoleId, k)
.in(PlatUserRole::getUserId, userIdList));
});
}
// @Override
// public void exportTemplate(HttpServletResponse response) {
// ExcelUtil.exportTemplate(response, "用户角色关联.xls", "用户角色关联\n以英文逗号分割多个角色名称", PlatUserRoleImportDTO.class);
// }
// @Override
// public ExcelImportVo importExcel(String deptId, String hotelId, MultipartFile excelFile) throws Exception{
// return ExcelUtil.importExcel(deptId, excelFile, PlatUserRoleImportDTO.class, c -> {
//
// List<PlatUserRoleImportDTO> l = c.getList();
//
// List<ExcelErrorVo> excelErrorVoList = new ArrayList<>(10);
//
// List<String> accountList = new ArrayList<>(10);
//
// List<String> roleNameList = new ArrayList<>(10);
//
// Map<String, Set<Integer>> userAccountIndexMap = new HashMap<>(16);
// for (int i = 0; i < l.size(); i++) {
// PlatUserRoleImportDTO userRoleImportDTO = l.get(i);
//
// userAccountIndexMap.computeIfAbsent(userRoleImportDTO.getUserAccount(), k -> new HashSet<>(10)).add(i + 1);
//
// accountList.add(userRoleImportDTO.getUserAccount());
//
// roleNameList.addAll(Arrays.asList(userRoleImportDTO.getRoleName().split(",")));
// }
//
// accountList.add(-1 + "");
//
// PlatUserQueryDTO userQueryDTO = new PlatUserQueryDTO();
// userQueryDTO.setOrgId(deptId);
// userQueryDTO.setAccountList(accountList);
// List<PlatPersonDTOVO> userList = tntUserService.list(userQueryDTO);
// Map<String, PlatPersonDTOVO> userMap = StreamUtil.toMap(userList, PlatPersonDTOVO::getAccount);
//
// roleNameList = StreamUtil.filter(roleNameList, StringUtils::isNotBlank);
// roleNameList.add(-1 + "");
//
// PlatRoleDTOVO tntRoleDTOVO = new PlatRoleDTOVO();
// tntRoleDTOVO.setOrgId(deptId);
// tntRoleDTOVO.setNameList(roleNameList);
// List<PlatRoleDTOVO> roleList = list(tntRoleDTOVO);
//
// Map<String, PlatRoleDTOVO> roleMap = StreamUtil.toMap(roleList, PlatRoleDTOVO::getName);
//
// int start = 3;
//
// int successCount = 0;
//
// for (int i = 0; i < l.size(); i++) {
// PlatUserRoleImportDTO userRoleImportDTO = l.get(i);
//
// boolean isImport = true;
//
// if (StringUtils.isBlank(userRoleImportDTO.getUserAccount())) {
// excelErrorVoList.add(new ExcelErrorVo(i + start, "用户工号", "用户工号为空"));
// isImport = false;
// } else {
//
// Set<Integer> set = userAccountIndexMap.get(userRoleImportDTO.getUserAccount());
// if (set.size() != 1) {
// excelErrorVoList.add(new ExcelErrorVo(i + start, "用户工号", "导入的数据存在重复的用户工号"));
// isImport = false;
// }
//
// PlatPersonDTOVO p = userMap.get(userRoleImportDTO.getUserAccount());
// if (p == null) {
// excelErrorVoList.add(new ExcelErrorVo(i + start, "用户工号", "数据库不存在该工号的用户"));
// isImport = false;
// }
// }
//
// if (StringUtils.isBlank(userRoleImportDTO.getRoleName())) {
// excelErrorVoList.add(new ExcelErrorVo(i + start, "角色名称", "角色名称为空"));
// isImport = false;
// } else {
// List<String> rList = StreamUtil.filter(Arrays.asList(userRoleImportDTO.getRoleName().split(",")), StringUtils::isNotBlank);
// Set<String> rSet = new HashSet<>(rList);
// if (rSet.size() < rList.size()) {
// excelErrorVoList.add(new ExcelErrorVo(i + start, "角色名称", "角色名称存在重复值"));
// isImport = false;
// }
//
// for (String e : rSet) {
// PlatRoleDTOVO r = roleMap.get(e);
// if (r == null) {
// excelErrorVoList.add(new ExcelErrorVo(i + start, "角色名称", e + "数据库不存在"));
// isImport = false;
// }
// }
// }
//
// if (isImport) {
// successCount++;
// }
//
// }
//
// if (excelErrorVoList.size() == 0) {
// List<PlatUserRole> userRoleList = new ArrayList<>(10);
//
// List<String> userIdList = new ArrayList<>(10);
// l.forEach(e -> {
// PlatPersonDTOVO p = userMap.get(e.getUserAccount());
//
// userIdList.add(p.getId());
//
// List<String> rList = StreamUtil.filter(Arrays.asList(e.getRoleName().split(",")), StringUtils::isNotBlank);
// List<PlatRoleDTOVO> r = StreamUtil.map(rList, roleMap::get);
// userRoleList.addAll(StreamUtil.map(r, rr -> {
// PlatUserRole tntUserRole = new PlatUserRole();
// tntUserRole.setUserId(p.getId());
// tntUserRole.setRoleId(rr.getId());
//
// return tntUserRole;
// }));
// });
//
// tntUserRoleService.remove(new QueryWrapper<PlatUserRole>().lambda()
// .in(PlatUserRole::getUserId, userIdList));
//
// tntUserRoleService.saveBatch(userRoleList);
// }
//
// //return excelErrorVoList;
//
// ExcelImportVo excelImportVo = new ExcelImportVo();
// excelImportVo.setTotalCount(l.size());
// excelImportVo.setErrorCount(excelErrorVoList.size());
// //excelImportVo.setSuccessCount(list.size() - excelErrorVoList.size());
// excelImportVo.setSuccessCount(successCount);
// excelImportVo.setList(excelErrorVoList);
//
// return excelImportVo;
//
//
// }, c -> {
//
// });
// }
@Transactional
@Override
public void assignMenuList(PlatRoleMenuDTO roleMenuDTO) {
//removeAssignMenuList(roleMenuDTOList);
adminRoleCantDo(roleMenuDTO.getRoleId());
tntRoleMenuService.remove(new QueryWrapper<PlatRoleMenu>().lambda()
.eq(PlatRoleMenu::getRoleId, roleMenuDTO.getRoleId()));
List<PlatRoleMenu> roleMenuList = StreamUtil.map(roleMenuDTO.getMenuIdList(), e -> {
PlatRoleMenu tntRoleMenu = new PlatRoleMenu();
tntRoleMenu.setRoleId(roleMenuDTO.getRoleId());
tntRoleMenu.setMenuId(e);
tntRoleMenu.setTenantId(roleMenuDTO.getTenantId());
return tntRoleMenu;
});
tntRoleMenuService.saveBatch(roleMenuList);
}
@Override
public List<PlatRoleMenu> getAssignMenuList(String id) {
List<PlatRoleMenu> roleMenuList = tntRoleMenuService.list(new QueryWrapper<PlatRoleMenu>().lambda()
.eq(PlatRoleMenu::getRoleId, id));
List<String> menuIdList = StreamUtil.map(roleMenuList, PlatRoleMenu::getMenuId);
menuIdList.add(-1 + "");
List<PlatMenu> menuList = tntMenuService.list(new QueryWrapper<PlatMenu>().lambda()
.in(PlatMenu::getId, menuIdList));
Map<String, PlatMenu> menuMap = StreamUtil.toMap(menuList, PlatMenu::getId);
List<PlatRoleMenu> newList = new ArrayList<>(10);
roleMenuList.forEach(e -> {
PlatMenu menu = menuMap.get(e.getMenuId());
if (menu != null) {
e.setMenuName(menu.getName());
newList.add(e);
}
});
return newList;
}
// @Transactional
// @Override
// public void assignWechatMenuList(PlatRoleMenuDTO roleMenuDTO) {
// //removeAssignWechatMenuList(roleMenuDTOList);
//
// adminRoleCantDo(roleMenuDTO.getRoleId());
//
// tntRoleWechatMenuService.remove(new QueryWrapper<PlatRoleWechatMenu>().lambda()
// .eq(PlatRoleWechatMenu::getRoleId, roleMenuDTO.getRoleId()));
//
// List<PlatRoleWechatMenu> roleMenuList = StreamUtil.map(roleMenuDTO.getMenuIdList(), e -> {
// PlatRoleWechatMenu tntRoleMenu = new PlatRoleWechatMenu();
// tntRoleMenu.setRoleId(roleMenuDTO.getRoleId());
// tntRoleMenu.setMenuId(e);
// tntRoleMenu.setTenantId(roleMenuDTO.getTenantId());
//
// return tntRoleMenu;
// });
//
// tntRoleWechatMenuService.saveBatch(roleMenuList);
// }
// @Override
// public List<PlatRoleWechatMenu> getWechatMenuListByRoleId(String roleId) {
// List<PlatRoleWechatMenu> roleWechatMenuList = tntRoleWechatMenuService.list(new QueryWrapper<PlatRoleWechatMenu>().lambda()
// .eq(PlatRoleWechatMenu::getRoleId, roleId));
// return roleWechatMenuList;
// }
@Transactional
@Override
public void assignDeptList(PlatRoleDeptDTOVO tntRoleDeptDTO) {
//removeAssignDeptList(roleDeptDTOList);
adminRoleCantDo(tntRoleDeptDTO.getRoleId());
tntRoleDeptService.remove(new QueryWrapper<PlatRoleOrg>().lambda()
.eq(PlatRoleOrg::getRoleId, tntRoleDeptDTO.getRoleId()));
List<PlatRoleOrg> roleMenuList = StreamUtil.map(tntRoleDeptDTO.getDeptIdList(), e -> {
PlatRoleOrg tntRoleDept = new PlatRoleOrg();
tntRoleDept.setRoleId(tntRoleDeptDTO.getRoleId());
tntRoleDept.setOrgId(e);
tntRoleDept.setTenantId(tntRoleDeptDTO.getTenantId());
return tntRoleDept;
});
tntRoleDeptService.saveBatch(roleMenuList);
}
@Override
public List<PlatRoleOrg> getDeptListByRoleId(String roleId) {
List<PlatRoleOrg> roleDeptList = tntRoleDeptService.list(new QueryWrapper<PlatRoleOrg>().lambda()
.eq(PlatRoleOrg::getRoleId, roleId));
return roleDeptList;
}
public static String getNewName(String name) {
return name + "_1";
}
@Override
public void copyRole(String roleId) {
PlatRole tntRole = getById(roleId);
PlatRole newRole = BeanDtoVoUtils.convert(tntRole, PlatRole.class);
newRole.setName(getNewName(tntRole.getName()));
newRole.setId(null);
// newRole.setIsAdmin(CommonEnum.NO.getValue());
save(newRole);
List<PlatUserRole> userRoleList = tntUserRoleService.list(new QueryWrapper<PlatUserRole>().lambda()
.eq(PlatUserRole::getRoleId, roleId));
List<PlatUserRole> userRoleListNew = BeanDtoVoUtils.listVo(userRoleList, PlatUserRole.class);
userRoleListNew.forEach(e -> {
e.setId(null);
e.setRoleId(newRole.getId());
});
tntUserRoleService.saveBatch(userRoleListNew);
List<PlatRoleMenu> roleMenuList = tntRoleMenuService.list(new QueryWrapper<PlatRoleMenu>().lambda()
.eq(PlatRoleMenu::getRoleId, roleId));
List<PlatRoleMenu> roleMenuListNew = BeanDtoVoUtils.listVo(roleMenuList, PlatRoleMenu.class);
roleMenuListNew.forEach(e -> {
e.setId(null);
e.setRoleId(newRole.getId());
});
tntRoleMenuService.saveBatch(roleMenuListNew);
// List<PlatRoleWechatMenu> wechatMenuList = tntRoleWechatMenuService.list(new QueryWrapper<PlatRoleWechatMenu>().lambda()
// .eq(PlatRoleWechatMenu::getRoleId, roleId));
// wechatMenuList.forEach(e -> {
// e.setId(null);
// e.setRoleId(newRole.getId());
// });
// tntRoleWechatMenuService.saveBatch(wechatMenuList);
List<PlatRoleOrg> roleDeptList = tntRoleDeptService.list(new QueryWrapper<PlatRoleOrg>().lambda()
.eq(PlatRoleOrg::getRoleId, roleId));
roleDeptList.forEach(e -> {
e.setId(null);
e.setRoleId(newRole.getId());
});
tntRoleDeptService.saveBatch(roleDeptList);
}
@Override
public List<PlatRoleDTOVO> getList(PlatRoleDTOVO dto) {
LambdaQueryWrapper<PlatRole> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StringUtils.isNotBlank(dto.getName()), PlatRole::getName, dto.getName());
queryWrapper.eq(StringUtils.isNotBlank(dto.getOrgId()), PlatRole::getOrgId, dto.getOrgId());
List<PlatRole> platRoleList = list(queryWrapper);
List<PlatRoleDTOVO> rolVOList = BeanDtoVoUtils.listVo(platRoleList, PlatRoleDTOVO.class);
JoinUtil.join(rolVOList, tntDeptService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> {
r.setDeptName(e.getName());
});
return BeanDtoVoUtils.listVo(platRoleList, PlatRoleDTOVO.class);
}
} }
...@@ -2,12 +2,15 @@ package com.makeit.service.platform.auth.impl; ...@@ -2,12 +2,15 @@ package com.makeit.service.platform.auth.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.makeit.common.dto.LoginDTO; import com.makeit.common.dto.LoginDTO;
import com.makeit.common.dto.StatusDTO; import com.makeit.common.dto.StatusDTO;
import com.makeit.common.entity.BaseBusEntity; import com.makeit.common.entity.BaseBusEntity;
import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO; import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO; import com.makeit.common.page.PageVO;
import com.makeit.entity.platform.auth.PlatOrg; import com.makeit.entity.platform.auth.PlatOrg;
...@@ -80,13 +83,13 @@ import java.util.function.Consumer; ...@@ -80,13 +83,13 @@ import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* @author lixl * @author lixl
* @description 针对表【plat_user(租户账号管理)】的数据库操作Service实现 * @description 针对表【plat_user(租户账号管理)】的数据库操作Service实现
* @createDate 2023-08-30 20:10:25 * @createDate 2023-08-30 20:10:25
*/ */
@Service @Service
public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser> public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
implements PlatUserService{ implements PlatUserService {
@Autowired @Autowired
private PlatTenantService platTenantService; private PlatTenantService platTenantService;
...@@ -670,43 +673,26 @@ implements PlatUserService{ ...@@ -670,43 +673,26 @@ implements PlatUserService{
private LambdaQueryWrapper<PlatUser> listLambdaQueryWrapper(PlatUserQueryDTO dto) { private LambdaQueryWrapper<PlatUser> listLambdaQueryWrapper(PlatUserQueryDTO dto) {
//TODO 用标签查人可能慢
List<String> labelUserIdList = new ArrayList<>(10);
labelUserIdList.add(-1 + "");
// if (StringUtils.isNotBlank(dto.getLabelId())) {
// labelUserIdList.addAll(
// StreamUtil.map(
// tntUserLabelService.list(new QueryWrapper<PlatUserLabel>().lambda()
// .eq(PlatUserLabel::getLabelId, dto.getLabelId())
// .eq(PlatUserLabel::getStatus, LabelEnum.LabelUserStatusEnum.EFFECT.getValue())
// ),
// PlatUserLabel::getPlatUserId)
// );
// }
LambdaQueryWrapper<PlatUser> lambdaQueryWrapper = new QueryWrapper<PlatUser>().lambda() LambdaQueryWrapper<PlatUser> lambdaQueryWrapper = new QueryWrapper<PlatUser>().lambda()
.eq(PlatUser::getIsTenant, IsTenantAccountEnum.NO.getValue()) .eq(PlatUser::getIsTenant, IsTenantAccountEnum.NO.getValue())
.like(StringUtils.isNotBlank(dto.getAccount()), PlatUser::getAccount, dto.getAccount()) .like(StringUtils.isNotBlank(dto.getAccount()), PlatUser::getAccount, dto.getAccount())
.in(dto.getAccountList() != null, PlatUser::getAccount, dto.getAccountList()) .in(CollectionUtils.isNotEmpty(dto.getAccountList()), PlatUser::getAccount, dto.getAccountList())
.like(StringUtils.isNotBlank(dto.getName()), PlatUser::getUsername, dto.getName()) .like(StringUtils.isNotBlank(dto.getName()), PlatUser::getUsername, dto.getName())
.in(dto.getNameList() != null, PlatUser::getUsername, dto.getName()) .in(CollectionUtils.isNotEmpty(dto.getNameList()), PlatUser::getUsername, dto.getName())
.like(StringUtils.isNotBlank(dto.getMobile()), PlatUser::getMobile, dto.getMobile()) .like(StringUtils.isNotBlank(dto.getMobile()), PlatUser::getMobile, dto.getMobile())
.eq(StringUtils.isNotBlank(dto.getStatus()), PlatUser::getStatus, dto.getStatus()) .eq(StringUtils.isNotBlank(dto.getStatus()), PlatUser::getStatus, dto.getStatus())
.in(StringUtils.isNotBlank(dto.getLabelId()), PlatUser::getId, labelUserIdList)
.eq(PlatUser::getTenantId, TenantIdUtil.getTenantId()) .eq(PlatUser::getTenantId, TenantIdUtil.getTenantId())
.and(StringUtils.isNotBlank(dto.getKeyword()), qw -> { .and(StringUtils.isNotBlank(dto.getKeyword()), qw -> {
qw.like(StringUtils.isNotBlank(dto.getKeyword()), PlatUser::getUsername, dto.getKeyword()) qw.like(StringUtils.isNotBlank(dto.getKeyword()), PlatUser::getUsername, dto.getKeyword())
.or() .or()
.like(StringUtils.isNotBlank(dto.getKeyword()), PlatUser::getAccount, dto.getKeyword()); .like(StringUtils.isNotBlank(dto.getKeyword()), PlatUser::getAccount, dto.getKeyword());
}) });
//.in(PlatUser::getOrgId, DeptUtil.getDeptCantTapIdList(dto.getDeptId(), dto.getFromHotel()))
;
roleIdFilter(lambdaQueryWrapper, dto); roleIdFilter(lambdaQueryWrapper, dto);
roleIdList(lambdaQueryWrapper, dto); roleIdList(lambdaQueryWrapper, dto);
if (dto.getDeptIdList() != null) { if (CollectionUtils.isNotEmpty(dto.getDeptIdList())) {
dto.getDeptIdList().add(-1 + ""); dto.getDeptIdList().add(-1 + "");
lambdaQueryWrapper.in(PlatUser::getOrgId, dto.getDeptIdList()); lambdaQueryWrapper.in(PlatUser::getOrgId, dto.getDeptIdList());
} }
...@@ -723,10 +709,6 @@ implements PlatUserService{ ...@@ -723,10 +709,6 @@ implements PlatUserService{
p.setDeptName(d.getName()); p.setDeptName(d.getName());
}); });
JoinUtil.joinSplit(tntUserDTOVOList, platOrgService, null, PlatPersonDTOVO::getChargeDeptId, PlatOrg::getId, (p, d) -> {
p.setChargeDeptName(d.stream().map(PlatOrg::getName).collect(Collectors.joining(",")));
});
} }
@Override @Override
...@@ -815,7 +797,7 @@ implements PlatUserService{ ...@@ -815,7 +797,7 @@ implements PlatUserService{
} }
private void roleIdList(LambdaQueryWrapper<PlatUser> lambdaQueryWrapper, PlatUserQueryDTO dto) { private void roleIdList(LambdaQueryWrapper<PlatUser> lambdaQueryWrapper, PlatUserQueryDTO dto) {
if (dto.getRoleIdList() != null) { if (CollectionUtils.isNotEmpty(dto.getRoleIdList())) {
dto.getRoleIdList().add(-1 + ""); dto.getRoleIdList().add(-1 + "");
List<String> idList = new ArrayList<>(); List<String> idList = new ArrayList<>();
...@@ -848,7 +830,7 @@ implements PlatUserService{ ...@@ -848,7 +830,7 @@ implements PlatUserService{
lambdaQueryWrapper.and(qw -> { lambdaQueryWrapper.and(qw -> {
qw.in(dto.getDeptIdList() != null, PlatUser::getOrgId, dto.getDeptIdList()) qw.in(dto.getDeptIdList() != null, PlatUser::getOrgId, dto.getDeptIdList())
.or(StringUtils.isNotBlank(dto.getChargeDeptId())) .or(StringUtils.isNotBlank(dto.getChargeDeptId()))
//.like(StringUtils.isNotBlank(dto.getChargeDeptId()), PlatUser::getChargeDeptId, dto.getChargeDeptId()) //.like(StringUtils.isNotBlank(dto.getChargeDeptId()), PlatUser::getChargeDeptId, dto.getChargeDeptId())
; ;
}); });
} }
...@@ -1012,38 +994,39 @@ implements PlatUserService{ ...@@ -1012,38 +994,39 @@ implements PlatUserService{
// //
// } // }
// @Override @Override
// public List<PlatRole> getRoleListWithTag(String userId) { public List<PlatRole> getRoleListWithTag(String userId) {
//
// List<PlatRole> roleList = getRoleList(userId);
//
// List<String> deptIdList = StreamUtil.map(roleList, TntRole::getDeptId);
//
// List<PlatOrg> deptList = platOrgService.list(new QueryWrapper<PlatOrg>().lambda()
// .in(PlatOrg::getId, deptIdList)
// .eq(PlatOrg::getStatus, CommonEnum.YES.getValue())
// );
//
// Map<String, PlatOrg> deptMap = StreamUtil.toMap(deptList, PlatOrg::getId);
//// roleList.forEach(e -> {
//// PlatOrg dept = deptMap.get(e.PlatOrg());
//// if (dept != null) {
//// e.setTag(dept.getTag());
//// }
//// });
//
// return roleList;
// }
// @Override List<PlatRole> roleList = getRoleList(userId);
// public TntRole getMaxRole(String userId) {
// List<TntRole> roleList = getRoleListWithTag(userId); List<String> deptIdList = StreamUtil.map(roleList, PlatRole::getOrgId);
// if (roleList.isEmpty()) {
// return null; List<PlatOrg> deptList = platOrgService.list(new QueryWrapper<PlatOrg>().lambda()
// } .in(PlatOrg::getId, deptIdList)
// TntRole tntRole = Collections.min(roleList, Comparator.comparing(o -> DeptEnum.tagLevelMap.get(o.getTag()))); .eq(PlatOrg::getStatus, CommonEnum.YES.getValue())
// return tntRole; );
// }
Map<String, PlatOrg> deptMap = StreamUtil.toMap(deptList, PlatOrg::getId);
// roleList.forEach(e -> {
// PlatOrg dept = deptMap.get(e.PlatOrg());
// if (dept != null) {
// e.setTag(dept.getTag());
// }
// });
return roleList;
}
@Override
public PlatRole getMaxRole(String userId) {
List<PlatRole> roleList = getRoleListWithTag(userId);
if (roleList.isEmpty()) {
return null;
}
//todo 2023年9月4日
//PlatRole tntRole = Collections.min(roleList, Comparator.comparing(o -> DeptEnum.tagLevelMap.get(o.getTag())));
return roleList.get(0);
}
@Override @Override
public List<PlatOrg> getDeptList() { public List<PlatOrg> getDeptList() {
...@@ -1110,7 +1093,6 @@ implements PlatUserService{ ...@@ -1110,7 +1093,6 @@ implements PlatUserService{
} }
@Override @Override
public List<PlatOrg> getDeptSelfAndChildrenByDeptName(List<String> deptNames, Map<String, PlatOrg> selfAndChildren) { public List<PlatOrg> getDeptSelfAndChildrenByDeptName(List<String> deptNames, Map<String, PlatOrg> selfAndChildren) {
if (CollectionUtils.isEmpty(deptNames)) { if (CollectionUtils.isEmpty(deptNames)) {
...@@ -1154,34 +1136,34 @@ implements PlatUserService{ ...@@ -1154,34 +1136,34 @@ implements PlatUserService{
return platOrgService.getDeptSelfAndChildren(deptId); return platOrgService.getDeptSelfAndChildren(deptId);
} }
// @Override @Override
// public List<PlatOrg> getHotelList(String deptId) {//新增编辑角色 那边的管理范围 //不包含自己 public List<PlatOrg> getHotelList(String deptId) {//新增编辑角色 那边的管理范围 //不包含自己
// List<PlatOrg> newList = getDeptList(); List<PlatOrg> newList = getDeptList();
// if (StringUtils.isBlank(deptId)) { if (StringUtils.isBlank(deptId)) {
// return StreamUtil.filter(newList, e -> DeptEnum.DeptTagEnum.HOTEL.getValue().equals(e.getTag())); return newList;
// //return newList; //return newList;
// } else { } else {
// List<PlatOrg> treeList = platOrgService.tree(newList); List<PlatOrg> treeList = platOrgService.tree(newList);
//
// List<PlatOrg> matchList = StreamUtil.filter(newList, e -> e.getId().equals(deptId)); List<PlatOrg> matchList = StreamUtil.filter(newList, e -> e.getId().equals(deptId));
// if (matchList.isEmpty()) { if (matchList.isEmpty()) {
// return new ArrayList<>(10); return new ArrayList<>(10);
// } }
//
// List<PlatOrg> deptList = new ArrayList<>(10); List<PlatOrg> deptList = new ArrayList<>(10);
//
// if (DeptEnum.DeptTagEnum.HOTEL.getValue().equals(matchList.get(0).getTag())) { // if (DeptEnum.DeptTagEnum.HOTEL.getValue().equals(matchList.get(0).getTag())) {
// deptList.add(matchList.get(0)); // deptList.add(matchList.get(0));
// } // }
//
// platOrgService.flat(matchList.get(0).getChildren(), deptList); platOrgService.flat(matchList.get(0).getChildren(), matchList);
// deptList.forEach(e -> { deptList.forEach(e -> {
// e.setChildren(null); e.setChildren(null);
// }); });
// return StreamUtil.filter(deptList, e -> DeptEnum.DeptTagEnum.HOTEL.getValue().equals(e.getTag())); //return StreamUtil.filter(deptList, e -> DeptEnum.DeptTagEnum.HOTEL.getValue().equals(e.getTag()));
// //return deptList; return matchList;
// } }
// } }
@Override @Override
public List<PlatOrg> getCandidateDeptList() {//新增编辑角色 那边的管理范围 //不包含自己 public List<PlatOrg> getCandidateDeptList() {//新增编辑角色 那边的管理范围 //不包含自己
...@@ -1231,4 +1213,19 @@ implements PlatUserService{ ...@@ -1231,4 +1213,19 @@ implements PlatUserService{
fillDept(tntUserDTOVOList); fillDept(tntUserDTOVOList);
return PageUtil.toPageVO(tntUserDTOVOList, pageList); return PageUtil.toPageVO(tntUserDTOVOList, pageList);
} }
/**
* 更新用户的tenantId
*
* @param tenantId
* @param platUserId
*/
@Transactional
public void updatePlatUserTenantId(String tenantId, String platUserId) {
LambdaUpdateWrapper<PlatUser> updateWrapper = Wrappers.lambdaUpdate(PlatUser.class)
.set(PlatUser::getTenantId, tenantId)
.eq(BaseEntity::getId, platUserId);
this.update(updateWrapper);
}
} }
...@@ -29,5 +29,5 @@ public interface PlatMenuService extends IService<PlatMenu> { ...@@ -29,5 +29,5 @@ public interface PlatMenuService extends IService<PlatMenu> {
void sync(); void sync();
List<PlatMenu> loadMenuCodeLis(); List<PlatMenu> loadMenuCodeList();
} }
...@@ -235,7 +235,7 @@ implements PlatMenuService { ...@@ -235,7 +235,7 @@ implements PlatMenuService {
} }
@Override @Override
public List<PlatMenu> loadMenuCodeLis() { public List<PlatMenu> loadMenuCodeList() {
List<PlatMenu> list = StreamUtil.filter(this.load(), e -> TreeConst.TOP_LEVEL.equals(e.getParentId())); List<PlatMenu> list = StreamUtil.filter(this.load(), e -> TreeConst.TOP_LEVEL.equals(e.getParentId()));
return list; return list;
} }
...@@ -250,7 +250,7 @@ implements PlatMenuService { ...@@ -250,7 +250,7 @@ implements PlatMenuService {
//插入匹配过滤条件 //插入匹配过滤条件
provider.addIncludeFilter(new RegexPatternTypeFilter(Pattern.compile(".*Controller"))); provider.addIncludeFilter(new RegexPatternTypeFilter(Pattern.compile(".*Controller")));
final Set<BeanDefinition> classes = provider.findCandidateComponents("com.makeit.controller.tenant"); final Set<BeanDefinition> classes = provider.findCandidateComponents("com.makeit.controller.plat");
//从bean中加载数据 //从bean中加载数据
for (BeanDefinition bean : classes) { for (BeanDefinition bean : classes) {
......
...@@ -31,7 +31,6 @@ import com.makeit.utils.data.convert.BeanDtoVoUtils; ...@@ -31,7 +31,6 @@ import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil; import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil; import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.redis.RedisCacheUtil; import com.makeit.utils.redis.RedisCacheUtil;
import com.makeit.utils.redis.ScheduleLockUtil;
import com.makeit.utils.user.plat.PlatUserUtil; import com.makeit.utils.user.plat.PlatUserUtil;
import com.makeit.utils.user.plat.PlatUserVO; import com.makeit.utils.user.plat.PlatUserVO;
import com.makeit.utils.user.plat.TntUserJoinUtil; import com.makeit.utils.user.plat.TntUserJoinUtil;
...@@ -190,10 +189,12 @@ implements PlatTenantService { ...@@ -190,10 +189,12 @@ implements PlatTenantService {
PlatTenant tntTenant = BeanDtoVoUtils.convert(dto, PlatTenant.class); PlatTenant tntTenant = BeanDtoVoUtils.convert(dto, PlatTenant.class);
save(tntTenant); save(tntTenant);
dto.setId(tntTenant.getId()); dto.setId(tntTenant.getId());
//setMenuList(dto);
sysConfigService.copyForTenant(dto); sysConfigService.copyForTenant(dto);
//更新用户的tenantId
platUserService.updatePlatUserTenantId(tntTenant.getId(),dto.getPlatUserId());
return tntTenant.getId(); return tntTenant.getId();
} }
...@@ -203,8 +204,14 @@ implements PlatTenantService { ...@@ -203,8 +204,14 @@ implements PlatTenantService {
checkName(dto); checkName(dto);
checkDate(dto); checkDate(dto);
PlatTenant tntTenant = BeanDtoVoUtils.convert(dto, PlatTenant.class); PlatTenant tntTenant = BeanDtoVoUtils.convert(dto, PlatTenant.class);
PlatTenant platTenant = getById(tntTenant.getId());
updateById(tntTenant); updateById(tntTenant);
//setMenuList(dto);
//更新用户的tenantId
if(!StringUtils.equals(dto.getPlatUserId(),platTenant.getPlatUserId())) {
platUserService.updatePlatUserTenantId(null, dto.getPlatUserId());
}
platUserService.updatePlatUserTenantId(tntTenant.getId(),dto.getPlatUserId());
saasOperationLogService.add("平台端-租户账号-编辑", dto.getId()); saasOperationLogService.add("平台端-租户账号-编辑", dto.getId());
...@@ -216,7 +223,7 @@ implements PlatTenantService { ...@@ -216,7 +223,7 @@ implements PlatTenantService {
TntUserJoinUtil.join(platUserService,Arrays.asList(userVO), PlatTenantDTOVO::getPlatUserId,(t,u)->t.setPlatUserVO(BeanDtoVoUtils.convert(u,PlatUserVO.class)) ,PlatUser::getId); TntUserJoinUtil.join(platUserService,Arrays.asList(userVO), PlatTenantDTOVO::getPlatUserId,(t,u)->t.setPlatUserVO(BeanDtoVoUtils.convert(u,PlatUserVO.class)) ,PlatUser::getId);
//platOperationLogService.add("平台端-租户账号-详情", id); saasOperationLogService.add("平台端-租户账号-详情", id);
return userVO; return userVO;
} }
...@@ -261,9 +268,9 @@ implements PlatTenantService { ...@@ -261,9 +268,9 @@ implements PlatTenantService {
@Override @Override
public void changeStatusJob() { public void changeStatusJob() {
if (!ScheduleLockUtil.lockWithLog("TntTenantServiceImpl:changeStatusJob")) { // if (!ScheduleLockUtil.lockWithLog("TntTenantServiceImpl:changeStatusJob")) {
return; // return;
} // }
List<PlatTenant> tntTenantList = list(new QueryWrapper<PlatTenant>().lambda() List<PlatTenant> tntTenantList = list(new QueryWrapper<PlatTenant>().lambda()
.lt(PlatTenant::getEndTime, LocalDate.now()) .lt(PlatTenant::getEndTime, LocalDate.now())
......
...@@ -67,11 +67,11 @@ implements SaasRoleService{ ...@@ -67,11 +67,11 @@ implements SaasRoleService{
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_NAME_DUPLICATE); throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_NAME_DUPLICATE);
} }
old = getOne(new QueryWrapper<SaasRole>().lambda() // old = getOne(new QueryWrapper<SaasRole>().lambda()
.eq(SaasRole::getCode, dto.getCode())); // .eq(SaasRole::getName, dto.getName()));
if (old != null && !old.getId().equals(dto.getId())) { // if (old != null && !old.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_CODE_DUPLICATE); // throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_CODE_DUPLICATE);
} // }
} }
@Transactional @Transactional
......
...@@ -19,10 +19,10 @@ import java.util.List; ...@@ -19,10 +19,10 @@ import java.util.List;
@Data @Data
public class PlatPersonDTOVO extends BaseIdDTO { public class PlatPersonDTOVO extends BaseIdDTO {
// @NotBlank(message = "用户名不能为空") @NotBlank(message = "用户名不能为空")
// @Size(max = 64, message = "用户名最长为64字符") @Size(max = 64, message = "用户名最长为64字符")
// @ApiModelProperty(value = "用户名") @ApiModelProperty(value = "用户名")
// private String username; private String username;
@NotBlank(message = "名称不能为空") @NotBlank(message = "名称不能为空")
@Size(max = 64, message = "名称最长为64字符") @Size(max = 64, message = "名称最长为64字符")
...@@ -30,23 +30,13 @@ public class PlatPersonDTOVO extends BaseIdDTO { ...@@ -30,23 +30,13 @@ public class PlatPersonDTOVO extends BaseIdDTO {
@ApiModelProperty(value = "账户") @ApiModelProperty(value = "账户")
private String account; private String account;
//@NotBlank(message = "密码不能为空")
@Size(max = 32, message = "密码最长为64字符") @Size(max = 32, message = "密码最长为64字符")
@ApiModelProperty(value = "密码") @ApiModelProperty(value = "密码")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY) @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String password; private String password;
// @ApiModelProperty(value = "姓名")
// private String name;
@NotBlank(message = "姓名不能为空")
@Size(max = 64, message = "用户名最长为64字符")
@ApiModelProperty(value = "姓名")
private String name;
@NotBlank(message = "手机号不能为空") @NotBlank(message = "手机号不能为空")
@Pattern(regexp = "1[0-9]{10}", message = "手机号格式不对") @Pattern(regexp = "1[0-9]{10}", message = "手机号格式不对")
//@Size(max = 11, message = "手机号最长为64字符")
@ApiModelProperty(value = "手机号") @ApiModelProperty(value = "手机号")
private String mobile; private String mobile;
...@@ -55,69 +45,31 @@ public class PlatPersonDTOVO extends BaseIdDTO { ...@@ -55,69 +45,31 @@ public class PlatPersonDTOVO extends BaseIdDTO {
@ApiModelProperty(value = "状态 0禁用 1启用") @ApiModelProperty(value = "状态 0禁用 1启用")
private String status; private String status;
@NotBlank(message = "部门不能为空")
@ApiModelProperty(value = "部门树id") @ApiModelProperty(value = "部门树id")
private String deptId; private String deptId;
@ApiModelProperty(value = "分管部门id")
private String chargeDeptId;
@NotBlank(message = "性别不能为空")
@Pattern(regexp = "1|2", message = "性别可选值为 1男 2女")
@ApiModelProperty(value = "性别 1男 2女")
private String sex;
@ApiModelProperty(value = "职位")
private String post;
//@NotNull(message = "职级不能为空")
@ApiModelProperty(value = "职级")
private Integer postLevel;
@ApiModelProperty(value = "职级描述")
private String postLevelDesc;
@NotBlank(message = "类型不能为空")
@Pattern(regexp = "1|2", message = "类型可选值为 1默认 2自建")
@ApiModelProperty(value = "类型 1默认 2自建")
private String type;
@ApiModelProperty(value = "企业微信id")
private String wechatId;
@Size(max = 512, message = "备注最长512字符") @Size(max = 512, message = "备注最长512字符")
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String remark; private String remark;
@ApiModelProperty(value = "在职状态 0离职 1在职")
private String empStatus;
/** /**
* 创建时间 * 创建时间
*/ */
@ApiModelProperty(value = "创建时间", required = false) @ApiModelProperty(value = "创建时间", required = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createdAt; private LocalDateTime createDate;
/** /**
* 更新时间 * 更新时间
*/ */
@ApiModelProperty(value = "更新时间",required = false) @ApiModelProperty(value = "更新时间",required = false)
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime updatedAt; private LocalDateTime updateDate;
@ApiModelProperty(value = "部门名称") @ApiModelProperty(value = "部门名称")
private String deptName; private String deptName;
@ApiModelProperty(value = "分管部门名称")
private String chargeDeptName;
@ApiModelProperty(value = "头像") @ApiModelProperty(value = "头像")
private String avatar; private String avatar;
...@@ -125,7 +77,4 @@ public class PlatPersonDTOVO extends BaseIdDTO { ...@@ -125,7 +77,4 @@ public class PlatPersonDTOVO extends BaseIdDTO {
@ApiModelProperty(value = "角色集合") @ApiModelProperty(value = "角色集合")
private List<PlatRoleDTOVO> roleList; private List<PlatRoleDTOVO> roleList;
@ApiModelProperty("是否常用 0否 1是")
private String isFrequent;
} }
...@@ -110,11 +110,11 @@ sa-token: ...@@ -110,11 +110,11 @@ sa-token:
interceptor: interceptor:
## 登录拦截路径 ## 登录拦截路径
authenticationTntPath: /** authenticationTntPath: /**
authenticationTntPathIgnore: /swagger-resources/**,/v2/api-docs/**,/sys/login/**,/sys/dictionaryCategory/getDictionaryCategoryByList,/mobile/**,/doc.html,/saas/**,/error authenticationTntPathIgnore: /swagger-resources/**,/v2/api-docs/**,/plat/login/**,/sys/dictionaryCategory/getDictionaryCategoryByList,/mobile/**,/doc.html,/saas/**,/error
## 权限拦截路径 ## 权限拦截路径
authorizationTntPath: /** authorizationTntPath: /**
authorizationTntPathIgnore: /swagger-resources/**,/v2/api-docs/**,/sys/login/**,/sys/dictionaryCategory/getDictionaryCategoryByList,/mobile/**,/doc.html,/saas/**,/error authorizationTntPathIgnore: /swagger-resources/**,/v2/api-docs/**,/plat/login/**,/sys/dictionaryCategory/getDictionaryCategoryByList,/mobile/**,/doc.html,/saas/**,/error
## saas端登录拦截路径 ## saas端登录拦截路径
authenticationSaasPath: /saas/** authenticationSaasPath: /saas/**
...@@ -133,27 +133,18 @@ tenant: ...@@ -133,27 +133,18 @@ tenant:
table: table:
prefix: prefix:
- sys_ - sys_
- esop_ - plat_
- base_
- fixture_
- mat_
# - wflow_model # - wflow_model
# - wflow_record # - wflow_record
ignore: ignore:
- sys_file - sys_file
- sys_dictionary - sys_dictionary
- sys_dictionary_category - sys_dictionary_category
- sys_auth_dept
- sys_factory
- sys_auth_menu
- sys_auth_role
- sys_auth_role_menu
- sys_auth_role_user
- sys_auth_role_factory
- sys_auth_user
- wflow_model_perms
- sys_config_category - sys_config_category
- sys_config - sys_config
- plat_tenant
- plat_tenant_menu
- plat_user
rsa: rsa:
......
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 sign in to comment