Compare commits
4 Commits
1d0d6e7d8a
...
2b3f5b49e0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2b3f5b49e0 | ||
![]() |
7cc778776e | ||
![]() |
d92d517650 | ||
![]() |
b0264f1e2a |
@ -0,0 +1,77 @@
|
||||
package cn.iocoder.yudao.common;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 检测相关和角色和其对应的权重
|
||||
*
|
||||
* 权重分配如下:
|
||||
* 检测业务管理员
|
||||
* 检测站老板
|
||||
* 检测官方
|
||||
* 检测商户
|
||||
* 经销商
|
||||
* 合作商
|
||||
* 引车员
|
||||
* 环检员
|
||||
* 外检员
|
||||
* 外检底检
|
||||
* 一审
|
||||
* 环检预审
|
||||
* 检测用户
|
||||
* @author 小李
|
||||
* @date 15:39 2024/12/15
|
||||
**/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum InspectionRoleCommon {
|
||||
|
||||
/** 检测业务管理员 */
|
||||
JIANCE("jiance", 1),
|
||||
|
||||
/** 检测站老板 */
|
||||
JCBOSS("jcboss", 1),
|
||||
|
||||
/** 检测官方 */
|
||||
JCGF("jcgf", 2),
|
||||
|
||||
/** 检测商户 */
|
||||
JCSHOP("jcshop", 2),
|
||||
|
||||
/** 经销商 */
|
||||
DEALERS("dealers", 2),
|
||||
|
||||
/** 合作商 */
|
||||
PARTNERS("partners", 2),
|
||||
|
||||
/** 引车员 */
|
||||
JCYCY("jcycy", 3),
|
||||
|
||||
/** 环检员 */
|
||||
JCHJY("jchjy", 4),
|
||||
|
||||
/** 外检员 */
|
||||
JCWJY("jcwjy", 4),
|
||||
|
||||
/** 外检底检 */
|
||||
JCWJDJ("jcwjdj", 4),
|
||||
|
||||
/** 一审 */
|
||||
JCYSZZ("jcyszz", 4),
|
||||
|
||||
/** 环检预审 */
|
||||
JCHJYS("jchjys", 4),
|
||||
|
||||
/** 检测用户 */
|
||||
JCYH("jcyh", 4),
|
||||
|
||||
/** 检测员工 */
|
||||
JCWORKER("jcworker", 4);
|
||||
|
||||
/** 角色Code */
|
||||
private final String code;
|
||||
|
||||
/** 角色权重 */
|
||||
private final Integer weight;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.inspection.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.core.controller.BaseController;
|
||||
import cn.iocoder.yudao.module.inspection.entity.InspectionFile;
|
||||
@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* inspectionFileController
|
||||
@ -105,4 +107,19 @@ public class InspectionFileController extends BaseController
|
||||
}
|
||||
return toAjax(inspectionFileService.deleteInspectionFileById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id统计数量
|
||||
*
|
||||
* @author 小李
|
||||
* @date 14:30 2024/12/14
|
||||
* @param ids ids
|
||||
**/
|
||||
@GetMapping("/getCountByIds")
|
||||
public CommonResult<?> getCountByIds(@RequestParam(value = "ids" ,required = false) List<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)){
|
||||
return null;
|
||||
}
|
||||
return success(inspectionFileService.getCountByIds(ids));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.inspection.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.common.InspectionRoleCommon;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
||||
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
||||
import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 检测用的工具Controller
|
||||
*
|
||||
* @author 小李
|
||||
* @date 15:36 2024/12/15
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/admin-api/inspection/util")
|
||||
public class InspectionUtilController {
|
||||
|
||||
@Resource
|
||||
private PermissionApi permissionApi;
|
||||
|
||||
@Resource
|
||||
private RoleApi roleApi;
|
||||
|
||||
/**
|
||||
* 根据用户取出当前用户的角色,只针对检测
|
||||
*
|
||||
* @author 小李
|
||||
* @date 15:15 2024/12/15
|
||||
**/
|
||||
@GetMapping("/getRoleName")
|
||||
public CommonResult<?> getRoleName(){
|
||||
String name = "未知岗位";
|
||||
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(SecurityFrameworkUtils.getLoginUserId());
|
||||
if (CollUtil.isEmpty(roleIdsByUserId)){
|
||||
return success(name);
|
||||
}
|
||||
List<RoleReqDTO> roleList = roleApi.getRoleList();
|
||||
List<RoleReqDTO> roles = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).collect(Collectors.toList());
|
||||
List<InspectionRoleCommon> roleCommons = Arrays.asList(InspectionRoleCommon.values());
|
||||
List<String> codes = roleCommons.stream().map(InspectionRoleCommon::getCode).collect(Collectors.toList());
|
||||
List<RoleReqDTO> inspectionRoles = roles.stream().filter(item -> codes.contains(item.getCode())).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(inspectionRoles)){
|
||||
return success(name);
|
||||
}
|
||||
Integer index = Integer.MAX_VALUE;
|
||||
for (RoleReqDTO inspectionRole : inspectionRoles) {
|
||||
InspectionRoleCommon inspectionRoleCommon = InspectionRoleCommon.valueOf(inspectionRole.getCode().toUpperCase());
|
||||
if (ObjectUtil.isEmpty(inspectionRoleCommon)){
|
||||
continue;
|
||||
}
|
||||
Integer weight = inspectionRoleCommon.getWeight();
|
||||
if (weight < index){
|
||||
index = weight;
|
||||
name = inspectionRole.getName();
|
||||
}
|
||||
}
|
||||
return success(name);
|
||||
}
|
||||
}
|
@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* inspectionFileService接口
|
||||
*
|
||||
@ -63,4 +66,13 @@ public interface IInspectionFileService extends IService<InspectionFile>
|
||||
* @return 分页结果
|
||||
*/
|
||||
IPage<InspectionFile> selectInspectionFileList(Page<InspectionFile> page, InspectionFile inspectionFile);
|
||||
|
||||
/**
|
||||
* 根据id统计数量
|
||||
*
|
||||
* @author 小李
|
||||
* @date 14:30 2024/12/14
|
||||
* @param ids ids
|
||||
**/
|
||||
Map<Long, Long> getCountByIds(List<Long> ids);
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* inspectionFileService业务层处理
|
||||
@ -160,12 +162,32 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
|
||||
@Override
|
||||
public IPage<InspectionFile> selectInspectionFileList(Page<InspectionFile> page, InspectionFile inspectionFile) {
|
||||
// 创建一个空的 QueryWrapper
|
||||
QueryWrapper<InspectionFile> queryWrapper = new QueryWrapper<>();
|
||||
LambdaQueryWrapper<InspectionFile> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(inspectionFile.getFatherId())) {
|
||||
queryWrapper.eq("father_id", inspectionFile.getFatherId());
|
||||
queryWrapper.eq(InspectionFile::getFatherId, inspectionFile.getFatherId());
|
||||
}
|
||||
queryWrapper.orderByAsc(InspectionFile::getType);
|
||||
queryWrapper.orderByDesc(InspectionFile::getCreateTime);
|
||||
if (ObjectUtil.isNotEmpty(inspectionFile.getFileName())){
|
||||
queryWrapper.like(InspectionFile::getFileName, inspectionFile.getFileName());
|
||||
}
|
||||
|
||||
// 直接调用 MyBatis-Plus 的 page 方法进行分页查询
|
||||
return this.page(page, queryWrapper); // 返回符合条件的分页查询结果
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id统计数量
|
||||
*
|
||||
* @author 小李
|
||||
* @date 14:30 2024/12/14
|
||||
* @param ids ids
|
||||
**/
|
||||
@Override
|
||||
public Map<Long, Long> getCountByIds(List<Long> ids){
|
||||
List<InspectionFile> inspectionFiles = baseMapper.selectList(new LambdaQueryWrapper<InspectionFile>().in(InspectionFile::getFatherId, ids));
|
||||
return inspectionFiles.stream().collect(Collectors.groupingBy(
|
||||
InspectionFile::getFatherId,
|
||||
Collectors.counting()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,6 @@ public class SysLoginController {
|
||||
return success(loginService.login(authLoginReqVO));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 汽修小程序登录方法
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user