Browse Source

部门信息简报任务列表查询

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
34dec5b8b6
2 changed files with 34 additions and 12 deletions
  1. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/QueryInspectionListServiceEnum.java
  2. +32
    -10
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryNewInspectionListService.java

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/QueryInspectionListServiceEnum.java View File

QUERY_IS_FAILED(1230600, "获取数据失败"), QUERY_IS_FAILED(1230600, "获取数据失败"),
USER_ID_IS_NULL(1230601, "用户id为空"), USER_ID_IS_NULL(1230601, "用户id为空"),
USER_IS_NOT_EXIST(1230602, "用户不存在"), USER_IS_NOT_EXIST(1230602, "用户不存在"),
DEPT_ID_IS_NULL(1230601, "用户id为空"),
DEPT_IS_NOT_EXIST(1230603, "部门不存在");
DEPT_ID_IS_NULL(1230603, "部门id为空"),
DEPT_IS_NOT_EXIST(1230604, "部门不存在");


/** /**
* 错误码 * 错误码

+ 32
- 10
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryNewInspectionListService.java View File

package com.tuoheng.admin.service.inspection.query; package com.tuoheng.admin.service.inspection.query;


import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.UserTypeEnum; import com.tuoheng.admin.enums.UserTypeEnum;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionListServiceEnum;
import com.tuoheng.admin.enums.code.inspectionFile.ListByDeptUserTypeEnum; import com.tuoheng.admin.enums.code.inspectionFile.ListByDeptUserTypeEnum;
import com.tuoheng.admin.mapper.InspectionFileMapper; import com.tuoheng.admin.mapper.InspectionFileMapper;
import com.tuoheng.admin.mapper.InspectionMapper; import com.tuoheng.admin.mapper.InspectionMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import java.util.List;

/** /**
* @Author ChengWang * @Author ChengWang
* @Date 2022/12/2 * @Date 2022/12/2
JsonResult.error(ListByDeptUserTypeEnum.USER_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_IS_NULL.getMsg()); JsonResult.error(ListByDeptUserTypeEnum.USER_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_IS_NULL.getMsg());
} }
String tenantId = user.getTenantId(); String tenantId = user.getTenantId();
String deptId = user.getDeptId();
//判断用户角色 1超级管理员 2部门管理员 3普通用户 //判断用户角色 1超级管理员 2部门管理员 3普通用户
if(null == user.getType()){ if(null == user.getType()){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
//若角色为超级管理员,查询任务表最新五条数据 //若角色为超级管理员,查询任务表最新五条数据
if(UserTypeEnum.SUPER_ADMIN.getCode()==user.getType()){ if(UserTypeEnum.SUPER_ADMIN.getCode()==user.getType()){

List<Inspection> inspectionList = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getTenantId, tenantId)
.eq(Inspection::getMark, 1)
.orderByDesc(Inspection::getCreateTime)
.last("limit 5"));
if(inspectionList==null){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
return JsonResult.success(inspectionList);
} }







return null;

//若角色为部门管理员或普通用户,查询最新五条数据
if(UserTypeEnum.SUPER_ADMIN.getCode()==user.getType() || UserTypeEnum.ORDINARY_USER.getCode()==user.getType()){
if(StringUtils.isEmpty(deptId)){
JsonResult.error(QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getCode(),QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getMsg());
}
List<Inspection> inspectionList = inspectionMapper.selectList(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getTenantId, tenantId)
.eq(Inspection::getDeptId, deptId)
.eq(Inspection::getMark, 1)
.orderByDesc(Inspection::getCreateTime)
.last("limit 5"));
if(inspectionList==null){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
return JsonResult.success(inspectionList);
}
return JsonResult.error();


} }
} }

Loading…
Cancel
Save