liuxiaolong
2019-05-06 f99bc8c6a1d10610373738edd7d0aa0181c81d99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package com.cloud.user.service.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.cloud.common.constants.GlobalDict;
import com.cloud.common.utils.OrgTypeUtil;
import com.cloud.common.utils.PageUtil;
import com.cloud.model.sys.GloDict;
import com.cloud.user.dao.GolDictDao;
import com.cloud.user.service.GolDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Service
public class GolDictServiceImpl implements GolDictService{
 
    @Autowired
    private GolDictDao golDictDao;
 
    @Override
    public List<Map<String, Object>> getTeacherPact(Map<String,Object> params) {
        List<Map<String, Object>> list = new ArrayList<>();
        list =  golDictDao.getTeacherPact(params);
        if(list.size()>0){
            for(Map<String,Object> map:list){
                if(map.containsKey("revJson")&&!"".equals(map.get("revJson").toString())){
                    try{
                        JSONObject jsonObject = JSONObject.parseObject(map.get("revJson").toString());
                        map.put("btnStyle",jsonObject.get("color").toString());
                        map.remove("revJson");
                    }catch (Exception ex){
                        map.put("btnStyle","");
                        map.remove("revJson");
                        ex.printStackTrace();
                    }
                }else{
                    map.put("btnStyle","");
                }
            }
            Map<String,Object> map = new HashMap<>();
            map.put("PactCount",list.size());
            list.add(0,map);
        }else{
            Map<String,Object> map = new HashMap<>();
            map.put("Message","没有查询到数据!!!");
            list.add(0,map);
        }
        return list;
    }
 
    @Override
    public Map<String, Object> getPeoType(Map<String,Object> params) {
        List<Map<String, Object>> data = golDictDao.getPeoType(params);
        Map<String,Object> map = new HashMap<>();
        if(data.size() > 0){
            map.put("data",data);
            map.put("message","查询成功!!!");
            map.put("code","0");
        }else{
            map.put("data","");
            map.put("message","暂无数据!!!");
            map.put("code","1");
        }
        return map;
    }
 
    @Override
    public Map<String, Object> getOrgType(Map<String,Object> params) {
        List<Map<String,Object>> data = golDictDao.getOrgType(params);
        Long schoolValue = Long.parseLong(OrgTypeUtil.getByKey(GlobalDict.SCHOOL).getValue());
        for(Map<String,Object> map:data){
            if(Long.parseLong(map.get("value").toString())<=schoolValue&&map.get("scope").toString().equals(OrgTypeUtil.BUSINESS_TYPE)){
                map.put("isAdmin",true);
            }else{
                map.put("isAdmin",false);
            }
        }
        Map<String,Object> map = new HashMap<>();
        if(data.size() > 0){
            map.put("data",data);
            map.put("message","查询成功!!!");
            map.put("code","0");
        }else{
            map.put("data","");
            map.put("message","暂无数据!!!");
            map.put("code","1");
        }
        return map;
    }
 
    @Override
    public Map<String, Object> getGloDicts(Map<String, Object> params) {
        Map<String,Object> map = new HashMap<>();
        Integer count = golDictDao.getGloDictsCount(params);
        if(count > 0){
            PageUtil.pageParamConver(params,false);
            List<Map<String,Object>> data = golDictDao.getGloDicts(params);
            map.put("data",data);
            map.put("message","查询成功!!!");
            map.put("code","0");
        }else {
            map.put("data","");
            map.put("message","暂无数据!!!");
            map.put("code","1");
        }
        return map;
    }
 
    @Override
    public Map<String, Object> saveGloDicts(@RequestParam Map<String,Object> params) {
        Integer status = golDictDao.insertSelective(params);
        Map<String,Object> map = new HashMap<>();
        if(status > 0 ){
            map.put("message","添加成功!!!");
            map.put("code","0");
        }else{
            map.put("message","添加失败!!!");
            map.put("code","1");
        }
        return map;
    }
 
    @Override
    public Map<String, Object> updateGloDicts(Map<String,Object> params) {
        Integer status = golDictDao.updateByPrimaryKeySelective(params);
        Map<String,Object> map = new HashMap<>();
        if(status > 0){
            map.put("message","修改成功!!!");
            map.put("code","0");
        }else {
            map.put("message","修改失败!!!");
            map.put("code","1");
        }
        return map;
    }
 
    @Override
    public Map<String, Object> deleteGloDicts(Integer id) {
        Integer status = golDictDao.deleteGloDicts(id);
        Map<String,Object> map = new HashMap<>();
        if(status > 0){
            map.put("message","删除成功!!!");
            map.put("code","0");
        }else {
            map.put("message","删除失败!!!");
            map.put("code","1");
        }
        return map;
    }
}