| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.api.R; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.ProjectStatusCountDTO; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.ProjectMapper; |
| | | import com.whyc.mapper.UserMapper; |
| | | import com.whyc.pojo.Project; |
| | | import com.whyc.pojo.User; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | @Resource |
| | | private ProjectMapper mapper; |
| | | |
| | | |
| | | @Resource |
| | | private UserMapper userMapper; |
| | | |
| | | |
| | | public Response addProject(Project project){ |
| | |
| | | return new Response().set(1,project); |
| | | } |
| | | |
| | | public Response getProjectStatusData(){ |
| | | ProjectStatusCountDTO proDto = new ProjectStatusCountDTO(); |
| | | proDto.setTotal(mapper.selectCount(null)); |
| | | proDto.setCanceled(getCountByStatus(0)); |
| | | proDto.setOngoing(getCountByStatus(1)); |
| | | proDto.setFinished(getCountByStatus(2)); |
| | | proDto.setPostponed(getCountByStatus(3)); |
| | | |
| | | public Response<IPage<Project>> getPageByCondition(int pageNum,int pageSize,Project project){ |
| | | return new Response().set(1,proDto); |
| | | } |
| | | public int getCountByStatus(int status){ |
| | | QueryWrapper<Project> queryWrapper = new QueryWrapper(); |
| | | return mapper.selectCount(queryWrapper.eq("status",status)); |
| | | } |
| | | |
| | | |
| | | public Response<PageInfo<Project>> getPageByCondition(int pageNum,int pageSize,Project project){ |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | QueryWrapper<Project> queryWrapper = new QueryWrapper<>(project); |
| | | IPage<Project> page = mapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper); |
| | | return new Response<IPage<Project>>().set(1, page); |
| | | List<Project> list = mapper.selectList(queryWrapper); |
| | | for (Project p:list) { |
| | | String managers = p.getManager(); |
| | | if (StringUtils.isNotEmpty(managers)){ |
| | | String[] strings = managers.split(","); |
| | | List<String> managerUser = new ArrayList<>(); |
| | | for (int i = 0; i < strings.length; i++) { |
| | | User user = userMapper.selectById(strings[i]); |
| | | managerUser.add(user.getRealName()); |
| | | } |
| | | p.setManagerInfo(managerUser); |
| | | } |
| | | String parters = p.getParter(); |
| | | if (StringUtils.isNotEmpty(parters)){ |
| | | String[] strings1 = parters.split(","); |
| | | List<String> parterUser = new ArrayList<>(); |
| | | for (int i = 0; i < strings1.length; i++) { |
| | | User user = userMapper.selectById(strings1[i]); |
| | | parterUser.add(user.getRealName()); |
| | | } |
| | | p.setParterInfo(parterUser); |
| | | } |
| | | } |
| | | PageInfo<Project> pageInfo = new PageInfo<>(list); |
| | | return new Response<PageInfo<Project>>().set(1, pageInfo); |
| | | } |
| | | |
| | | public Response updateProject(Project project){ |