Commit 0f5a6a8c by huangtao

physic

parent 5eaa647a
Showing with 248 additions and 287 deletions
......@@ -3,7 +3,7 @@ package com.jmai.sys.controller;
import com.jmai.sys.aop.Auth;
import com.jmai.sys.dto.*;
import com.jmai.sys.service.OrganizationService;
import com.jmai.sys.service.DeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -18,41 +18,41 @@ import java.util.List;
@Slf4j
@Auth
@RestController
@RequestMapping("/organization")
@RequestMapping("/dept")
@Api(tags = "组织")
@ApiImplicitParams({@ApiImplicitParam(paramType = "header", name = "Access-Token", value = "凭证", required = true, dataType = "string")})
public class OrganizationController {
public class DeptController {
@Resource
private OrganizationService organizationService;
private DeptService deptService;
@PostMapping("/listOrganization")
@PostMapping("/listDept")
@ApiOperation(value = "查询组织列表", notes = "")
public ResponseData<List<OrganizationDto>> listOrganization(@RequestBody @Valid OrganizationQueryReq req) {
List<OrganizationDto> page = organizationService.listOrganization(req);
public ResponseData<List<DeptDto>> listDept(@RequestBody @Valid DeptQueryReq req) {
List<DeptDto> page = deptService.listDept(req);
return ResponseData.ok(page);
}
@PostMapping("/getOrganization")
@PostMapping("/getDept")
@ApiOperation(value = "获取组织信息", notes = "")
public ResponseData<OrganizationDto> getOrganization(@RequestParam("organizationId") Long organizationId) {
OrganizationDto dto = organizationService.getOrganizationOrThrow(organizationId);
public ResponseData<DeptDto> getDept(@RequestParam("deptId") Long deptId) {
DeptDto dto = deptService.getDeptOrThrow(deptId);
return ResponseData.ok(dto);
}
@PostMapping("/createOrganization")
@PostMapping("/createDept")
@ApiOperation(value = "创建组织", notes = "")
public ResponseData<OrganizationDto> createWarehouse(@RequestBody @Valid OrganizationCreateReq req) {
OrganizationDto dto = organizationService.createOrganization(req);
public ResponseData<DeptDto> createWarehouse(@RequestBody @Valid DeptCreateReq req) {
DeptDto dto = deptService.createDept(req);
return ResponseData.ok(dto);
}
@PostMapping("/updateOrganization")
@PostMapping("/updateDept")
@ApiOperation(value = "更新组织信息", notes = "")
public ResponseData<OrganizationDto> updateWarehouse(@RequestBody @Valid OrganizationUpdateReq req) {
OrganizationDto dto = organizationService.updateOrganization(req);
public ResponseData<DeptDto> updateWarehouse(@RequestBody @Valid DeptUpdateReq req) {
DeptDto dto = deptService.updateDept(req);
return ResponseData.ok(dto);
}
}
......@@ -10,11 +10,11 @@ import java.time.LocalDateTime;
@Data
@ApiModel
public class OrganizationCreateReq extends BaseReq {
public class DeptCreateReq extends BaseReq {
@ApiModelProperty(value = "组织名称")
private String organizationName;
private String deptName;
@ApiModelProperty(value = "备注描述")
private String remark;
......
......@@ -6,12 +6,12 @@ import lombok.Data;
@Data
@ApiModel(description = "组织")
public class OrganizationDto {
public class DeptDto {
@ApiModelProperty(value = "组织ID")
private Long organizationId;
private Long deptId;
@ApiModelProperty(value = "组织名称")
private String organizationName;
private String deptName;
@ApiModelProperty(value = "层级")
private Integer level;
......
......@@ -14,12 +14,12 @@ import java.util.List;
*/
@Data
@ApiModel
public class OrganizationQueryReq extends PageReq {
public class DeptQueryReq extends PageReq {
@ApiModelProperty(value = "组织ID")
private Long organizationId;
private Long deptId;
@ApiModelProperty(value = "组织名称")
private String organizationName;
private String deptName;
@ApiModelProperty(value = "层级")
private Integer level;
......
......@@ -9,13 +9,13 @@ import java.time.LocalDateTime;
@Data
@ApiModel
public class OrganizationUpdateReq extends BaseReq {
public class DeptUpdateReq extends BaseReq {
@ApiModelProperty(value = "组织ID")
private Long organizationId;
private Long deptId;
@ApiModelProperty(value = "组织名称")
private String organizationName;
private String deptName;
@ApiModelProperty(value = "备注描述")
private String remark;
......
......@@ -18,15 +18,15 @@ import static com.jmai.sys.service.UserService.KEY_ALL;
@ApiModel(description = "用户信息")
public class FullUserDto extends UserDto implements IDataPerms {
@ApiModelProperty(value = "授权组织(编号)列表(逗号隔开)")
private String organizationIdList;
private String deptIdList;
@ApiModelProperty(value = "授权仓库/站点(名称)列表(逗号隔开)")
private String organizationNameList;
private String deptNameList;
@JsonIgnore
@JSONField(serialize = false)
public List<String> getOrganizationIdAsList() {
return extractStringList(organizationIdList);
public List<String> getDeptIdAsList() {
return extractStringList(deptIdList);
}
protected List<String> extractStringList(String input) {
......
......@@ -28,15 +28,15 @@ public class UserDto extends BaseDto implements IStatus {
private String mobile;
@ApiModelProperty(value = "组织")
private String authOrganizationList;
private String authDeptList;
@ApiModelProperty(value = "状态:0 - 禁用,1 - 启用")
private Integer status;
@JsonIgnore
@JSONField(serialize = false)
public List<Long> getOrganizationAsList() {
return extractLongList(authOrganizationList);
public List<Long> getDeptAsList() {
return extractLongList(authDeptList);
}
......
......@@ -25,25 +25,25 @@ public class UserUpdateReq {
private Long userType;
@ApiModelProperty(value = "组织(ID)列表(逗号隔开)")
private Object authOrganizationList;
private Object authDeptList;
@ApiModelProperty(value = "用户角色(ID)列表(逗号隔开)")
private Object roleList;
@ApiModelProperty(value = "组织(ID)")
private Long organizationId;
private Long deptId;
@ApiModelProperty(value = "状态:0 - 禁用,1 - 启用")
private Integer status;
public String getAuthOrganizationList() {
return getAuthOrganizationAsList()
public String getAuthDeptList() {
return getAuthDeptAsList()
.stream()
.map(String::valueOf)
.collect(Collectors.joining(","));
}
public List<Long> getAuthOrganizationAsList() {
return BaseService.extractLongList(authOrganizationList);
public List<Long> getAuthDeptAsList() {
return BaseService.extractLongList(authDeptList);
}
public String getRoleList() {
......
......@@ -9,10 +9,10 @@ import lombok.Data;
@Data
@ApiModel(description = "组织")
@TableName("sys_organization")
public class SysOrganization extends BaseVersionEntity {
@TableName("sys_dept")
public class SysDept extends BaseVersionEntity {
@ApiModelProperty(value = "组织名称")
private String organizationName;
private String deptName;
@ApiModelProperty(value = "层级")
private Integer level;
......
......@@ -28,10 +28,10 @@ public class SysUser extends BaseExtEntity implements IStatus {
private Long type;
@ApiModelProperty(value = "组织(ID)列表(逗号隔开)")
private String authOrganizationList;
private String authDeptList;
@ApiModelProperty(value = "组织(ID)")
private Long organizationId;
private Long deptId;
@ApiModelProperty(value = "用户类型(角色)列表(逗号隔开)")
private String roleList;
......@@ -39,8 +39,8 @@ public class SysUser extends BaseExtEntity implements IStatus {
@ApiModelProperty(value = "状态:0 - 禁用,1 - 启用")
private Integer status;
public List<Long> getAuthOrganizationAsList() {
return BaseService.extractLongList(getAuthOrganizationList());
public List<Long> getAuthDeptAsList() {
return BaseService.extractLongList(getAuthDeptList());
}
public List<Long> getRoleAsList() {
......
package com.jmai.sys.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(description = "用户组织关系")
@TableName("sys_user_organization")
public class SysUserOrganization extends BaseVersionEntity {
@ApiModelProperty(value = "用户ID")
private Long userId;
@ApiModelProperty(value = "组织ID")
private String organization_id;
}
......@@ -69,8 +69,8 @@ public enum ErrorCode implements ServiceCode {
DEPT_DENIED(90105, "部门/科室数据权限未授权"),
/* 仓库 */
ORGANIZATION_NOT_FOUND(100001, "组织不存在"),
ORGANIZATION_NAME_EXISTED(100003, "组织名称已存在"),
DEPT_NOT_FOUND(100001, "组织不存在"),
DEPT_NAME_EXISTED(100003, "组织名称已存在"),
/* 商品 */
PRODUCT_NOT_FOUND(200001, "无首营数据"),
......
package com.jmai.sys.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jmai.sys.entity.SysOrganization;
import com.jmai.sys.entity.SysUserOrganization;
import com.jmai.sys.entity.SysDept;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysUserOrganizationMapper extends BaseMapper<SysUserOrganization> {
public interface SysDeptMapper extends BaseMapper<SysDept> {
}
package com.jmai.sys.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jmai.sys.entity.SysMenu;
import com.jmai.sys.entity.SysOrganization;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime;
import java.util.List;
@Mapper
public interface SysOrganizationMapper extends BaseMapper<SysOrganization> {
}
package com.jmai.sys.service;
import cn.hutool.core.util.ObjectUtil;
import com.jmai.api.exception.ServiceException;
import com.jmai.sys.dto.DeptCreateReq;
import com.jmai.sys.dto.DeptDto;
import com.jmai.sys.dto.DeptQueryReq;
import com.jmai.sys.dto.DeptUpdateReq;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static com.jmai.sys.exception.ErrorCode.DEPT_NOT_FOUND;
public interface DeptService {
Map<Long, DeptDto> getDeptMap(List<Long> deptIds);
List<DeptDto> listDept(DeptQueryReq req);
default DeptDto getDeptOrThrow(Long deptId) {
return getDept(deptId)
.orElseThrow(() -> new ServiceException(DEPT_NOT_FOUND, "部门:"+ deptId));
}
default Optional<DeptDto> getDept(Long deptId) {
DeptQueryReq req = new DeptQueryReq();
req.setDeptId(deptId);
List<DeptDto> list = listDept(req);
return selectOne(list);
}
public static <T> Optional<T> selectOne(List<T> list) {
if (ObjectUtil.isEmpty(list)) {
return Optional.empty();
}
if (list.size() > 1) {
throw new ServiceException("列表大于1");
}
return Optional.of(list.get(0));
}
DeptDto createDept(DeptCreateReq req);
default Optional<DeptDto> getDeptByName(String deptName) {
DeptQueryReq req = new DeptQueryReq();
req.setDeptName(deptName);
List<DeptDto> list = listDept(req);
return selectOne(list);
}
DeptDto updateDept(DeptUpdateReq req);
}
package com.jmai.sys.service;
import cn.hutool.core.util.ObjectUtil;
import com.jmai.api.exception.ServiceException;
import com.jmai.sys.dto.OrganizationCreateReq;
import com.jmai.sys.dto.OrganizationDto;
import com.jmai.sys.dto.OrganizationQueryReq;
import com.jmai.sys.dto.OrganizationUpdateReq;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static com.jmai.sys.exception.ErrorCode.ORGANIZATION_NOT_FOUND;
public interface OrganizationService {
Map<Long, OrganizationDto> getOrganizationMap(List<Long> organizationIds);
List<OrganizationDto> listOrganization(OrganizationQueryReq req);
default OrganizationDto getOrganizationOrThrow(Long organizationId) {
return getOrganization(organizationId)
.orElseThrow(() -> new ServiceException(ORGANIZATION_NOT_FOUND, ":" + organizationId));
}
default Optional<OrganizationDto> getOrganization(Long organizationId) {
OrganizationQueryReq req = new OrganizationQueryReq();
req.setOrganizationId(organizationId);
List<OrganizationDto> list = listOrganization(req);
return selectOne(list);
}
public static <T> Optional<T> selectOne(List<T> list) {
if (ObjectUtil.isEmpty(list)) {
return Optional.empty();
}
if (list.size() > 1) {
throw new ServiceException("列表大于1");
}
return Optional.of(list.get(0));
}
OrganizationDto createOrganization(OrganizationCreateReq req);
default Optional<OrganizationDto> getOrganizationByName(String organizationName) {
OrganizationQueryReq req = new OrganizationQueryReq();
req.setOrganizationName(organizationName);
List<OrganizationDto> list = listOrganization(req);
return selectOne(list);
}
OrganizationDto updateOrganization(OrganizationUpdateReq req);
}
package com.jmai.sys.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.jmai.api.exception.ServiceException;
import com.jmai.sys.AbstractService;
import com.jmai.sys.dto.DeptCreateReq;
import com.jmai.sys.dto.DeptDto;
import com.jmai.sys.dto.DeptQueryReq;
import com.jmai.sys.dto.DeptUpdateReq;
import com.jmai.sys.entity.SysDept;
import com.jmai.sys.mapper.SysDeptMapper;
import com.jmai.sys.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import static com.jmai.sys.exception.ErrorCode.*;
@Slf4j
@Service
public class DeptServiceImpl extends AbstractService implements DeptService {
@Resource
private SysDeptMapper sysDeptMapper;
private DeptDto convertTo(SysDept dept) {
if (ObjectUtil.isEmpty(dept)) {
return null;
}
DeptDto dto = copyTo(dept, new DeptDto());
dto.setDeptId(dept.getId());
return dto;
}
public Map<Long, DeptDto> getDeptMap(List<Long> deptIds) {
if (ObjectUtil.isEmpty(deptIds)) {
return Collections.emptyMap();
}
deptIds = deptIds.stream().distinct().collect(Collectors.toList());
List<SysDept> warehouseList = sysDeptMapper.selectList(Wrappers.lambdaQuery(SysDept.class)
.in(SysDept::getId, deptIds));
return convertToMap(warehouseList, SysDept::getId, this::convertTo);
}
@Override
public List<DeptDto> listDept(DeptQueryReq req){
Wrapper<SysDept> query = buildQuery(req);
List<SysDept> depts = sysDeptMapper.selectList(query);
return convertTo(depts, this::convertTo);
}
@Override
public DeptDto createDept(DeptCreateReq req) {
Optional<DeptDto> existed = getDeptByName(req.getDeptName());
if (existed.isPresent()) {
throw new ServiceException(DEPT_NAME_EXISTED, ":仓库名称=" + req.getDeptName());
}
SysDept dept = copyTo(req, new SysDept());
if(ObjectUtil.isNotEmpty(req.getParentId())){
DeptDto deptOrThrow = getDeptOrThrow(req.getParentId());
Integer level = deptOrThrow.getLevel();
dept.setLevel(level+1);
}
sysDeptMapper.insert(dept);
return convertTo(dept);
}
@Override
public DeptDto updateDept(DeptUpdateReq req) {
SysDept dept = sysDeptMapper.selectById(req.getDeptId());
if (ObjectUtil.isEmpty(dept)) {
throw new ServiceException(DEPT_NOT_FOUND, "部门=" + req.getDeptId());
}
if (ObjectUtil.isNotEmpty(req.getDeptName())
&& !dept.getDeptName().equals(req.getDeptName())) {
Optional<DeptDto> existed = getDeptByName(req.getDeptName());
if (existed.isPresent()) {
throw new ServiceException(DEPT_NAME_EXISTED, ":部门名称=" + req.getDeptName());
}
}
dept = copyTo(req, new SysDept());
sysDeptMapper.updateById(dept);
return convertTo(dept);
}
private Wrapper<SysDept> buildQuery(DeptQueryReq req) {
return Wrappers.lambdaQuery(SysDept.class)
.eq(ObjectUtil.isNotEmpty(req.getLevel()), SysDept::getLevel, req.getLevel())
.eq(ObjectUtil.isNotEmpty(req.getDeptId()), SysDept::getId, req.getDeptId())
.eq(ObjectUtil.isNotEmpty(req.getDeptName()), SysDept::getDeptName, req.getDeptName())
.orderByDesc(SysDept::getCreateTime);
}
}
package com.jmai.sys.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.jmai.api.exception.ServiceException;
import com.jmai.sys.AbstractService;
import com.jmai.sys.dto.OrganizationCreateReq;
import com.jmai.sys.dto.OrganizationDto;
import com.jmai.sys.dto.OrganizationQueryReq;
import com.jmai.sys.dto.OrganizationUpdateReq;
import com.jmai.sys.entity.SysOrganization;
import com.jmai.sys.mapper.SysOrganizationMapper;
import com.jmai.sys.service.OrganizationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import static com.jmai.sys.exception.ErrorCode.ORGANIZATION_NAME_EXISTED;
import static com.jmai.sys.exception.ErrorCode.ORGANIZATION_NOT_FOUND;
@Slf4j
@Service
public class OrganizationServiceImpl extends AbstractService implements OrganizationService {
@Resource
private SysOrganizationMapper sysOrganizationMapper;
private OrganizationDto convertTo(SysOrganization organization) {
if (ObjectUtil.isEmpty(organization)) {
return null;
}
OrganizationDto dto = copyTo(organization, new OrganizationDto());
dto.setOrganizationId(organization.getId());
return dto;
}
public Map<Long, OrganizationDto> getOrganizationMap(List<Long> organizationIds) {
if (ObjectUtil.isEmpty(organizationIds)) {
return Collections.emptyMap();
}
organizationIds = organizationIds.stream().distinct().collect(Collectors.toList());
List<SysOrganization> warehouseList = sysOrganizationMapper.selectList(Wrappers.lambdaQuery(SysOrganization.class)
.in(SysOrganization::getId, organizationIds));
return convertToMap(warehouseList, SysOrganization::getId, this::convertTo);
}
@Override
public List<OrganizationDto> listOrganization(OrganizationQueryReq req){
Wrapper<SysOrganization> query = buildQuery(req);
List<SysOrganization> organizations = sysOrganizationMapper.selectList(query);
return convertTo(organizations, this::convertTo);
}
@Override
public OrganizationDto createOrganization(OrganizationCreateReq req) {
Optional<OrganizationDto> existed = getOrganizationByName(req.getOrganizationName());
if (existed.isPresent()) {
throw new ServiceException(ORGANIZATION_NAME_EXISTED, ":仓库名称=" + req.getOrganizationName());
}
SysOrganization organization = copyTo(req, new SysOrganization());
if(ObjectUtil.isNotEmpty(req.getParentId())){
OrganizationDto organizationOrThrow = getOrganizationOrThrow(req.getParentId());
Integer level = organizationOrThrow.getLevel();
organization.setLevel(level+1);
}
sysOrganizationMapper.insert(organization);
return convertTo(organization);
}
@Override
public OrganizationDto updateOrganization(OrganizationUpdateReq req) {
SysOrganization organization = sysOrganizationMapper.selectById(req.getOrganizationId());
if (ObjectUtil.isEmpty(organization)) {
throw new ServiceException(ORGANIZATION_NOT_FOUND, "仓库=" + req.getOrganizationId());
}
if (ObjectUtil.isNotEmpty(req.getOrganizationName())
&& !organization.getOrganizationName().equals(req.getOrganizationName())) {
Optional<OrganizationDto> existed = getOrganizationByName(req.getOrganizationName());
if (existed.isPresent()) {
throw new ServiceException(ORGANIZATION_NAME_EXISTED, ":仓库名称=" + req.getOrganizationName());
}
}
organization = copyTo(req, new SysOrganization());
sysOrganizationMapper.updateById(organization);
return convertTo(organization);
}
private Wrapper<SysOrganization> buildQuery(OrganizationQueryReq req) {
return Wrappers.lambdaQuery(SysOrganization.class)
.eq(ObjectUtil.isNotEmpty(req.getLevel()), SysOrganization::getLevel, req.getLevel())
.eq(ObjectUtil.isNotEmpty(req.getOrganizationId()), SysOrganization::getId, req.getOrganizationId())
.eq(ObjectUtil.isNotEmpty(req.getOrganizationName()), SysOrganization::getOrganizationName, req.getOrganizationName())
.orderByDesc(SysOrganization::getCreateTime);
}
}
......@@ -27,7 +27,7 @@ import com.jmai.sys.mapper.SysUserMapper;
import com.jmai.sys.mapper.SysUserTokenMapper;
import com.jmai.sys.service.ConfigService;
import com.jmai.sys.service.DictService;
import com.jmai.sys.service.OrganizationService;
import com.jmai.sys.service.DeptService;
import com.jmai.sys.service.UserService;
import com.jmai.sys.util.PasswordUtil;
import lombok.Data;
......@@ -65,7 +65,7 @@ public class UserServiceImpl extends AbstractService implements UserService {
private SysUserLoginMapper userLoginMapper;
@Resource
private OrganizationService organizationService;
private DeptService deptService;
@Data
......@@ -119,64 +119,64 @@ public class UserServiceImpl extends AbstractService implements UserService {
List<FullUserDto> dtoList = convertTo(userList, this::convertToFullUser);
// 填充授权仓库名称
List<Long> organizationIdList = dtoList.stream()
.flatMap(user -> user.getOrganizationAsList().stream())
List<Long> deptIdList = dtoList.stream()
.flatMap(user -> user.getDeptAsList().stream())
.filter(ObjectUtil::isNotEmpty)
.distinct()
.collect(Collectors.toList());
Map<Long, OrganizationDto> organizationMap = ObjectUtil.isEmpty(organizationIdList) ?
Map<Long, DeptDto> deptMap = ObjectUtil.isEmpty(deptIdList) ?
Collections.emptyMap() :
organizationService.getOrganizationMap(organizationIdList);
deptService.getDeptMap(deptIdList);
dtoList.forEach(dto -> {
dto.setOrganizationIdList(extractOrganizationIdList(dto.getAuthOrganizationList(), organizationMap));
dto.setOrganizationNameList(extractOrganizationNameList(dto.getAuthOrganizationList(), organizationMap));
dto.setDeptIdList(extractDeptIdList(dto.getAuthDeptList(), deptMap));
dto.setDeptNameList(extractDeptNameList(dto.getAuthDeptList(), deptMap));
});
return dtoList;
}
private String extractOrganizationIdList(String userOrganizationList, Map<Long, OrganizationDto> organizationMap) {
if (ObjectUtil.isEmpty(userOrganizationList)) {
private String extractDeptIdList(String userDeptList, Map<Long, DeptDto> deptMap) {
if (ObjectUtil.isEmpty(userDeptList)) {
// 无s授权住址
return "";
}
if (ObjectUtil.equals(userOrganizationList, KEY_ALL)) {
if (ObjectUtil.equals(userDeptList, KEY_ALL)) {
// 授权全部仓库
return KEY_NAME_ALL;
}
if (ObjectUtil.isEmpty(organizationMap)) {
if (ObjectUtil.isEmpty(deptMap)) {
// 未找到仓库
return userOrganizationList;
return userDeptList;
}
return extractLongList(userOrganizationList)
return extractLongList(userDeptList)
.stream()
.filter(organizationMap::containsKey)
.filter(deptMap::containsKey)
.map(id -> {
OrganizationDto organization = organizationMap.get(id);
return ObjectUtil.isEmpty(organization) ? "" : organization.getOrganizationId().toString();
DeptDto dept = deptMap.get(id);
return ObjectUtil.isEmpty(dept) ? "" : dept.getDeptId().toString();
})
.filter(StrUtil::isNotBlank)
.collect(Collectors.joining(","));
}
private String extractOrganizationNameList(String userOrganizationList, Map<Long, OrganizationDto> organizationMap) {
if (ObjectUtil.isEmpty(userOrganizationList)) {
private String extractDeptNameList(String userDeptList, Map<Long, DeptDto> deptMap) {
if (ObjectUtil.isEmpty(userDeptList)) {
// 无s授权住址
return "";
}
if (ObjectUtil.equals(userOrganizationList, KEY_ALL)) {
if (ObjectUtil.equals(userDeptList, KEY_ALL)) {
// 授权全部仓库
return KEY_NAME_ALL;
}
if (ObjectUtil.isEmpty(organizationMap)) {
if (ObjectUtil.isEmpty(deptMap)) {
// 未找到仓库
return userOrganizationList;
return userDeptList;
}
return extractLongList(userOrganizationList)
return extractLongList(userDeptList)
.stream()
.filter(organizationMap::containsKey)
.filter(deptMap::containsKey)
.map(id -> {
OrganizationDto organization = organizationMap.get(id);
return ObjectUtil.isEmpty(organization) ? "" : organization.getOrganizationName();
DeptDto dept = deptMap.get(id);
return ObjectUtil.isEmpty(dept) ? "" : dept.getDeptName();
})
.filter(StrUtil::isNotBlank)
.collect(Collectors.joining(","));
......@@ -342,8 +342,8 @@ public class UserServiceImpl extends AbstractService implements UserService {
user.setMobile(req.getMobile());
updated = true;
}
if (updated(req.getOrganizationId(), user.getOrganizationId())) {
user.setOrganizationId(req.getOrganizationId());
if (updated(req.getDeptId(), user.getDeptId())) {
user.setDeptId(req.getDeptId());
updated = true;
}
......@@ -369,13 +369,13 @@ public class UserServiceImpl extends AbstractService implements UserService {
user.setType(newUserType.getCode());
updated = true;
}
if (!CollectionUtil.disjunction(req.getAuthOrganizationAsList(), user.getAuthOrganizationAsList()).isEmpty()) {
user.setAuthOrganizationList(Optional.ofNullable(req.getAuthOrganizationList()).orElse(""));
if (!CollectionUtil.disjunction(req.getAuthDeptAsList(), user.getAuthDeptAsList()).isEmpty()) {
user.setAuthDeptList(Optional.ofNullable(req.getAuthDeptList()).orElse(""));
updated = true;
}
if (!CollectionUtil.disjunction(req.getRoleAsList(), user.getRoleAsList()).isEmpty()) {
user.setAuthOrganizationList(Optional.ofNullable(req.getAuthOrganizationList()).orElse(""));
user.setAuthDeptList(Optional.ofNullable(req.getAuthDeptList()).orElse(""));
updated = true;
}
......
This diff could not be displayed because it is too large.
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