Commit 7c183d72 authored by cq990612's avatar cq990612

优化代码结构

parent 45511f79
......@@ -37,7 +37,7 @@ public interface WorkUserMapper extends BaseMapper<WorkUser> {
*/
List<StatisticsTableDto> getStatisticsTableDtos(List<Integer> userIds);
List<UserRoleDto> getUserRoleDto();
List<UserRoleDto> getUserRoleDto(Integer status);
List<WorkRole> getUserRole(Integer id);
......
......@@ -30,7 +30,7 @@
SELECT <include refid="Base_Column_List"/>
FROM <include refid="table"/>
WHERE year(day_start) = year(#{date})
ORDER BY day_start
ORDER BY day_type desc,day_start asc
</select>
</mapper>
......@@ -122,7 +122,7 @@ GROUP_CONCAT(DISTINCT(u.name)) as 'participants',p.cost_budget,p.work_time,p.sta
if(cost is NULL,0.00,cost) as 'currentLaborCost',if(total_time is NULL,0.00,total_time) as 'totalCurrentWorkingHours',
if(now() BETWEEN p.start_time and p.end_time,'否','是') as 'isItOverdue',
if(p.create_time = p.modify_time,'否','是') as 'isThereABudgetChange'
from work_project p LEFT JOIN (select project_id,SUM(total_time) as 'total_time',SUM(cost)as 'cost'
from work_project p LEFT JOIN (select project_id,SUM(total_time) as 'total_time',SUM(cost) as 'cost'
FROM work_project_time_cost
GROUP BY project_id) o on p.id = o.project_id
LEFT JOIN work_user_project up ON p.id = up.project_id
......
......@@ -113,6 +113,11 @@
select u.id as 'id',u.name as 'name',u.status as 'status',r.id as 'role_id',r.name as 'role_name'
from work_user u LEFT JOIN (select role_id,user_id FROM work_user_role GROUP BY user_id) ur ON u.id = ur.user_id
LEFT JOIN work_role r on ur.role_id = r.id
<where>
<if test="null !=status">
status = #{status}
</if>
</where>
</select>
<select id="getUserRole" resultType="cn.wisenergy.model.app.WorkRole">
......
......@@ -16,7 +16,6 @@ import java.util.Date;
public interface WorkHolidayService {
Boolean isHoliday(Date date);
Boolean addAndModifyHoliday(WorkHoliday workHoliday);
Boolean deleteHoliday(Integer id);
......
package cn.wisenergy.service;
import cn.wisenergy.model.app.WorkProject;
import cn.wisenergy.model.dto.UserProjectDto;
import java.util.List;
......@@ -22,8 +21,6 @@ public interface WorkUserProjectService {
*/
List<Integer> getProjectIdByUserId(Integer userId);
List<WorkProject> getUserManageProject(Integer userId);
/**
* 根据项目id获取参与人数
* @param projectId 项目id
......@@ -31,7 +28,18 @@ public interface WorkUserProjectService {
*/
List<UserProjectDto> getUserProjectByProjectId(Integer projectId);
/**
* 根据项目id删除数据
* @param projectId 项目id
* @return boolean
*/
Boolean deleteByProjectId(Integer projectId);
/**
* 批量插入
* @param userIds 用户id
* @param projectId 项目id
* @return boolean
*/
Boolean insertBatch(List<Integer> userIds, Integer projectId);
}
......@@ -55,7 +55,7 @@ public interface WorkUserService {
*/
List<OrganizationStructureDto> getOrganizationStructure();
AllRoleAndUserRoleDto getUserRoleDto(Integer userId,Integer page, Integer pageSize);
AllRoleAndUserRoleDto getUserRoleDto(Integer userId,Integer page, Integer pageSize,Integer status);
Boolean modifyRole(Integer userId, List<Integer> roleIds);
......
......@@ -479,8 +479,8 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
if (null == reviewerId || null == id || StringUtils.isEmpty(reason)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
// 判断当前用户是否有权限
isManager(reviewerId);
int i = workTimeOrderMapper.updateStatusById(reviewerId, id, reason);
if (i == 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.UPDATE_DATA_FAIL);
......
......@@ -4,13 +4,9 @@ import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.WorkProjectMapper;
import cn.wisenergy.mapper.WorkUserProjectMapper;
import cn.wisenergy.model.app.WorkProject;
import cn.wisenergy.model.app.WorkUser;
import cn.wisenergy.model.app.WorkUserProject;
import cn.wisenergy.model.dto.UserProjectDto;
import cn.wisenergy.model.enums.ManagerEnum;
import cn.wisenergy.service.WorkUserProjectService;
import cn.wisenergy.service.WorkUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -35,9 +31,6 @@ public class WorkUserProjectServiceImpl implements WorkUserProjectService {
@Autowired
private WorkUserProjectMapper workUserProjectMapper;
@Autowired
private WorkUserService workUserService;
@Autowired
WorkProjectMapper workProjectMapper;
......@@ -67,32 +60,7 @@ public class WorkUserProjectServiceImpl implements WorkUserProjectService {
}
@Override
public List<WorkProject> getUserManageProject(Integer userId) {
log.info("WorkUserProjectServiceImpl[]getUserManageProject[]input.param" + userId);
if (userId == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
WorkUser user = workUserService.getById(userId);
Integer level = user.getLevel();
if (!level.equals(ManagerEnum.IS_PROJECT_DIRECTOR.getCode()) || !level.equals(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode())) {
return null;
}
QueryWrapper<WorkProject> wrapper = new QueryWrapper<>();
//项目负责人查看管理项目
if (level.equals(ManagerEnum.IS_PROJECT_DIRECTOR.getCode())) {
wrapper.eq("manager_id", user.getId());
}
//部门负责人查看部门项目
if (level.equals(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode())) {
wrapper.eq("dept_id", user.getDeptId());
}
//项目未结
wrapper.eq("is_conclusion", 0);
//查询
return workProjectMapper.selectList(wrapper);
}
/**
* 根据项目id获取参与人数
......@@ -113,6 +81,12 @@ public class WorkUserProjectServiceImpl implements WorkUserProjectService {
return userByProjectId;
}
/**
* 根据项目id删除数据
* @param projectId 项目id
* @return boolean
*/
@Override
public Boolean deleteByProjectId(Integer projectId) {
log.info("WorkUserProjectServiceImpl[]deleteByProjectId[]input.param.projectId:{}" + projectId);
......@@ -123,6 +97,12 @@ public class WorkUserProjectServiceImpl implements WorkUserProjectService {
return i != 0;
}
/**
* 批量插入
* @param userIds 用户id
* @param projectId 项目id
* @return boolean
*/
@Override
public Boolean insertBatch(List<Integer> userIds, Integer projectId) {
log.info("WorkUserProjectServiceImpl[]deleteByProjectId[]input.param.userIds:{}projectId:{}" + userIds,projectId);
......
......@@ -151,15 +151,15 @@ public class WorkUserServiceImpl implements WorkUserService {
}
@Override
public AllRoleAndUserRoleDto getUserRoleDto(Integer userId, Integer page, Integer pageSize) {
log.info("WorkUserServiceImpl[]getUserRoleDto[]input.param.userId:{},page:{},pageSize:{}" + userId, page, pageSize);
public AllRoleAndUserRoleDto getUserRoleDto(Integer userId, Integer page, Integer pageSize,Integer status) {
log.info("WorkUserServiceImpl[]getUserRoleDto[]input.param.userId:{},page:{},pageSize:{},status:{}" + userId, page, pageSize,status);
if (!UserRoleLevelUtils.isManagerLevel(userId, LevelEnum.ACCOUNTMANAGEMENT.getLevelName())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN);
}
page = page == null ? 1 : page;
pageSize = pageSize == null ? 10 : pageSize;
Page<UserRoleDto> startPage = PageHelper.startPage(page, pageSize);
List<UserRoleDto> userRoleDtos = workUserMapper.getUserRoleDto();
List<UserRoleDto> userRoleDtos = workUserMapper.getUserRoleDto(status);
if (CollectionUtils.isEmpty(userRoleDtos)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.QUERY_DATA_IS_NULL);
}
......
......@@ -89,12 +89,13 @@ public class SystemController extends BaseController {
@ApiImplicitParams({
@ApiImplicitParam(name = "userId",value = "管理员id",dataType = "int",required = true),
@ApiImplicitParam(name = "page", value = "当前页", dataType = "int",required = true),
@ApiImplicitParam(name = "pageSize",value = "记录数",dataType = "int",required = true)
@ApiImplicitParam(name = "pageSize",value = "记录数",dataType = "int",required = true),
@ApiImplicitParam(name = "status",value = "账号状态",dataType = "int")
})
@GetMapping("/getAllRole")
public Result<AllRoleAndUserRoleDto> getAllRole(Integer userId,Integer page,Integer pageSize) {
log.info("SystemController[]getAllRole[]input.param.userId:{},page:{},pageSize:{}" + userId, page, pageSize);
AllRoleAndUserRoleDto allRoleAndUserRoleDto = workUserService.getUserRoleDto(userId,page,pageSize);
public Result<AllRoleAndUserRoleDto> getAllRole(Integer userId,Integer page,Integer pageSize,Integer status) {
log.info("SystemController[]getAllRole[]input.param.userId:{},page:{},pageSize:{},status:{}" + userId, page, pageSize,status);
AllRoleAndUserRoleDto allRoleAndUserRoleDto = workUserService.getUserRoleDto(userId,page,pageSize,status);
return getResult(allRoleAndUserRoleDto);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment