| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.TTesterOtherTaskDTO; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.model.TProjectTeam; |
| | | import com.ruoyi.system.model.TProjectTeamStaff; |
| | | import com.ruoyi.system.model.TTesterOtherTask; |
| | | import com.ruoyi.system.query.TTesterOtherTaskQuery; |
| | | import com.ruoyi.system.service.TProjectTeamService; |
| | | import com.ruoyi.system.service.TProjectTeamStaffService; |
| | | import com.ruoyi.system.service.TTesterOtherTaskService; |
| | | import com.ruoyi.system.vo.TProjectTeamVO; |
| | | import com.ruoyi.system.vo.TTesterOtherTaskVO; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequestMapping("/t-tester-other-task") |
| | | public class TTesterOtherTaskController { |
| | | |
| | | private final TTesterOtherTaskService testerOtherTaskService; |
| | | private final TokenService tokenService; |
| | | private final TProjectTeamService projectTeamService; |
| | | private final TProjectTeamStaffService projectTeamStaffService; |
| | | private final SysUserMapper sysUserMapper; |
| | | @Autowired |
| | | public TTesterOtherTaskController(TTesterOtherTaskService testerOtherTaskService, TokenService tokenService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, SysUserMapper sysUserMapper) { |
| | | this.testerOtherTaskService = testerOtherTaskService; |
| | | this.tokenService = tokenService; |
| | | this.projectTeamService = projectTeamService; |
| | | this.projectTeamStaffService = projectTeamStaffService; |
| | | this.sysUserMapper = sysUserMapper; |
| | | } |
| | | |
| | | /** |
| | | * 实验员其他任务管理列表 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:testerOtherTask:list')") |
| | | @ApiOperation(value = "实验员其他任务管理分页列表", response = TTesterOtherTaskQuery.class) |
| | | @PostMapping(value = "/api/t-tester-other-task/pageList") |
| | | public R<PageInfo<TTesterOtherTaskVO>> pageList(@RequestBody String param) { |
| | | TTesterOtherTaskQuery query = JSON.parseObject(param, TTesterOtherTaskQuery.class); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | if(roleType != 1){ |
| | | // 查询用户所在项目组 |
| | | List<TProjectTeamStaff> projectTeamStaffs = projectTeamStaffService.list(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId, userId)); |
| | | if(projectTeamStaffs.size() > 0){ |
| | | // 查询项目组id |
| | | List<String> teamIds = projectTeamStaffs.stream().map(TProjectTeamStaff::getTeamId).distinct().collect(Collectors.toList()); |
| | | query.setTeamIds(teamIds); |
| | | } |
| | | } |
| | | return R.ok(testerOtherTaskService.pageList(query)); |
| | | } |
| | | |
| | | /** |
| | | * 添加实验员其他任务管理管理 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:testerOtherTask:add')") |
| | | @Log(title = "实验员其他任务管理信息-新增实验员其他任务管理", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "添加实验员其他任务管理",response = TTesterOtherTaskDTO.class) |
| | | @PostMapping(value = "/api/t-tester-other-task/add") |
| | | public R<Boolean> add(@RequestBody String param) { |
| | | TTesterOtherTaskDTO dto = JSON.parseObject(param,TTesterOtherTaskDTO.class); |
| | | // 通过当前用户查询项目组 |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | if(Objects.isNull(projectTeamStaff)){ |
| | | return R.fail("当前用户未分配项目组,无法创建实验员其他任务"); |
| | | } |
| | | // 查询项目组 |
| | | TProjectTeam projectTeam = projectTeamService.getById(projectTeamStaff.getTeamId()); |
| | | if(Objects.isNull(projectTeam)){ |
| | | return R.fail("项目组不存在"); |
| | | } |
| | | if(projectTeam.getStatus() == 2){ |
| | | return R.fail("项目组已封存,无法创建项目课题方案"); |
| | | } |
| | | testerOtherTaskService.save(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改实验员其他任务管理 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:testerOtherTask:edit')") |
| | | @Log(title = "实验员其他任务管理信息-修改实验员其他任务管理", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "修改实验员其他任务管理") |
| | | @PostMapping(value = "/api/t-tester-other-task/update") |
| | | public R<Boolean> update(@RequestBody String param) { |
| | | TTesterOtherTaskDTO dto = JSON.parseObject(param,TTesterOtherTaskDTO.class); |
| | | testerOtherTaskService.updateById(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 查看实验员其他任务管理详情 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:testerOtherTask:detail')") |
| | | @ApiOperation(value = "查看实验员其他任务管理详情") |
| | | @GetMapping(value = "/open/t-tester-other-task/getDetailById") |
| | | public R<TTesterOtherTaskVO> getDetailById(@RequestParam String id) { |
| | | TTesterOtherTask testerOtherTask = testerOtherTaskService.getById(id); |
| | | TTesterOtherTaskVO testerOtherTaskVO = new TTesterOtherTaskVO(); |
| | | BeanUtils.copyProperties(testerOtherTask, testerOtherTaskVO); |
| | | // 查询项目组信息 |
| | | TProjectTeam projectTeam = projectTeamService.getById(testerOtherTask.getTeamId()); |
| | | TProjectTeamVO projectTeamVO = new TProjectTeamVO(); |
| | | BeanUtils.copyProperties(projectTeam, projectTeamVO); |
| | | // 查询项目组成员 |
| | | List<TProjectTeamStaff> projectTeamStaffs = projectTeamStaffService.list(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getTeamId, projectTeam.getId())); |
| | | List<Long> userIds = projectTeamStaffs.stream().map(TProjectTeamStaff::getUserId).collect(Collectors.toList()); |
| | | userIds = userIds.stream().distinct().collect(Collectors.toList()); |
| | | List<SysUser> sysUsers = sysUserMapper.selectUserByIds(userIds); |
| | | // 拼接项目组成员名称 |
| | | projectTeamVO.setStaffName(sysUsers.stream().map(SysUser::getNickName).collect(Collectors.joining(","))); |
| | | testerOtherTaskVO.setProjectTeam(projectTeamVO); |
| | | // 查询是演员信息 |
| | | SysUser sysUser = sysUserMapper.selectUserById(testerOtherTaskVO.getTesterId()); |
| | | if(Objects.nonNull(sysUser)){ |
| | | testerOtherTaskVO.setTesterName(sysUser.getNickName()); |
| | | } |
| | | return R.ok(testerOtherTaskVO); |
| | | } |
| | | |
| | | /** |
| | | * 删除实验员其他任务管理 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:testerOtherTask:delete')") |
| | | @Log(title = "实验员其他任务管理信息-删除实验员其他任务管理", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "删除实验员其他任务管理") |
| | | @DeleteMapping(value = "/open/t-tester-other-task/deleteById") |
| | | public R<Boolean> deleteById(@RequestParam String id) { |
| | | return R.ok(testerOtherTaskService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除实验员其他任务管理 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:testerOtherTask:delete')") |
| | | @Log(title = "实验员其他任务管理信息-删除实验员其他任务管理", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "批量删除实验员其他任务管理") |
| | | @DeleteMapping(value = "/open/t-tester-other-task/deleteByIds") |
| | | public R<Boolean> deleteByIds(@RequestBody List<String> ids) { |
| | | return R.ok(testerOtherTaskService.removeByIds(ids)); |
| | | } |
| | | |
| | | } |
| | | |