Commit 7bfcd65c by 李小龙

组织角色

parent 88b6ee64
Showing with 574 additions and 359 deletions
......@@ -53,7 +53,7 @@ public class SwaggerSaasConfig {
Docket docket = new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("03-平台端");
.groupName("03-平台端-人员管理");
ApiSelectorBuilder builder = docket.select();
//api过滤
builder = builder.apis(
......
......@@ -29,7 +29,7 @@ public class PlatLoginController {
@ApiOperation("退出登录")
@PostMapping("logout")
public ApiResponseEntity<?> logout() {
public ApiResponseEntity<Void> logout() {
platUserService.logout();
return ApiResponseUtils.success();
}
......
package com.makeit.controller.plat;
import com.makeit.common.dto.BaseIdDTO;
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.entity.platform.auth.PlatOrg;
import com.makeit.global.annotation.Action;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.vo.platform.auth.PlatOrgQueryDTO;
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/org")
public class PlatOrgController {
@Autowired
private PlatOrgService platOrgService;
@Autowired
private PlatUserService platUserService;
@Action(module = "平台端-组织", name = "分页列表", code = "plat:org:page")
@ApiOperation("树形列表")
@PostMapping("page")
public ApiResponseEntity<PageVO<PlatOrg>> page(@RequestBody PageReqDTO<PlatOrgQueryDTO> pageReqDTO){
return ApiResponseUtils.success(platOrgService.page(pageReqDTO));
}
@Action(module = "平台端-组织", name = "不分页列表", code = "plat:org:list")
@ApiOperation("树形列表")
@PostMapping("list")
public ApiResponseEntity<List<PlatOrg>> list(@RequestBody PlatOrgQueryDTO platOrgQueryDTO){
return ApiResponseUtils.success(platOrgService.subOrgList(platOrgQueryDTO));
}
@Action(module = "平台端-组织", name = "树形列表", code = "plat:org:tree")
@ApiOperation("树形列表")
@PostMapping("tree")
public ApiResponseEntity<List<PlatOrg>> tree(@RequestBody PlatOrgQueryDTO tntDept){
return ApiResponseUtils.success(platOrgService.tree(tntDept));
}
@ApiOperation("树形列表(AuthIgnore)")
@PostMapping("treeAuthIgnore")
public ApiResponseEntity<List<PlatOrg>> treeAuthIgnore(@RequestBody PlatOrgQueryDTO tntDept){
return ApiResponseUtils.success(platOrgService.tree(tntDept));
}
@Action(module = "平台端-组织", name = "新增", code = "plat:org:add")
@ApiOperation("新增")
@PostMapping("add")
public ApiResponseEntity<String> add(@Validated @RequestBody PlatOrg tntDept){
return ApiResponseUtils.success(platOrgService.add(tntDept));
}
@Action(module = "平台端-组织", name = "编辑", code = "plat:org:edit")
@ApiOperation("编辑")
@PostMapping("edit")
public ApiResponseEntity<Void> edit(@Validated @RequestBody PlatOrg tntDept){
platOrgService.edit(tntDept);
return ApiResponseUtils.success();
}
@Action(module = "平台端-组织", name = "详情", code = "plat:org:view")
@ApiOperation("详情")
@PostMapping("view")
public ApiResponseEntity<PlatOrg> view(@RequestBody BaseIdDTO baseIdDTO){
return ApiResponseUtils.success(platOrgService.view(baseIdDTO.getId()));
}
@Action(module = "平台端-组织", name = "删除", code = "plat:org:del")
@ApiOperation("删除")
@PostMapping("del")
public ApiResponseEntity<PlatOrg> del(@RequestBody BaseIdDTO baseIdDTO){
platOrgService.del(baseIdDTO.getId());
return ApiResponseUtils.success();
}
@ApiOperation("左上方组织树")
@PostMapping("deptTree")
public ApiResponseEntity<List<PlatOrg>> tree(){
return ApiResponseUtils.success(platUserService.getDeptTreeList());
}
@ApiOperation("当前账号的权限级别树")
@PostMapping("belongToScopeTree")
public ApiResponseEntity<List<PlatOrg>> belongToScopeTree(@RequestBody BaseIdDTO baseIdDTO){
return ApiResponseUtils.success(platOrgService.belongToOrgTree());
}
@ApiOperation("启用|禁用")
@PostMapping("enable")
public ApiResponseEntity<Void> enable(@RequestBody PlatOrg param){
platOrgService.enable(param);
return ApiResponseUtils.success();
}
}
......@@ -11,6 +11,8 @@ 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.PlatOrg;
import com.makeit.entity.platform.auth.PlatRole;
import com.makeit.entity.platform.auth.PlatRoleMenu;
import com.makeit.entity.platform.auth.PlatRoleOrg;
import com.makeit.global.annotation.Action;
......@@ -76,15 +78,14 @@ public class PlatRoleController {
@Action(module = "平台端-角色", name = "新增", code = "tnt:role:add")
@ApiOperation("新增")
@PostMapping("add")
public ApiResponseEntity<?> add(@Validated @RequestBody PlatRoleDTOVO dto) {
platRoleService.add(dto);
return ApiResponseUtils.success();
public ApiResponseEntity<String> add(@Validated @RequestBody PlatRoleDTOVO dto) {
return ApiResponseUtils.success(platRoleService.add(dto));
}
@Action(module = "平台端-角色", name = "编辑", code = "tnt:role:edit")
@ApiOperation("编辑")
@PostMapping("edit")
public ApiResponseEntity<?> edit(@Validated @RequestBody PlatRoleDTOVO dto) {
public ApiResponseEntity<Void> edit(@Validated @RequestBody PlatRoleDTOVO dto) {
platRoleService.edit(dto);
return ApiResponseUtils.success();
}
......@@ -99,7 +100,7 @@ public class PlatRoleController {
@Action(module = "平台端-角色", name = "删除", code = "tnt:role:del")
@ApiOperation("删除")
@PostMapping("del")
public ApiResponseEntity<?> del(@RequestBody BaseIdDTO dto) {
public ApiResponseEntity<Void> del(@RequestBody BaseIdDTO dto) {
platRoleService.del(dto.getId());
return ApiResponseUtils.success();
}
......@@ -107,7 +108,7 @@ public class PlatRoleController {
@Action(module = "平台端-角色", name = "改变状态", code = "tnt:role:changeStatus")
@ApiOperation("改变状态")
@PostMapping("changeStatus")
public ApiResponseEntity<?> changeStatus(@RequestBody StatusDTO dto) {
public ApiResponseEntity<Void> changeStatus(@RequestBody StatusDTO dto) {
platRoleService.changeStatus(dto);
return ApiResponseUtils.success();
}
......@@ -115,7 +116,7 @@ public class PlatRoleController {
@Action(module = "平台端-角色", name = "分配用户", code = "tnt:role:assignUserList")
@ApiOperation("分配用户")
@PostMapping("assignUserList")
public ApiResponseEntity<?> assignUserList(@RequestBody List<PlatUserRoleDTO> userRoleDTOList) {//参数要不要是一个对象里 有一个数组
public ApiResponseEntity<Void> assignUserList(@RequestBody List<PlatUserRoleDTO> userRoleDTOList) {//参数要不要是一个对象里 有一个数组
platRoleService.assignUserList(userRoleDTOList);
return ApiResponseUtils.success();
}
......@@ -123,7 +124,7 @@ public class PlatRoleController {
@Action(module = "平台端-角色", name = "删除分配用户", code = "tnt:role:removeAssignUserList")
@ApiOperation("删除分配用户")
@PostMapping("removeAssignUserList")
public ApiResponseEntity<?> removeAssignUserList(@RequestBody List<PlatUserRoleDTO> userRoleDTOList) {
public ApiResponseEntity<Void> removeAssignUserList(@RequestBody List<PlatUserRoleDTO> userRoleDTOList) {
platRoleService.removeAssignUserList(userRoleDTOList);
return ApiResponseUtils.success();
}
......@@ -131,7 +132,7 @@ public class PlatRoleController {
@Action(module = "平台端-角色", name = "分配菜单", code = "tnt:role:assignMenuList")
@ApiOperation("分配菜单")
@PostMapping("assignMenuList")
public ApiResponseEntity<?> assignMenuList(@RequestBody PlatRoleMenuDTO roleMenuDTO) {
public ApiResponseEntity<Void> assignMenuList(@RequestBody PlatRoleMenuDTO roleMenuDTO) {
platRoleService.assignMenuList(roleMenuDTO);
return ApiResponseUtils.success();
}
......@@ -143,38 +144,22 @@ public class PlatRoleController {
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) {
public ApiResponseEntity<List<PlatOrg>> getCandidateDeptList(@RequestBody BaseOrgDTO deptDTO) {
return ApiResponseUtils.success(platUserService.getHotelList(deptDTO.getOrgId()));
}
@ApiOperation("管理范围可选值2")
@PostMapping("getCandidateDeptList2")
public ApiResponseEntity<?> getCandidateDeptList2(@RequestBody BaseOrgDTO deptDTO) {
public ApiResponseEntity<List<PlatOrg>> 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) {
public ApiResponseEntity<Void> assignDeptList(@RequestBody PlatRoleDeptDTOVO roleDeptDTO) {
platRoleService.assignDeptList(roleDeptDTO);
return ApiResponseUtils.success();
}
......@@ -189,7 +174,7 @@ public class PlatRoleController {
@Action(module = "平台端-角色", name = "复制角色及关联", code = "tnt:role:copyRole")
@ApiOperation("复制角色及关联")
@PostMapping("copyRole")
public ApiResponseEntity<?> copyRole(@RequestBody BaseIdDTO baseIdDTO) {
public ApiResponseEntity<Void> copyRole(@RequestBody BaseIdDTO baseIdDTO) {
platRoleService.copyRole(baseIdDTO.getId());
return ApiResponseUtils.success();
}
......@@ -200,20 +185,12 @@ public class PlatRoleController {
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));
// }
@ApiOperation("人员管理-角色")
@PostMapping("belongTo")
public ApiResponseEntity<List<PlatRole>> belongTo(@Validated @RequestBody BaseIdDTO baseIdDTO) {
List<PlatRole> list = platRoleService.belongTo(baseIdDTO);
return ApiResponseUtils.success(list);
}
}
......@@ -10,6 +10,7 @@ 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.module.admin.vo.plat.PlatUserLoginVO;
import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.vo.platform.auth.PlatPersonDTOVO;
import io.swagger.annotations.Api;
......@@ -75,15 +76,14 @@ public class PlatUserController {
@Action(module = "平台端-人员", name = "新增", code = "plat:user:add")
@ApiOperation("新增")
@PostMapping("add")
public ApiResponseEntity<?> add(@Validated @RequestBody PlatPersonDTOVO dto) {
platUserService.addPerson(dto);
return ApiResponseUtils.success();
public ApiResponseEntity<String> add(@Validated @RequestBody PlatPersonDTOVO dto) {
return ApiResponseUtils.success(platUserService.addPerson(dto));
}
@Action(module = "平台端-人员", name = "编辑", code = "plat:user:edit")
@ApiOperation("编辑")
@PostMapping("edit")
public ApiResponseEntity<?> edit(@Validated @RequestBody PlatPersonDTOVO dto) {
public ApiResponseEntity<Void> edit(@Validated @RequestBody PlatPersonDTOVO dto) {
platUserService.editPerson(dto);
return ApiResponseUtils.success();
}
......@@ -91,7 +91,7 @@ public class PlatUserController {
@Action(module = "平台端-人员", name = "改变密码", code = "plat:user:changePassword")
@ApiOperation("改变密码")
@PostMapping("changePassword")
public ApiResponseEntity<?> changePassword(@RequestBody PlatUserDTOVO dto) {
public ApiResponseEntity<Void> changePassword(@RequestBody PlatUserDTOVO dto) {
platUserService.changePassword(dto);
return ApiResponseUtils.success();
}
......@@ -106,7 +106,7 @@ public class PlatUserController {
@Action(module = "平台端-人员", name = "删除", code = "plat:user:del")
@ApiOperation("删除")
@PostMapping("del")
public ApiResponseEntity<?> del(@RequestBody BaseIdDTO dto) {
public ApiResponseEntity<Void> del(@RequestBody BaseIdDTO dto) {
platUserService.del(dto.getId());
return ApiResponseUtils.success();
}
......@@ -114,41 +114,34 @@ public class PlatUserController {
@Action(module = "平台端-人员", name = "改变状态", code = "plat:user:changeStatus")
@ApiOperation("改变状态")
@PostMapping("changeStatus")
public ApiResponseEntity<?> changeStatus(@RequestBody StatusDTO dto) {
public ApiResponseEntity<Void> changeStatus(@RequestBody StatusDTO dto) {
platUserService.changeStatus(dto);
return ApiResponseUtils.success();
}
// @ApiOperation("获取当前登录用户角色菜单")
// @PostMapping("getRoleMenu")
// public ApiResponseEntity<PlatUserLoginVO> getRoleAndMenuList() {
// return ApiResponseUtils.success(platUserService.getRoleAndMenuList());
// }
//
// @ApiOperation("获取当前登录用户角色菜单2")
// @PostMapping("getRoleMenu2")
// public ApiResponseEntity<PlatUserLoginVO> getRoleAndMenuList2() {
// return ApiResponseUtils.success(platUserService.getRoleAndMenuList2());
// }
// //@Action(module = "平台端-人员", name = "获取当前登录用户企业微信菜单", code = "tnt:user:getWechatMenuList")
// @ApiOperation("获取当前登录用户企业微信菜单")
// @PostMapping("getWechatMenuList")
// public ApiResponseEntity<PlatUserLoginVO> getWechatMenuList() {
// return ApiResponseUtils.success(platUserService.getWechatMenuList());
// }
// @ApiOperation("获取当前登录用户信息")
// @PostMapping("getUserVO")
// public ApiResponseEntity<PlatUserLoginVO> getUserInfo() {
// return ApiResponseUtils.success(platUserService.getUserVO());
// }
//
// @ApiOperation("获取当前登录用户详细信息")
// @PostMapping("getUserDetail")
// public ApiResponseEntity<PlatPersonDTOVO> getUserDetail() {
// return ApiResponseUtils.success(platUserService.getUserDetail());
// }
@ApiOperation("获取当前登录用户角色菜单")
@PostMapping("getRoleMenu")
public ApiResponseEntity<PlatUserLoginVO> getRoleAndMenuList() {
return ApiResponseUtils.success(platUserService.getRoleAndMenuList());
}
@ApiOperation("获取当前登录用户角色菜单2")
@PostMapping("getRoleMenu2")
public ApiResponseEntity<PlatUserLoginVO> getRoleAndMenuList2() {
return ApiResponseUtils.success(platUserService.getRoleAndMenuList2());
}
@ApiOperation("获取当前登录用户信息")
@PostMapping("getUserVO")
public ApiResponseEntity<PlatUserLoginVO> getUserInfo() {
return ApiResponseUtils.success(platUserService.getUserVO());
}
@ApiOperation("获取当前登录用户详细信息")
@PostMapping("getUserDetail")
public ApiResponseEntity<PlatPersonDTOVO> getUserDetail() {
return ApiResponseUtils.success(platUserService.getUserDetail());
}
}
......@@ -18,4 +18,7 @@ public class BaseOrgDTO extends BaseTenantDTO implements Serializable {
@ApiModelProperty(value = "部门树冗余 id")
private String path;
@ApiModelProperty(value = "父级id")
private String parentId;
}
package com.makeit.module.admin.dto.plat;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.makeit.common.dto.BaseOrgDTO;
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.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
@ApiModel("租户端角色 列表 新增 编辑 详情")
......@@ -23,33 +20,9 @@ public class PlatRoleDTOVO extends BaseOrgDTO implements Serializable {
@ApiModelProperty(value = "名称")
private String name;
@NotBlank(message = "编码不能为空")
@Size(max = 64, message = "编码最长为64字符")
@Pattern(regexp = "[a-zA-Z0-9]{0,64}", message = "编码只能为大小写英文字符和数字")
@ApiModelProperty(value = "编码")
private String code;
// @NotBlank(message = "状态不能为空")
// @Pattern(regexp = "0|1", message = "状态可选值为 0禁用 1启用")
// @ApiModelProperty(value = "状态 0禁用 1启用")
// private String status;
@Size(max = 512, message = "备注最长512字符")
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "是否管理员角色 0否 1是")
private String isAdmin;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间", required = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createdAt;
@ApiModelProperty(value = "关键词 查询用")
private String keyword;
@TableField(exist = false)
@ApiModelProperty(value = "部门名称")
......
......@@ -18,10 +18,7 @@ public class PlatUserQueryDTO extends BaseOrgDTO {
private String account;
@ApiModelProperty(value = "姓名")
private String name;
// @ApiModelProperty(value = "姓名")
// private String username;
private String username;
@ApiModelProperty(value = "手机号")
private String mobile;
......@@ -63,9 +60,6 @@ public class PlatUserQueryDTO extends BaseOrgDTO {
private List<String> roleIdList;
@ApiModelProperty(value = "部门id集合")
private List<String> deptIdList;
@ApiModelProperty("分管部门树id")
private String chargeDeptId;
private List<String> orgIdList;
}
......@@ -21,12 +21,6 @@ public class PlatTenantVO extends BaseIdDTO implements Serializable {
@ApiModelProperty(value = "状态 0停用 1启用")
private String status;
// @ApiModelProperty(value = "开始时间")
// private LocalDateTime startTime;
//
// @ApiModelProperty(value = "结束时间")
// private LocalDateTime endTime;
@ApiModelProperty(value = "开始时间")
private LocalDate startTime;
......@@ -47,13 +41,13 @@ public class PlatTenantVO extends BaseIdDTO implements Serializable {
*/
@ApiModelProperty(value = "创建时间",required = false)
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime createdAt;
private LocalDateTime createDate;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间",required = false)
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime updatedAt;
private LocalDateTime updateDate;
}
......@@ -30,7 +30,7 @@ public class PlatUserLoginVO implements Serializable {
private String isTenant;
@ApiModelProperty(value = "部门树id")
private String deptId;
private String orgId;
@ApiModelProperty("token")
private String token;
......
......@@ -14,7 +14,7 @@ public class PlatUserVO implements Serializable {
private String isTenant;
private String deptId;
private String orgId;
public PlatUserVO() {
}
......
......@@ -30,7 +30,7 @@ public class WechatUserInfo implements Serializable {
private String tenantId;
private String isFactory;
private String deptId;
private String orgId;
private String account;
......
......@@ -58,10 +58,7 @@ public class PlatPersonDTOVO extends BaseIdDTO {
@NotBlank(message = "部门不能为空")
@ApiModelProperty(value = "部门树id")
private String deptId;
@ApiModelProperty(value = "分管部门id")
private String chargeDeptId;
private String orgId;
@NotBlank(message = "性别不能为空")
@Pattern(regexp = "1|2", message = "性别可选值为 1男 2女")
......@@ -100,7 +97,7 @@ public class PlatPersonDTOVO extends BaseIdDTO {
*/
@ApiModelProperty(value = "创建时间", required = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createdAt;
private LocalDateTime createDate;
/**
* 更新时间
......@@ -109,15 +106,9 @@ public class PlatPersonDTOVO extends BaseIdDTO {
@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;
......
......@@ -21,6 +21,6 @@ public class PlatRoleDeptDTOVO extends BaseTenantDTO {
// private String hotelId;
@ApiModelProperty(value = "部门树id集合")
private List<String> deptIdList;
private List<String> orgIdList;
}
......@@ -7,6 +7,6 @@ import lombok.experimental.FieldNameConstants;
@Data
public class PlatUserCountVO {
//private String id;
private String deptId;
private String orgId;
private Integer count;
}
......@@ -6,6 +6,7 @@ import com.makeit.common.entity.BaseBusEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -17,14 +18,14 @@ import java.util.List;
public class PlatOrg extends BaseBusEntity {
/**
* 租户id
* 父级id
*/
private String tenantId;
private String parentId;
/**
* 父级id
* 全路径id
*/
private String parentId;
private String path;
/**
* 组织名称
......@@ -53,7 +54,7 @@ public class PlatOrg extends BaseBusEntity {
@ApiModelProperty(value = "子集")
@TableField(exist = false)
private List<PlatOrg> children;
private List<PlatOrg> children = new ArrayList<>();
@TableField(exist = false)
private PlatOrg parent;
......
......@@ -18,16 +18,16 @@ import java.util.function.Function;
public class DeptUtil {
private static PlatUserService tntUserService;
private static PlatUserService platUserService;
private static PlatOrgService tntDeptService;
private static PlatOrgService platOrgService;
public static PlatOrg getById(String deptId) {
return tntDeptService.getById(deptId);
return platOrgService.getById(deptId);
}
public static List<PlatOrg> getHotelList() {
List<PlatOrg> deptList = tntDeptService.list(new QueryWrapper<PlatOrg>().lambda()
List<PlatOrg> deptList = platOrgService.list(new QueryWrapper<PlatOrg>().lambda()
//.eq(PlatOrg::getTag, DeptEnum.DeptTagEnum.HOTEL.getValue())
//.eq(TntDept::getStatus, CommonEnum.YES.getValue())
);
......@@ -147,7 +147,7 @@ public class DeptUtil {
//不涉及角色
public static List<String> findSelfAndAllChildrenIdList(String deptId) {
List<String> idList = StreamUtil.map(tntDeptService.findSelfAndAllChildren(deptId), PlatOrg::getId);
List<String> idList = StreamUtil.map(platOrgService.findSelfAndAllChildren(deptId), PlatOrg::getId);
idList.add(-1 + "");
return idList;
}
......@@ -178,7 +178,7 @@ public class DeptUtil {
// }
public static <T> void join(List<T> list, Function<T, String> getNid, BiConsumer<T, PlatOrg> consumer) {
JoinUtil.join(list, tntDeptService, null, getNid, PlatOrg::getId, consumer);
JoinUtil.join(list, platOrgService, null, getNid, PlatOrg::getId, consumer);
}
public static String getDeptName(List<String> applyDeptIds, Map<String, String> deptMap) {
......
......@@ -2,12 +2,15 @@ package com.makeit.service.platform.auth;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.vo.platform.auth.PlatOrgQueryDTO;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author lixl
......@@ -60,7 +63,7 @@ public interface PlatOrgService extends IService<PlatOrg> {
Comparator<PlatOrg> getComparator();
void add(PlatOrg dto);
String add(PlatOrg dto);
void edit(PlatOrg dto);
......@@ -80,4 +83,27 @@ public interface PlatOrgService extends IService<PlatOrg> {
List<PlatOrg> getSelfAndAllParent(String deptId);
List<PlatOrg> getDeptSelfAndChildren(String deptId);
/**
* 获取所属组织
* 当前账号所属角色的权限级别,可查看某一级或者某一级及其下级
* @return
*/
List<PlatOrg> belongToOrgTree();
/**
* 启用|禁用
* @param param
*/
void enable(PlatOrg param);
/**
* 获取用户权限范围
*/
Set<String> getOrgIdListByUserId(String userId);
PageVO<PlatOrg> page(PageReqDTO<PlatOrgQueryDTO> pageReqDTO);
List<PlatOrg> subOrgList(PlatOrgQueryDTO platOrgQueryDTO);
}
......@@ -4,6 +4,9 @@ package com.makeit.service.platform.auth;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.platform.auth.PlatRoleOrg;
import java.util.Collection;
import java.util.List;
/**
* @author lixl
* @description 针对表【plat_role_org(租户端角色部门关联表)】的数据库操作Service
......@@ -11,4 +14,11 @@ import com.makeit.entity.platform.auth.PlatRoleOrg;
*/
public interface PlatRoleOrgService extends IService<PlatRoleOrg> {
/**
* 根据角色获取所属组织
* @param roleIds
* @return
*/
List<PlatRoleOrg> getByRoleIds(Collection<String> roleIds);
}
......@@ -2,6 +2,7 @@ package com.makeit.service.platform.auth;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.dto.StatusDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
......@@ -25,7 +26,7 @@ public interface PlatRoleService extends IService<PlatRole> {
PageVO<PlatRoleDTOVO> page(PageReqDTO<PlatRoleDTOVO> page);
void add(PlatRoleDTOVO dto);
String add(PlatRoleDTOVO dto);
void edit(PlatRoleDTOVO dto);
......@@ -35,27 +36,14 @@ public interface PlatRoleService extends IService<PlatRole> {
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);
......@@ -70,4 +58,11 @@ public interface PlatRoleService extends IService<PlatRole> {
* @return
*/
List<PlatRoleDTOVO> getList(PlatRoleDTOVO dto);
/**
* 当前用户的所属组织下的角色
* @param baseIdDTO
* @return
*/
List<PlatRole> belongTo(BaseIdDTO baseIdDTO);
}
......@@ -4,6 +4,8 @@ package com.makeit.service.platform.auth;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.platform.auth.PlatUserRole;
import java.util.List;
/**
* @author lixl
* @description 针对表【plat_user_role(租户端用户角色关联表)】的数据库操作Service
......@@ -11,4 +13,10 @@ import com.makeit.entity.platform.auth.PlatUserRole;
*/
public interface PlatUserRoleService extends IService<PlatUserRole> {
/**
* 根据userId 获取
* @param userId
* @return
*/
List<PlatUserRole> getByUserId(String userId);
}
......@@ -80,7 +80,7 @@ public interface PlatUserService extends IService<PlatUser> {
List<PlatPersonDTOVO> auditUserList(PlatUserQueryDTO dto);
void addPerson(PlatPersonDTOVO dto);
String addPerson(PlatPersonDTOVO dto);
void editPerson(PlatPersonDTOVO dto);
......
package com.makeit.service.platform.auth.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.service.impl.ServiceImpl;
import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatRole;
import com.makeit.entity.platform.auth.PlatRoleOrg;
import com.makeit.entity.platform.auth.PlatUserRole;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.id.TreeConst;
import com.makeit.global.aspect.tenant.TenantIdUtil;
......@@ -10,8 +20,14 @@ import com.makeit.mapper.platform.auth.PlatOrgMapper;
import com.makeit.module.admin.dto.plat.PlatUserQueryDTO;
import com.makeit.module.system.service.SysConfigCategoryService;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.auth.PlatRoleOrgService;
import com.makeit.service.platform.auth.PlatRoleService;
import com.makeit.service.platform.auth.PlatUserRoleService;
import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.user.plat.PlatUserUtil;
import com.makeit.utils.user.plat.PlatUserVO;
import com.makeit.vo.platform.auth.PlatOrgQueryDTO;
import com.makeit.vo.platform.auth.PlatUserCountVO;
import org.apache.commons.collections4.CollectionUtils;
......@@ -29,8 +45,10 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author lixl
......@@ -49,6 +67,13 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
@Autowired
private SysConfigCategoryService sysConfigCategoryService;
@Autowired
private PlatUserRoleService platUserRoleService;
@Autowired
private PlatRoleOrgService platRoleOrgService;
@Autowired
private PlatRoleService platRoleService;
@Override
public List<PlatOrg> filter(List<PlatOrg> deptList, PlatOrgQueryDTO dto) {
return new HashSet<>(deptList).stream()
......@@ -69,18 +94,11 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
}
@Override
public List<PlatOrg> list(PlatOrgQueryDTO dto) {//parent_path find_in_set ?
public List<PlatOrg> list(PlatOrgQueryDTO dto) {
// List<TntDept> tntDeptList = list(new QueryWrapper<TntDept>().lambda()
// .like(StringUtils.isNotBlank(dto.getName()), TntDept::getName, dto.getName())
// .eq(StringUtils.isNotBlank(dto.getStatus()), TntDept::getStatus, dto.getStatus())
// .in(TntDept::getId, DeptUtil.getDeptSelfAndChildrenIdList(dto.getId()))
// .orderByAsc(TntDept::getSort)
// .orderByAsc(TntDept::getCreatedAt)
// );
List<PlatOrg> deptList = list(new QueryWrapper<PlatOrg>().lambda()
//.eq(PlatOrg::getTag, DeptEnum.DeptTagEnum.DEPT.getValue())
.eq(StringUtils.isNotBlank(dto.getType()),PlatOrg::getType,dto.getType())
);
deptList.forEach(e -> {
......@@ -245,10 +263,6 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
@Override
public Map<String, List<PlatOrg>> findSelfAndAllParent(List<String> deptIdList) {
List<PlatOrg> deptList = list(new QueryWrapper<PlatOrg>().lambda()
// .in(PlatOrg::getTag,
// Arrays.asList(DeptEnum.DeptTagEnum.HOTEL.getValue(),
// DeptEnum.DeptTagEnum.DEPT.getValue())
// )
.eq(PlatOrg::getStatus, CommonEnum.YES.getValue())
.orderByAsc(PlatOrg::getId)
);
......@@ -289,10 +303,6 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
PlatOrg parent = map.get(tntDept.getParentId());
if (parent != null) {
// if (CommonEnum.YES.getValue().equals(parent.getCanTap())) {
// tntDept.setCanTap(CommonEnum.YES.getValue());
// }
//这里有硬编码
//应该是角色挂的节点(包含) 和 酒店节点(包含) 之间的所有节点都表红
......@@ -360,7 +370,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
//System.out.println(tntUserService.listCount(new TntUserQueryDTO()));
List<PlatUserCountVO> countVOList = platUserService.listCount(new PlatUserQueryDTO());
Map<String, Integer> countVOMap = countVOList.stream().collect(Collectors.toMap(PlatUserCountVO::getDeptId, PlatUserCountVO::getCount));
Map<String, Integer> countVOMap = countVOList.stream().collect(Collectors.toMap(PlatUserCountVO::getOrgId, PlatUserCountVO::getCount));
Map<PlatOrg, List<PlatOrg>> deptMap = new HashMap<>(16);
......@@ -385,102 +395,47 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
deptMap.put(d, c);
}
//
// deptMap.forEach((k, v) -> {
// int i = 0;
// for (PlatOrg d : v) {
// Integer c = countVOMap.get(d.getId());
// if (c == null) {
// c = 0;
// }
// i = i + c;
// }
// k.setCount(i);
// });
return tree;
}
private void check(PlatOrg dto) {
// PlatMenu old = getOne(new QueryWrapper<PlatOrg>().lambda()
// .eq(PlatMenu::getCode, dto.getCode()));
// if (old != null && !old.getId().equals(dto.getId())) {
// throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_NAME_DUPLICATE);
// }
PlatOrg parent = getById(dto.getParentId());
// if (parent != null) {
// if (DeptEnum.DeptTagEnum.GROUP.getValue().equals(parent.getTag())) {
// if (!DeptEnum.DeptTagEnum.BRAND.getValue().equals(dto.getTag()) && !DeptEnum.DeptTagEnum.HOTEL.getValue().equals(dto.getTag())) {
// throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_DEPT_LEVEL);
// }
// }
// if (DeptEnum.DeptTagEnum.BRAND.getValue().equals(parent.getTag())) {
// if (!DeptEnum.DeptTagEnum.HOTEL.getValue().equals(dto.getTag()) && !DeptEnum.DeptTagEnum.BRAND.getValue().equals(dto.getTag())) {
// throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_DEPT_LEVEL);
// }
// }
// if (DeptEnum.DeptTagEnum.HOTEL.getValue().equals(parent.getTag())) {
// if (!DeptEnum.DeptTagEnum.DEPT.getValue().equals(dto.getTag())) {
// throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_DEPT_LEVEL);
// }
// }
// if (DeptEnum.DeptTagEnum.DEPT.getValue().equals(parent.getTag())) {
// if (!DeptEnum.DeptTagEnum.DEPT.getValue().equals(dto.getTag())) {
// throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_DEPT_LEVEL);
// }
// }
//
// if (DeptEnum.DeptTypeEnum.DEFAULT.getValue().equals(parent.getType()) && DeptEnum.DeptTypeEnum.SELF.getValue().equals(dto.getType())) {
// throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR);//要不要具体化
// }
//
// }
//
// if (DeptEnum.DeptTagEnum.HOTEL.getValue().equals(dto.getTag()) && StringUtils.isBlank(dto.getHotelId())) {
// throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR);//要不要具体化
// }
// if (TreeConst.TOP_LEVEL.equals(dto.getParentId())) {
// dto.setLevel(0);
// } else {
// dto.setLevel(parent.getLevel() + 1);
// }
}
@Transactional
@Override
public void add(PlatOrg dto) {
public String add(PlatOrg dto) {
check(dto);
dto.setTenantId(TenantIdUtil.getTenantId());
if(StringUtils.isBlank(dto.getParentId())){
String tenantId = TenantIdUtil.getTenantId();
dto.setParentId(tenantId);
dto.setPath(tenantId);
}else {
PlatOrg parent = getById(dto.getParentId());
dto.setPath(parent.getPath()+","+parent.getId());
}
save(dto);
// if (DeptEnum.DeptTagEnum.HOTEL.getValue().equals(dto.getTag())) {
// tntAsyncCommonService.copyConfigForHotel(dto);
// }
return dto.getId();
}
@Transactional
@Override
public void edit(PlatOrg dto) {
check(dto);
updateById(dto);
dto.setTenantId(TenantIdUtil.getTenantId());
// if (DeptEnum.DeptTagEnum.HOTEL.getValue().equals(dto.getTag())) {
//// long configCategoryCount = tntConfigCategoryService.count(new QueryWrapper<TntConfigCategory>().lambda()
//// .eq(TntConfigCategory::getDeptId, dto.getId()));
////
//// if (configCategoryCount != 0) {
//// return;
//// }
// tntAsyncCommonService.copyConfigForHotel(dto);
// }
if(StringUtils.isBlank(dto.getParentId())){
String tenantId = TenantIdUtil.getTenantId();
dto.setParentId(tenantId);
dto.setPath(tenantId);
}else {
PlatOrg parent = getById(dto.getParentId());
dto.setPath(parent.getPath()+","+parent.getId());
}
updateById(dto);
}
@Override
......@@ -518,14 +473,6 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
@Override
public List<PlatOrg> listWithoutDept() {
List<PlatOrg> deptList = list(new QueryWrapper<PlatOrg>().lambda()
//.eq(PlatOrg::getTenantId, TenantIdUtil.getTenantId())
// .in(PlatOrg::getTag,
// Arrays.asList(
// DeptEnum.DeptTagEnum.GROUP.getValue(),
// DeptEnum.DeptTagEnum.BRAND.getValue(),
// DeptEnum.DeptTagEnum.HOTEL.getValue()
// )
// )
.eq(PlatOrg::getStatus, CommonEnum.YES.getValue())
.orderByAsc(PlatOrg::getSort)
.orderByAsc(PlatOrg::getCreateDate)
......@@ -557,4 +504,111 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
}
/**
* 获取权限范围树
* 当前账号所属角色的权限级别,可查看某一级或者某一级及其下级
* @return
*/
@Override
public List<PlatOrg> belongToOrgTree() {
PlatUserVO userVO = PlatUserUtil.getUserVO();
String isTenant = userVO.getIsTenant();
//如果是租户账号 则有所有权限
if(StringUtils.equals(isTenant,CommonEnum.YES.getValue())){
List<PlatOrg> orgList = this.list(new LambdaQueryWrapper<PlatOrg>().eq(PlatOrg::getStatus,CommonEnum.YES.getValue()));
return getOrgTree(orgList);
}
//平台账号
Set<String> orgIdList = getOrgIdListByUserId(userVO.getId());
List<PlatOrg> orgList = this.list(new LambdaQueryWrapper<PlatOrg>().in(BaseEntity::getId,orgIdList).eq(PlatOrg::getStatus,CommonEnum.YES.getValue()));
if(CollectionUtils.isEmpty(orgList)){
return new ArrayList<>();
}
Set<String> allOrgIdSet = orgList.stream().flatMap(vo -> {
String path = vo.getPath();
String[] split = StringUtils.split(path, ",");
return Stream.of(split);
}).collect(Collectors.toSet());
List<PlatOrg> allOrgList = this.list(new LambdaQueryWrapper<PlatOrg>().in(BaseEntity::getId,allOrgIdSet).eq(PlatOrg::getStatus,CommonEnum.YES.getValue()));
orgList.addAll(allOrgList);
return getOrgTree(orgList);
}
/**
* 获取权限范围
*
* @param userId
* @return
*/
@Override
public Set<String> getOrgIdListByUserId(String userId) {
List<PlatUserRole> userRoleList =platUserRoleService.getByUserId(userId);
if(CollectionUtils.isEmpty(userRoleList)){
return new HashSet<>();
}
List<PlatRoleOrg> roleOrgList = platRoleOrgService.getByRoleIds(userRoleList.stream().map(PlatUserRole::getRoleId).collect(Collectors.toSet()));
if(CollectionUtils.isEmpty(roleOrgList)){
return new HashSet<>();
}
List<PlatRole> roleList = platRoleService.listByIds(roleOrgList.stream().map(PlatRoleOrg::getRoleId).collect(Collectors.toList()));
return roleList.stream().flatMap(vo-> Stream.of(vo.getDataScope().split(","))).collect(Collectors.toSet());
}
private List<PlatOrg> getOrgTree(List<PlatOrg> orgList) {
Map<String, List<PlatOrg>> parentIdMap = orgList.stream().collect(Collectors.groupingBy(PlatOrg::getParentId));
orgList.forEach(vo->{
List<PlatOrg> childList = parentIdMap.get(vo.getId());
vo.setChildren(childList);
});
return orgList.stream().filter(vo -> StringUtils.equals(vo.getTenantId(), vo.getParentId())).collect(Collectors.toList());
}
/**
* 启用|禁用
*
* @param param
*/
@Override
public void enable(PlatOrg param) {
LambdaUpdateWrapper<PlatOrg> lambdaUpdateWrapper = Wrappers.lambdaUpdate(PlatOrg.class)
.set(PlatOrg::getStatus, param.getStatus())
.eq(BaseEntity::getId, param.getId());
this.update(lambdaUpdateWrapper);
}
@Override
public PageVO<PlatOrg> page(PageReqDTO<PlatOrgQueryDTO> pageReqDTO) {
String tenantId = TenantIdUtil.getTenantId();
PlatOrgQueryDTO dto = pageReqDTO.getData();
Page<PlatOrg> p = PageUtil.toMpPage(pageReqDTO);
LambdaQueryWrapper<PlatOrg> queryWrapper = getLambdaQueryWrapper(dto);
queryWrapper.eq(BaseEntity::getId,tenantId);
Page<PlatOrg> pageList = page(p, queryWrapper);
List<PlatOrg> records = pageList.getRecords();
records.forEach(vo->{
dto.setParentId(tenantId);
List<PlatOrg> subOrgList = subOrgList(dto);
vo.setChildren(subOrgList);
});
return PageUtil.toPageVO(pageList.getRecords(), pageList);
}
private LambdaQueryWrapper<PlatOrg> getLambdaQueryWrapper(PlatOrgQueryDTO dto) {
LambdaQueryWrapper<PlatOrg> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatOrg::getParentId, dto.getParentId())
.orderByDesc(BaseEntity::getUpdateDate);
return queryWrapper;
}
@Override
public List<PlatOrg> subOrgList(PlatOrgQueryDTO platOrgQueryDTO) {
LambdaQueryWrapper<PlatOrg> queryWrapper = getLambdaQueryWrapper(platOrgQueryDTO);
return list(queryWrapper);
}
}
package com.makeit.service.platform.auth.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.platform.auth.PlatRoleOrg;
import com.makeit.mapper.platform.auth.PlatRoleOrgMapper;
import com.makeit.service.platform.auth.PlatRoleOrgService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* @author lixl
* @description 针对表【plat_role_org(租户端角色部门关联表)】的数据库操作Service实现
......@@ -15,4 +21,19 @@ import org.springframework.stereotype.Service;
public class PlatRoleOrgServiceImpl extends ServiceImpl<PlatRoleOrgMapper, PlatRoleOrg>
implements PlatRoleOrgService{
/**
* 根据角色获取所属组织
*
* @param roleIds
* @return
*/
@Override
public List<PlatRoleOrg> getByRoleIds(Collection<String> roleIds) {
if(CollectionUtils.isEmpty(roleIds)){
return new ArrayList<>();
}
LambdaQueryWrapper<PlatRoleOrg> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(PlatRoleOrg::getRoleId,roleIds);
return list(queryWrapper);
}
}
package com.makeit.server.platform.auth.impl;
package com.makeit.service.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.makeit.common.dto.BaseIdDTO;
import com.makeit.common.dto.StatusDTO;
import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.auth.PlatRoleDeptDTOVO;
......@@ -35,6 +37,7 @@ 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 com.makeit.utils.user.plat.PlatUserVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -54,35 +57,30 @@ import java.util.Map;
public class PlatRoleServiceImpl extends ServiceImpl<PlatRoleMapper, PlatRole>
implements PlatRoleService {
@Autowired
private PlatUserService tntUserService;
private PlatUserService platUserService;
@Autowired
private PlatUserRoleService tntUserRoleService;
private PlatUserRoleService platUserRoleService;
@Autowired
private PlatRoleMenuService tntRoleMenuService;
private PlatRoleMenuService platRoleMenuService;
@Autowired
private PlatMenuService tntMenuService;
private PlatMenuService platMenuService;
// @Autowired
// private PlatRoleWechatMenuService tntRoleWechatMenuService;
@Autowired
private PlatRoleOrgService tntRoleDeptService;
private PlatRoleOrgService platRoleOrgService;
@Autowired
private PlatOrgService tntDeptService;
private PlatOrgService platOrgService;
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);
}
......@@ -92,7 +90,7 @@ implements PlatRoleService {
List<PlatRole> tntRoleList = list(listWrapper(dto));
List<PlatRoleDTOVO> rolVOList = BeanDtoVoUtils.listVo(tntRoleList, PlatRoleDTOVO.class);
JoinUtil.join(rolVOList, tntDeptService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> {
JoinUtil.join(rolVOList, platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> {
r.setDeptName(e.getName());
});
......@@ -109,7 +107,7 @@ implements PlatRoleService {
List<PlatRoleDTOVO> tntUserVOList = BeanDtoVoUtils.listVo(pageList.getRecords(), PlatRoleDTOVO.class);
JoinUtil.join(tntUserVOList, tntDeptService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> {
JoinUtil.join(tntUserVOList, platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> {
r.setDeptName(e.getName());
});
......@@ -141,7 +139,7 @@ implements PlatRoleService {
private boolean checkLevel(PlatRoleDTOVO dto) {
if (!IsTenantAccountEnum.YES.getValue().equals(PlatUserUtil.getUserVO().getIsTenant())) {
PlatRole tntRole = tntUserService.getMaxRole(PlatUserUtil.getUserId());
PlatRole tntRole = platUserService.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
......@@ -167,9 +165,10 @@ implements PlatRoleService {
@Transactional
@Override
public void add(PlatRoleDTOVO dto) {
public String add(PlatRoleDTOVO dto) {
check(dto);
save(BeanDtoVoUtils.convert(dto, PlatRole.class));
return dto.getId();
}
@Transactional
......@@ -185,7 +184,7 @@ implements PlatRoleService {
PlatRoleDTOVO vo = BeanDtoVoUtils.convert(getById(id), PlatRoleDTOVO.class);
JoinUtil.join(Arrays.asList(vo), tntDeptService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> {
JoinUtil.join(Arrays.asList(vo), platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> {
r.setDeptName(e.getName());
});
......@@ -220,7 +219,7 @@ implements PlatRoleService {
removeAssignUserList(userRoleDTOList);
List<PlatUserRole> userRoleList = BeanDtoVoUtils.listVo(userRoleDTOList, PlatUserRole.class);
tntUserRoleService.saveBatch(userRoleList);
platUserRoleService.saveBatch(userRoleList);
}
@Transactional
......@@ -233,7 +232,7 @@ implements PlatRoleService {
List<String> userIdList = StreamUtil.map(v, PlatUserRoleDTO::getUserId);
userIdList.add(-1 + "");
tntUserRoleService.remove(new QueryWrapper<PlatUserRole>().lambda()
platUserRoleService.remove(new QueryWrapper<PlatUserRole>().lambda()
.eq(PlatUserRole::getRoleId, k)
.in(PlatUserRole::getUserId, userIdList));
});
......@@ -388,7 +387,7 @@ implements PlatRoleService {
adminRoleCantDo(roleMenuDTO.getRoleId());
tntRoleMenuService.remove(new QueryWrapper<PlatRoleMenu>().lambda()
platRoleMenuService.remove(new QueryWrapper<PlatRoleMenu>().lambda()
.eq(PlatRoleMenu::getRoleId, roleMenuDTO.getRoleId()));
List<PlatRoleMenu> roleMenuList = StreamUtil.map(roleMenuDTO.getMenuIdList(), e -> {
......@@ -400,18 +399,18 @@ implements PlatRoleService {
return tntRoleMenu;
});
tntRoleMenuService.saveBatch(roleMenuList);
platRoleMenuService.saveBatch(roleMenuList);
}
@Override
public List<PlatRoleMenu> getAssignMenuList(String id) {
List<PlatRoleMenu> roleMenuList = tntRoleMenuService.list(new QueryWrapper<PlatRoleMenu>().lambda()
List<PlatRoleMenu> roleMenuList = platRoleMenuService.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()
List<PlatMenu> menuList = platMenuService.list(new QueryWrapper<PlatMenu>().lambda()
.in(PlatMenu::getId, menuIdList));
Map<String, PlatMenu> menuMap = StreamUtil.toMap(menuList, PlatMenu::getId);
......@@ -466,10 +465,10 @@ implements PlatRoleService {
adminRoleCantDo(tntRoleDeptDTO.getRoleId());
tntRoleDeptService.remove(new QueryWrapper<PlatRoleOrg>().lambda()
platRoleOrgService.remove(new QueryWrapper<PlatRoleOrg>().lambda()
.eq(PlatRoleOrg::getRoleId, tntRoleDeptDTO.getRoleId()));
List<PlatRoleOrg> roleMenuList = StreamUtil.map(tntRoleDeptDTO.getDeptIdList(), e -> {
List<PlatRoleOrg> roleMenuList = StreamUtil.map(tntRoleDeptDTO.getOrgIdList(), e -> {
PlatRoleOrg tntRoleDept = new PlatRoleOrg();
tntRoleDept.setRoleId(tntRoleDeptDTO.getRoleId());
tntRoleDept.setOrgId(e);
......@@ -478,12 +477,12 @@ implements PlatRoleService {
return tntRoleDept;
});
tntRoleDeptService.saveBatch(roleMenuList);
platRoleOrgService.saveBatch(roleMenuList);
}
@Override
public List<PlatRoleOrg> getDeptListByRoleId(String roleId) {
List<PlatRoleOrg> roleDeptList = tntRoleDeptService.list(new QueryWrapper<PlatRoleOrg>().lambda()
List<PlatRoleOrg> roleDeptList = platRoleOrgService.list(new QueryWrapper<PlatRoleOrg>().lambda()
.eq(PlatRoleOrg::getRoleId, roleId));
return roleDeptList;
}
......@@ -502,23 +501,23 @@ implements PlatRoleService {
save(newRole);
List<PlatUserRole> userRoleList = tntUserRoleService.list(new QueryWrapper<PlatUserRole>().lambda()
List<PlatUserRole> userRoleList = platUserRoleService.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);
platUserRoleService.saveBatch(userRoleListNew);
List<PlatRoleMenu> roleMenuList = tntRoleMenuService.list(new QueryWrapper<PlatRoleMenu>().lambda()
List<PlatRoleMenu> roleMenuList = platRoleMenuService.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);
platRoleMenuService.saveBatch(roleMenuListNew);
// List<PlatRoleWechatMenu> wechatMenuList = tntRoleWechatMenuService.list(new QueryWrapper<PlatRoleWechatMenu>().lambda()
// .eq(PlatRoleWechatMenu::getRoleId, roleId));
......@@ -529,13 +528,13 @@ implements PlatRoleService {
// });
// tntRoleWechatMenuService.saveBatch(wechatMenuList);
List<PlatRoleOrg> roleDeptList = tntRoleDeptService.list(new QueryWrapper<PlatRoleOrg>().lambda()
List<PlatRoleOrg> roleDeptList = platRoleOrgService.list(new QueryWrapper<PlatRoleOrg>().lambda()
.eq(PlatRoleOrg::getRoleId, roleId));
roleDeptList.forEach(e -> {
e.setId(null);
e.setRoleId(newRole.getId());
});
tntRoleDeptService.saveBatch(roleDeptList);
platRoleOrgService.saveBatch(roleDeptList);
}
@Override
......@@ -546,7 +545,7 @@ implements PlatRoleService {
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) -> {
JoinUtil.join(rolVOList, platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> {
r.setDeptName(e.getName());
});
......@@ -554,4 +553,19 @@ implements PlatRoleService {
}
/**
* 当前用户的所属组织下的角色
*
* @param baseIdDTO
* @return
*/
@Override
public List<PlatRole> belongTo(BaseIdDTO baseIdDTO) {
PlatUserVO userVO = PlatUserUtil.getUserVO();
if(StringUtils.equals(userVO.getIsTenant(),CommonEnum.YES.getValue())){
List<PlatRole> roleList = this.list(new LambdaQueryWrapper<PlatRole>().orderByDesc(BaseEntity::getUpdateDate));
return roleList;
}
return null;
}
}
package com.makeit.service.platform.auth.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.platform.auth.PlatUserRole;
import com.makeit.mapper.platform.auth.PlatUserRoleMapper;
import com.makeit.service.platform.auth.PlatRoleOrgService;
import com.makeit.service.platform.auth.PlatUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author lixl
* @description 针对表【plat_user_role(租户端用户角色关联表)】的数据库操作Service实现
......@@ -15,4 +20,21 @@ import org.springframework.stereotype.Service;
public class PlatUserRoleServiceImpl extends ServiceImpl<PlatUserRoleMapper, PlatUserRole>
implements PlatUserRoleService{
@Autowired
private PlatRoleOrgService platRoleOrgService;
/**
* 根据userId 获取
*
* @param userId
* @return
*/
@Override
public List<PlatUserRole> getByUserId(String userId) {
LambdaQueryWrapper<PlatUserRole> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatUserRole::getUserId,userId);
return list(queryWrapper);
}
}
......@@ -114,28 +114,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
@Autowired
private PlatOrgService platOrgService;
//
// @Autowired
// private TntRoleWechatMenuService tntRoleWechatMenuService;
//
//
// @Autowired
// private TntFrequentUserService tntFrequentUserService;
//
//
// @Autowired
// private TntUserLabelService tntUserLabelService;
// @Autowired
// private TntCustomGroupService tntCustomGroupService;
//
// @Autowired
// private TntCustomGroupUserService tntCustomGroupUserService;
// @Autowired
// private TntLoginLogService tntLoginLogService;
@Autowired
private SysDictionaryCategoryService sysDictionaryCategoryService;
......@@ -149,8 +127,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
LambdaQueryWrapper<PlatUser> lambdaQueryWrapper = new QueryWrapper<PlatUser>().lambda()
.like(StringUtils.isNotBlank(dto.getAccount()), PlatUser::getAccount, dto.getAccount())
//.like(StringUtils.isNotBlank(dto.getUsername()), TntUser::getUserName, dto.getUsername())
.like(StringUtils.isNotBlank(dto.getName()), PlatUser::getUsername, dto.getName())
.like(StringUtils.isNotBlank(dto.getUsername()), PlatUser::getUsername, dto.getUsername())
.like(StringUtils.isNotBlank(dto.getMobile()), PlatUser::getMobile, dto.getMobile())
.eq(StringUtils.isNotBlank(dto.getStatus()), PlatUser::getStatus, dto.getStatus());
......@@ -376,24 +353,29 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
}
PlatUser tntUser = getOne(new QueryWrapper<PlatUser>().lambda()
PlatUser platUser = getOne(new QueryWrapper<PlatUser>().lambda()
.eq(PlatUser::getAccount, loginDTO.getAccount())
.or()
.eq(PlatUser::getMobile, loginDTO.getAccount())
);
//这样在所有租户内工号不能重复
if (tntUser == null) {
if (platUser == null) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_USER_PASSWORD);
}
if (CommonEnum.NO.getValue().equals(tntUser.getStatus())) {
if (CommonEnum.NO.getValue().equals(platUser.getStatus())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_USER_HAS_DISABLED);
}
if (!PasswordUtils.validatePassword(loginDTO.getPassword(), tntUser.getPassword())) {
if (!PasswordUtils.validatePassword(loginDTO.getPassword(), platUser.getPassword())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_USER_PASSWORD);
}
PlatUserLoginVO userLoginVO = BeanDtoVoUtils.convert(tntUser, PlatUserLoginVO.class);
/**
* 校验机场
*/
checkUserOrg(platUser);
PlatUserLoginVO userLoginVO = BeanDtoVoUtils.convert(platUser, PlatUserLoginVO.class);
String token = IdGen.getUUID();
userLoginVO.setToken(token);
......@@ -405,6 +387,28 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
return userLoginVO;
}
/**
* 校验组织
* @param platUser
*/
private void checkUserOrg(PlatUser platUser) {
String orgId = platUser.getOrgId();
//禁用的子公司其下属账号无法登录
PlatOrg platOrg = platOrgService.getById(orgId);
if(platOrg==null){
throw new BusinessException("找不到组织");
}
String path = platOrg.getPath();
String[] split = StringUtils.split(path, ",");
LambdaQueryWrapper<PlatOrg> platOrgLambdaQueryWrapper = new LambdaQueryWrapper<>();
platOrgLambdaQueryWrapper.in(BaseEntity::getId,split)
.eq(PlatOrg::getStatus,CommonEnum.NO.getValue());
long count = platOrgService.count(platOrgLambdaQueryWrapper);
if(count>0){
throw new BusinessException("禁用的子公司其下属账号无法登录");
}
}
private void fillMenuList(List<PlatMenu> menuList, PlatUserLoginVO userLoginVO) {
// List<TntMenu> buttonList = StreamUtil.filter(menuList, e -> SysEnum.MenuTypeEnum.MENU.getValue().equals(e.getCategory()) || SysEnum.MenuTypeEnum.BUTTON.getValue().equals(e.getCategory()));
......@@ -472,7 +476,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
tntUserRoleMenuRedisVO.setId(userLoginVO.getId());
tntUserRoleMenuRedisVO.setIsTenant(tntUserRoleMenuRedisVO.getIsTenant());
if (userLoginVO.getRoleList() != null) {
tntUserRoleMenuRedisVO.setRoleCodeList(StreamUtil.map(userLoginVO.getRoleList(), PlatRoleDTOVO::getCode));
tntUserRoleMenuRedisVO.setRoleCodeList(StreamUtil.map(userLoginVO.getRoleList(), PlatRoleDTOVO::getId));
}
if (userLoginVO.getButtonList() != null) {
tntUserRoleMenuRedisVO.setButtonCodeList(StreamUtil.map(userLoginVO.getButtonList(), PlatButtonVO::getCode));
......@@ -677,8 +681,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
.eq(PlatUser::getIsTenant, IsTenantAccountEnum.NO.getValue())
.like(StringUtils.isNotBlank(dto.getAccount()), PlatUser::getAccount, dto.getAccount())
.in(CollectionUtils.isNotEmpty(dto.getAccountList()), PlatUser::getAccount, dto.getAccountList())
.like(StringUtils.isNotBlank(dto.getName()), PlatUser::getUsername, dto.getName())
.in(CollectionUtils.isNotEmpty(dto.getNameList()), PlatUser::getUsername, dto.getName())
.like(StringUtils.isNotBlank(dto.getUsername()), PlatUser::getUsername, dto.getUsername())
.in(CollectionUtils.isNotEmpty(dto.getNameList()), PlatUser::getUsername, dto.getUsername())
.like(StringUtils.isNotBlank(dto.getMobile()), PlatUser::getMobile, dto.getMobile())
.eq(StringUtils.isNotBlank(dto.getStatus()), PlatUser::getStatus, dto.getStatus())
.eq(PlatUser::getTenantId, TenantIdUtil.getTenantId())
......@@ -692,9 +696,9 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
roleIdList(lambdaQueryWrapper, dto);
if (CollectionUtils.isNotEmpty(dto.getDeptIdList())) {
dto.getDeptIdList().add(-1 + "");
lambdaQueryWrapper.in(PlatUser::getOrgId, dto.getDeptIdList());
if (CollectionUtils.isNotEmpty(dto.getOrgIdList())) {
dto.getOrgIdList().add(-1 + "");
lambdaQueryWrapper.in(PlatUser::getOrgId, dto.getOrgIdList());
}
lambdaQueryWrapper.orderByDesc(PlatUser::getCreateDate);
......@@ -705,8 +709,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
private void fillDept(List<PlatPersonDTOVO> tntUserDTOVOList) {
JoinUtil.join(tntUserDTOVOList, platOrgService, PlatPersonDTOVO::getDeptId, PlatOrg::getId, (p, d) -> {
p.setDeptName(d.getName());
JoinUtil.join(tntUserDTOVOList, platOrgService, PlatPersonDTOVO::getOrgId, PlatOrg::getId, (p, d) -> {
p.setOrgName(d.getName());
});
}
......@@ -739,7 +743,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
List<Map<String, Object>> tntUserList = listMaps(
new DynamicQuery<PlatUser>()
.select(SqlUtil.count(PlatUserCountVO.Fields.count),
SqlUtil.as(PlatUserCountVO.Fields.deptId)
SqlUtil.as(PlatUserCountVO.Fields.orgId)
)
.eq(BaseBusEntity.Fields.tenantId, TenantIdUtil.getTenantId())
.eq(PlatUser.Fields.isTenant, IsTenantAccountEnum.NO.getValue())
......@@ -815,7 +819,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
LambdaQueryWrapper<PlatUser> lambdaQueryWrapper = new QueryWrapper<PlatUser>().lambda()
.eq(PlatUser::getIsTenant, IsTenantAccountEnum.NO.getValue())
.like(StringUtils.isNotBlank(dto.getAccount()), PlatUser::getAccount, dto.getAccount())
.like(StringUtils.isNotBlank(dto.getName()), PlatUser::getUsername, dto.getName())
.like(StringUtils.isNotBlank(dto.getUsername()), PlatUser::getUsername, dto.getUsername())
.like(StringUtils.isNotBlank(dto.getMobile()), PlatUser::getMobile, dto.getMobile())
.eq(StringUtils.isNotBlank(dto.getStatus()), PlatUser::getStatus, dto.getStatus())
//.eq(dto.getPostLevel() != null, PlatUser::getPostLevel, dto.getPostLevel())
......@@ -825,16 +829,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
roleIdList(lambdaQueryWrapper, dto);
if (dto.getDeptIdList() != null || StringUtils.isNotBlank(dto.getChargeDeptId())) {
dto.getDeptIdList().add(-1 + "");
lambdaQueryWrapper.and(qw -> {
qw.in(dto.getDeptIdList() != null, PlatUser::getOrgId, dto.getDeptIdList())
.or(StringUtils.isNotBlank(dto.getChargeDeptId()))
//.like(StringUtils.isNotBlank(dto.getChargeDeptId()), PlatUser::getChargeDeptId, dto.getChargeDeptId())
;
});
}
lambdaQueryWrapper.orderByDesc(PlatUser::getCreateDate);
List<PlatPersonDTOVO> tntUserList = BeanDtoVoUtils.listVo(list(lambdaQueryWrapper), PlatPersonDTOVO.class);
......@@ -861,7 +855,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
@Transactional
@Override
public void addPerson(PlatPersonDTOVO dto) {
public String addPerson(PlatPersonDTOVO dto) {
checkPerson(BeanDtoVoUtils.convert(dto, PlatUserDTOVO.class));
PlatUser user = BeanDtoVoUtils.convert(dto, PlatUser.class);
user.setIsTenant(CommonEnum.NO.getValue());
......@@ -880,6 +874,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
save(user);
dto.setId(user.getId());
setRoleList(dto);
return user.getId();
}
......@@ -1064,7 +1060,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
// }
// });
PlatOrg userDept = map.get(PlatUserUtil.getUserVO().getDeptId());
PlatOrg userDept = map.get(PlatUserUtil.getUserVO().getOrgId());
// if (userDept != null) {
// userDept.setCanTap(CommonEnum.YES.getValue());
// }
......@@ -1204,7 +1200,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
Page<PlatUser> p = PageUtil.toMpPage(page);
LambdaQueryWrapper<PlatUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.like(StringUtils.isNotBlank(dto.getName()), PlatUser::getUsername, dto.getName());
lambdaQueryWrapper.like(StringUtils.isNotBlank(dto.getUsername()), PlatUser::getUsername, dto.getUsername());
lambdaQueryWrapper.like(StringUtils.isNotBlank(dto.getAccount()), PlatUser::getAccount, dto.getAccount());
lambdaQueryWrapper.eq(StringUtils.isNotBlank(dto.getStatus()), PlatUser::getStatus, dto.getStatus());
Page<PlatUser> pageList = page(p, lambdaQueryWrapper);
......
......@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatUser;
import com.makeit.entity.saas.PlatTenant;
import com.makeit.entity.saas.PlatTenantMenu;
......@@ -22,6 +23,7 @@ import com.makeit.module.admin.dto.plat.PlatTenantMenuDTO;
import com.makeit.module.admin.dto.plat.PlatTenantStatusDTO;
import com.makeit.module.admin.vo.plat.PlatTenantVO;
import com.makeit.module.system.service.SysConfigService;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.service.saas.PlatTenantMenuService;
import com.makeit.service.saas.PlatTenantService;
......@@ -70,6 +72,9 @@ implements PlatTenantService {
@Autowired
private PlatTenantMenuService platTenantMenuService;
@Autowired
private PlatOrgService platOrgService;
private LambdaQueryWrapper<PlatTenant> listLambdaQueryWrapper(PlatTenantVO dto, boolean userAccountLike) {
List<String> tenantUserIdList = new ArrayList<>(10);
......@@ -195,6 +200,10 @@ implements PlatTenantService {
//更新用户的tenantId
platUserService.updatePlatUserTenantId(tntTenant.getId(),dto.getPlatUserId());
//组织表增加一条数据
PlatOrg platOrg = convertToPlatOrg(tntTenant);
platOrgService.add(platOrg);
return tntTenant.getId();
}
......@@ -213,10 +222,23 @@ implements PlatTenantService {
}
platUserService.updatePlatUserTenantId(tntTenant.getId(),dto.getPlatUserId());
PlatOrg platOrg = convertToPlatOrg(platTenant);
//更新组织表
platOrgService.edit(platOrg);
saasOperationLogService.add("平台端-租户账号-编辑", dto.getId());
}
public PlatOrg convertToPlatOrg(PlatTenant platTenant){
PlatOrg platOrg = new PlatOrg();
platOrg.setTenantId(platTenant.getId());
platOrg.setName(platTenant.getName());
platOrg.setStatus(platTenant.getStatus());
platOrg.setId(platTenant.getId());
return platOrg;
}
@Override
public PlatTenantDTOVO view(String id) {
PlatTenantDTOVO userVO = BeanDtoVoUtils.convert(getById(id), PlatTenantDTOVO.class);
......
......@@ -15,7 +15,7 @@ public class PlatOrgQueryDTO extends BaseOrgDTO {
@ApiModelProperty(value = "状态 0禁用 1启用")
private String status;
@ApiModelProperty(value = "是否从酒店开始 0否 1是")
private String fromHotel;
@ApiModelProperty(value = "字典类型 1-居家 2-机构")
private String type;
}
......@@ -46,7 +46,7 @@ public class PlatPersonDTOVO extends BaseIdDTO {
private String status;
@ApiModelProperty(value = "部门树id")
private String deptId;
private String orgId;
@Size(max = 512, message = "备注最长512字符")
@ApiModelProperty(value = "备注")
......@@ -67,7 +67,7 @@ public class PlatPersonDTOVO extends BaseIdDTO {
private LocalDateTime updateDate;
@ApiModelProperty(value = "部门名称")
private String deptName;
private String orgName;
@ApiModelProperty(value = "头像")
......
......@@ -7,6 +7,6 @@ import lombok.experimental.FieldNameConstants;
@Data
public class PlatUserCountVO {
//private String id;
private String deptId;
private String orgId;
private Integer count;
}
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