|
|
@@ -4,21 +4,21 @@ import com.dao.dashboard.DashboardsMapper;
|
|
|
import com.dao.user.UserMapper;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.model.bo.DashOrder;
|
|
|
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.model.vo.dataVo.DashboardOrderInfo;
|
|
|
import com.server.chart.ChartsUtilService;
|
|
|
import com.util.GetTokenData;
|
|
|
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;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class DashboardsService {
|
|
|
@@ -36,12 +36,12 @@ public class DashboardsService {
|
|
|
/*
|
|
|
保存看板
|
|
|
*/
|
|
|
- public RepEntity setDashboards(String token, DashboardsInfo dashboardsInfo){
|
|
|
+ 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);
|
|
|
+ BeanUtils.copyProperties(dashboardsInfo, dashboards);
|
|
|
dashboards.setCreateBy(name);
|
|
|
dashboards.setCreateId(userId);
|
|
|
dashboardsMapper.setDashboards(dashboards);
|
|
|
@@ -57,7 +57,7 @@ public class DashboardsService {
|
|
|
int userId = Integer.parseInt(stringMap.get("id"));
|
|
|
String name = stringMap.get("name");
|
|
|
int createId = dashboardsMapper.getCreateIdById(dashboardsInfo.getId());
|
|
|
- if (userId != createId){
|
|
|
+ if (userId != createId) {
|
|
|
return new RepEntity(RepCode.NoAuthority);
|
|
|
}
|
|
|
Dashboards dashboards = new Dashboards();
|
|
|
@@ -72,14 +72,14 @@ public class DashboardsService {
|
|
|
/*
|
|
|
删除看板
|
|
|
*/
|
|
|
- public RepEntity delDashboards(String token, List<Integer> idList){
|
|
|
+ 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()){
|
|
|
+ while (isList.hasNext()) {
|
|
|
int id = (int) isList.next();
|
|
|
int createId = dashboardsMapper.getCreateIdById(id);
|
|
|
- if (userId != createId){
|
|
|
+ if (userId != createId) {
|
|
|
return new RepEntity(RepCode.NoAuthority);
|
|
|
}
|
|
|
}
|
|
|
@@ -90,7 +90,7 @@ public class DashboardsService {
|
|
|
/*
|
|
|
查看看板
|
|
|
*/
|
|
|
- public RepEntity getListDashboards(String token, TestPage testPage){
|
|
|
+ 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());
|
|
|
@@ -101,24 +101,57 @@ public class DashboardsService {
|
|
|
/*
|
|
|
查看单个看板
|
|
|
*/
|
|
|
- public RepEntity getDashboards(String token, int id){
|
|
|
+ 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));
|
|
|
+ Dashboards dashboards = dashboardsMapper.getDashboards(userId, id);
|
|
|
+ if (dashboards == null){
|
|
|
+ return new RepEntity(RepCode.DashboardNonExistent);
|
|
|
+ }
|
|
|
+ return new RepEntity(RepCode.success, dashboards);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
转交看板
|
|
|
*/
|
|
|
- public RepEntity changeDashOrder(String token, ChangeOrderInfo changeOrderInfo){
|
|
|
+ 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){
|
|
|
+ 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);
|
|
|
}
|
|
|
+
|
|
|
+ /*
|
|
|
+ 查看看板分发对象
|
|
|
+ */
|
|
|
+ public RepEntity getDashOrder(String token, int dashId) {
|
|
|
+ Map<String, String> stringMap = getTokenData.getTokenData(token);
|
|
|
+ int userId = Integer.parseInt(stringMap.get("id"));
|
|
|
+ int createId = dashboardsMapper.getCreateIdById(dashId);
|
|
|
+ if (userId != createId) {
|
|
|
+ return new RepEntity(RepCode.NoAuthority);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<DashOrder> userNames = new ArrayList<>();
|
|
|
+ List<DashOrder> groupNames = new ArrayList<>();
|
|
|
+ List<String> type = dashboardsMapper.getType(dashId);
|
|
|
+ Iterator isType = type.iterator();
|
|
|
+ while (isType.hasNext()){
|
|
|
+ String ty = String.valueOf(isType.next());
|
|
|
+ if ("1".equals(ty)){
|
|
|
+ userNames = dashboardsMapper.getOrderName(dashId);
|
|
|
+ }else {
|
|
|
+ groupNames = dashboardsMapper.getOrderGroupName(dashId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ DashboardOrderInfo dashboardOrderInfo = new DashboardOrderInfo();
|
|
|
+ dashboardOrderInfo.setUserNames(userNames);
|
|
|
+ dashboardOrderInfo.setGroupNames(groupNames);
|
|
|
+ return new RepEntity(RepCode.success, dashboardOrderInfo);
|
|
|
+ }
|
|
|
}
|