更新字典项目模块,支持通过DictProject对象查询,新增英文名称字段,优化用户服务,增加根据用户ID查询本单位下所有用户的分页数据功能。
This commit is contained in:
@ -59,17 +59,14 @@ public class DictProjectController{
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询字典数据
|
* 查询字典数据(支持通过dictProject对象的code和parentType属性查询详情或列表)
|
||||||
* @param parentCode 字典父类code
|
* @param dictProject 查询条件
|
||||||
* @param toParentCode 字典父类对应的父类code
|
|
||||||
* @return 返回结果
|
* @return 返回结果
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询数据集合")
|
@ApiOperation("查询数据集合(支持详情查询)")
|
||||||
@GetMapping("/getDictList")
|
@GetMapping("/getDictList")
|
||||||
public BaseResponse<List<DictProject>> getDictList(@ApiParam(value = "字典父类code", required = true)String parentCode,
|
public BaseResponse<List<DictProject>> getDictList(DictProject dictProject) {
|
||||||
@ApiParam(value = "字典父类对应的父类code", required = true)String toParentCode){
|
return BaseResponse.success(dictProjectService.selectDictList(dictProject));
|
||||||
|
|
||||||
return BaseResponse.success(dictProjectService.getDictList(parentCode,toParentCode));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<result column="default_flag" jdbcType="VARCHAR" property="defaultFlag"/>
|
<result column="default_flag" jdbcType="VARCHAR" property="defaultFlag"/>
|
||||||
<result column="order_flag" jdbcType="INTEGER" property="orderFlag"/>
|
<result column="order_flag" jdbcType="INTEGER" property="orderFlag"/>
|
||||||
<result column="description" jdbcType="VARCHAR" property="description"/>
|
<result column="description" jdbcType="VARCHAR" property="description"/>
|
||||||
|
<result column="en_name" jdbcType="VARCHAR" property="enName"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<select id="selectMaxId">
|
<select id="selectMaxId">
|
||||||
select max(id) from dict_project
|
select max(id) from dict_project
|
||||||
|
@ -83,6 +83,12 @@ public class DictProject implements Serializable {
|
|||||||
@ApiModelProperty(value = "描述")
|
@ApiModelProperty(value = "描述")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 英文名称
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "英文名称")
|
||||||
|
private String enName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典子项
|
* 字典子项
|
||||||
*/
|
*/
|
||||||
|
@ -51,4 +51,16 @@ public class DictRegion implements Serializable {
|
|||||||
@ApiModelProperty(value = "缩写")
|
@ApiModelProperty(value = "缩写")
|
||||||
private String ab;
|
private String ab;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID路径,逗号分隔
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "ID路径,逗号分隔")
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称路径,逗号分隔
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "名称路径,逗号分隔")
|
||||||
|
private String pathName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public interface IDictProjectService extends IBaseService<DictProject>{
|
|||||||
List<DictProject> getDictList(String parentCode, String toParentCode);
|
List<DictProject> getDictList(String parentCode, String toParentCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有字典
|
* 查询所有字典(支持传code和parentType时返回详情,否则返回列表)
|
||||||
* @param dictProject
|
* @param dictProject
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package com.coscoshipping.ebtp.system.dict.service.impl;
|
package com.coscoshipping.ebtp.system.dict.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
|
import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
|
||||||
|
|
||||||
import com.coscoshipping.ebtp.system.dict.dao.DictProjectMapper;
|
import com.coscoshipping.ebtp.system.dict.dao.DictProjectMapper;
|
||||||
import com.coscoshipping.ebtp.system.dict.entity.DictProject;
|
import com.coscoshipping.ebtp.system.dict.entity.DictProject;
|
||||||
import com.coscoshipping.ebtp.system.dict.service.IDictProjectService;
|
import com.coscoshipping.ebtp.system.dict.service.IDictProjectService;
|
||||||
@ -74,7 +75,14 @@ public class DictProjectServiceImpl extends BaseServiceImpl<DictProjectMapper, D
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<DictProject> selectDictList(DictProject dictProject) {
|
public List<DictProject> selectDictList(DictProject dictProject) {
|
||||||
return this.list(mapper.getCustomQueryWrapper(dictProject).orderByAsc(DictProject::getOrderFlag));
|
|
||||||
|
if (dictProject != null && dictProject.getCode() != null && dictProject.getParentType() != null) {
|
||||||
|
return this.list(Wrappers.<DictProject>lambdaQuery()
|
||||||
|
.eq(DictProject::getCode, dictProject.getCode())
|
||||||
|
.eq(DictProject::getParentType, dictProject.getParentType())
|
||||||
|
.last("limit 1"));
|
||||||
|
}
|
||||||
|
return ListUtil.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,9 +13,11 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.coscoshipping.ebtp.system.user.entity.SysUser;
|
import com.coscoshipping.ebtp.system.user.entity.SysUser;
|
||||||
import com.coscoshipping.ebtp.system.user.service.SysUserService;
|
import com.coscoshipping.ebtp.system.user.service.SysUserService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@ -24,114 +26,112 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||||||
@RestController
|
@RestController
|
||||||
@Api(value = "门户用户表")
|
@Api(value = "门户用户表")
|
||||||
@RequestMapping("/v1/sysuser")
|
@RequestMapping("/v1/sysuser")
|
||||||
public class SysUserController{
|
public class SysUserController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SysUserService iSysUserService;
|
private SysUserService iSysUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入新数据
|
* 插入新数据
|
||||||
*
|
*
|
||||||
* @param sysUser
|
* @param sysUser
|
||||||
*
|
* @return
|
||||||
* @return
|
*/
|
||||||
*/
|
@ApiOperation("插入新数据")
|
||||||
@ApiOperation("插入新数据")
|
@PostMapping("/insert")
|
||||||
@PostMapping("/insert")
|
public BaseResponse<Boolean> insert(@ApiParam(value = "对象数据", required = true) @RequestBody @Valid SysUserVO sysUser) {
|
||||||
public BaseResponse<Boolean> insert(@ApiParam(value = "对象数据", required = true) @RequestBody @Valid SysUserVO sysUser){
|
|
||||||
|
|
||||||
Boolean i = iSysUserService.insertByVo(sysUser);
|
Boolean i = iSysUserService.insertByVo(sysUser);
|
||||||
|
|
||||||
return BaseResponse.success(i);
|
return BaseResponse.success(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改数据
|
* 修改数据
|
||||||
*
|
*
|
||||||
* @param sysUser
|
* @param sysUser
|
||||||
*
|
* @return
|
||||||
* @return
|
*/
|
||||||
*/
|
@ApiOperation("修改数据")
|
||||||
@ApiOperation("修改数据")
|
@PostMapping("/update")
|
||||||
@PostMapping("/update")
|
public BaseResponse<Boolean> update(@ApiParam(value = "对象数据", required = true) @RequestBody SysUser sysUser) {
|
||||||
public BaseResponse<Boolean> update(@ApiParam(value = "对象数据", required = true) @RequestBody SysUser sysUser){
|
|
||||||
|
|
||||||
Boolean i = iSysUserService.updateById(sysUser);
|
Boolean i = iSysUserService.updateById(sysUser);
|
||||||
|
|
||||||
return BaseResponse.success(i);
|
return BaseResponse.success(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据
|
* 查询数据
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*
|
* @return
|
||||||
* @return
|
*/
|
||||||
*/
|
@ApiOperation("根据id查询数据")
|
||||||
@ApiOperation("根据id查询数据")
|
@GetMapping("/{id}")
|
||||||
@GetMapping("/{id}")
|
public BaseResponse<SysUser> get(@ApiParam(value = "主键id", required = true) @PathVariable String id) {
|
||||||
public BaseResponse<SysUser> get(@ApiParam(value = "主键id", required = true) @PathVariable String id){
|
|
||||||
|
|
||||||
SysUser sysUser = iSysUserService.getById(id);
|
SysUser sysUser = iSysUserService.getById(id);
|
||||||
|
|
||||||
return BaseResponse.success(sysUser);
|
return BaseResponse.success(sysUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除数据
|
* 删除数据
|
||||||
* @param id 主键id
|
*
|
||||||
* @return BaseResponse<Boolean>
|
* @param id 主键id
|
||||||
* @author dino
|
* @return BaseResponse<Boolean>
|
||||||
* @date 2020/10/21 14:56
|
* @author dino
|
||||||
*/
|
* @date 2020/10/21 14:56
|
||||||
@ApiOperation(value = "delete",notes = "删除数据")
|
*/
|
||||||
@GetMapping("/del/{id}")
|
@ApiOperation(value = "delete", notes = "删除数据")
|
||||||
public BaseResponse<Boolean> delete(@ApiParam(value = "主键id", required = true) @PathVariable Long id) {
|
@GetMapping("/del/{id}")
|
||||||
Boolean i = iSysUserService.removeById(id);
|
public BaseResponse<Boolean> delete(@ApiParam(value = "主键id", required = true) @PathVariable Long id) {
|
||||||
return BaseResponse.success(i);
|
Boolean i = iSysUserService.removeById(id);
|
||||||
}
|
return BaseResponse.success(i);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据
|
* 查询数据
|
||||||
*
|
*
|
||||||
* @param param
|
* @param param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询列表数据")
|
@ApiOperation("查询列表数据")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public BaseResponse<List<SysUser>> list(@ApiParam(value = "查询对象数据", required = false) SysUser param) {
|
public BaseResponse<List<SysUser>> list(@ApiParam(value = "查询对象数据", required = false) SysUser param) {
|
||||||
//查询
|
//查询
|
||||||
LambdaQueryWrapper<SysUser> query = Wrappers.lambdaQuery(param);
|
LambdaQueryWrapper<SysUser> query = Wrappers.lambdaQuery(param);
|
||||||
List<SysUser> list = iSysUserService.list(query);
|
List<SysUser> list = iSysUserService.list(query);
|
||||||
//异常处理
|
//异常处理
|
||||||
//RespsExceptionEnum.FRAME_EXCEPTION_DEMO_NOT_FIND.customValid(list.isEmpty());
|
//RespsExceptionEnum.FRAME_EXCEPTION_DEMO_NOT_FIND.customValid(list.isEmpty());
|
||||||
return BaseResponse.success(list);
|
return BaseResponse.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询分页数据
|
* 查询分页数据
|
||||||
*
|
*
|
||||||
* @param sysUserVO 分页信息
|
* @param sysUserVO 分页信息
|
||||||
*
|
* @return 返回结果
|
||||||
* @return 返回结果
|
*/
|
||||||
*/
|
@ApiOperation("查询分页数据")
|
||||||
@ApiOperation("查询分页数据")
|
@PostMapping("/getPage")
|
||||||
@PostMapping("/getPage")
|
public BaseResponse<IPage<SysUser>> getPage(@ApiParam(value = "对象数据", required = true) @RequestBody SysUserVO sysUserVO) {
|
||||||
public BaseResponse<IPage<SysUser>> getPage(@ApiParam(value = "对象数据", required = true) @RequestBody SysUserVO sysUserVO){
|
|
||||||
|
|
||||||
return BaseResponse.success(iSysUserService.getPage(sysUserVO));
|
return BaseResponse.success(iSysUserService.getPage(sysUserVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询内部用户数据")
|
@ApiOperation("查询内部用户数据")
|
||||||
@PostMapping("/innerUserInfo")
|
@PostMapping("/innerUserInfo")
|
||||||
public BaseResponse<SysInnerUserInfo> getInnerUserInfo(@RequestParam String employeeNumber){
|
public BaseResponse<SysInnerUserInfo> getInnerUserInfo(@RequestParam String employeeNumber) {
|
||||||
|
|
||||||
return BaseResponse.success(iSysUserService.getInnerUserInfo(employeeNumber));
|
return BaseResponse.success(iSysUserService.getInnerUserInfo(employeeNumber));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID集合查询所有用户信息
|
* 根据用户ID集合查询所有用户信息
|
||||||
|
*
|
||||||
* @param ids 用户ID集合
|
* @param ids 用户ID集合
|
||||||
* @return 用户信息列表
|
* @return 用户信息列表
|
||||||
*/
|
*/
|
||||||
@ -141,4 +141,16 @@ public class SysUserController{
|
|||||||
List<SysUser> users = iSysUserService.getUsersByIds(ids);
|
List<SysUser> users = iSysUserService.getUsersByIds(ids);
|
||||||
return BaseResponse.success(users);
|
return BaseResponse.success(users);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询本单位下所有用户分页数据
|
||||||
|
*
|
||||||
|
* @param sysUserVO 分页及查询条件
|
||||||
|
* @return 分页用户数据
|
||||||
|
*/
|
||||||
|
@ApiOperation("根据用户ID查询本单位下所有用户分页数据")
|
||||||
|
@PostMapping("/getPageByUserCompany")
|
||||||
|
public BaseResponse<IPage<SysUser>> getPageByUserCompany(@ApiParam(value = "分页及查询条件", required = true) @RequestBody SysUserVO sysUserVO) {
|
||||||
|
return BaseResponse.success(iSysUserService.getPageByUserCompany(sysUserVO));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,14 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 对数据表 sys_user 操作的 service
|
* 对数据表 sys_user 操作的 service
|
||||||
* @author yss
|
|
||||||
*
|
*
|
||||||
|
* @author yss
|
||||||
*/
|
*/
|
||||||
public interface SysUserService extends IBaseService<SysUser>{
|
public interface SysUserService extends IBaseService<SysUser> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色分页
|
* 角色分页
|
||||||
|
*
|
||||||
* @param sysUserVO 标段信息
|
* @param sysUserVO 标段信息
|
||||||
* @return 返回结果
|
* @return 返回结果
|
||||||
*/
|
*/
|
||||||
@ -28,6 +29,7 @@ public interface SysUserService extends IBaseService<SysUser>{
|
|||||||
|
|
||||||
|
|
||||||
Boolean updateByVo(SysUserVO vo);
|
Boolean updateByVo(SysUserVO vo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过角色ID删除角色
|
* 通过角色ID删除角色
|
||||||
*
|
*
|
||||||
@ -40,8 +42,17 @@ public interface SysUserService extends IBaseService<SysUser>{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID集合查询所有用户信息
|
* 根据用户ID集合查询所有用户信息
|
||||||
|
*
|
||||||
* @param ids 用户ID集合
|
* @param ids 用户ID集合
|
||||||
* @return 用户信息列表
|
* @return 用户信息列表
|
||||||
*/
|
*/
|
||||||
List<SysUser> getUsersByIds(List<String> ids);
|
List<SysUser> getUsersByIds(List<String> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询本单位下所有用户分页数据
|
||||||
|
*
|
||||||
|
* @param sysUserVO 分页及查询条件
|
||||||
|
* @return 分页用户数据
|
||||||
|
*/
|
||||||
|
IPage<SysUser> getPageByUserCompany(SysUserVO sysUserVO);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import com.coscoshipping.ebtp.system.user.service.SysUserService;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对数据表 sys_user 操作的 serviceImpl
|
* 对数据表 sys_user 操作的 serviceImpl
|
||||||
@ -88,6 +89,39 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
|||||||
return userList;
|
return userList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<SysUser> getPageByUserCompany( SysUserVO sysUserVO) {
|
||||||
|
String userId = sysUserVO.getUserId();
|
||||||
|
// 1. 通过userId查找用户
|
||||||
|
SysUser user = this.getById(userId);
|
||||||
|
if (user == null) {
|
||||||
|
return new Page<>();
|
||||||
|
}
|
||||||
|
// 2. 查找用户所在公司
|
||||||
|
SysOrg company = sysOrgService.getCompanyByOrgId(user.getOrgId());
|
||||||
|
if (company == null || company.getOrgId() == null) {
|
||||||
|
return new Page<>();
|
||||||
|
}
|
||||||
|
// 3. 查找所有下级部门(含自身)
|
||||||
|
SysOrg queryOrg = new SysOrg();
|
||||||
|
queryOrg.setOrgId(company.getOrgId());
|
||||||
|
List<SysOrg> orgList = sysOrgService.queryOrgWithChildren(queryOrg);
|
||||||
|
if (orgList == null || orgList.isEmpty()) {
|
||||||
|
return new Page<>();
|
||||||
|
}
|
||||||
|
List<String> orgIds = orgList.stream().map(SysOrg::getOrgId).collect(Collectors.toList());
|
||||||
|
// 4. 分页查所有这些orgId下的用户
|
||||||
|
LambdaQueryWrapper<SysUser> userQuery = buildQueryWrapper(sysUserVO);
|
||||||
|
userQuery.in(SysUser::getOrgId, orgIds);
|
||||||
|
if (null == sysUserVO.getBasePageRequest()) {
|
||||||
|
sysUserVO.setBasePageRequest(new BasePageRequest());
|
||||||
|
}
|
||||||
|
IPage<SysUser> result = new Page<>(sysUserVO.getBasePageRequest().getPageNo(), sysUserVO.getBasePageRequest().getPageSize());
|
||||||
|
result = this.page(result, userQuery);
|
||||||
|
result.getRecords().forEach(u -> u.setPassword(null));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存前的数据校验
|
* 保存前的数据校验
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user