初始化
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.njcn.user;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月09日 20:59
|
||||
*/
|
||||
@Slf4j
|
||||
@MapperScan("com.njcn.**.mapper")
|
||||
@EnableFeignClients(basePackages = "com.njcn")
|
||||
@SpringBootApplication(scanBasePackages = "com.njcn")
|
||||
public class UserBootApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(UserBootApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.njcn.user.controller;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.user.enums.UserResponseEnum;
|
||||
import com.njcn.user.pojo.po.AuthClient;
|
||||
import com.njcn.user.service.IAuthClientService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-15
|
||||
*/
|
||||
@Slf4j
|
||||
@Validated
|
||||
@Api(tags = "客户端信息管理")
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/authClient")
|
||||
public class AuthClientController extends BaseController {
|
||||
|
||||
private final IAuthClientService authClientService;
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getAuthClientByName/{clientName}")
|
||||
@ApiOperation("根据客户端名查询信息")
|
||||
@ApiImplicitParam(name = "clientName", value = "客户端名称", required = true)
|
||||
public HttpResult<AuthClient> getAuthClientByName(@PathVariable("clientName") String clientName) {
|
||||
String methodDescribe = getMethodDescribe("getAuthClientByName");
|
||||
LogUtil.njcnDebug(log, "{},客户端为:{}", methodDescribe, clientName);
|
||||
AuthClient authClient = authClientService.getAuthClientByName(clientName);
|
||||
if (Objects.isNull(authClient)) {
|
||||
throw new BusinessException(UserResponseEnum.NOT_FOUND_CLIENT);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, authClient, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.njcn.user.controller;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.user.pojo.param.ComponentParam;
|
||||
import com.njcn.user.pojo.vo.ComponentVO;
|
||||
import com.njcn.user.service.IComponentService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/component")
|
||||
@Api(tags = "组件信息管理")
|
||||
@AllArgsConstructor
|
||||
public class ComponentController extends BaseController {
|
||||
|
||||
private final IComponentService componentService;
|
||||
|
||||
/**
|
||||
* 新增组件
|
||||
* @param componentParam 组件数据
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增组件")
|
||||
@ApiImplicitParam(name = "componentParam", value = "组件数据", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody @Validated ComponentParam componentParam) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},用户数据为:{}", methodDescribe, componentParam);
|
||||
boolean result = componentService.addComponent(componentParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除组件
|
||||
* @param id 组件id
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除组件")
|
||||
@ApiImplicitParam(name = "id", value = "组件id", required = true)
|
||||
public HttpResult<Boolean> delete(@RequestParam @Validated String id) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},组件id为:{}", methodDescribe, id);
|
||||
boolean result = componentService.deleteComponent(id);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改组件
|
||||
* @param componentParam 组件数据
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("修改组件")
|
||||
@ApiImplicitParam(name = "componentParam", value = "组件数据", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated ComponentParam.ComponentUpdateParam componentParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},更新的菜单信息为:{}", methodDescribe,componentParam);
|
||||
boolean result = componentService.updateComponent(componentParam);
|
||||
if (result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/componentTree")
|
||||
@ApiOperation("组件树")
|
||||
public HttpResult<List<ComponentVO>> getComponentTree(){
|
||||
String methodDescribe = getMethodDescribe("getComponentTree");
|
||||
List<ComponentVO> list = componentService.getComponentTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/userComponentTree")
|
||||
@ApiOperation("用户组件树")
|
||||
public HttpResult<List<ComponentVO>> getUserComponentTree(){
|
||||
String methodDescribe = getMethodDescribe("getUserComponentTree");
|
||||
List<ComponentVO> list = componentService.getUserComponentTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,260 @@
|
||||
package com.njcn.user.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.system.pojo.dto.AreaTreeDTO;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.user.pojo.param.DeptParam;
|
||||
import com.njcn.user.pojo.vo.DeptAllTreeVO;
|
||||
import com.njcn.user.pojo.vo.DeptTreeVO;
|
||||
import com.njcn.user.pojo.vo.DeptVO;
|
||||
import com.njcn.user.service.IDeptService;
|
||||
import com.njcn.web.pojo.param.DeptLineParam;
|
||||
import com.njcn.web.utils.ControllerUtil;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器(部门信息)
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/dept")
|
||||
@Api(tags = "部门管理")
|
||||
@AllArgsConstructor
|
||||
public class DeptController extends BaseController {
|
||||
|
||||
private final IDeptService deptService;
|
||||
|
||||
/**
|
||||
* 分页查询部门信息
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("查询部门信息")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<DeptVO>> list(@RequestBody @Validated DeptParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<DeptVO> result = deptService.listDept(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/getAreaTree")
|
||||
@ApiOperation("查询区域树")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id",value = "区域id",required = false),
|
||||
@ApiImplicitParam(name = "type", value = "区域类型", required = true)
|
||||
})
|
||||
public HttpResult<Object> getAreaTree(@RequestParam(required = false)@ApiParam("id")String id , @RequestParam("type") Integer type) {
|
||||
String methodDescribe = getMethodDescribe("getAreaTree");
|
||||
List<AreaTreeDTO> result = deptService.getAreaTree(id,type);
|
||||
if (!result.isEmpty()) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
*
|
||||
* @param deptParam 部门信息
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增部门信息")
|
||||
@ApiImplicitParam(name = "deptParam", value = "部门信息数据", required = true)
|
||||
public HttpResult<Object> add(@RequestBody @Validated DeptParam deptParam) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},部门信息数据为:{}", methodDescribe, deptParam);
|
||||
boolean result = deptService.addDept(deptParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改部门信息
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改部门信息")
|
||||
@ApiImplicitParam(name = "updateParam", value = "部门信息", required = true)
|
||||
public HttpResult<Object> update(@RequestBody @Validated DeptParam.DeptUpdateParam updateParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, updateParam);
|
||||
boolean result = deptService.updateDept(updateParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除部门信息
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除部门信息")
|
||||
@ApiImplicitParam(name = "ids", value = "部门索引", required = true)
|
||||
public HttpResult<Object> delete(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},部门信息数据为:{}", methodDescribe, ids);
|
||||
boolean result = deptService.deleteDept(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有关联信息
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/selectPid")
|
||||
@ApiOperation("是否有关联信息")
|
||||
@ApiImplicitParam(name = "ids", value = "部门索引", required = true)
|
||||
public HttpResult<Object> selectPid(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("selectPid");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, ids);
|
||||
boolean result = deptService.selectPid(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.DELETE_PID_EXIST, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.DELETE_PID_UNEXIST, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门树
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/deptTree")
|
||||
@ApiOperation("部门信息树")
|
||||
public HttpResult<Object> deptTree() {
|
||||
String methodDescribe = getMethodDescribe("deptTree");
|
||||
List<DeptTreeVO> result = deptService.deptTree();
|
||||
if (!result.isEmpty()) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
} else {
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件获取后代部门索引
|
||||
*
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getDeptDescendantIndexes")
|
||||
@ApiOperation("获取后代部门索引")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "部门id", required = true),
|
||||
@ApiImplicitParam(name = "type", value = "部门类型", required = true)
|
||||
})
|
||||
public HttpResult<List<DeptDTO>> getDeptDescendantIndexes(@RequestParam("id") String id, @RequestParam("type") List<Integer> type) {
|
||||
String methodDescribe = getMethodDescribe("getDeptDescendantIndexes");
|
||||
List<DeptDTO> deptInfos = deptService.getDeptDescendantIndexes(id,type);
|
||||
if (CollectionUtil.isEmpty(deptInfos)) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, deptInfos, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 功能描述: 根据区域索引获取部门索引
|
||||
*
|
||||
* @return
|
||||
* @author xy
|
||||
* @date 2022/2/14 15:04
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getDeptIdByArea")
|
||||
@ApiOperation("根据区域索引获取部门索引")
|
||||
@ApiIgnore
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "area", value = "区域id", required = true)
|
||||
})
|
||||
public HttpResult<String> getDeptIdByArea(@RequestParam("area") String area) {
|
||||
String methodDescribe = getMethodDescribe("getDeptIdByArea");
|
||||
String deptId = deptService.getDeptIdByArea(area);
|
||||
if (Objects.isNull(deptId)) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, deptId, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 功能描述: 根据区域索引获取部门索引
|
||||
*
|
||||
* @return
|
||||
* @author denghuajun
|
||||
* @date 2022/2/24 15:04
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getAreaIdByDeptId")
|
||||
@ApiOperation("根据区域索引获取部门索引")
|
||||
@ApiImplicitParam(name = "deptId", value = "部门id", required = true)
|
||||
public HttpResult<String> getAreaIdByDeptId(@RequestParam("deptId") String deptId) {
|
||||
String methodDescribe = getMethodDescribe("getAreaIdByDeptId");
|
||||
String areaId = deptService.getAreaIdByDeptId(deptId);
|
||||
if (Objects.isNull(areaId)) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, areaId, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据登录用户获取部门树
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/loginDeptTree")
|
||||
@ApiOperation("根据登录用户获取部门树")
|
||||
public HttpResult<Object> loginDeptTree() {
|
||||
String methodDescribe = getMethodDescribe("loginDeptTree");
|
||||
List<DeptAllTreeVO> result = deptService.loginDeptTree();
|
||||
if (!result.isEmpty()) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
} else {
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
package com.njcn.user.controller;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.user.pojo.param.FunctionParam;
|
||||
import com.njcn.user.pojo.param.RoleParam;
|
||||
import com.njcn.user.pojo.po.Function;
|
||||
import com.njcn.user.pojo.vo.FunctionVO;
|
||||
import com.njcn.user.service.IFunctionService;
|
||||
import com.njcn.user.service.IRoleFunctionService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/function")
|
||||
@Api(tags = "菜单信息管理")
|
||||
@AllArgsConstructor
|
||||
public class FunctionController extends BaseController {
|
||||
|
||||
private final IFunctionService functionService;
|
||||
|
||||
private final IRoleFunctionService roleFunctionService;
|
||||
|
||||
/**
|
||||
* 新增资源
|
||||
* @param functionParam 资源数据
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增菜单")
|
||||
@ApiImplicitParam(name = "functionParam", value = "菜单数据", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody @Validated FunctionParam functionParam) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},菜单数据为:{}", methodDescribe, functionParam);
|
||||
boolean result = functionService.addFunction(functionParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("修改菜单")
|
||||
@ApiImplicitParam(name = "functionParam", value = "菜单数据", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated FunctionParam.FunctionUpdateParam functionParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},更新的菜单信息为:{}", methodDescribe,functionParam);
|
||||
boolean result = functionService.updateFunction(functionParam);
|
||||
if (result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除菜单")
|
||||
@ApiImplicitParam(name = "id", value = "菜单id", required = true)
|
||||
public HttpResult<Boolean> delete(@RequestParam @Validated String id) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},删除的菜单id为:{}", methodDescribe,id);
|
||||
boolean result = functionService.deleteFunction(id);
|
||||
if (result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/functionTree")
|
||||
@ApiOperation("菜单树")
|
||||
public HttpResult<List<FunctionVO>> getFunctionTree() {
|
||||
String methodDescribe = getMethodDescribe("getFunctionTree");
|
||||
List<FunctionVO> list = functionService.getFunctionTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getFunctionById")
|
||||
@ApiOperation("菜单详情")
|
||||
@ApiImplicitParam(name = "id", value = "菜单id", required = true)
|
||||
public HttpResult<Function> getFunctionById(String id){
|
||||
String methodDescribe = getMethodDescribe("getFunctionById");
|
||||
LogUtil.njcnDebug(log, "{},菜单id为:{}", methodDescribe,id);
|
||||
Function function = functionService.getFunctionById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,function,methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getButtonById")
|
||||
@ApiOperation("获取按钮")
|
||||
@ApiImplicitParam(name = "id", value = "菜单id", required = true)
|
||||
public HttpResult<List<Function>> getButtonById(String id){
|
||||
String methodDescribe = getMethodDescribe("getButtonById");
|
||||
LogUtil.njcnDebug(log, "{},菜单id为:{}", methodDescribe,id);
|
||||
List<Function> list = functionService.getButtonsById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getRouteMenu")
|
||||
@ApiOperation("路由菜单")
|
||||
public HttpResult<List<FunctionVO>> getRouteMenu(){
|
||||
String methodDescribe = getMethodDescribe("getRouteMenu");
|
||||
List<FunctionVO> list = functionService.getRouteMenu();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@PostMapping("/assignFunctionByRoleIndexes")
|
||||
@ApiOperation("角色分配菜单")
|
||||
@ApiImplicitParam(name = "roleFunctionComponent", value = "角色信息", required = true)
|
||||
public HttpResult<Boolean> assignFunctionByRoleIndexes(@RequestBody @Validated RoleParam.RoleFunctionComponent roleFunctionComponent) {
|
||||
String methodDescribe = getMethodDescribe("assignFunctionByRoleIndexes");
|
||||
LogUtil.njcnDebug(log, "{},传入的角色id和资源id集合为:{}", methodDescribe,roleFunctionComponent);
|
||||
boolean result = functionService.updateRoleComponent(roleFunctionComponent);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/userFunctionTree")
|
||||
@ApiOperation("用户菜单树")
|
||||
public HttpResult<List<FunctionVO>> getUserFunctionTree() {
|
||||
String methodDescribe = getMethodDescribe("getUserFunctionTree");
|
||||
List<FunctionVO> list = functionService.getUserFunctionTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.njcn.user.controller;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.user.pojo.param.HomePageParam;
|
||||
import com.njcn.user.pojo.po.HomePage;
|
||||
import com.njcn.user.service.IHomePageService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/homePage")
|
||||
@Api(tags = "驾驶舱配置管理")
|
||||
@AllArgsConstructor
|
||||
public class HomePageController extends BaseController {
|
||||
|
||||
private final IHomePageService homePageService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增驾驶舱")
|
||||
@ApiImplicitParam(name = "homePage", value = "驾驶舱实体", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody HomePageParam homePage){
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},驾驶舱实体为:{}", methodDescribe,homePage);
|
||||
boolean result = homePageService.add(homePage);
|
||||
if (result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true,methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false,methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除驾驶舱")
|
||||
@ApiImplicitParam(name = "id", value = "驾驶舱id", required = true)
|
||||
public HttpResult<Boolean> delete(@RequestParam String id){
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},驾驶舱实体为:{}", methodDescribe,id);
|
||||
boolean result = homePageService.delete(id);
|
||||
if (result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true,methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false,methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.UPDATE)
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("修改驾驶舱")
|
||||
@ApiImplicitParam(name = "homePageUpdate", value = "驾驶舱实体", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated HomePageParam.HomePageUpdateParam homePageUpdate){
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改的驾驶舱实体:{}", methodDescribe,homePageUpdate);
|
||||
boolean result = homePageService.update(homePageUpdate);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,result,methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getHomePages")
|
||||
@ApiOperation("用户驾驶舱")
|
||||
public HttpResult<List<HomePage>> getHomePages(){
|
||||
String methodDescribe = getMethodDescribe("getHomePages");
|
||||
List<HomePage> list = homePageService.getHomePagesByUserId(RequestUtil.getUserIndex());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getHomePageById")
|
||||
@ApiOperation("驾驶舱详情")
|
||||
@ApiImplicitParam(name = "id", value = "驾驶舱id", required = true)
|
||||
public HttpResult<HomePage> getHomePageById(String id){
|
||||
String methodDescribe = getMethodDescribe("getHomePageById");
|
||||
LogUtil.njcnDebug(log, "{},传入的ID为:{}", methodDescribe,id);
|
||||
HomePage homePage = homePageService.getHomePageById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,homePage,methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getUsedHomePage")
|
||||
@ApiOperation("已使用驾驶舱")
|
||||
@ApiImplicitParam(name = "path", value = "驾驶舱路径", required = true)
|
||||
public HttpResult<List<String>> getUsedHomePage(String path){
|
||||
String methodDescribe = getMethodDescribe("getUsedHomePage");
|
||||
LogUtil.njcnDebug(log, "{},传入的驾驶舱路径为:{}", methodDescribe,path);
|
||||
List<String> list = homePageService.getUsedHomePage(path);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.njcn.user.controller;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.user.pojo.param.RoleParam;
|
||||
import com.njcn.user.pojo.po.RoleComponent;
|
||||
import com.njcn.user.service.IRoleComponentService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/roleComponent")
|
||||
@Api(tags = "角色组件管理")
|
||||
@AllArgsConstructor
|
||||
public class RoleComponentController extends BaseController {
|
||||
|
||||
private final IRoleComponentService roleComponentService;
|
||||
|
||||
/**
|
||||
* 根据角色id查询相关联的组件
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/selectRoleComponent")
|
||||
@ApiOperation("角色组件树")
|
||||
@ApiImplicitParam(name = "idList", value = "角色索引集合", required = true)
|
||||
public HttpResult<Object> selectRoleComponent(@RequestParam("idList") List<String> idList) {
|
||||
String methodDescribe = getMethodDescribe("selectRoleComponent");
|
||||
LogUtil.njcnDebug(log, "{},传入的角色id集合:{}", methodDescribe, idList);
|
||||
List<String> result = roleComponentService.selectRoleComponent(idList);
|
||||
if (result.isEmpty()) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, result, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@PostMapping("/assignComponentsByRoleIndex")
|
||||
@ApiOperation("角色分配组件")
|
||||
@ApiImplicitParam(name = "roleFunctionComponent", value = "角色信息", required = true)
|
||||
public HttpResult<Boolean> assignComponentsByRoleIndex(@RequestBody @Validated RoleParam.RoleFunctionComponent roleFunctionComponent) {
|
||||
String methodDescribe = getMethodDescribe("assignComponentsByRoleIndex");
|
||||
LogUtil.njcnDebug(log, "{},传入的角色Guid:{},传入的组件集合为:{}", methodDescribe,roleFunctionComponent);
|
||||
boolean result = roleComponentService.updateRoleComponent(roleFunctionComponent);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.njcn.user.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.user.pojo.param.DeptParam;
|
||||
import com.njcn.user.pojo.param.RoleParam;
|
||||
import com.njcn.user.pojo.po.Role;
|
||||
import com.njcn.user.pojo.vo.RoleVO;
|
||||
import com.njcn.user.service.IRoleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/role")
|
||||
@Api(tags = "角色管理")
|
||||
@AllArgsConstructor
|
||||
public class RoleController extends BaseController {
|
||||
|
||||
private final IRoleService roleService;
|
||||
|
||||
/**
|
||||
* 分页查询角色信息
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("查询角色信息")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<RoleVO>> list(@RequestBody @Validated RoleParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<RoleVO> result = roleService.listRole(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
*
|
||||
* @param roleParam 角色新增
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增角色信息")
|
||||
@ApiImplicitParam(name = "roleParam", value = "角色信息数据", required = true)
|
||||
public HttpResult<Object> add(@RequestBody @Validated RoleParam roleParam) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},角色信息数据为:{}", methodDescribe, roleParam);
|
||||
boolean result = roleService.addRole(roleParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改角色信息
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改角色信息")
|
||||
@ApiImplicitParam(name = "updateParam", value = "角色信息", required = true)
|
||||
public HttpResult<Object> update(@RequestBody @Validated RoleParam.RoleUpdateParam updateParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},角色信息数据为:{}", methodDescribe, updateParam);
|
||||
boolean result = roleService.updateRole(updateParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除角色信息
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除角色信息")
|
||||
@ApiImplicitParam(name = "ids", value = "角色索引", required = true)
|
||||
public HttpResult<Object> delete(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},角色信息数据为:{}", methodDescribe, ids);
|
||||
boolean result = roleService.deleteRole(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色id查询相关联的资源和组件
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/selectFunctionComponent")
|
||||
@ApiOperation("根据角色id查询相关联的资源和组件")
|
||||
@ApiImplicitParam(name = "ids", value = "角色索引", required = true)
|
||||
public HttpResult<Object> selectFunctionComponent(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("selectFunctionComponent");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, ids);
|
||||
boolean result = roleService.selectRelevance(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.DELETE_PID_EXIST, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.DELETE_PID_UNEXIST, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据权限类型查询相关角色
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/selectRoleDetail")
|
||||
@ApiOperation("根据权限类型查询相关角色")
|
||||
@ApiImplicitParam(name = "id", value = "权限类型索引", required = true)
|
||||
public HttpResult<Object> selectRoleDetail(@RequestParam("id") Integer id) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, id);
|
||||
List<Role> result = roleService.selectRoleDetail(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.njcn.user.controller;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.user.service.IRoleFunctionService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/roleFunction")
|
||||
@Api(tags = "角色资源管理")
|
||||
@AllArgsConstructor
|
||||
public class RoleFunctionController extends BaseController {
|
||||
private final IRoleFunctionService roleFunctionService;
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/getFunctionsByRoleIndex")
|
||||
@ApiOperation("根据角色id查询相关联的资源")
|
||||
@ApiImplicitParam(name = "id", value = "角色id", required = true)
|
||||
public HttpResult<List<String>> getFunctionsByRoleIndex(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getFunctionsByRoleIndex");
|
||||
LogUtil.njcnDebug(log, "{},传入的角色id:{}", methodDescribe,id);
|
||||
List<String> list = roleFunctionService.getFunctionsByRoleIndex(id);
|
||||
if(list.isEmpty()){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, list, methodDescribe);
|
||||
}else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,337 @@
|
||||
package com.njcn.user.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.LogInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.constant.SecurityConstants;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.common.utils.sm.DesUtils;
|
||||
import com.njcn.common.utils.sm.Sm2;
|
||||
import com.njcn.poi.util.PoiUtil;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.user.enums.UserResponseEnum;
|
||||
import com.njcn.user.pojo.dto.UserDTO;
|
||||
import com.njcn.user.pojo.param.UserParam;
|
||||
import com.njcn.user.pojo.param.UserPasswordParam;
|
||||
import com.njcn.user.pojo.vo.UserVO;
|
||||
import com.njcn.user.service.IUserService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
@Api(tags = "用户信息管理")
|
||||
@AllArgsConstructor
|
||||
public class UserController extends BaseController {
|
||||
|
||||
private final IUserService userService;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getUserByName/{loginName}")
|
||||
@ApiOperation("根据登录名查询用户信息")
|
||||
@ApiImplicitParam(name = "loginName", value = "登录名", required = true)
|
||||
public HttpResult<UserDTO> getUserByName(@PathVariable String loginName) {
|
||||
RequestUtil.saveLoginName(loginName);
|
||||
String methodDescribe = getMethodDescribe("getUserByName");
|
||||
LogUtil.njcnDebug(log, "{},登录名为:{}", methodDescribe, loginName);
|
||||
UserDTO user = userService.getUserByName(loginName);
|
||||
if (Objects.isNull(user)) {
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_WRONG_PWD);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, user, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/judgeUserStatus/{loginName}")
|
||||
@ApiOperation("认证后根据用户名判断用户状态")
|
||||
@ApiImplicitParam(name = "loginName", value = "登录名", required = true)
|
||||
public HttpResult<Boolean> judgeUserStatus(@PathVariable String loginName) {
|
||||
RequestUtil.saveLoginName(loginName);
|
||||
String methodDescribe = getMethodDescribe("judgeUserStatus");
|
||||
LogUtil.njcnDebug(log, "{},登录名为:{}", methodDescribe, loginName);
|
||||
userService.judgeUserStatus(loginName);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增用户
|
||||
*
|
||||
* @param addUserParam 用户数据
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增用户")
|
||||
@ApiImplicitParam(name = "addUserParam", value = "新增用户", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody @Validated UserParam.UserAddParam addUserParam) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},用户数据为:{}", methodDescribe, addUserParam);
|
||||
boolean result = userService.addUser(addUserParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param id 用户id
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除用户")
|
||||
@ApiImplicitParam(name = "id", value = "用户id", required = true)
|
||||
public HttpResult<Boolean> delete(@RequestParam @Validated String id) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},用户id为:{}", methodDescribe, id);
|
||||
boolean result = userService.deleteUser(id);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*
|
||||
* @param updateUserParam 用户数据
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("修改用户")
|
||||
@ApiImplicitParam(name = "updateUserParam", value = "修改用户", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated UserParam.UserUpdateParam updateUserParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},用户数据为:{}", methodDescribe, updateUserParam);
|
||||
boolean result = userService.updateUser(updateUserParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("列表分页")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<UserVO>> getUserList(@RequestBody @Validated UserParam.UserQueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("getUserList");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<UserVO> list = userService.userList(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/exportUser")
|
||||
@ApiOperation("用户数据")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<String> exportUser(@RequestBody @Validated UserParam.UserQueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("exportUser");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userService.exportUser(queryParam,methodDescribe), methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.DOWNLOAD)
|
||||
@GetMapping("/exportUserExcel")
|
||||
@ApiOperation("导出用户数据")
|
||||
@ApiImplicitParam(name = "filePath", value = "报表路径", required = true)
|
||||
public void exportUserExcel(String filePath, HttpServletResponse response) {
|
||||
PoiUtil.exportFileByAbsolutePath(filePath,response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/checkUserList")
|
||||
@ApiOperation("审核用户列表")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<UserVO>> getCheckList(@RequestBody @Validated UserParam.UserQueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("getCheckList");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<UserVO> list = userService.checkUserList(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id获取用户详情
|
||||
*
|
||||
* @param id 用户id
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getUserById")
|
||||
@ApiOperation("用户详情")
|
||||
@ApiImplicitParam(name = "id", value = "用户id", required = true)
|
||||
public HttpResult<UserVO> getUserById(@RequestParam @Validated String id) {
|
||||
String methodDescribe = getMethodDescribe("getUserById");
|
||||
LogUtil.njcnDebug(log, "{},用户id为:{}", methodDescribe, id);
|
||||
UserVO userVO = userService.getUserById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userVO, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核用户
|
||||
*
|
||||
* @param list 用户id集合
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PutMapping("/check")
|
||||
@ApiOperation("审核用户")
|
||||
@ApiImplicitParam(name = "list", value = "用户id集合", required = true)
|
||||
public HttpResult<Boolean> check(@RequestBody @Validated List<String> list) {
|
||||
String methodDescribe = getMethodDescribe("check");
|
||||
LogUtil.njcnDebug(log, "{},用户id集合为:{}", methodDescribe, list);
|
||||
boolean result = userService.checkUser(list);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param id 用户id
|
||||
* @param newPassword 用户新密码
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PutMapping("/updatePassword")
|
||||
@ApiOperation("修改密码")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "用户id", required = true),
|
||||
@ApiImplicitParam(name = "newPassword", value = "用户新密码", required = true)
|
||||
})
|
||||
public HttpResult<Boolean> updatePassword(String id, String newPassword) {
|
||||
String methodDescribe = getMethodDescribe("updatePassword");
|
||||
LogUtil.njcnDebug(log, "{},用户id:{},修改的用户密码为:{}", methodDescribe, id, newPassword);
|
||||
boolean result = userService.updatePassword(id, newPassword);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/generateSm2Key")
|
||||
@ApiOperation("根据登录名获取公钥")
|
||||
@ApiImplicitParam(name = "loginName", value = "登录名", required = true)
|
||||
public HttpResult<String> generateSm2Key(String loginName, @ApiIgnore HttpServletRequest request) {
|
||||
if (StrUtil.isBlankIfStr(loginName)) {
|
||||
RequestUtil.saveLoginName(LogInfo.UNKNOWN_USER);
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USERNAME_INVALID);
|
||||
}
|
||||
String methodDescribe = getMethodDescribe("generateSm2Key");
|
||||
loginName = DesUtils.aesDecrypt(loginName);
|
||||
RequestUtil.saveLoginName(loginName);
|
||||
Map<String, String> keyMap;
|
||||
try {
|
||||
keyMap = Sm2.getSm2CipHer();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new BusinessException(CommonResponseEnum.SM2_CIPHER_ERROR);
|
||||
}
|
||||
String publicKey = keyMap.get("publicKey");
|
||||
String privateKey = keyMap.get("privateKey");
|
||||
String ip = request.getHeader(SecurityConstants.REQUEST_HEADER_KEY_CLIENT_REAL_IP);
|
||||
//秘钥先删除再添加
|
||||
redisUtil.delete(loginName + ip);
|
||||
// 保存私钥到 redis
|
||||
redisUtil.saveByKeyWithExpire(loginName + ip, privateKey, 5*60L);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, publicKey, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@PutMapping("/updateUserLoginErrorTimes/{loginName}")
|
||||
@ApiOperation("更新用户登录认证密码错误次数")
|
||||
@ApiImplicitParam(name = "loginName", value = "登录名", required = true)
|
||||
public HttpResult<String> updateUserLoginErrorTimes(@PathVariable String loginName) {
|
||||
RequestUtil.saveLoginName(loginName);
|
||||
String methodDescribe = getMethodDescribe("updateUserLoginErrorTimes");
|
||||
LogUtil.njcnDebug(log, "{},登录名为:{}", methodDescribe, loginName);
|
||||
String result = userService.updateUserLoginErrorTimes(loginName);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 密码二次确认
|
||||
* @param password 确认密码
|
||||
*/
|
||||
@OperateInfo
|
||||
@GetMapping("/passwordConfirm")
|
||||
@ApiOperation("密码二次确认")
|
||||
@ApiImplicitParam(name = "password", value = "确认密码")
|
||||
public HttpResult<Boolean> passwordConfirm(String password) {
|
||||
String methodDescribe = getMethodDescribe("passwordConfirm");
|
||||
LogUtil.njcnDebug(log, "{},用户输入的密码:{}", methodDescribe, password);
|
||||
boolean result = userService.passwordConfirm(password);
|
||||
if (result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首次登录修改密码
|
||||
*
|
||||
* @param userPasswordParam 用户信息
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PutMapping("/updateFirstPassword")
|
||||
@ApiOperation("首次登录修改密码")
|
||||
@ApiImplicitParam(name = "userPasswordParam", value = "加密用户信息", required = true)
|
||||
public HttpResult<Boolean> updateFirstPassword(@RequestBody @Validated UserPasswordParam userPasswordParam, @ApiIgnore HttpServletRequest request) {
|
||||
RequestUtil.saveLoginName(DesUtils.aesDecrypt(userPasswordParam.getName()));
|
||||
String methodDescribe = getMethodDescribe("updateFirstPassword");
|
||||
LogUtil.njcnDebug(log, "{},加密用户信息为:{}", methodDescribe, userPasswordParam);
|
||||
String ip = request.getHeader(SecurityConstants.REQUEST_HEADER_KEY_CLIENT_REAL_IP);
|
||||
boolean result = userService.updateFirstPassword(userPasswordParam.getName(), userPasswordParam.getPassword(), ip);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.user.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/userRole")
|
||||
public class UserRoleController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.user.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/userSet")
|
||||
public class UserSetController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.user.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/userStrategy")
|
||||
public class UserStrategyController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.njcn.user.init;
|
||||
|
||||
import com.njcn.user.service.IFunctionService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
*
|
||||
* 容器启动完成时加载角色权限规则至Redis缓存
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class InitPermissionRoles implements CommandLineRunner {
|
||||
|
||||
private final IFunctionService functionService;
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
functionService.refreshRolesFunctionsCache();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.user.pojo.po.AuthClient;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-15
|
||||
*/
|
||||
public interface AuthClientMapper extends BaseMapper<AuthClient> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.user.pojo.dto.ComponentDTO;
|
||||
import com.njcn.user.pojo.po.Component;
|
||||
import com.njcn.user.pojo.vo.ComponentVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface ComponentMapper extends BaseMapper<Component> {
|
||||
|
||||
List<ComponentDTO> getAllComponent();
|
||||
|
||||
List<ComponentDTO> getComponentByList(@Param("list")List<String> list);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.njcn.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.user.pojo.vo.DeptAllTreeVO;
|
||||
import com.njcn.user.pojo.vo.DeptTreeVO;
|
||||
import com.njcn.user.pojo.vo.DeptVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface DeptMapper extends BaseMapper<Dept> {
|
||||
|
||||
/**
|
||||
* 分页查询字典数据
|
||||
* @param page 分页数据
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 字典数据
|
||||
*/
|
||||
Page<DeptVO> page(@Param("page")Page<DeptVO> page, @Param("ew") QueryWrapper<DeptVO> queryWrapper);
|
||||
|
||||
// /**
|
||||
// * 查询部门排序最后一位
|
||||
// * @return 排序最后一位
|
||||
// */
|
||||
// Integer getSortNum();
|
||||
|
||||
/**
|
||||
* 查询父节点的所有上层节点
|
||||
* @param id
|
||||
* @return 父节点的所有上层节点
|
||||
*/
|
||||
String getIdString(@Param("id")String id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return 部门树
|
||||
*/
|
||||
List<DeptTreeVO> getDeptTree(@Param("id")String id, @Param("type")List<Integer> type);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return 部门树
|
||||
*/
|
||||
List<DeptAllTreeVO> getAllDeptTree(@Param("id")String id, @Param("type")List<Integer> type);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param state 部门状态
|
||||
* @return 查询已经绑定的行政区域
|
||||
*/
|
||||
List<String> deptArea(@Param("state")Integer state);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ids 部门集合
|
||||
* @param state 状态
|
||||
* @return 查询
|
||||
*/
|
||||
List<Dept> selectPid(@Param("ids")List<String> ids,@Param("state")Integer state);
|
||||
|
||||
/**
|
||||
* 删除部门和监测点的绑定
|
||||
* @param ids 部门集合
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteDeptLine(@Param("ids")List<String> ids);
|
||||
|
||||
/**
|
||||
* 删除部门和用户的绑定
|
||||
* @param ids 部门集合
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteUserDept(@Param("ids")List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据条件获取后代部门索引
|
||||
* @param id 部门id
|
||||
* @param type 指定部门类型
|
||||
* @return 后代部门索引
|
||||
*/
|
||||
List<DeptDTO> getDeptDescendantIndexes(@Param("id")String id, @Param("type")List<Integer> type);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.njcn.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.user.pojo.po.Function;
|
||||
import com.njcn.user.pojo.vo.FunctionVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface FunctionMapper extends BaseMapper<Function> {
|
||||
|
||||
List<FunctionVO> getAllFunctions();
|
||||
|
||||
List<FunctionVO> getFunctionsByList(@Param("list")List<String> functionList);
|
||||
|
||||
List<FunctionVO> getUserFunctionsByList(@Param("list")List<String> functionList);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.user.pojo.po.HomePage;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface HomePageMapper extends BaseMapper<HomePage> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.user.pojo.po.Component;
|
||||
import com.njcn.user.pojo.po.RoleComponent;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface RoleComponentMapper extends BaseMapper<RoleComponent> {
|
||||
/**
|
||||
* 根据角色id集合查询是否绑定
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<RoleComponent> selectRoleComponet(@Param("ids")List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.user.pojo.po.Component;
|
||||
import com.njcn.user.pojo.po.RoleFunction;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface RoleFunctionMapper extends BaseMapper<RoleFunction> {
|
||||
/**
|
||||
* 根据角色id集合查询是否绑定
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<RoleFunction> selectRoleFunction(@Param("ids")List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.njcn.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.user.pojo.po.Role;
|
||||
import com.njcn.user.pojo.vo.RoleVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface RoleMapper extends BaseMapper<Role> {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询字典数据
|
||||
* @param page 分页数据
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 字典数据
|
||||
*/
|
||||
Page<RoleVO> page(@Param("page")Page<RoleVO> page, @Param("ew") QueryWrapper<RoleVO> queryWrapper);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除角色和用户的绑定
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteUserRole(@Param("ids")List<String> ids);
|
||||
|
||||
/**
|
||||
* 删除角色和资源的绑定
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteFunctionRole(@Param("ids")List<String> ids);
|
||||
|
||||
/**
|
||||
* 删除角色和组件的绑定
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteComponentRole(@Param("ids")List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.njcn.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.user.pojo.dto.excel.UserExcel;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.user.pojo.vo.UserVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
/**
|
||||
* 根据部门ids集合查询是否有用户绑定
|
||||
*
|
||||
* @param ids 部门id集合
|
||||
* @param state 用户状态
|
||||
* @return 绑定的结果
|
||||
*/
|
||||
List<User> selectDeptsId(@Param("ids") List<String> ids, @Param("state") Integer state);
|
||||
|
||||
/**
|
||||
* 分页查询用户数据
|
||||
*
|
||||
* @param page 分页数据
|
||||
* @param queryWrapper 查询条件
|
||||
* @param state 用户状态
|
||||
* @param type 用户类型
|
||||
* @return 用户数据
|
||||
*/
|
||||
Page<UserVO> page(@Param("page") Page<UserVO> page, @Param("ew") QueryWrapper<UserVO> queryWrapper, @Param("state") Integer state, @Param("type") Integer type);
|
||||
|
||||
/**
|
||||
* 审核用户列表
|
||||
*
|
||||
* @param page 分页数据
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 用户数据
|
||||
*/
|
||||
Page<UserVO> checkPage(@Param("page") Page<UserVO> page, @Param("ew") QueryWrapper<UserVO> queryWrapper);
|
||||
|
||||
/**
|
||||
* 查询需要导出的用户数据
|
||||
*
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 查询出的用户数据
|
||||
*/
|
||||
List<UserExcel> queryExportUser(@Param("ew") QueryWrapper<UserExcel> queryWrapper);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.user.pojo.po.UserRole;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface UserRoleMapper extends BaseMapper<UserRole> {
|
||||
/**
|
||||
* 根据角色id集合查询是否绑定
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<UserRole> selectUserRole(@Param("ids")List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.user.pojo.po.UserSet;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface UserSetMapper extends BaseMapper<UserSet> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.user.pojo.po.UserStrategy;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface UserStrategyMapper extends BaseMapper<UserStrategy> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.user.mapper.AuthClientMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.user.mapper.ComponentMapper">
|
||||
|
||||
<select id="getAllComponent" resultType="ComponentDTO">
|
||||
SELECT * from sys_component WHERE State = 1
|
||||
</select>
|
||||
|
||||
<select id="getComponentByList" resultType="ComponentDTO">
|
||||
SELECT * from sys_component WHERE State = 1 and Id in
|
||||
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,158 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.user.mapper.DeptMapper">
|
||||
|
||||
<!--获取部门分页列表-->
|
||||
<select id="page" resultType="DeptVO">
|
||||
SELECT sys_dept.*,
|
||||
sys_area.name areaName
|
||||
FROM sys_dept sys_dept
|
||||
,sys_area sys_area
|
||||
WHERE sys_dept.area = sys_area.id
|
||||
AND ${ew.sqlSegment}
|
||||
</select>
|
||||
|
||||
<!-- <!–查询排序–>-->
|
||||
<!-- <select id="getSortNum" resultType="int">-->
|
||||
<!-- SELECT MAX(sys_dept.sort) sort-->
|
||||
<!-- FROM sys_dept sys_dept-->
|
||||
<!-- WHERE sys_dept.state = 1-->
|
||||
<!-- </select>-->
|
||||
|
||||
<select id="getIdString" resultType="String">
|
||||
SELECT sys_dept.pids pids
|
||||
FROM sys_dept sys_dept
|
||||
WHERE sys_dept.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getDeptTree" resultType="DeptTreeVO">
|
||||
SELECT
|
||||
T3.*,
|
||||
T5.id area,
|
||||
T5.name areaName
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
@codes AS _ids,
|
||||
(
|
||||
SELECT @codes := GROUP_CONCAT( id ) FROM sys_dept WHERE FIND_IN_SET( pid, @codes ) ) AS T1
|
||||
FROM
|
||||
sys_dept s,
|
||||
( SELECT @codes := #{id} ) T4
|
||||
WHERE
|
||||
@codes IS NOT NULL
|
||||
<if test="type != null">
|
||||
AND s.type in
|
||||
<foreach collection="type" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
) T2,
|
||||
sys_dept T3,
|
||||
sys_area T5
|
||||
WHERE
|
||||
FIND_IN_SET( T3.id, T2._ids )
|
||||
AND t3.area = t5.id
|
||||
AND t3.State = 1
|
||||
</select>
|
||||
|
||||
<select id="getAllDeptTree" resultType="DeptAllTreeVO">
|
||||
SELECT
|
||||
T3.*
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
@codes AS _ids,
|
||||
(
|
||||
SELECT @codes := GROUP_CONCAT( id ) FROM sys_dept WHERE FIND_IN_SET( pid, @codes ) ) AS T1
|
||||
FROM
|
||||
sys_dept s,
|
||||
( SELECT @codes := #{id} ) T4
|
||||
WHERE
|
||||
@codes IS NOT NULL
|
||||
<if test="type != null">
|
||||
AND s.type in
|
||||
<foreach collection="type" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
) T2,
|
||||
sys_dept T3,
|
||||
sys_area T5
|
||||
WHERE
|
||||
FIND_IN_SET( T3.id, T2._ids )
|
||||
AND t3.area = t5.id
|
||||
AND t3.State = 1
|
||||
</select>
|
||||
|
||||
<select id="deptArea" resultType="String">
|
||||
SELECT sys_dept.area
|
||||
FROM sys_dept sys_dept
|
||||
WHERE sys_dept.state = #{state}
|
||||
</select>
|
||||
|
||||
<select id="selectPid" resultType="Dept">
|
||||
SELECT sys_dept.*
|
||||
FROM sys_dept sys_dept
|
||||
WHERE sys_dept.pid in
|
||||
<foreach item="item" index="index" collection="ids" open="("
|
||||
separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
AND sys_dept.state = #{state}
|
||||
</select>
|
||||
|
||||
<delete id="deleteDeptLine">
|
||||
DELETE FROM pq_dept_line where id in
|
||||
<foreach item="item" index="index" collection="ids" open="("
|
||||
separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="deleteUserDept">
|
||||
update sys_user set Dept_Id = "" where Dept_Id in
|
||||
<foreach item="item" index="index" collection="ids" open="("
|
||||
separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="getDeptDescendantIndexes" resultType="DeptDTO">
|
||||
SELECT
|
||||
T3.id,
|
||||
T3.pid,
|
||||
T3.pids,
|
||||
T3.NAME,
|
||||
T3.type,
|
||||
T5.NAME area ,
|
||||
T3.Remark
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
@codes AS _ids,
|
||||
(
|
||||
SELECT @codes := GROUP_CONCAT( id ) FROM sys_dept WHERE FIND_IN_SET( pid, @codes ) ) AS T1
|
||||
FROM
|
||||
sys_dept s,
|
||||
( SELECT @codes := #{id} ) T4
|
||||
WHERE
|
||||
@codes IS NOT NULL
|
||||
<if test="type != null">
|
||||
AND s.type in
|
||||
<foreach collection="type" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
) T2,
|
||||
sys_dept T3,
|
||||
sys_area T5
|
||||
WHERE
|
||||
FIND_IN_SET( T3.id, T2._ids )
|
||||
AND t3.area = t5.id
|
||||
AND t3.State = 1
|
||||
Order by T3.sort asc
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.user.mapper.FunctionMapper">
|
||||
|
||||
<select id="getAllFunctions" resultType="FunctionVO">
|
||||
SELECT
|
||||
Id,Pid,
|
||||
`Name` title,
|
||||
`Code`,
|
||||
Path routePath,
|
||||
Icon,Sort,
|
||||
Type,
|
||||
Remark
|
||||
FROM
|
||||
sys_function
|
||||
WHERE
|
||||
STATE = 1 AND Type IN(0,1)
|
||||
</select>
|
||||
|
||||
<select id="getFunctionsByList" resultType="FunctionVO">
|
||||
SELECT
|
||||
Id,Pid,
|
||||
`Name` title,
|
||||
`Code`,
|
||||
Path routePath,
|
||||
Icon,Sort,
|
||||
Type,
|
||||
Remark
|
||||
FROM
|
||||
sys_function
|
||||
WHERE
|
||||
STATE = 1 AND Type = 0
|
||||
AND
|
||||
Id in
|
||||
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getUserFunctionsByList" resultType="FunctionVO">
|
||||
SELECT
|
||||
Id,Pid,
|
||||
`Name` title,
|
||||
`Code`,
|
||||
Path routePath,
|
||||
Icon,Sort,
|
||||
Type,
|
||||
Remark
|
||||
FROM
|
||||
sys_function
|
||||
WHERE
|
||||
STATE = 1 AND Type IN (0,1)
|
||||
AND
|
||||
Id in
|
||||
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.user.mapper.HomePageMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.user.mapper.RoleComponentMapper">
|
||||
<select id="selectRoleComponet" resultType="RoleComponent">
|
||||
select sys_role_component.*
|
||||
from sys_role_component sys_role_component
|
||||
where sys_role_component.role_id in
|
||||
<foreach item="item" index="index" collection="ids" open="("
|
||||
separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.user.mapper.RoleFunctionMapper">
|
||||
<select id="selectRoleFunction" resultType="RoleFunction">
|
||||
select sys_role_function.*
|
||||
from sys_role_function sys_role_function
|
||||
where sys_role_function.role_id in
|
||||
<foreach item="item" index="index" collection="ids" open="("
|
||||
separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.user.mapper.RoleMapper">
|
||||
|
||||
<!--获取角色分页列表-->
|
||||
<select id="page" resultType="RoleVO">
|
||||
SELECT sys_role.*
|
||||
FROM sys_role sys_role
|
||||
WHERE ${ew.sqlSegment}
|
||||
</select>
|
||||
|
||||
<delete id="deleteUserRole">
|
||||
DELETE FROM sys_user_role where role_id in
|
||||
<foreach item="item" index="index" collection="ids" open="("
|
||||
separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteFunctionRole">
|
||||
DELETE FROM sys_role_function where role_id in
|
||||
<foreach item="item" index="index" collection="ids" open="("
|
||||
separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteComponentRole">
|
||||
DELETE FROM sys_role_component where role_id in
|
||||
<foreach item="item" index="index" collection="ids" open="("
|
||||
separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.user.mapper.UserMapper">
|
||||
<select id="selectDeptsId" resultType="User">
|
||||
select sys_user.*
|
||||
from sys_user sys_user
|
||||
where sys_user.Dept_Id in
|
||||
<foreach item="item" index="index" collection="ids" open="("
|
||||
separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
and sys_user.state =#{state}
|
||||
</select>
|
||||
|
||||
<select id="page" resultType="UserVO">
|
||||
SELECT
|
||||
sys_user.* ,
|
||||
sys_dept.name deptName
|
||||
FROM
|
||||
sys_user sys_user LEFT JOIN
|
||||
sys_dept sys_dept
|
||||
ON sys_user.Dept_Id = sys_dept.Id
|
||||
<where>
|
||||
<if test="state != -1">
|
||||
sys_user.State = #{state}
|
||||
</if>
|
||||
<if test="type != -1">
|
||||
and sys_user.Casual_User = #{type}
|
||||
</if>
|
||||
and ${ew.sqlSegment}
|
||||
</where>
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
<select id="checkPage" resultType="UserVO">
|
||||
SELECT
|
||||
sys_user.* ,
|
||||
sys_dept.name deptId
|
||||
FROM
|
||||
sys_user sys_user LEFT JOIN
|
||||
sys_dept sys_dept
|
||||
ON sys_user.Dept_Id = sys_dept.Id
|
||||
<where>
|
||||
and ${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="queryExportUser" resultType="UserExcel">
|
||||
SELECT
|
||||
sys_user.id,
|
||||
sys_user.name,
|
||||
sys_user.login_name loginName,
|
||||
sys_user.phone,
|
||||
sys_user.Register_Time registerTime,
|
||||
sys_user.Login_Time loginTime,
|
||||
sys_user.Casual_User casualUser,
|
||||
sys_user.State state,
|
||||
sys_dept.name deptName
|
||||
FROM sys_user sys_user
|
||||
LEFT JOIN
|
||||
sys_dept sys_dept
|
||||
ON sys_user.Dept_Id = sys_dept.Id
|
||||
Where ${ew.sqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.user.mapper.UserRoleMapper">
|
||||
<select id="selectUserRole" resultType="UserRole">
|
||||
select sys_user_role.*
|
||||
from sys_user_role sys_user_role
|
||||
where sys_user_role.role_id in
|
||||
<foreach item="item" index="index" collection="ids" open="("
|
||||
separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.user.mapper.UserSetMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.user.mapper.UserStrategyMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.user.pojo.po.AuthClient;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-15
|
||||
*/
|
||||
public interface IAuthClientService extends IService<AuthClient> {
|
||||
|
||||
/**
|
||||
* 根据客户端名称获取客户端
|
||||
* @param clientName 客户端名称
|
||||
* @return .
|
||||
*/
|
||||
AuthClient getAuthClientByName(String clientName);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.njcn.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.user.pojo.param.ComponentParam;
|
||||
import com.njcn.user.pojo.po.Component;
|
||||
import com.njcn.user.pojo.vo.ComponentVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface IComponentService extends IService<Component> {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增组件
|
||||
*
|
||||
* @param componentParam
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/19 9:55
|
||||
*/
|
||||
boolean addComponent(ComponentParam componentParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 删除组件
|
||||
*
|
||||
* @param id
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/19 9:55
|
||||
*/
|
||||
boolean deleteComponent(String id);
|
||||
|
||||
/**
|
||||
* 功能描述: 修改组件
|
||||
*
|
||||
* @param componentParam
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/19 9:55
|
||||
*/
|
||||
boolean updateComponent(ComponentParam.ComponentUpdateParam componentParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 获取组件树
|
||||
*
|
||||
* @param
|
||||
* @return com.njcn.user.pojo.po.Component
|
||||
* @author xy
|
||||
* @date 2022/1/19 14:45
|
||||
*/
|
||||
List<ComponentVO> getComponentTree();
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述: 获取用户组件树
|
||||
* @param
|
||||
* @return java.util.List<com.njcn.user.pojo.vo.ComponentVO>
|
||||
* @author xy
|
||||
* @date 2022/1/24 12:33
|
||||
*/
|
||||
List<ComponentVO> getUserComponentTree();
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.njcn.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.system.pojo.dto.AreaTreeDTO;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.user.pojo.param.DeptParam;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.user.pojo.vo.DeptAllTreeVO;
|
||||
import com.njcn.user.pojo.vo.DeptTreeVO;
|
||||
import com.njcn.user.pojo.vo.DeptVO;
|
||||
import com.njcn.web.pojo.param.DeptLineParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface IDeptService extends IService<Dept> {
|
||||
|
||||
/**
|
||||
* 根据前台传递参数,分页查询部门信息
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @return 部门列表
|
||||
*/
|
||||
Page<DeptVO> listDept(DeptParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
*
|
||||
* @param deptParam 部门信息
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean addDept(DeptParam deptParam);
|
||||
|
||||
/**
|
||||
* 修改部门信息
|
||||
*
|
||||
* @param updateParam 部门数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean updateDept(DeptParam.DeptUpdateParam updateParam);
|
||||
|
||||
/**
|
||||
* 批量逻辑删除部门数据
|
||||
*
|
||||
* @param ids 字典id集合
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean deleteDept(List<String> ids);
|
||||
|
||||
|
||||
/**
|
||||
* 部门树
|
||||
* @return 结果
|
||||
*/
|
||||
List<DeptTreeVO> deptTree();
|
||||
|
||||
/**
|
||||
* 根据登录用户获取区域树
|
||||
* @return 结果
|
||||
*/
|
||||
List<DeptAllTreeVO> loginDeptTree();
|
||||
|
||||
/**
|
||||
* 已经绑定的区域
|
||||
* @return 已经绑定的区域
|
||||
*/
|
||||
List<String> deptArea();
|
||||
|
||||
/**
|
||||
* 行政树
|
||||
* @param id id
|
||||
* @param type type
|
||||
* @return 结果
|
||||
*/
|
||||
List<AreaTreeDTO> getAreaTree(String id, Integer type);
|
||||
|
||||
/**
|
||||
* 获取省份ids
|
||||
* @param ids ids
|
||||
* @return 结果
|
||||
*/
|
||||
boolean selectPid(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据部门id获取部门名称
|
||||
* @param id
|
||||
* @return java.lang.String
|
||||
* @author xy
|
||||
*/
|
||||
String getNameByDeptId(String id);
|
||||
|
||||
/**
|
||||
* 根据条件获取后代部门索引
|
||||
* @param id 部门id
|
||||
* @param type 指定部门类型
|
||||
* @return 后代部门索引
|
||||
*/
|
||||
List<DeptDTO> getDeptDescendantIndexes(String id, List<Integer> type);
|
||||
|
||||
/**
|
||||
* 根据区域索引获取部门索引
|
||||
* @param area
|
||||
* @return java.lang.String
|
||||
* @author xy
|
||||
* @date 2022/2/14 15:08
|
||||
*/
|
||||
String getDeptIdByArea(String area);
|
||||
|
||||
/**
|
||||
* 根据部门索引获取区域索引
|
||||
* @param deptId
|
||||
* @return java.lang.String
|
||||
* @author denghuajun
|
||||
* @date 2022/2/24 15:08
|
||||
*/
|
||||
String getAreaIdByDeptId(String deptId);
|
||||
|
||||
/**
|
||||
* 功能描述: 获取顶层部门的id
|
||||
* @param
|
||||
* @return java.lang.String
|
||||
* @author xy
|
||||
* @date 2022/3/28 9:32
|
||||
*/
|
||||
String getTopDeptId();
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.njcn.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.user.pojo.param.FunctionParam;
|
||||
import com.njcn.user.pojo.param.RoleParam;
|
||||
import com.njcn.user.pojo.po.Function;
|
||||
import com.njcn.user.pojo.vo.FunctionVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface IFunctionService extends IService<Function> {
|
||||
|
||||
/**
|
||||
* 刷新用户权限信息到缓存中
|
||||
*/
|
||||
void refreshRolesFunctionsCache();
|
||||
|
||||
/**
|
||||
* 功能描述:新增资源
|
||||
*
|
||||
* @param functionParam 资源参数
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/17 11:19
|
||||
*/
|
||||
boolean addFunction(FunctionParam functionParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 修改菜单
|
||||
*
|
||||
* @param functionParam
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/17 14:23
|
||||
*/
|
||||
boolean updateFunction(FunctionParam.FunctionUpdateParam functionParam);
|
||||
|
||||
/**
|
||||
* 功能描述:删除菜单
|
||||
*
|
||||
* @param id
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/17 16:53
|
||||
*/
|
||||
boolean deleteFunction(String id);
|
||||
|
||||
/**
|
||||
* 功能描述: 获取菜单树
|
||||
*
|
||||
* @param
|
||||
* @return java.util.List<com.njcn.user.pojo.vo.FunctionVO>
|
||||
* @author xy
|
||||
* @date 2022/1/17 17:04
|
||||
*/
|
||||
List<FunctionVO> getFunctionTree();
|
||||
|
||||
/**
|
||||
* 功能描述: 根据id获取菜单详情
|
||||
*
|
||||
* @param id
|
||||
* @return com.njcn.user.pojo.po.Function
|
||||
* @author xy
|
||||
* @date 2022/1/17 17:39
|
||||
*/
|
||||
Function getFunctionById(String id);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据菜单id获取按钮
|
||||
*
|
||||
* @param id
|
||||
* @return java.util.List<com.njcn.user.pojo.po.Function>
|
||||
* @author xy
|
||||
* @date 2022/1/17 17:40
|
||||
*/
|
||||
List<Function> getButtonsById(String id);
|
||||
|
||||
/**
|
||||
* 功能描述: 获取路由菜单
|
||||
*
|
||||
* @param
|
||||
* @return java.util.List<com.njcn.user.pojo.vo.FunctionVO>
|
||||
* @author xy
|
||||
* @date 2022/1/18 13:47
|
||||
*/
|
||||
List<FunctionVO> getRouteMenu();
|
||||
|
||||
/**
|
||||
* 功能描述: 角色分配菜单
|
||||
*
|
||||
* @param roleFunctionComponent
|
||||
* @return java.util.List<com.njcn.user.pojo.vo.FunctionVO>
|
||||
* @author xy
|
||||
* @date 2022/2/17 17:00
|
||||
*/
|
||||
Boolean updateRoleComponent(RoleParam.RoleFunctionComponent roleFunctionComponent);
|
||||
|
||||
/**
|
||||
* 功能描述: 获取用户菜单树
|
||||
*
|
||||
* @param
|
||||
* @return java.util.List<com.njcn.user.pojo.vo.FunctionVO>
|
||||
* @author xy
|
||||
* @date 2022/2/21 11:29
|
||||
*/
|
||||
List<FunctionVO> getUserFunctionTree();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.njcn.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.user.pojo.param.HomePageParam;
|
||||
import com.njcn.user.pojo.po.HomePage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface IHomePageService extends IService<HomePage> {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增驾驶舱
|
||||
*
|
||||
* @param homePageParam
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/18 16:54
|
||||
*/
|
||||
boolean add(HomePageParam homePageParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 删除驾驶舱
|
||||
*
|
||||
* @param id
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/18 16:54
|
||||
*/
|
||||
boolean delete(String id);
|
||||
|
||||
/**
|
||||
* 功能描述: 修改驾驶舱
|
||||
*
|
||||
* @param homePageUpdate
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/18 16:54
|
||||
*/
|
||||
boolean update(HomePageParam.HomePageUpdateParam homePageUpdate);
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述: 获取用户的首页模式
|
||||
*
|
||||
* @param id
|
||||
* @return java.util.List<com.njcn.user.pojo.po.HomePage>
|
||||
* @author xy
|
||||
* @date 2022/1/18 15:33
|
||||
*/
|
||||
List<HomePage> getHomePagesByUserId(String id);
|
||||
|
||||
/**
|
||||
* 功能描述:根据驾驶舱id获取详情
|
||||
*
|
||||
* @param id
|
||||
* @return com.njcn.user.pojo.po.HomePage
|
||||
* @author xy
|
||||
* @date 2022/1/18 17:29
|
||||
*/
|
||||
HomePage getHomePageById(String id);
|
||||
|
||||
/**
|
||||
* 功能描述:查看已使用的驾驶舱路径
|
||||
*
|
||||
* @param path
|
||||
* @return java.util.List<java.lang.String>
|
||||
* @author xy
|
||||
* @date 2022/1/18 17:34
|
||||
*/
|
||||
List<String> getUsedHomePage(String path);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.user.pojo.param.RoleParam;
|
||||
import com.njcn.user.pojo.po.RoleComponent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface IRoleComponentService extends IService<RoleComponent> {
|
||||
|
||||
/**
|
||||
* 功能描述: 根据角色id获取组件
|
||||
*
|
||||
* @param idList
|
||||
* @return java.util.List<java.lang.String>
|
||||
* @author xy
|
||||
* @date 2022/1/24 12:41
|
||||
*/
|
||||
List<String> selectRoleComponent(List<String> idList);
|
||||
|
||||
boolean updateRoleComponent(RoleParam.RoleFunctionComponent roleFunctionComponent);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.user.pojo.po.RoleFunction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface IRoleFunctionService extends IService<RoleFunction> {
|
||||
List<String> getFunctionsByRoleIndex(String id);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据角色集合获取菜单方法
|
||||
*
|
||||
* @param roleList
|
||||
* @return java.util.List<java.lang.String>
|
||||
* @author xy
|
||||
* @date 2022/1/18 14:22
|
||||
*/
|
||||
List<String> getFunctionsByList(List<String> roleList);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.njcn.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.user.pojo.param.RoleParam;
|
||||
import com.njcn.user.pojo.po.Role;
|
||||
import com.njcn.user.pojo.vo.RoleVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface IRoleService extends IService<Role> {
|
||||
|
||||
/**
|
||||
* 根据用户id获取角色名
|
||||
* @param id 用户id
|
||||
* @return 角色名集合
|
||||
*/
|
||||
List<String> getRoleNameByUserId(String id);
|
||||
|
||||
/**
|
||||
* 根据用户id获取角色名称 name
|
||||
* @param id 用户id
|
||||
* @return 角色名集合
|
||||
*/
|
||||
List<String> getNameByUserId(String id);
|
||||
|
||||
/**
|
||||
* 根据用户id获取角色id
|
||||
* @param id 用户id
|
||||
* @return 角色名集合
|
||||
*/
|
||||
List<String> getIdByUserId(String id);
|
||||
|
||||
/**
|
||||
* 分页查询角色列表
|
||||
* @param queryParam
|
||||
* @return
|
||||
*/
|
||||
Page<RoleVO> listRole(RoleParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 根据权限类型分页查询角色列表
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<Role> selectRoleDetail(Integer id);
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
*
|
||||
* @param deptParam 角色信息
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean addRole(RoleParam deptParam);
|
||||
|
||||
/**
|
||||
* 修改部门信息
|
||||
*
|
||||
* @param updateParam 角色数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean updateRole(RoleParam.RoleUpdateParam updateParam);
|
||||
|
||||
/**
|
||||
* 批量逻辑删除角色数据
|
||||
*
|
||||
* @param ids 角色id集合
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean deleteRole(List<String> ids);
|
||||
|
||||
Boolean selectRelevance(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.njcn.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.user.pojo.po.UserRole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface IUserRoleService extends IService<UserRole> {
|
||||
|
||||
/**
|
||||
* 根据用户索引获取 用户--角色关系数据
|
||||
* @param id 用户ID
|
||||
* @return 关系数据
|
||||
*/
|
||||
List<UserRole> getUserRoleByUserId(String id);
|
||||
|
||||
/**
|
||||
* 功能描述:新增用户和角色的关系
|
||||
* TODO
|
||||
*
|
||||
* @param id
|
||||
* @param roles
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2021/12/30 16:24
|
||||
*/
|
||||
boolean addUserRole(String id,List<String> roles);
|
||||
|
||||
/**
|
||||
* 功能描述:修改用户和角色的关系
|
||||
* TODO
|
||||
*
|
||||
* @param id
|
||||
* @param roles
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/13 14:14
|
||||
*/
|
||||
boolean updateUserRole(String id,List<String> roles);
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.njcn.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.user.pojo.param.UserParam;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.user.pojo.dto.UserDTO;
|
||||
import com.njcn.user.pojo.vo.UserVO;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface IUserService extends IService<User> {
|
||||
|
||||
/**
|
||||
* 根据登录名获取用户信息
|
||||
* @param loginName 登录名
|
||||
* @return 用户信息
|
||||
*/
|
||||
UserDTO getUserByName(String loginName);
|
||||
|
||||
/**
|
||||
* 认证结束后,判断用户状态是否能正常访问系统
|
||||
* @param loginName 登录名
|
||||
*/
|
||||
void judgeUserStatus(String loginName);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增用户
|
||||
* TODO
|
||||
* 1.sys_user_set表生成工作秘钥和SM4密码
|
||||
* 2.sys_user新增用户
|
||||
* 3.sys_user_role新增用户和角色关系
|
||||
* @param addUserParam
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2021/12/30 11:42
|
||||
*/
|
||||
boolean addUser(UserParam.UserAddParam addUserParam);
|
||||
|
||||
/**
|
||||
* 功能描述:更新用户
|
||||
* TODO
|
||||
* @param updateUserParam
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/13 13:38
|
||||
*/
|
||||
boolean updateUser(UserParam.UserUpdateParam updateUserParam);
|
||||
|
||||
/**
|
||||
* 功能描述:删除用户
|
||||
* TODO
|
||||
*
|
||||
* @param id
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/13 16:31
|
||||
*/
|
||||
boolean deleteUser(String id);
|
||||
|
||||
/**
|
||||
* 功能描述:审核用户
|
||||
* TODO
|
||||
*
|
||||
* @param list
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/13 16:31
|
||||
*/
|
||||
boolean checkUser(List<String> list);
|
||||
|
||||
/**
|
||||
* 功能描述:根据用户id获取用户详情
|
||||
* TODO
|
||||
*
|
||||
* @param id
|
||||
* @return com.njcn.user.pojo.vo.UserVO
|
||||
* @author xy
|
||||
* @date 2022/1/13 17:10
|
||||
*/
|
||||
UserVO getUserById(String id);
|
||||
|
||||
/**
|
||||
* 功能描述:根据查询条件分页查询列表
|
||||
* TODO
|
||||
*
|
||||
* @param queryParam
|
||||
* @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.njcn.user.pojo.vo.UserVO>
|
||||
* @author xy
|
||||
* @date 2022/1/14 9:26
|
||||
*/
|
||||
Page<UserVO> userList(UserParam.UserQueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 功能描述:查询待审核用户列表
|
||||
* TODO
|
||||
*
|
||||
* @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.njcn.user.pojo.vo.UserVO>
|
||||
* @author xy
|
||||
* @date 2022/1/14 9:26
|
||||
*/
|
||||
Page<UserVO> checkUserList(UserParam.UserQueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 修改用户密码
|
||||
* TODO
|
||||
*
|
||||
* @param id
|
||||
* @param password
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/14 15:21
|
||||
*/
|
||||
boolean updatePassword(String id,String password);
|
||||
|
||||
/**
|
||||
* 功能描述:修改用户登录认证密码错误次数
|
||||
* @param loginName 登录名
|
||||
* @return boolean
|
||||
* @author xy
|
||||
*/
|
||||
String updateUserLoginErrorTimes(String loginName);
|
||||
|
||||
/**
|
||||
* 功能描述:密码二次确认
|
||||
* @param password
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/1/19 16:37
|
||||
*/
|
||||
boolean passwordConfirm(String password);
|
||||
|
||||
/**
|
||||
* 功能描述:首次登录修改密码
|
||||
*
|
||||
* @param loginName 登录名
|
||||
* @param password 密码
|
||||
* @param ip ip
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/1 15:39
|
||||
*/
|
||||
boolean updateFirstPassword(String loginName, String password, String ip);
|
||||
|
||||
/**
|
||||
* 根据前端条件,查询用户数据,并保存在本地
|
||||
*
|
||||
* @param queryParam 导出用户列表的条件参数
|
||||
* @return 用户列表表格的绝对路径
|
||||
*/
|
||||
String exportUser(UserParam.UserQueryParam queryParam,String methodDescribe);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.njcn.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.user.pojo.param.UserParam;
|
||||
import com.njcn.user.pojo.po.UserSet;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface IUserSetService extends IService<UserSet> {
|
||||
|
||||
/**
|
||||
* 功能描述:
|
||||
* 新增用户时,去用户配置表存储工作秘钥和SM4密码
|
||||
*
|
||||
* @param addUserParam
|
||||
* @return com.njcn.user.pojo.po.UserSet
|
||||
* @author xy
|
||||
* @date 2021/12/30 16:03
|
||||
*/
|
||||
UserSet addUserSet(UserParam.UserAddParam addUserParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 登陆后 修改用户密码
|
||||
*
|
||||
* @param id 用户id
|
||||
* @param newPassword 新密码
|
||||
* @return java.lang.String
|
||||
* @author xy
|
||||
* @date 2022/1/21 12:39
|
||||
*/
|
||||
String updatePassword(String id,String newPassword);
|
||||
|
||||
/**
|
||||
* 功能描述: 未登录 修改用户密码
|
||||
*
|
||||
* @param id 用户id
|
||||
* @param newPassword 新密码
|
||||
* @param name 用户名
|
||||
* @param ip ip
|
||||
* @return java.lang.String
|
||||
* @author xy
|
||||
* @date 2022/1/21 12:39
|
||||
*/
|
||||
String updateFirstPassword(String id, String newPassword, String name, String ip);
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述:
|
||||
*
|
||||
* @param password
|
||||
* @return java.lang.String
|
||||
* @author xy
|
||||
* @date 2022/1/19 16:58
|
||||
*/
|
||||
String getDecryptPassword(String password);
|
||||
|
||||
/**
|
||||
* 功能描述: 获取当前用户配置信息
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return com.njcn.user.pojo.po.UserSet
|
||||
* @author xy
|
||||
* @date 2022/1/19 17:03
|
||||
*/
|
||||
UserSet getUserSetByUserId(String userId);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.user.pojo.po.UserStrategy;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
public interface IUserStrategyService extends IService<UserStrategy> {
|
||||
|
||||
/**
|
||||
* 查询用户策略数据
|
||||
* @return 用户策略信息
|
||||
* @param casualUser
|
||||
*/
|
||||
UserStrategy getUserStrategy(Integer casualUser);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
import com.njcn.system.pojo.po.Area;
|
||||
import com.njcn.user.mapper.AuthClientMapper;
|
||||
import com.njcn.user.pojo.po.AuthClient;
|
||||
import com.njcn.user.service.IAuthClientService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-15
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AuthClientServiceImpl extends ServiceImpl<AuthClientMapper, AuthClient> implements IAuthClientService {
|
||||
|
||||
@Override
|
||||
public AuthClient getAuthClientByName(String clientName) {
|
||||
return lambdaQuery()
|
||||
.eq(AuthClient::getName,clientName)
|
||||
.eq(AuthClient::getState,DataStateEnum.ENABLE.getCode())
|
||||
.one();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.user.enums.UserResponseEnum;
|
||||
import com.njcn.user.mapper.ComponentMapper;
|
||||
import com.njcn.user.pojo.constant.ComponentState;
|
||||
import com.njcn.user.pojo.constant.FunctionState;
|
||||
import com.njcn.user.pojo.dto.ComponentDTO;
|
||||
import com.njcn.user.pojo.param.ComponentParam;
|
||||
import com.njcn.user.pojo.po.Component;
|
||||
import com.njcn.user.pojo.vo.ComponentVO;
|
||||
import com.njcn.user.service.IComponentService;
|
||||
import com.njcn.user.service.IRoleComponentService;
|
||||
import com.njcn.user.service.IRoleService;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component> implements IComponentService {
|
||||
|
||||
private final ComponentMapper componentMapper;
|
||||
|
||||
private final IRoleService roleService;
|
||||
|
||||
private final IRoleComponentService roleComponentService;
|
||||
|
||||
@Override
|
||||
public boolean addComponent(ComponentParam componentParam) {
|
||||
checkComponentParam(componentParam,false);
|
||||
Component component = new Component();
|
||||
BeanUtil.copyProperties(componentParam, component);
|
||||
String functionGroup = componentParam.getFunctionGroup().stream().map(String::valueOf).collect(Collectors.joining(","));
|
||||
component.setFunctionGroup(functionGroup);
|
||||
component.setState(ComponentState.ENABLE);
|
||||
if (Objects.equals(componentParam.getPid(), FunctionState.FATHER_PID)){
|
||||
component.setPids(FunctionState.FATHER_PID);
|
||||
} else {
|
||||
Component fatherComponent = this.lambdaQuery().eq(Component::getId,componentParam.getPid()).one();
|
||||
if (Objects.equals(fatherComponent.getPid(),FunctionState.FATHER_PID)){
|
||||
component.setPids(componentParam.getPid());
|
||||
} else {
|
||||
String pidS = fatherComponent.getPids();
|
||||
component.setPids(pidS+","+componentParam.getPid());
|
||||
}
|
||||
}
|
||||
return this.save(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteComponent(String id) {
|
||||
return this.lambdaUpdate()
|
||||
.set(Component::getState, ComponentState.DELETE)
|
||||
.in(Component::getId, id)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateComponent(ComponentParam.ComponentUpdateParam componentParam) {
|
||||
checkComponentParam(componentParam,true);
|
||||
Component component = new Component();
|
||||
BeanUtil.copyProperties(componentParam, component);
|
||||
String functionGroup = componentParam.getFunctionGroup().stream().map(String::valueOf).collect(Collectors.joining(","));
|
||||
component.setFunctionGroup(functionGroup);
|
||||
return this.updateById(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ComponentVO> getComponentTree() {
|
||||
List<ComponentVO> list = new ArrayList<>();
|
||||
List<ComponentDTO> componentList = componentMapper.getAllComponent();
|
||||
componentList.forEach(item->{
|
||||
ComponentVO componentVO = new ComponentVO();
|
||||
BeanUtil.copyProperties(item, componentVO);
|
||||
componentVO.setFunctionGroup(Arrays.stream(item.getFunctionGroup().split(",")).map(s -> Integer.valueOf(s.trim())).collect(Collectors.toList()));
|
||||
list.add(componentVO);
|
||||
});
|
||||
return list.stream()
|
||||
.filter(fun -> Objects.equals(ComponentState.FATHER_PID,fun.getPid()))
|
||||
.peek(funS -> funS.setChildren(getChildCategoryList(funS, list)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ComponentVO> getUserComponentTree() {
|
||||
List<ComponentVO> result = new ArrayList<>();
|
||||
List<ComponentVO> componentVOList = new ArrayList<>();
|
||||
List<String> roleList = roleService.getIdByUserId(RequestUtil.getUserIndex());
|
||||
if (!CollectionUtils.isEmpty(roleList)){
|
||||
List<String> componentList = roleComponentService.selectRoleComponent(roleList);
|
||||
if (!CollectionUtils.isEmpty(componentList)){
|
||||
List<ComponentDTO> list = componentMapper.getComponentByList(componentList);
|
||||
list.forEach(item->{
|
||||
ComponentVO componentVO = new ComponentVO();
|
||||
BeanUtil.copyProperties(item, componentVO);
|
||||
componentVO.setFunctionGroup(Arrays.stream(item.getFunctionGroup().split(",")).map(s -> Integer.valueOf(s.trim())).collect(Collectors.toList()));
|
||||
componentVOList.add(componentVO);
|
||||
});
|
||||
result = componentVOList.stream()
|
||||
.filter(fun -> Objects.equals(ComponentState.FATHER_PID,fun.getPid()))
|
||||
.peek(funS -> funS.setChildren(getChildCategoryList(funS, componentVOList)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归组装组件表
|
||||
*/
|
||||
private List<ComponentVO> getChildCategoryList(ComponentVO currMenu, List<ComponentVO> categories) {
|
||||
return categories.stream().filter(o -> Objects.equals(o.getPid(),currMenu.getId()))
|
||||
.peek(o -> o.setChildren(getChildCategoryList(o, categories)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数,
|
||||
* 1.检查是否存在相同名称的组件
|
||||
*/
|
||||
private void checkComponentParam(ComponentParam componentParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<Component> componentLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
componentLambdaQueryWrapper
|
||||
.eq(Component::getName, componentParam.getName())
|
||||
.eq(Component::getState, ComponentState.ENABLE);
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (componentParam instanceof ComponentParam.ComponentUpdateParam) {
|
||||
componentLambdaQueryWrapper.ne(Component::getId, ((ComponentParam.ComponentUpdateParam) componentParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(componentLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(UserResponseEnum.COMPONENT_NAME_EXIST);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.device.api.DeptLineFeignClient;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
import com.njcn.system.pojo.dto.AreaTreeDTO;
|
||||
import com.njcn.user.enums.UserResponseEnum;
|
||||
import com.njcn.user.enums.UserStatusEnum;
|
||||
import com.njcn.user.mapper.DeptMapper;
|
||||
import com.njcn.user.mapper.UserMapper;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.user.pojo.param.DeptParam;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.user.pojo.vo.DeptAllTreeVO;
|
||||
import com.njcn.user.pojo.vo.DeptTreeVO;
|
||||
import com.njcn.user.pojo.vo.DeptVO;
|
||||
import com.njcn.user.service.IDeptService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.pojo.param.DeptLineParam;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import com.njcn.web.utils.WebUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements IDeptService {
|
||||
|
||||
private final AreaFeignClient areaFeignClient;
|
||||
|
||||
private final DeptLineFeignClient deptLineFeignClient;
|
||||
|
||||
private final UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public Page<DeptVO> listDept(DeptParam.QueryParam queryParam) {
|
||||
QueryWrapper<DeptVO> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
//查询参数不为空,进行条件填充
|
||||
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
||||
//部门根据名称模糊查询
|
||||
queryWrapper
|
||||
.and(param -> param.like("sys_dept.name", queryParam.getSearchValue()));
|
||||
}
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), "sys_dept.sort");
|
||||
}
|
||||
}
|
||||
queryWrapper.ne("sys_dept.state", DataStateEnum.DELETED.getCode());
|
||||
//初始化分页数据
|
||||
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addDept(DeptParam deptParam) {
|
||||
checkDicDataCode(deptParam, false);
|
||||
Dept dept = new Dept();
|
||||
BeanUtil.copyProperties(deptParam, dept);
|
||||
if (deptParam.getPid().equals("-1")) {
|
||||
//上层节点
|
||||
dept.setPids("0");
|
||||
} else {
|
||||
String pids = "," + deptParam.getPid();
|
||||
String pid = this.baseMapper.getIdString(deptParam.getPid());
|
||||
//上层节点
|
||||
dept.setPids(pid + pids);
|
||||
}
|
||||
//默认为正常状态
|
||||
dept.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(dept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDept(DeptParam.DeptUpdateParam updateParam) {
|
||||
checkDicDataCode(updateParam, true);
|
||||
Dept dept = new Dept();
|
||||
BeanUtil.copyProperties(updateParam, dept);
|
||||
return this.updateById(dept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDept(List<String> ids) {
|
||||
LambdaQueryWrapper<Dept> queryWrapperDept = new LambdaQueryWrapper<>();
|
||||
queryWrapperDept.eq(Dept::getState, DataStateEnum.ENABLE.getCode());
|
||||
//查询出所有部门
|
||||
List<Dept> deptList = this.baseMapper.selectList(queryWrapperDept);
|
||||
List<String> allIds = new ArrayList<>();
|
||||
for (String id : ids) {
|
||||
for (Dept dept : deptList) {
|
||||
if (dept.getId().equalsIgnoreCase(id) || dept.getPids().indexOf(id) > 0){
|
||||
allIds.add(dept.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
allIds = allIds.stream().distinct().collect(Collectors.toList());
|
||||
/**
|
||||
* 删除部门和监测点的绑定
|
||||
*/
|
||||
this.baseMapper.deleteDeptLine(allIds);
|
||||
/**
|
||||
* 清空用户和部门的绑定关系
|
||||
*/
|
||||
this.baseMapper.deleteUserDept(allIds);
|
||||
return this.lambdaUpdate().set(Dept::getState, DataStateEnum.DELETED.getCode()).in(Dept::getId, allIds).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptTreeVO> deptTree() {
|
||||
List<Integer> deptType = WebUtil.filterDeptType();
|
||||
String deptIndex = RequestUtil.getDeptIndex();
|
||||
List<DeptTreeVO> deptList = this.baseMapper.getDeptTree(deptIndex, deptType);
|
||||
return deptList.stream()
|
||||
.filter(deptVO -> deptVO.getId().equals(deptIndex))
|
||||
.peek(deptFirst -> {
|
||||
deptFirst.setChildren(getChildren(deptFirst, deptList));
|
||||
if (deptFirst.getType() == 0) {
|
||||
deptFirst.setName(deptFirst.getAreaName());
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptAllTreeVO> loginDeptTree() {
|
||||
List<Integer> deptType = WebUtil.filterDeptType();
|
||||
String deptIndex = RequestUtil.getDeptIndex();
|
||||
List<DeptAllTreeVO> deptList = this.baseMapper.getAllDeptTree(deptIndex, deptType);
|
||||
return deptList.stream()
|
||||
.filter(deptVO -> deptVO.getId().equals(deptIndex))
|
||||
.peek(deptFirst -> {
|
||||
deptFirst.setChildren(getChildrens(deptFirst, deptList));
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> deptArea() {
|
||||
return this.baseMapper.deptArea(DataStateEnum.ENABLE.getCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AreaTreeDTO> getAreaTree(String id, Integer type) {
|
||||
List<String> areaTreeVO = deptArea();
|
||||
HttpResult<List<AreaTreeDTO>> areaTreeDTOS = areaFeignClient.areaDeptTree(id, type);
|
||||
List<AreaTreeDTO> list = areaTreeDTOS.getData();
|
||||
for (AreaTreeDTO areaTreeVOList : list) {
|
||||
if (areaTreeVO.contains(areaTreeVOList.getId())) {
|
||||
areaTreeVOList.setName(areaTreeVOList.getName() + "(已被绑定)");
|
||||
areaTreeVOList.setIsFalse(1);
|
||||
}
|
||||
if (areaTreeVOList.getChildren().size() != 0) {
|
||||
for (AreaTreeDTO treeDTO : areaTreeVOList.getChildren()) {
|
||||
if (areaTreeVO.contains(treeDTO.getId())) {
|
||||
treeDTO.setName(treeDTO.getName() + "(已被绑定)");
|
||||
treeDTO.setIsFalse(1);
|
||||
}
|
||||
if (treeDTO.getChildren().size() != 0) {
|
||||
for (AreaTreeDTO areaTreeDTO : treeDTO.getChildren()) {
|
||||
if (areaTreeVO.contains(areaTreeDTO.getId())) {
|
||||
areaTreeDTO.setName(areaTreeDTO.getName() + "(已被绑定)");
|
||||
areaTreeDTO.setIsFalse(1);
|
||||
}
|
||||
if (areaTreeDTO.getChildren().size() != 0) {
|
||||
for (AreaTreeDTO dto : areaTreeDTO.getChildren()) {
|
||||
if (areaTreeVO.contains(dto.getId())) {
|
||||
dto.setName(dto.getName() + "(已被绑定)");
|
||||
dto.setIsFalse(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectPid(List<String> ids) {
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
*/
|
||||
List<Dept> dept = this.baseMapper.selectPid(ids, DataStateEnum.ENABLE.getCode());
|
||||
/**
|
||||
* 判断是否存在绑定关系
|
||||
*/
|
||||
HttpResult<Boolean> deptLineVOHttpResult = deptLineFeignClient.selectDeptBindLines(ids);
|
||||
/**
|
||||
* 用户是否关联
|
||||
*/
|
||||
List<User> userList = userMapper.selectDeptsId(ids, DataStateEnum.ENABLE.getCode());
|
||||
|
||||
if (dept.size() > 0 || deptLineVOHttpResult.getData() || userList.size() > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameByDeptId(String id) {
|
||||
if (!Objects.isNull(lambdaQuery().eq(Dept::getId, id).one())) {
|
||||
return lambdaQuery().eq(Dept::getId, id).one().getName();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptDTO> getDeptDescendantIndexes(String id, List<Integer> type) {
|
||||
return this.baseMapper.getDeptDescendantIndexes(id, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDeptIdByArea(String area) {
|
||||
Dept dept = lambdaQuery().eq(Dept::getArea, area).eq(Dept::getState, UserStatusEnum.NORMAL.getCode()).one();
|
||||
if (!Objects.isNull(dept)) {
|
||||
return dept.getId();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAreaIdByDeptId(String deptId) {
|
||||
Dept dept = lambdaQuery().eq(Dept::getId, deptId).eq(Dept::getState, UserStatusEnum.NORMAL.getCode()).one();
|
||||
if (!Objects.isNull(dept)) {
|
||||
return dept.getArea();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTopDeptId() {
|
||||
return this.lambdaQuery().eq(Dept::getPid,"0").one().getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数,检查是否存在相同编码的部门
|
||||
*/
|
||||
private void checkDicDataCode(DeptParam deptParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<Dept> deptLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
deptLambdaQueryWrapper
|
||||
.eq(Dept::getName, deptParam.getName())
|
||||
.eq(Dept::getState, DataStateEnum.ENABLE.getCode());
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (deptParam instanceof DeptParam.DeptUpdateParam) {
|
||||
deptLambdaQueryWrapper.ne(Dept::getId, ((DeptParam.DeptUpdateParam) deptParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(deptLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(UserResponseEnum.DEPT_NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查找所有部门的下级部门
|
||||
*/
|
||||
private List<DeptTreeVO> getChildren(DeptTreeVO deptFirst, List<DeptTreeVO> allDept) {
|
||||
return allDept.stream().filter(dept -> dept.getPid().equals(deptFirst.getId()))
|
||||
.peek(deptVo -> {
|
||||
deptVo.setChildren(getChildren(deptVo, allDept));
|
||||
if (deptVo.getType() == 0) {
|
||||
deptVo.setName(deptVo.getAreaName());
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查找所有部门的下级部门
|
||||
*/
|
||||
private List<DeptAllTreeVO> getChildrens(DeptAllTreeVO deptFirst, List<DeptAllTreeVO> allDept) {
|
||||
return allDept.stream().filter(dept -> dept.getPid().equals(deptFirst.getId()))
|
||||
.peek(deptVo -> {
|
||||
deptVo.setChildren(getChildrens(deptVo, allDept));
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.constant.SecurityConstants;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.redis.pojo.enums.RedisKeyEnum;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.user.enums.UserResponseEnum;
|
||||
import com.njcn.user.mapper.FunctionMapper;
|
||||
import com.njcn.user.mapper.RoleFunctionMapper;
|
||||
import com.njcn.user.pojo.constant.FunctionState;
|
||||
import com.njcn.user.pojo.constant.UserType;
|
||||
import com.njcn.user.pojo.param.FunctionParam;
|
||||
import com.njcn.user.pojo.param.RoleParam;
|
||||
import com.njcn.user.pojo.po.*;
|
||||
import com.njcn.user.pojo.vo.FunctionVO;
|
||||
import com.njcn.user.service.*;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class FunctionServiceImpl extends ServiceImpl<FunctionMapper, Function> implements IFunctionService {
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
private final IRoleService roleService;
|
||||
|
||||
private final IRoleFunctionService roleFunctionService;
|
||||
|
||||
private final FunctionMapper functionMapper;
|
||||
|
||||
private final IUserRoleService userRoleService;
|
||||
|
||||
private final IHomePageService homePageService;
|
||||
|
||||
private final RoleFunctionMapper roleFunctionMapper;
|
||||
|
||||
/**
|
||||
* 将系统中角色--资源对应数据缓存到redis
|
||||
* 先清除,再缓存
|
||||
*/
|
||||
@Override
|
||||
public void refreshRolesFunctionsCache() {
|
||||
redisUtil.delete(RedisKeyEnum.ROLE_FUNCTION_KEY.getKey());
|
||||
redisUtil.delete(RedisKeyEnum.PUBLIC_FUNCTIONS_KEY.getKey());
|
||||
//缓存公共资源
|
||||
List<Function> publicFunctions = lambdaQuery()
|
||||
.eq(Function::getType, 2)
|
||||
.eq(Function::getState, DataStateEnum.ENABLE.getCode())
|
||||
.list();
|
||||
redisUtil.saveByKey(
|
||||
RedisKeyEnum.PUBLIC_FUNCTIONS_KEY.getKey()
|
||||
, publicFunctions.stream().map(Function::getPath).collect(Collectors.toList())
|
||||
);
|
||||
|
||||
//缓存每个角色对应的资源
|
||||
Map<String, List<String>> roleFunctionInfo = new HashMap<>(8);
|
||||
List<Role> roles = roleService.lambdaQuery()
|
||||
.eq(Role::getState, DataStateEnum.ENABLE.getCode())
|
||||
.list();
|
||||
|
||||
roles.forEach(role -> {
|
||||
//根据当前角色列表获取其所对应的所有资源
|
||||
List<RoleFunction> roleFunctions = roleFunctionService.lambdaQuery()
|
||||
.eq(RoleFunction::getRoleId, role.getId())
|
||||
.list();
|
||||
//根据角色权限关系表获取权限的uri
|
||||
if (CollectionUtil.isEmpty(roleFunctions)) {
|
||||
roleFunctionInfo.put(SecurityConstants.AUTHORITY_PREFIX+role.getCode(), null);
|
||||
} else {
|
||||
List<Function> functions = lambdaQuery()
|
||||
.in(Function::getId, roleFunctions.stream().map(RoleFunction::getFunctionId).collect(Collectors.toList()))
|
||||
.eq(Function::getState, DataStateEnum.ENABLE.getCode())
|
||||
.list();
|
||||
roleFunctionInfo.put(SecurityConstants.AUTHORITY_PREFIX+role.getCode(), functions.stream().map(Function::getPath).collect(Collectors.toList()));
|
||||
}
|
||||
});
|
||||
redisUtil.saveByKey(RedisKeyEnum.ROLE_FUNCTION_KEY.getKey(), roleFunctionInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFunction(FunctionParam functionParam) {
|
||||
checkFunctionParam(functionParam,false);
|
||||
Function function = new Function();
|
||||
BeanUtil.copyProperties(functionParam, function);
|
||||
function.setState(FunctionState.ENABLE);
|
||||
if (Objects.equals(functionParam.getPid(),FunctionState.FATHER_PID)){
|
||||
function.setPids(FunctionState.FATHER_PID);
|
||||
} else {
|
||||
Function fatherFaction = this.lambdaQuery().eq(Function::getId,functionParam.getPid()).one();
|
||||
if (Objects.equals(fatherFaction.getPid(),FunctionState.FATHER_PID)){
|
||||
function.setPids(functionParam.getPid());
|
||||
} else {
|
||||
String pidS = fatherFaction.getPids();
|
||||
function.setPids(pidS+","+functionParam.getPid());
|
||||
}
|
||||
}
|
||||
boolean result = this.save(function);
|
||||
if (result){
|
||||
//刷新redis里面的资源权限
|
||||
refreshRolesFunctionsCache();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateFunction(FunctionParam.FunctionUpdateParam functionParam) {
|
||||
checkFunctionParam(functionParam,true);
|
||||
Function function = new Function();
|
||||
BeanUtil.copyProperties(functionParam, function);
|
||||
boolean result = this.updateById(function);
|
||||
if (result){
|
||||
refreshRolesFunctionsCache();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteFunction(String id) {
|
||||
boolean result = this.lambdaUpdate()
|
||||
.set(Function::getState, FunctionState.DELETE)
|
||||
.in(Function::getId,id)
|
||||
.update();
|
||||
if (result){
|
||||
refreshRolesFunctionsCache();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionVO> getFunctionTree() {
|
||||
List<FunctionVO> list = functionMapper.getAllFunctions();
|
||||
return list.stream()
|
||||
.filter(fun -> Objects.equals(FunctionState.FATHER_PID,fun.getPid()))
|
||||
.peek(funS -> funS.setChildren(getChildCategoryList(funS, list)))
|
||||
.sorted(Comparator.comparingInt(FunctionVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function getFunctionById(String id) {
|
||||
return this.lambdaQuery().eq(Function::getId,id).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Function> getButtonsById(String id) {
|
||||
return this.lambdaQuery().eq(Function::getPid,id).eq(Function::getType,FunctionState.BUTTON).eq(Function::getState,FunctionState.ENABLE).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionVO> getRouteMenu() {
|
||||
List<FunctionVO> result = new ArrayList<>();
|
||||
List<String> functionList = new ArrayList<>();
|
||||
if (Objects.equals(RequestUtil.getUsername(),UserType.SUPER_ADMIN)){
|
||||
//查询所有菜单
|
||||
functionList = this.lambdaQuery().eq(Function::getState, FunctionState.ENABLE).list().stream().map(Function::getId).distinct().collect(Collectors.toList());
|
||||
} else {
|
||||
List<String> roleList = userRoleService.getUserRoleByUserId(RequestUtil.getUserIndex()).stream().map(UserRole::getRoleId).distinct().collect(Collectors.toList());
|
||||
functionList = roleFunctionService.getFunctionsByList(roleList);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(functionList)){
|
||||
return result;
|
||||
}
|
||||
List<FunctionVO> functionVOList = functionMapper.getFunctionsByList(functionList);
|
||||
result = functionVOList.stream()
|
||||
.filter(fun -> Objects.equals(FunctionState.FATHER_PID,fun.getPid()))
|
||||
.peek(funS -> funS.setChildren(getChildCategoryList(funS, functionVOList)))
|
||||
.sorted(Comparator.comparingInt(FunctionVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
//组装驾驶舱
|
||||
setDriverChildren(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateRoleComponent(RoleParam.RoleFunctionComponent roleFunctionComponent) {
|
||||
deleteComponentsByRoleIndex(roleFunctionComponent.getId());
|
||||
if (!roleFunctionComponent.getIdList().isEmpty()){
|
||||
RoleFunction roleFunction = new RoleFunction();
|
||||
roleFunction.setRoleId(roleFunctionComponent.getId());
|
||||
roleFunctionComponent.getIdList().forEach(
|
||||
pojo->{
|
||||
roleFunction.setFunctionId(pojo);
|
||||
roleFunctionMapper.insert(roleFunction);
|
||||
});
|
||||
}
|
||||
refreshRolesFunctionsCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionVO> getUserFunctionTree() {
|
||||
List<FunctionVO> result = new ArrayList<>();
|
||||
List<String> functionList = new ArrayList<>();
|
||||
if (Objects.equals(RequestUtil.getUsername(), UserType.SUPER_ADMIN)){
|
||||
//查询所有菜单
|
||||
functionList = this.lambdaQuery().eq(Function::getState, FunctionState.ENABLE).list().stream().map(Function::getId).distinct().collect(Collectors.toList());
|
||||
} else {
|
||||
List<String> roleList = userRoleService.getUserRoleByUserId(RequestUtil.getUserIndex()).stream().map(UserRole::getRoleId).distinct().collect(Collectors.toList());
|
||||
functionList = roleFunctionService.getFunctionsByList(roleList);
|
||||
}
|
||||
List<FunctionVO> functionVOList = functionMapper.getUserFunctionsByList(functionList);
|
||||
result = functionVOList.stream()
|
||||
.filter(fun -> Objects.equals(FunctionState.FATHER_PID,fun.getPid()))
|
||||
.peek(funS -> funS.setChildren(getChildCategoryList(funS, functionVOList)))
|
||||
.sorted(Comparator.comparingInt(FunctionVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
//组装驾驶舱
|
||||
setDriverChildren(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色删除资源
|
||||
* @param roleIndex
|
||||
*/
|
||||
public void deleteComponentsByRoleIndex(String roleIndex) {
|
||||
QueryWrapper<RoleFunction> roleFunctionQueryWrapper = new QueryWrapper<>();
|
||||
roleFunctionQueryWrapper.eq("sys_role_function.role_id",roleIndex);
|
||||
roleFunctionMapper.delete(roleFunctionQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前分类找出子类,递归找出子类的子类
|
||||
*/
|
||||
private List<FunctionVO> getChildCategoryList(FunctionVO currMenu, List<FunctionVO> categories) {
|
||||
return categories.stream().filter(o -> Objects.equals(o.getPid(),currMenu.getId()))
|
||||
.peek(o -> o.setChildren(getChildCategoryList(o, categories)))
|
||||
.sorted(Comparator.comparingInt(FunctionVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装驾驶舱子级
|
||||
* @param list
|
||||
*/
|
||||
private void setDriverChildren(List<FunctionVO> list) {
|
||||
List<HomePage> homePages = homePageService.getHomePagesByUserId(RequestUtil.getUserIndex());
|
||||
list.forEach(item->{
|
||||
if (Objects.equals(item.getRoutePath(),FunctionState.DRIVER_NAME)){
|
||||
homePages.forEach(po->{
|
||||
FunctionVO functionVO = new FunctionVO();
|
||||
functionVO.setId(po.getId());
|
||||
functionVO.setPid(item.getId());
|
||||
functionVO.setTitle(po.getName());
|
||||
functionVO.setCode(item.getCode());
|
||||
functionVO.setRouteName(po.getPath().substring(po.getPath().lastIndexOf("/")+1));
|
||||
functionVO.setRoutePath(po.getPath());
|
||||
functionVO.setIcon(po.getIcon());
|
||||
functionVO.setSort(po.getSort());
|
||||
functionVO.setType(item.getType());
|
||||
functionVO.setRemark(po.getName());
|
||||
functionVO.setChildren(new ArrayList<>());
|
||||
item.getChildren().add(functionVO);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数,
|
||||
* 1.检查是否存在相同名称的菜单
|
||||
*/
|
||||
private void checkFunctionParam(FunctionParam functionParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<Function> functionLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
functionLambdaQueryWrapper
|
||||
.eq(Function::getPath, functionParam.getPath())
|
||||
.eq(Function::getState, FunctionState.ENABLE);
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (functionParam instanceof FunctionParam.FunctionUpdateParam) {
|
||||
functionLambdaQueryWrapper.ne(Function::getId, ((FunctionParam.FunctionUpdateParam) functionParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(functionLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(UserResponseEnum.FUNCTION_PATH_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.system.enums.SystemResponseEnum;
|
||||
import com.njcn.system.pojo.param.DictTypeParam;
|
||||
import com.njcn.system.pojo.po.DictType;
|
||||
import com.njcn.user.enums.UserResponseEnum;
|
||||
import com.njcn.user.mapper.HomePageMapper;
|
||||
import com.njcn.user.pojo.constant.HomePageState;
|
||||
import com.njcn.user.pojo.param.HomePageParam;
|
||||
import com.njcn.user.pojo.po.HomePage;
|
||||
import com.njcn.user.service.IHomePageService;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Service
|
||||
public class HomePageServiceImpl extends ServiceImpl<HomePageMapper, HomePage> implements IHomePageService {
|
||||
|
||||
@Override
|
||||
public boolean add(HomePageParam homePageParam) {
|
||||
checkHomePageName(homePageParam,false);
|
||||
String component = homePageParam.getLayout().replace(""","\"");
|
||||
HomePage homePage = new HomePage();
|
||||
BeanUtil.copyProperties(homePageParam, homePage);
|
||||
homePage.setUserId(RequestUtil.getUserIndex());
|
||||
homePage.setState(HomePageState.ENABLE);
|
||||
homePage.setLayout(component);
|
||||
return this.save(homePage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(String id) {
|
||||
return this.lambdaUpdate()
|
||||
.set(HomePage::getState, HomePageState.DELETE)
|
||||
.in(HomePage::getId, id)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(HomePageParam.HomePageUpdateParam homePageUpdate) {
|
||||
checkHomePageName(homePageUpdate,true);
|
||||
HomePage homePage = new HomePage();
|
||||
BeanUtil.copyProperties(homePageUpdate, homePage);
|
||||
return this.updateById(homePage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HomePage> getHomePagesByUserId(String id) {
|
||||
List<String> userList = new ArrayList<>();
|
||||
userList.add(id);
|
||||
userList.add(HomePageState.DEFAULT_USER_ID);
|
||||
return this.lambdaQuery().in(HomePage::getUserId,userList).eq(HomePage::getState, HomePageState.ENABLE).orderByAsc(HomePage::getSort).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HomePage getHomePageById(String id) {
|
||||
return this.lambdaQuery().in(HomePage::getId,id).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsedHomePage(String path) {
|
||||
return this.lambdaQuery().in(HomePage::getUserId,RequestUtil.getUserIndex()).eq(HomePage::getState,HomePageState.ENABLE).likeRight(HomePage::getPath,path).list().stream().map(HomePage::getPath).distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数,检查是否存在相同名称的首页
|
||||
*/
|
||||
private void checkHomePageName(HomePageParam homePageParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<HomePage> homePageLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
homePageLambdaQueryWrapper
|
||||
.eq(HomePage::getName,homePageParam.getName())
|
||||
.eq(HomePage::getState, HomePageState.ENABLE);
|
||||
//更新的时候,需排除当前记录
|
||||
if(isExcludeSelf){
|
||||
if(homePageParam instanceof HomePageParam.HomePageUpdateParam){
|
||||
homePageLambdaQueryWrapper.ne(HomePage::getId,((HomePageParam.HomePageUpdateParam) homePageParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(homePageLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(UserResponseEnum.REGISTER_HOMEPAGE_NAME_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.njcn.user.mapper.RoleComponentMapper;
|
||||
import com.njcn.user.pojo.param.RoleParam;
|
||||
import com.njcn.user.pojo.po.RoleComponent;
|
||||
import com.njcn.user.service.IRoleComponentService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Service
|
||||
public class RoleComponentServiceImpl extends ServiceImpl<RoleComponentMapper, RoleComponent> implements IRoleComponentService {
|
||||
|
||||
@Override
|
||||
public List<String> selectRoleComponent(List<String> idList) {
|
||||
return this.lambdaQuery().in(RoleComponent::getRoleId,idList).list().stream().map(RoleComponent::getComponentId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRoleComponent(RoleParam.RoleFunctionComponent roleFunctionComponent) {
|
||||
deleteComponentsByRoleIndex(roleFunctionComponent.getId());
|
||||
if (!roleFunctionComponent.getIdList().isEmpty()){
|
||||
RoleComponent roleComponent = new RoleComponent();
|
||||
roleComponent.setRoleId(roleFunctionComponent.getId());
|
||||
roleFunctionComponent.getIdList().forEach(
|
||||
pojo->{
|
||||
roleComponent.setComponentId(pojo);
|
||||
this.baseMapper.insert(roleComponent);
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色删除组件
|
||||
* @param roleIndex
|
||||
* @return
|
||||
*/
|
||||
public boolean deleteComponentsByRoleIndex(String roleIndex) {
|
||||
QueryWrapper<RoleComponent> roleComponentQueryWrapper = new QueryWrapper<>();
|
||||
roleComponentQueryWrapper.eq("sys_role_component.role_id",roleIndex);
|
||||
int row = this.baseMapper.delete(roleComponentQueryWrapper);
|
||||
return row > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.user.mapper.RoleFunctionMapper;
|
||||
import com.njcn.user.pojo.po.RoleFunction;
|
||||
import com.njcn.user.service.IRoleFunctionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Service
|
||||
public class RoleFunctionServiceImpl extends ServiceImpl<RoleFunctionMapper, RoleFunction> implements IRoleFunctionService {
|
||||
|
||||
@Override
|
||||
public List<String> getFunctionsByRoleIndex(String id) {
|
||||
List<String> functionList = new ArrayList<>();
|
||||
QueryWrapper<RoleFunction> componentQueryWrapper = new QueryWrapper<>();
|
||||
componentQueryWrapper.eq("sys_role_function.role_id",id);
|
||||
functionList = this.baseMapper.selectList(componentQueryWrapper).stream().map(RoleFunction::getFunctionId).collect(Collectors.toList());
|
||||
return functionList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getFunctionsByList(List<String> roleList) {
|
||||
return this.lambdaQuery().in(RoleFunction::getRoleId,roleList).list().stream().map(RoleFunction::getFunctionId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.user.enums.UserResponseEnum;
|
||||
import com.njcn.user.mapper.RoleComponentMapper;
|
||||
import com.njcn.user.mapper.RoleFunctionMapper;
|
||||
import com.njcn.user.mapper.RoleMapper;
|
||||
import com.njcn.user.mapper.UserRoleMapper;
|
||||
import com.njcn.user.pojo.constant.RoleType;
|
||||
import com.njcn.user.pojo.param.RoleParam;
|
||||
import com.njcn.user.pojo.po.Role;
|
||||
import com.njcn.user.pojo.po.RoleComponent;
|
||||
import com.njcn.user.pojo.po.RoleFunction;
|
||||
import com.njcn.user.pojo.po.UserRole;
|
||||
import com.njcn.user.pojo.vo.RoleVO;
|
||||
import com.njcn.user.service.IRoleService;
|
||||
import com.njcn.user.service.IUserRoleService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {
|
||||
|
||||
private final IUserRoleService userRoleService;
|
||||
|
||||
private final UserRoleMapper userRoleMapper;
|
||||
|
||||
private final RoleFunctionMapper roleFunctionMapper;
|
||||
|
||||
private final RoleComponentMapper roleComponentMapper;
|
||||
|
||||
@Override
|
||||
public List<String> getRoleNameByUserId(String id) {
|
||||
List<UserRole> userRoles = userRoleService.getUserRoleByUserId(id);
|
||||
if (CollectionUtils.isEmpty(userRoles)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<Role> roles = this.lambdaQuery()
|
||||
.select(Role::getCode)
|
||||
.eq(Role::getState, DataStateEnum.ENABLE.getCode())
|
||||
.in(Role::getId, userRoles.stream()
|
||||
.map(UserRole::getRoleId)
|
||||
.collect(Collectors.toList())
|
||||
).list();
|
||||
return roles
|
||||
.stream()
|
||||
.map(Role::getCode)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNameByUserId(String id) {
|
||||
List<UserRole> userRoles = userRoleService.getUserRoleByUserId(id);
|
||||
if (CollectionUtils.isEmpty(userRoles)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<Role> roles = this.lambdaQuery()
|
||||
.select(Role::getName)
|
||||
.eq(Role::getState, DataStateEnum.ENABLE.getCode())
|
||||
.in(Role::getId, userRoles.stream()
|
||||
.map(UserRole::getRoleId)
|
||||
.collect(Collectors.toList())
|
||||
).list();
|
||||
return roles
|
||||
.stream()
|
||||
.map(Role::getName)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getIdByUserId(String id) {
|
||||
return userRoleService.getUserRoleByUserId(id).stream().map(UserRole::getRoleId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<RoleVO> listRole(RoleParam.QueryParam queryParam) {
|
||||
QueryWrapper<RoleVO> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
//查询参数不为空,进行条件填充
|
||||
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
||||
//部门根据名称模糊查询
|
||||
queryWrapper
|
||||
.and(param -> param.like("sys_role.name", queryParam.getSearchValue()));
|
||||
}
|
||||
}
|
||||
queryWrapper.ne("sys_role.state", DataStateEnum.DELETED.getCode());
|
||||
if (queryParam.getType().equals(0)){
|
||||
queryWrapper.in("sys_role.type", queryParam.getType(),1);
|
||||
}else if(queryParam.getType().equals(1)){
|
||||
queryWrapper.eq("sys_role.type",2);
|
||||
}
|
||||
//初始化分页数据
|
||||
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> selectRoleDetail(Integer id) {
|
||||
List<Integer> role = new ArrayList<>();
|
||||
if (Objects.equals(id, RoleType.SUPER_ADMINISTRATOR)){
|
||||
role.add(RoleType.ADMINISTRATOR);
|
||||
} else {
|
||||
role.add(RoleType.USER);
|
||||
}
|
||||
QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.ne("sys_role.state", DataStateEnum.DELETED.getCode());
|
||||
queryWrapper.in("sys_role.type",role).orderByAsc("sys_role.type");
|
||||
List<Role> roleVOList = this.baseMapper.selectList(queryWrapper);
|
||||
return roleVOList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addRole(RoleParam roleParam) {
|
||||
checkDicDataCode(roleParam, false);
|
||||
Role role = new Role();
|
||||
BeanUtil.copyProperties(roleParam, role);
|
||||
//默认为正常状态
|
||||
role.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRole(RoleParam.RoleUpdateParam updateParam) {
|
||||
checkDicDataCode(updateParam, true);
|
||||
Role role = new Role();
|
||||
BeanUtil.copyProperties(updateParam, role);
|
||||
return this.updateById(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteRole(List<String> ids) {
|
||||
/**
|
||||
* 删除角色和用户的绑定
|
||||
*/
|
||||
this.baseMapper.deleteUserRole(ids);
|
||||
|
||||
/**
|
||||
* 删除角色和资源的绑定
|
||||
*/
|
||||
this.baseMapper.deleteFunctionRole(ids);
|
||||
|
||||
/**
|
||||
* 删除角色和组件的绑定
|
||||
*/
|
||||
this.baseMapper.deleteComponentRole(ids);
|
||||
return this.lambdaUpdate().set(Role::getState, DataStateEnum.DELETED.getCode()).in(Role::getId, ids).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean selectRelevance(List<String> ids) {
|
||||
/**
|
||||
* 判断角色是否和用户绑定
|
||||
*/
|
||||
List<UserRole> userRoleList = this.userRoleMapper.selectUserRole(ids);
|
||||
/**
|
||||
* 判断角色是否和资源绑定
|
||||
*/
|
||||
List<RoleFunction> roleFunctionList = this.roleFunctionMapper.selectRoleFunction(ids);
|
||||
/**
|
||||
* 判断角色是否和组件绑定
|
||||
*/
|
||||
List<RoleComponent> roleComponentList = this.roleComponentMapper.selectRoleComponet(ids);
|
||||
|
||||
if (userRoleList.size() > 0 || roleComponentList.size() > 0 || roleFunctionList.size() > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数,检查是否存在相同编码的角色代码
|
||||
*/
|
||||
private void checkDicDataCode(RoleParam roleParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<Role> roleLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
roleLambdaQueryWrapper
|
||||
.eq(Role::getName, roleParam.getName())
|
||||
.eq(Role::getState, DataStateEnum.ENABLE.getCode());
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (roleParam instanceof RoleParam.RoleUpdateParam) {
|
||||
roleLambdaQueryWrapper.ne(Role::getId, ((RoleParam.RoleUpdateParam) roleParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(roleLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(UserResponseEnum.ROLE_NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.njcn.user.mapper.UserMapper;
|
||||
import com.njcn.user.mapper.UserRoleMapper;
|
||||
import com.njcn.user.pojo.po.UserRole;
|
||||
import com.njcn.user.service.IUserRoleService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements IUserRoleService {
|
||||
|
||||
private final UserRoleMapper userRoleMapper;
|
||||
|
||||
@Override
|
||||
public List<UserRole> getUserRoleByUserId(String id) {
|
||||
return this.lambdaQuery().eq(UserRole::getUserId, id).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addUserRole(String id, List<String> roles) {
|
||||
boolean result = false;
|
||||
if (!CollectionUtil.isEmpty(roles)){
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setUserId(id);
|
||||
roles.forEach(pojo->{
|
||||
userRole.setRoleId(pojo);
|
||||
this.save(userRole);
|
||||
});
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean updateUserRole(String id, List<String> roles) {
|
||||
//删除原有关系
|
||||
List<String> userRoleList= this.lambdaQuery().eq(UserRole::getUserId, id).list().stream().map(UserRole::getRoleId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<UserRole> lambdaQuery = Wrappers.<UserRole>lambdaQuery();
|
||||
if (!CollectionUtils.isEmpty(userRoleList)){
|
||||
lambdaQuery.eq(UserRole::getUserId, id).in(UserRole::getRoleId,userRoleList);
|
||||
userRoleMapper.delete(lambdaQuery);
|
||||
}
|
||||
//新增关系
|
||||
roles.forEach(role->{
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setUserId(id);
|
||||
userRole.setRoleId(role);
|
||||
this.save(userRole);
|
||||
});
|
||||
// //查出原有的关系
|
||||
// List<String> userRoleList= this.lambdaQuery().eq(UserRole::getUserId, id).list().stream().map(UserRole::getRoleId).collect(Collectors.toList());
|
||||
// //存储共有的集合
|
||||
// List<String> allRole = roles.stream().filter(userRoleList::contains).collect(Collectors.toList());
|
||||
// userRoleList.removeAll(allRole);
|
||||
// //要删除的的集合
|
||||
// Set<String> deleteRole = new HashSet<>(userRoleList);
|
||||
// roles.removeAll(allRole);
|
||||
// //要新增的集合
|
||||
// Set<String> addRole = new HashSet<>(roles);
|
||||
// LambdaQueryWrapper<UserRole> lambdaQuery = Wrappers.<UserRole>lambdaQuery();
|
||||
// if (!CollectionUtils.isEmpty(deleteRole)){
|
||||
// lambdaQuery.eq(UserRole::getUserId, id).in(UserRole::getRoleId,deleteRole);
|
||||
// userRoleMapper.delete(lambdaQuery);
|
||||
// }
|
||||
// if (!CollectionUtils.isEmpty(addRole)){
|
||||
// addRole.forEach(role->{
|
||||
// UserRole userRole = new UserRole();
|
||||
// userRole.setUserId(id);
|
||||
// userRole.setRoleId(role);
|
||||
// this.save(userRole);
|
||||
// });
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,532 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.constant.LogInfo;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.common.utils.sm.DesUtils;
|
||||
import com.njcn.common.utils.sm.Sm4Utils;
|
||||
import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.poi.excel.ExcelUtil;
|
||||
import com.njcn.poi.pojo.bo.BaseLineProExcelBody;
|
||||
import com.njcn.user.enums.UserResponseEnum;
|
||||
import com.njcn.user.enums.UserStatusEnum;
|
||||
import com.njcn.user.mapper.UserMapper;
|
||||
import com.njcn.user.pojo.constant.UserState;
|
||||
import com.njcn.user.pojo.constant.UserType;
|
||||
import com.njcn.user.pojo.dto.UserDTO;
|
||||
import com.njcn.user.pojo.dto.excel.UserExcel;
|
||||
import com.njcn.user.pojo.param.UserParam;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.user.pojo.po.UserSet;
|
||||
import com.njcn.user.pojo.po.UserStrategy;
|
||||
import com.njcn.user.pojo.vo.UserVO;
|
||||
import com.njcn.user.service.*;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
|
||||
|
||||
private final IRoleService roleService;
|
||||
|
||||
private final IUserSetService userSetService;
|
||||
|
||||
private final IUserRoleService userRoleService;
|
||||
|
||||
private final IUserStrategyService userStrategyService;
|
||||
|
||||
private final IDeptService deptService;
|
||||
|
||||
private final GeneralInfo generalInfo;
|
||||
|
||||
@Override
|
||||
public UserDTO getUserByName(String loginName) {
|
||||
User user = getUserByLoginName(loginName);
|
||||
if (Objects.isNull(user)) {
|
||||
return null;
|
||||
}
|
||||
List<String> roleNames = roleService.getRoleNameByUserId(user.getId());
|
||||
UserSet userSet = userSetService.lambdaQuery().eq(UserSet::getUserId, user.getId()).one();
|
||||
return new UserDTO(user.getId(), user.getLoginName(), user.getName(), user.getPassword(), roleNames, userSet.getSecretKey(), userSet.getStandBy(), user.getDeptId(), user.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void judgeUserStatus(String loginName) {
|
||||
User user = getUserByLoginName(loginName);
|
||||
if (Objects.isNull(user)) {
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_WRONG_PWD);
|
||||
}
|
||||
//超级管理员则不做任何逻辑判断
|
||||
if (user.getType() == 0) {
|
||||
return;
|
||||
}
|
||||
//根据用户类型获取对应用户策略
|
||||
UserStrategy userStrategy = userStrategyService.lambdaQuery()
|
||||
.eq(UserStrategy::getType, user.getCasualUser())
|
||||
.eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode())
|
||||
.one();
|
||||
switch (user.getState()) {
|
||||
case UserState.LOCKED:
|
||||
LocalDateTime lockTime = user.getLockTime();
|
||||
lockTime = lockTime.plusMinutes(userStrategy.getLockPwdTime());
|
||||
LocalDateTime nowTime = LocalDateTime.now();
|
||||
//判断是否满足锁定时间
|
||||
if (nowTime.isBefore(lockTime)) {
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_LOCKED);
|
||||
}
|
||||
break;
|
||||
case UserState.DELETE:
|
||||
//用户已注销
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_DELETE);
|
||||
case UserState.UNCHECK:
|
||||
//用户未审核
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_UNAUDITED);
|
||||
case UserState.SLEEP:
|
||||
//用户已休眠
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_SLEEP);
|
||||
case UserState.OVERDUE:
|
||||
//用户密码已过期
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_PASSWORD_EXPIRED);
|
||||
default:
|
||||
if (user.getPwdState() == 1) {
|
||||
throw new BusinessException(UserResponseEnum.NEED_MODIFY_PWD);
|
||||
}
|
||||
//用户状态正常,判断其他细节
|
||||
judgeFirstLogin(user, userStrategy);
|
||||
}
|
||||
//所有验证通过后,更新用户登录时间,以及错误登录记录的信息归零。
|
||||
user.setState(UserState.ENABLE);
|
||||
user.setLoginErrorTimes(0);
|
||||
user.setLoginTime(LocalDateTime.now());
|
||||
user.setFirstErrorTime(null);
|
||||
user.setLockTime(null);
|
||||
this.baseMapper.updateById(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean addUser(UserParam.UserAddParam addUserParam) {
|
||||
/**
|
||||
* 检查注册用户的数据是否有重复
|
||||
* 1.登录名不能相同
|
||||
* 2.手机号不能相同 但手机号可以不填
|
||||
*/
|
||||
if (!Objects.isNull(getUserByLoginName(addUserParam.getLoginName()))) {
|
||||
throw new BusinessException(UserResponseEnum.REGISTER_LOGIN_NAME_EXIST);
|
||||
}
|
||||
if (StringUtils.isNotBlank(addUserParam.getPhone()) && !Objects.isNull(getUserByPhone(addUserParam.getPhone(), false, null))) {
|
||||
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_FAIL);
|
||||
}
|
||||
//sys_user_set表新增数据
|
||||
UserSet userSet = userSetService.addUserSet(addUserParam);
|
||||
//sys_user表新增数据
|
||||
User user = cloneUserBoToUser(addUserParam, userSet);
|
||||
//sys_user_role表新增数据
|
||||
boolean result = userRoleService.addUserRole(user.getId(), addUserParam.getRole());
|
||||
if (result) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean updateUser(UserParam.UserUpdateParam updateUserParam) {
|
||||
if (StringUtils.isNotBlank(updateUserParam.getPhone()) && !Objects.isNull(getUserByPhone(updateUserParam.getPhone(), true, updateUserParam.getId()))) {
|
||||
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_FAIL);
|
||||
}
|
||||
User user = new User();
|
||||
BeanUtil.copyProperties(updateUserParam, user);
|
||||
//修改用户角色表
|
||||
userRoleService.updateUserRole(updateUserParam.getId(), updateUserParam.getRole());
|
||||
return this.updateById(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteUser(String id) {
|
||||
return this.lambdaUpdate()
|
||||
.set(User::getState, UserState.DELETE)
|
||||
.in(User::getId, id)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkUser(List<String> list) {
|
||||
return this.lambdaUpdate()
|
||||
.set(User::getState, UserState.ENABLE)
|
||||
.in(User::getId, list)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVO getUserById(String id) {
|
||||
UserVO userVO = new UserVO();
|
||||
User user = lambdaQuery().eq(User::getId, id).one();
|
||||
if (Objects.isNull(user)) {
|
||||
return null;
|
||||
}
|
||||
BeanUtil.copyProperties(user, userVO);
|
||||
userVO.setDeptName(deptService.getNameByDeptId(user.getDeptId()));
|
||||
userVO.setRoleList(roleService.getIdByUserId(id));
|
||||
userVO.setRole(roleService.getNameByUserId(id));
|
||||
return userVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<UserVO> userList(UserParam.UserQueryParam queryParam) {
|
||||
QueryWrapper<UserVO> queryWrapper = new QueryWrapper<>();
|
||||
Page<UserVO> page = new Page<>();
|
||||
Integer type = this.lambdaQuery().eq(User::getId, RequestUtil.getUserIndex()).one().getType();
|
||||
if (Objects.equals(UserType.SUPER_ADMINISTRATOR, type)) {
|
||||
type = UserType.ADMINISTRATOR;
|
||||
} else if (Objects.equals(UserType.ADMINISTRATOR, type)) {
|
||||
type = UserType.USER;
|
||||
} else if (Objects.equals(UserType.USER, type)) {
|
||||
return page;
|
||||
}
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
//查询参数不为空,进行条件填充
|
||||
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
||||
//用户表提供用户名、登录名 模糊查询
|
||||
queryWrapper
|
||||
.and(param -> param.like("sys_user.name", queryParam.getSearchValue())
|
||||
.or().like("sys_user.login_Name", queryParam.getSearchValue()));
|
||||
}
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equalsIgnoreCase(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//默认根据最后登录时间排序
|
||||
queryWrapper.orderBy(true, false, "sys_user.login_time");
|
||||
}
|
||||
}
|
||||
queryWrapper.eq("sys_user.type", type);
|
||||
page = this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper, queryParam.getSearchState(), queryParam.getCasualUser());
|
||||
page.getRecords().forEach(item -> {
|
||||
item.setRoleList(roleService.getIdByUserId(item.getId()));
|
||||
item.setRole(roleService.getNameByUserId(item.getId()));
|
||||
});
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<UserVO> checkUserList(UserParam.UserQueryParam queryParam) {
|
||||
QueryWrapper<UserVO> queryWrapper = new QueryWrapper<>();
|
||||
Page<UserVO> page = new Page<>();
|
||||
Integer type = this.lambdaQuery().eq(User::getId, RequestUtil.getUserIndex()).one().getType();
|
||||
if (Objects.equals(UserType.SUPER_ADMINISTRATOR, type)) {
|
||||
type = UserType.ADMINISTRATOR;
|
||||
} else if (Objects.equals(UserType.ADMINISTRATOR, type)) {
|
||||
type = UserType.USER;
|
||||
} else if (Objects.equals(UserType.USER, type)) {
|
||||
return page;
|
||||
}
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
//查询参数不为空,进行条件填充
|
||||
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
||||
//用户表提供用户名、登录名 模糊查询
|
||||
queryWrapper
|
||||
.and(param -> param.like("sys_user.name", queryParam.getSearchValue())
|
||||
.or().like("sys_user.login_Name", queryParam.getSearchValue()));
|
||||
}
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equalsIgnoreCase(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//默认根据注册时间排序
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equalsIgnoreCase(DbConstant.ASC), "sys_user.register_Time");
|
||||
}
|
||||
}
|
||||
queryWrapper.eq("sys_user.type", type).eq("sys_user.state", UserState.UNCHECK);
|
||||
page = this.baseMapper.checkPage(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
page.getRecords().forEach(item -> {
|
||||
item.setRole(roleService.getNameByUserId(item.getId()));
|
||||
});
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePassword(String id, String password) {
|
||||
String secretPassword = userSetService.updatePassword(id, password);
|
||||
User user = lambdaQuery().eq(User::getId, id).one();
|
||||
user.setPassword(secretPassword);
|
||||
return this.updateById(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String updateUserLoginErrorTimes(String loginName) {
|
||||
User user = this.lambdaQuery().eq(User::getLoginName, loginName).one();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (Objects.nonNull(user)) {
|
||||
UserStrategy userStrategy = userStrategyService.getUserStrategy(user.getCasualUser());
|
||||
Integer loginErrorTimes = user.getLoginErrorTimes();
|
||||
++loginErrorTimes;
|
||||
if (Objects.isNull(user.getFirstErrorTime())) {
|
||||
//首次错误,错误1次、记录第一次错误时间
|
||||
user.setLoginErrorTimes(loginErrorTimes);
|
||||
user.setFirstErrorTime(LocalDateTime.now());
|
||||
} else if (loginErrorTimes <= userStrategy.getLimitPwdTimes()) {
|
||||
//如果次数在策略之内,还未被锁定
|
||||
LocalDateTime firstErrorTime = user.getFirstErrorTime();
|
||||
firstErrorTime = firstErrorTime.plusMinutes(userStrategy.getLockPwdCheck());
|
||||
if (now.isAfter(firstErrorTime)) {
|
||||
//重置密码错误次数、时间等记录
|
||||
user.setLoginErrorTimes(1);
|
||||
user.setFirstErrorTime(LocalDateTime.now());
|
||||
} else {
|
||||
user.setLoginErrorTimes(loginErrorTimes);
|
||||
}
|
||||
} else {
|
||||
user.setLockTime(LocalDateTime.now());
|
||||
user.setState(UserStatusEnum.LOCKED.getCode());
|
||||
user.setLoginErrorTimes(loginErrorTimes);
|
||||
this.baseMapper.updateById(user);
|
||||
return UserResponseEnum.LOGIN_USER_LOCKED.getMessage();
|
||||
}
|
||||
this.baseMapper.updateById(user);
|
||||
}
|
||||
return CommonResponseEnum.SUCCESS.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passwordConfirm(String password) {
|
||||
//当前用户加密密码
|
||||
String secretPassword = this.lambdaQuery().eq(User::getId, RequestUtil.getUserIndex()).one().getPassword();
|
||||
String decryptPassword = userSetService.getDecryptPassword(password);
|
||||
UserSet userSet = userSetService.getUserSetByUserId(RequestUtil.getUserIndex());
|
||||
String secretKey = userSet.getSecretKey();
|
||||
Sm4Utils sm4 = new Sm4Utils(secretKey);
|
||||
String mPwd = sm4.encryptData_ECB(decryptPassword);
|
||||
//二次确认加密密码
|
||||
String secondSecretPassword = sm4.encryptData_ECB(mPwd + secretKey);
|
||||
return Objects.equals(secretPassword, secondSecretPassword);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean updateFirstPassword(String secretName, String password, String ip) {
|
||||
String loginName = DesUtils.aesDecrypt(secretName);
|
||||
User user = this.lambdaQuery().eq(User::getLoginName, loginName).one();
|
||||
String secretPassword = userSetService.updateFirstPassword(user.getId(), password, loginName, ip);
|
||||
user.setPassword(secretPassword);
|
||||
user.setPwdState(UserState.NEEDLESS);
|
||||
return this.updateById(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String exportUser(UserParam.UserQueryParam queryParam, String methodDescribe) {
|
||||
QueryWrapper<UserExcel> queryWrapper = new QueryWrapper<>();
|
||||
List<UserExcel> userExcels;
|
||||
String fileName = methodDescribe + ".xlsx";
|
||||
String targetDir = generalInfo.getBusinessTempPath() + File.separator + RequestUtil.getUserIndex();
|
||||
File parentDir = new File(targetDir);
|
||||
if(!parentDir.exists()){
|
||||
parentDir.mkdirs();
|
||||
}
|
||||
File excel = new File(targetDir, fileName);
|
||||
Integer type = this.lambdaQuery().eq(User::getId, RequestUtil.getUserIndex()).one().getType() + 1;
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
//查询参数不为空,进行条件填充
|
||||
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
||||
//用户表提供用户名、登录名 模糊查询
|
||||
queryWrapper
|
||||
.and(param -> param.like("sys_user.name", queryParam.getSearchValue())
|
||||
.or().like("sys_user.login_Name", queryParam.getSearchValue()));
|
||||
}
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equalsIgnoreCase(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//默认根据最后登录时间排序
|
||||
queryWrapper.orderBy(true, false, "sys_user.login_time");
|
||||
}
|
||||
}
|
||||
queryWrapper.eq("sys_user.type", type);
|
||||
userExcels = this.baseMapper.queryExportUser(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(userExcels)) {
|
||||
userExcels = new ArrayList<>();
|
||||
} else {
|
||||
userExcels = userExcels.stream().peek(userExcel -> {
|
||||
userExcel.setRole(String.join(",", roleService.getNameByUserId(userExcel.getId())));
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
ExcelUtil.exportExcelWithTargetFile(excel, UserExcel.class, userExcels);
|
||||
return FileUtil.getAbsolutePath(excel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据登录名查询用户
|
||||
*
|
||||
* @param loginName 登录名
|
||||
* @return 用户信息
|
||||
*/
|
||||
private User getUserByLoginName(String loginName) {
|
||||
return lambdaQuery()
|
||||
.eq(User::getLoginName, loginName)
|
||||
.one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户
|
||||
*
|
||||
* @param phone 手机号码
|
||||
* @return 用户信息
|
||||
*/
|
||||
private User getUserByPhone(String phone, boolean result, String id) {
|
||||
if (result) {
|
||||
return lambdaQuery()
|
||||
.eq(User::getPhone, phone)
|
||||
.ne(User::getId, id)
|
||||
.one();
|
||||
} else {
|
||||
return lambdaQuery()
|
||||
.eq(User::getPhone, phone)
|
||||
.one();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否需要修改密码
|
||||
*/
|
||||
private void judgeFirstLogin(@NotNull User user, UserStrategy userStrategy) {
|
||||
if (user.getPwdState() == 1) {
|
||||
throw new BusinessException(UserResponseEnum.NEED_MODIFY_PWD);
|
||||
} else {
|
||||
judgeIp(user, userStrategy);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户是否在合理的IP内登录
|
||||
*/
|
||||
private void judgeIp(@NotNull User user, UserStrategy userStrategy) {
|
||||
String ipSection = user.getLimitIpStart() + "-" + user.getLimitIpEnd();
|
||||
if (RequestUtil.getRealIp().equalsIgnoreCase(LogInfo.UNKNOWN_IP)) {
|
||||
//feign接口可能获取的IP是空的
|
||||
throw new BusinessException(UserResponseEnum.INVALID_IP);
|
||||
} else if (!PubUtils.ipExistsInRange(RequestUtil.getRealIp(), ipSection)) {
|
||||
throw new BusinessException(UserResponseEnum.INVALID_IP);
|
||||
} else {
|
||||
judgeLimitTime(user, userStrategy);
|
||||
}
|
||||
judgeLimitTime(user, userStrategy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户是否在允许的时间段内登录
|
||||
*/
|
||||
private void judgeLimitTime(@NotNull User user, UserStrategy userStrategy) {
|
||||
int nowHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
|
||||
String[] limitTime = user.getLimitTime().split(StrUtil.DASHED);
|
||||
if (nowHour >= Integer.parseInt(limitTime[0]) && nowHour < Integer.parseInt(limitTime[1])) {
|
||||
judgePwdTimeValidity(user, userStrategy);
|
||||
} else {
|
||||
throw new BusinessException(UserResponseEnum.INVALID_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户密码是否已经过期
|
||||
*/
|
||||
private void judgePwdTimeValidity(@NotNull User user, UserStrategy userStrategy) {
|
||||
LocalDateTime pwdValidity = user.getPwdValidity();
|
||||
pwdValidity = pwdValidity.plusMonths(userStrategy.getLimitPwdDate());
|
||||
if (LocalDateTime.now().isBefore(pwdValidity)) {
|
||||
judgeLeisurePwd(user, userStrategy);
|
||||
} else {
|
||||
//将用户状态置为过期
|
||||
user.setState(UserState.OVERDUE);
|
||||
this.baseMapper.updateById(user);
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_PASSWORD_EXPIRED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户闲置
|
||||
*/
|
||||
private void judgeLeisurePwd(@NotNull User user, UserStrategy userStrategy) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime sleepTime = user.getLoginTime().plusDays(userStrategy.getSleep());
|
||||
LocalDateTime logoutTime = user.getLoginTime().plusDays(userStrategy.getLogout());
|
||||
if (now.isAfter(sleepTime) && now.isBefore(logoutTime)) {
|
||||
//将用户状态置为休眠
|
||||
user.setState(UserState.SLEEP);
|
||||
this.baseMapper.updateById(user);
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_SLEEP);
|
||||
} else if (now.isAfter(logoutTime)) {
|
||||
//将用户状态置为注销
|
||||
user.setState(UserState.DELETE);
|
||||
this.baseMapper.updateById(user);
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_DELETE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* sys_user表新增数据
|
||||
*
|
||||
* @param addUserParam 新增用户信息
|
||||
* @param userSet 用户配置信息
|
||||
* @return
|
||||
*/
|
||||
private User cloneUserBoToUser(UserParam.UserAddParam addUserParam, UserSet userSet) {
|
||||
User user = new User();
|
||||
BeanUtil.copyProperties(addUserParam, user);
|
||||
//设置用户id
|
||||
user.setId(userSet.getUserId());
|
||||
//对密码做处理 SM4加密(SM4_1密码+工作秘钥)
|
||||
String secretKey = userSet.getSecretKey();
|
||||
Sm4Utils sm4 = new Sm4Utils(secretKey);
|
||||
user.setPassword(sm4.encryptData_ECB(userSet.getStandBy() + secretKey));
|
||||
//新建用户为管理员时,默认部门为顶级部门
|
||||
if (Objects.equals(addUserParam.getType(), UserType.ADMINISTRATOR)) {
|
||||
user.setDeptId(deptService.getTopDeptId());
|
||||
}
|
||||
//填写一些默认值
|
||||
user.setState(UserState.UNCHECK);
|
||||
user.setOrigin(UserState.NORMAL_ORIGIN);
|
||||
user.setCasualUser(UserType.OFFICIAL);
|
||||
user.setPwdState(UserState.NEED);
|
||||
user.setRegisterTime(LocalDateTime.now());
|
||||
user.setLoginTime(LocalDateTime.now());
|
||||
user.setPwdValidity(LocalDateTime.now());
|
||||
user.setLoginErrorTimes(UserState.ERROR_PASSWORD_TIMES);
|
||||
user.setReferralCode(PubUtils.randomCode(6));
|
||||
this.save(user);
|
||||
return user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.common.pojo.constant.SecurityConstants;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.common.utils.sm.Sm2;
|
||||
import com.njcn.common.utils.sm.Sm4Utils;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.user.enums.UserResponseEnum;
|
||||
import com.njcn.user.mapper.UserMapper;
|
||||
import com.njcn.user.mapper.UserSetMapper;
|
||||
import com.njcn.user.pojo.constant.UserDefaultPassword;
|
||||
import com.njcn.user.pojo.constant.UserState;
|
||||
import com.njcn.user.pojo.param.UserParam;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.user.pojo.po.UserSet;
|
||||
import com.njcn.user.service.IUserSetService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserSetServiceImpl extends ServiceImpl<UserSetMapper, UserSet> implements IUserSetService {
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
private final UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public UserSet addUserSet(UserParam.UserAddParam addUserParam) {
|
||||
UserSet userSet = new UserSet();
|
||||
String userId = IdUtil.simpleUUID();
|
||||
userSet.setUserId(userId);
|
||||
String secretKey = PubUtils.randomCode(16);
|
||||
userSet.setSecretKey(secretKey);
|
||||
Sm4Utils sm4 = new Sm4Utils(secretKey);
|
||||
//SM4加密初始默认密码
|
||||
String strSm4 = sm4.encryptData_ECB(UserDefaultPassword.DEFAULT_PASSWORD);
|
||||
userSet.setStandBy(strSm4);
|
||||
this.save(userSet);
|
||||
return userSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String updatePassword(String id,String newPassword) {
|
||||
String password = getSecretPassword(newPassword);
|
||||
return updatePsd(id,password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String updateFirstPassword(String id, String newPassword, String name, String ip) {
|
||||
String password = getSecretPasswordNotLogin(newPassword, name, ip);
|
||||
return updatePsd(id,password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDecryptPassword(String password) {
|
||||
return getSecretPassword(password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserSet getUserSetByUserId(String userId) {
|
||||
return this.lambdaQuery().eq(UserSet::getUserId,userId).one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码公共方法
|
||||
* @param id
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
private String updatePsd(String id, String password) {
|
||||
Sm4Utils sm4;
|
||||
String psd,strSm4;
|
||||
String standard = PatternRegex.PASSWORD_REGEX;
|
||||
Pattern pattern = Pattern.compile(standard);
|
||||
Matcher m=pattern.matcher(password);
|
||||
if (!m.find()){
|
||||
throw new BusinessException(UserResponseEnum.SPECIAL_PASSWORD);
|
||||
}
|
||||
UserSet userSet = this.lambdaQuery().eq(UserSet::getUserId, id).one();
|
||||
QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
|
||||
userQueryWrapper.eq("sys_user.id",id);
|
||||
User user = userMapper.selectOne(userQueryWrapper);
|
||||
String secretPassword = user.getPassword();
|
||||
if (Objects.isNull(userSet)){
|
||||
UserSet newUserSet = new UserSet();
|
||||
String secretKey = PubUtils.randomCode(16);
|
||||
newUserSet.setSecretKey(secretKey);
|
||||
sm4 = new Sm4Utils(secretKey);
|
||||
strSm4 = sm4.encryptData_ECB(password);
|
||||
newUserSet.setStandBy(strSm4);
|
||||
newUserSet.setUserId(id);
|
||||
this.save(newUserSet);
|
||||
psd = sm4.encryptData_ECB(strSm4 + secretKey);
|
||||
} else {
|
||||
sm4 = new Sm4Utils(userSet.getSecretKey());
|
||||
strSm4 = sm4.encryptData_ECB(password);
|
||||
psd = sm4.encryptData_ECB(strSm4 + userSet.getSecretKey());
|
||||
}
|
||||
if (Objects.equals(secretPassword,psd)){
|
||||
throw new BusinessException(UserResponseEnum.REPEAT_PASSWORD);
|
||||
}
|
||||
return psd;
|
||||
}
|
||||
|
||||
/**
|
||||
* 未登录
|
||||
* 前端密文密码解码
|
||||
*/
|
||||
private String getSecretPasswordNotLogin(String password, String name, String ip) {
|
||||
String privateKey = redisUtil.getStringByKey(name + ip);
|
||||
//秘钥用完即删
|
||||
redisUtil.delete(name + ip);
|
||||
//对SM2解密面进行验证
|
||||
password = Sm2.getPasswordSM2Verify(privateKey, password);
|
||||
if (StrUtil.isBlankIfStr(password)) {
|
||||
throw new BusinessException(UserResponseEnum.PASSWORD_TRANSPORT_ERROR);
|
||||
}
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* 登陆后
|
||||
* 前端密文密码解码
|
||||
*/
|
||||
private String getSecretPassword(String password) {
|
||||
String loginName = RequestUtil.getUsername();
|
||||
String ip = RequestUtil.getRequest().getHeader(SecurityConstants.REQUEST_HEADER_KEY_CLIENT_REAL_IP);
|
||||
String privateKey = redisUtil.getStringByKey(loginName + ip);
|
||||
//秘钥用完即删
|
||||
redisUtil.delete(loginName + ip);
|
||||
//对SM2解密面进行验证
|
||||
password = Sm2.getPasswordSM2Verify(privateKey, password);
|
||||
if (StrUtil.isBlankIfStr(password)) {
|
||||
throw new BusinessException(UserResponseEnum.PASSWORD_TRANSPORT_ERROR);
|
||||
}
|
||||
return password;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.user.enums.UserResponseEnum;
|
||||
import com.njcn.user.mapper.UserStrategyMapper;
|
||||
import com.njcn.user.pojo.po.UserStrategy;
|
||||
import com.njcn.user.service.IUserStrategyService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Service
|
||||
public class UserStrategyServiceImpl extends ServiceImpl<UserStrategyMapper, UserStrategy> implements IUserStrategyService {
|
||||
|
||||
@Override
|
||||
public UserStrategy getUserStrategy(Integer casualUser) {
|
||||
UserStrategy userStrategy = this.lambdaQuery()
|
||||
.eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode())
|
||||
.eq(UserStrategy::getType, casualUser)
|
||||
.one();
|
||||
if (Objects.isNull(userStrategy)) {
|
||||
throw new BusinessException(UserResponseEnum.LACK_USER_STRATEGY);
|
||||
}
|
||||
return userStrategy;
|
||||
}
|
||||
}
|
||||
49
pqs-user/user-boot/src/main/resources/bootstrap.yml
Normal file
49
pqs-user/user-boot/src/main/resources/bootstrap.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10201
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
#nacos注册中心以及配置中心的指定
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-Id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.user.pojo
|
||||
18
pqs-user/user-boot/src/test/java/com/njcn/BaseJunitTest.java
Normal file
18
pqs-user/user-boot/src/test/java/com/njcn/BaseJunitTest.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.njcn;
|
||||
|
||||
import com.njcn.user.UserBootApplication;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月10日 15:05
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@SpringBootTest(classes = UserBootApplication.class)
|
||||
public class BaseJunitTest {
|
||||
}
|
||||
25
pqs-user/user-boot/src/test/java/com/njcn/UserTest.java
Normal file
25
pqs-user/user-boot/src/test/java/com/njcn/UserTest.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.njcn;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月14日 12:55
|
||||
*/
|
||||
public class UserTest extends BaseJunitTest{
|
||||
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
public void test(){
|
||||
|
||||
|
||||
System.out.println("hello");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user