935090232@qq.com
2021-11-21 59634aeabb04aae0e819bd4c5fe909bb9cdbeb28
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
package com.matrix.system.hive.action;
 
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.WebUtil;
import com.matrix.system.hive.action.util.QueryUtil;
import com.matrix.system.hive.bean.SysDepartInfo;
import com.matrix.system.hive.service.CodeService;
import com.matrix.system.hive.service.SysDepartInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
 
 
 
/**
 * 
 * @Title: DepartInfoController.java  
 * @Package com.zkingsoft.actions.admin  
 * @description 部门管理action
 * @author jyy
 * @email 18075895212@qq.com
 * @date 2016年7月11日 下午5:41:36
 */
@Controller
@RequestMapping(value = "admin/departInfo")
public class DepartInfoController extends BaseController {
    public static final String fnCode = "departInfo";
    public static final String search = fnCode + ":search";
    public static final String edit = fnCode + ":edit";
    public static final String del = fnCode + ":del";
    public static final String add = fnCode + ":add";
 
 
    @Resource
    private SysDepartInfoService currentService;
    @Resource
    private CodeService codeService;
 
    /**
     * 列表显示
     */
    @RequestMapping(value = "/showList")
    public @ResponseBody
    AjaxResult showList(SysDepartInfo departInfo, PaginationVO pageVo) {
        QueryUtil.setQueryLimit(departInfo);
        return showList(currentService, departInfo, pageVo);
    }
 
    /**
     * 新增或修改页面
     */
    @RequestMapping(value = "/addOrModify")
    public @ResponseBody AjaxResult addOrModify(SysDepartInfo departInfo) {
 
        if (departInfo.getId() != null) {
            if (departInfo.getParentId() != null && departInfo.getParentId().equals(departInfo.getId())) {
                throw new GlobleException("父级不能是自己");
            }
            return modify(currentService, departInfo, "部门");
        } else {
            QueryUtil.setQueryLimit(departInfo);
            departInfo.setDepartNo(codeService.getDepartCode());
            return add(currentService, departInfo, "部门");
        }
    }
 
    /**
     * 进入修改界面
     */
    @RequestMapping(value = "/editForm")
    public String editForm(Long id) {
        SysDepartInfo departInfo;
        if (id != null) {
            departInfo = currentService.findById(id);
            WebUtil.getRequest().setAttribute("obj", departInfo);
        }
        return "admin/hive/orgment/departInfo-form";
    }
 
    /**
     * 删除
     */
    @RequestMapping(value = "/del")
    public @ResponseBody AjaxResult del(Long  keys) {
 
        int i = currentService.removeById(keys);
        if (i > 0) {
            return new AjaxResult(AjaxResult.STATUS_SUCCESS,  "成功删除" + i + "条数据");
        } else {
            return new AjaxResult(AjaxResult.STATUS_FAIL,  "删除失败");
        }
    }
 
    /**
     * =======================================================
     * *******************公共的数据访问方法********************
     * =======================================================
     */
 
    @RequestMapping(value = "/findById")
    public @ResponseBody AjaxResult findById(Long id) {
        SysDepartInfo sysDepartInfo = super.findById(currentService, id);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, Arrays.asList(sysDepartInfo), 0);
    }
 
    /**
     * 显示所有的部门信息
     */
    @RequestMapping(value = "/showDepartInfo")
    public @ResponseBody AjaxResult showDepartInfo(SysDepartInfo departInfo, PaginationVO pageVo) {
        // 部门信息
        QueryUtil.setQueryLimit(departInfo);
        List<SysDepartInfo> departInfos = currentService.findByModel(departInfo);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, departInfos, 0);
    }
 
}