admin
2021-04-22 745320cbb4edfa4fbc8f0f95483a4ee7893d5769
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.yeshi.buwan.controller.admin.api;
 
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
 
import com.yeshi.buwan.util.SystemUtil;
import net.sf.json.JSONObject;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
 
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.buwan.domain.AdminInfo;
import com.yeshi.buwan.domain.system.DetailSystem;
import com.yeshi.buwan.domain.system.SystemInfo;
import com.yeshi.buwan.service.imp.SystemService;
import com.yeshi.buwan.util.Constant;
import com.yeshi.buwan.web.tag.PageEntity;
 
@Controller
@RequestMapping("admin/new/api/system")
public class SystemController {
    
    @Resource
    private SystemService systemService;
    /**
     * 子系统列表
     * 
     * @return
     */
    @RequestMapping("detailSystemList")
    public void detailSystemList(int pageIndex, String key, HttpSession session, PrintWriter out) {
        pageIndex = pageIndex <= 0 ? 1 : pageIndex;
        List<DetailSystem> list = systemService.getDetailSystemList(key, SystemUtil.getAdminSelectedSystem(session).getId(), pageIndex);
        long count = systemService.getDetailSystemListCount(key,SystemUtil.getAdminSelectedSystem(session).getId());
        PageEntity pe = new PageEntity();
        pe.setPageIndex(pageIndex);
        pe.setPageSize(Constant.pageCount);
        Map<String, String> map = new HashMap<String, String>();
        map.put("key", key);
        pe.setParams(map);
        pe.setTotalCount((int) count);
        JSONObject json =new JSONObject();
        json.put("code", "0");
        json.put("pageEntity", pe);    
        Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        json.put("detailSystemList", gson.toJson(list));
        out.print(json);
        return;
    }
    
    @RequestMapping("getSystemForAddDetailSystem")
    public void getSystemForAddDetailSystem(PrintWriter out) {
        List<SystemInfo> list = systemService.getSystemList();
        JSONObject json =new JSONObject();
        json.put("code", "0");
        Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        json.put("SystemInfoList", gson.toJson(list));
        out.print(json);
        return ;
    }
    
    /**
     * 添加详细的系统
     * 
     * @return
     */
    @RequestMapping("addDetailSystem")
    public void addDetailSystem(@RequestBody DetailSystem detailSystem,HttpServletRequest request,PrintWriter out) {
        DetailSystem ds = new DetailSystem();
        ds.setCreatetime(System.currentTimeMillis() + "");
        ds.setAppName(detailSystem.getAppName());
        ds.setBeizhu(detailSystem.getBeizhu());
        ds.setInfo((AdminInfo) request.getAttribute("ADMIN_USER"));
        ds.setIosUmengAppKey(detailSystem.getIosUmengAppKey());
        ds.setIosUmengMasterKey(detailSystem.getIosUmengMasterKey());
        ds.setPackageName(detailSystem.getPackageName());
        ds.setPlatform(detailSystem.getPlatform());
        ds.setSystem(new SystemInfo(detailSystem.getSystem().getId()));
        ds.setUmengAppKey(detailSystem.getUmengAppKey());//iosUmengAppKey
        ds.setUmengMasterKey(detailSystem.getUmengMasterKey());//iosUmengMasterKey
        ds.setSohuKey(detailSystem.getSohuKey());
        ds.setSohuPartner(detailSystem.getSohuPartner());
 
//        if (StringUtil.isNullOrEmpty(String.valueOf(detailSystem.isAppStoreIng()))){
//            ds.setAppStoreIng(false);
//        }
//        else {
//            ds.setAppStoreIng(true);
//            ds.setAppStoreVersion(detailSystem.getAppStoreVersion());
//        }
        
        System.out.println("detailSystem=="+ds.toString());
        systemService.addDetailSystem(ds);
        out.print("yes");
        return ;
    }
    
    @RequestMapping("getDetailSystem")
    public void getDetailSystem(String id,PrintWriter out) {
        DetailSystem ds = systemService.getDetailSystemById(id);
        JSONObject json =new JSONObject();
        json.put("code", "0");
        json.put("detailSystem",new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().toJson(ds));
        out.print(json);
        return ;
    }
    
    @RequestMapping("updateDetailSystem")
    public void updateDetailSystem(@RequestBody DetailSystem detailSystem,HttpServletRequest request,PrintWriter out) {
        DetailSystem ds = systemService.getDetailSystemById(detailSystem.getId());
        ds.setAppName(detailSystem.getAppName());
        ds.setBeizhu(detailSystem.getBeizhu());
        ds.setInfo((AdminInfo) request.getAttribute("ADMIN_USER"));
        ds.setIosUmengAppKey(detailSystem.getIosUmengAppKey());
        ds.setIosUmengMasterKey(detailSystem.getIosUmengMasterKey());
        ds.setPackageName(detailSystem.getPackageName());
        ds.setPlatform(detailSystem.getPlatform());
        ds.setSystem(new SystemInfo(detailSystem.getSystem().getId()));
        ds.setUmengAppKey(detailSystem.getUmengAppKey());//iosUmengAppKey
        ds.setUmengMasterKey(detailSystem.getUmengMasterKey());//iosUmengMasterKey
        ds.setSohuKey(detailSystem.getSohuKey());
        ds.setSohuPartner(detailSystem.getSohuPartner());
        System.out.println("detailSystem=="+ds.toString());
        systemService.updateDetailSystem(ds);
        out.print("yes");
        return ;
    }
    
    @RequestMapping("deleteDetailSystemList")
    public void deleteDetailSystemList(String ids,PrintWriter out) {
        
        if(ids == null || "".equals(ids.trim())){
            out.print("no");
            return;
        }
        
        String[] idArr = ids.split(",");
        for (String st : idArr) {
            System.out.println("id--"+st);
            systemService.deleteDetailSystem(st);
        }
        out.print("yes");
        return;
    }
    
}