cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
package cn.ksource.web.controller.business.pages.xtgl.xtgn;
 
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.HttpServletResponse;
 
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
 
import cn.ksource.beans.GG_XTGN;
import cn.ksource.core.page.PageInfo;
import cn.ksource.core.util.ConvertUtil;
import cn.ksource.core.util.FileUtil;
import cn.ksource.core.util.JsonUtil;
import cn.ksource.core.util.MyFileUploadException;
import cn.ksource.core.util.StringUtil;
import cn.ksource.core.web.SysInfo;
import cn.ksource.core.web.WebUtil;
import cn.ksource.web.facade.XtgnFacade;
import cn.ksource.web.service.xtgl.xtgn.XtgnService;
/**
 * 角色权限--系统功能控制器
 * @note:
 * @version
 * @author sxj
 * @date June 28, 2016 10:35:44 AM
 */
@Controller
@RequestMapping("/business/pages/xtgl/xtgn")
public class XtgnController {
 
    @Resource(name="xtgnFacade")
    private XtgnFacade xtgnFacade;
    
    @Resource(name="xtgnService")
    private XtgnService xtgnService;
    
    
    @RequestMapping("xtgnTreeList.html")
    public ModelAndView xtgnTreeList(HttpServletRequest request){
        ModelAndView modelAndView = new ModelAndView("/business/pages/xtgl/xtgn/xtgnTreeList");
        return  modelAndView;
    }
    
     /**
     * 查询系统功能树
     * @param request
     * @param response
     */
    @RequestMapping("xtgnTree.html")
    public ModelAndView xtgnTree(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/xtgl/xtgn/xtgnTree");
        List<Map> cates = xtgnFacade.queryXtgnTree(request);
        modelAndView.addObject("cates", cates);
        
        String firstCate = request.getParameter("firstCate");
        String secondCate = request.getParameter("secondCate");
        System.out.println("firstCate:"+firstCate+",secondCate:"+secondCate);
        modelAndView.addObject("firstCate", firstCate);
        modelAndView.addObject("secondCate", secondCate);
        
        return modelAndView;
    }
    
    
    
    /**
     * 查询系统功能列表
     */
    @RequestMapping("xtgnList.html")
    public ModelAndView xtgnList(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/xtgl/xtgn/xtgnList");
        return modelAndView;
    }
    
    
    /**
     * 查询系统功能列表数据
     */
    @RequestMapping("xtgnData.html")
    public ModelAndView xtgnData(HttpServletRequest request,PageInfo pageInfo) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/xtgl/xtgn/xtgnData");
        String pId = request.getParameter("pId");
        PageInfo info = xtgnFacade.queryXtgnData(pageInfo,pId);
        modelAndView.addObject("info", info);
        return modelAndView;
    }
    
    
    /**
     * 查询系统功能总数量
     */
    @RequestMapping("xtgnCount.html")
    public void xtgnCount(HttpServletRequest request,HttpServletResponse response) {
        String pId = request.getParameter("pId");
        int count = xtgnFacade.queryXtgnCount(pId);
        WebUtil.write(response, String.valueOf(count));
    }
    
    //删除系统功能
    @RequestMapping("delete.html")
    public void onDelete(HttpServletRequest request,HttpServletResponse response){
        String id = request.getParameter("id");
        Map result = xtgnFacade.deleteXtgn(id);
        WebUtil.write(response, JsonUtil.map2Json(result));
    }
    
    
    
    @RequestMapping(value="xtgnAdd.html",method=RequestMethod.GET)
    public ModelAndView xtgnAdd(HttpServletRequest request,HttpServletResponse response){
        ModelAndView view = new ModelAndView("/business/pages/xtgl/xtgn/xtgnAdd");
        String sjbh = request.getParameter("sjbh");
        Map xtgnMap = new HashMap();
        String id = request.getParameter("id");
        if (StringUtils.isNotBlank(id)) {
            xtgnMap = xtgnService.getXtgnInfo(id);
        }
        view.addObject("info", xtgnMap);
        view.addObject("sjbh", sjbh);
        return view;
    }
    
    @RequestMapping("checkGn_mark.html")
    public void checkUser(HttpServletRequest request,HttpServletResponse response){
        String gn_mark = request.getParameter("gn_mark");
        String sjbh = request.getParameter("sjbh");
        if(StringUtil.isNotBlank(gn_mark)){
            boolean loginNameExists = xtgnFacade.isGn_markExists(gn_mark,sjbh);
            if(loginNameExists){
                WebUtil.write(response,"0");
            }else{
                WebUtil.write(response,"1");
            }
        }else{
            WebUtil.write(response,"1");
        }
    }
    
    @RequestMapping(value="addXtgnSubmit.html",method=RequestMethod.POST)
    public ModelAndView xtgnAddSubmit(HttpServletRequest request,HttpServletResponse response) throws MyFileUploadException {
        String sjbh = request.getParameter("sjbh");
        String id = request.getParameter("id");
        String gnmc = request.getParameter("gnmc");
        String address = request.getParameter("address");
        String gn_mark = request.getParameter("gn_mark");
        String sxh = request.getParameter("sxh");
        String sfyl = request.getParameter("sfyl");
        String beiz = request.getParameter("beiz");
        GG_XTGN xtgn = new GG_XTGN();
        xtgn.setId(id).setAddress(address).setGn_mark(gn_mark).setBeiz(beiz).setGnmc(gnmc).setSxh(ConvertUtil.obj2Integer(sxh)).setSfyl(ConvertUtil.obj2Integer(sfyl));
        Map<String, String> fileMap = FileUtil.uploadFile4SpringMVC(request, "/static/style/menu_image", new String[]{"jpg","jpeg","png"});
        if (fileMap.containsKey("big_image")) {
            xtgn.setBig_image(fileMap.get("big_image"));
        }
        if (fileMap.containsKey("medium_image")) {
            xtgn.setMedium_image(fileMap.get("medium_image"));
        }
        if (fileMap.containsKey("small_image")) {
            xtgn.setSmall_image(fileMap.get("small_image"));
        }
        if (xtgn.getSjbh() != null && xtgn.getSjbh().equalsIgnoreCase("0")) {
            xtgn.setSjbh(null);
        }
        
        if (StringUtils.isBlank(xtgn.getSjbh())) {
            xtgn.setSjbh(null);
        }
        String firstCate = "";
        String secondCate = "";
        if(!StringUtil.isEmpty(sjbh)){
            GG_XTGN xtgnpid = new GG_XTGN(sjbh).getInstanceById();
            int type = ConvertUtil.obj2Integer(xtgnpid.getType());
            xtgn.setSjbh(sjbh);
            xtgn.setType(type+1);
            
            if(type==3) {
                GG_XTGN pidxtgnpid = new GG_XTGN(xtgnpid.getSjbh()).getInstanceById();
                firstCate = pidxtgnpid.getSjbh();
                secondCate = pidxtgnpid.getId();
            } else if(type==2) {
                firstCate = xtgnpid.getSjbh();
                secondCate = xtgnpid.getId();
            }else{
                firstCate = xtgnpid.getId();
            }
        }else{
            xtgn.setType(1);
        }
        
        
        xtgn.insertOrUpdate();
        String execJs = "window.top.document.getElementById('myiframe').contentWindow.query('"+sjbh+"');window.top.queryTree('"+firstCate+"','"+secondCate+"');window.top.hideDialog('0');";
        return WebUtil.sysInfoPage(request, "操作成功!",
                execJs,
                SysInfo.Success,"");
    }   
    
    
}