| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- package com.server;
- import com.dao.DashboardsMapper;
- import com.dao.UserMapper;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.github.pagehelper.PageInfo;
- import com.model.po.Dashboards;
- import com.model.pojo.RepCode;
- import com.model.pojo.RepEntity;
- import com.model.pojo.TestPage;
- import com.model.vo.configVo.ChangeOrderInfo;
- import com.model.vo.configVo.DashboardsInfo;
- import com.util.GetTokenData;
- import com.util.TimeUtil;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- @Service
- public class DashboardsService {
- @Autowired
- TimeUtil timeUtil;
- @Autowired
- DashboardsMapper dashboardsMapper;
- @Autowired
- ObjectMapper objectMapper;
- @Autowired
- GetTokenData getTokenData;
- @Autowired
- UserMapper userMapper;
- @Autowired
- ChartsUtilService chartsUtilService;
- /*
- 保存看板
- */
- public RepEntity setDashboards(String token, DashboardsInfo dashboardsInfo){
- Map<String, String> stringMap = getTokenData.getTokenData(token);
- int userId = Integer.parseInt(stringMap.get("id"));
- String name = stringMap.get("name");
- Dashboards dashboards = new Dashboards();
- BeanUtils.copyProperties(dashboardsInfo,dashboards);
- dashboards.setCreateBy(name);
- dashboards.setCreateId(userId);
- dashboardsMapper.setDashboards(dashboards);
- int id = dashboards.getId();
- return new RepEntity(RepCode.success, id);
- }
- /*
- 更新看板
- */
- public RepEntity updateDashboards(String token, DashboardsInfo dashboardsInfo) {
- Map<String, String> stringMap = getTokenData.getTokenData(token);
- int userId = Integer.parseInt(stringMap.get("id"));
- String name = stringMap.get("name");
- int createId = dashboardsMapper.getCreateIdById(dashboardsInfo.getId());
- if (userId != createId){
- return new RepEntity(RepCode.NoAuthority);
- }
- Dashboards dashboards = new Dashboards();
- BeanUtils.copyProperties(dashboardsInfo, dashboards);
- dashboards.setCreateBy(name);
- dashboards.setCreateId(userId);
- dashboardsMapper.updateDashboards(dashboards);
- return new RepEntity(RepCode.success);
- }
- /*
- 删除看板
- */
- public RepEntity delDashboards(String token, List<Integer> idList){
- Map<String, String> stringMap = getTokenData.getTokenData(token);
- int userId = Integer.parseInt(stringMap.get("id"));
- Iterator isList = idList.iterator();
- while (isList.hasNext()){
- int id = (int) isList.next();
- int createId = dashboardsMapper.getCreateIdById(id);
- if (userId != createId){
- return new RepEntity(RepCode.NoAuthority);
- }
- }
- dashboardsMapper.delDashboards(idList);
- return new RepEntity(RepCode.success);
- }
- /*
- 查看看板
- */
- public RepEntity getListDashboards(String token, TestPage testPage){
- Map<String, String> stringMap = getTokenData.getTokenData(token);
- int id = Integer.parseInt(stringMap.get("id"));
- List<Dashboards> getListDashboards = dashboardsMapper.getListDashboards(id, testPage.enablePaging());
- PageInfo<Dashboards> pageInfo = new PageInfo<>(getListDashboards);
- return new RepEntity(RepCode.success, pageInfo);
- }
- /*
- 查看单个看板
- */
- public RepEntity getDashboards(String token, int id){
- Map<String, String> stringMap = getTokenData.getTokenData(token);
- int userId = Integer.parseInt(stringMap.get("id"));
- return new RepEntity(RepCode.success, dashboardsMapper.getDashboards(userId, id));
- }
- /*
- 转交看板
- */
- public RepEntity changeDashOrder(String token, ChangeOrderInfo changeOrderInfo){
- Map<String, String> stringMap = getTokenData.getTokenData(token);
- int userId = Integer.parseInt(stringMap.get("id"));
- int createId = dashboardsMapper.getCreateIdById(changeOrderInfo.getId());
- if (userId != createId){
- return new RepEntity(RepCode.NoAuthority);
- }
- String name = userMapper.getName(changeOrderInfo.getUserId());
- dashboardsMapper.changeDashOrder(name, changeOrderInfo.getUserId(), changeOrderInfo.getId());
- return new RepEntity(RepCode.success);
- }
- }
|