hjg
2024-01-20 4a3404efc438b16044fd9170814e6545a3f86fae
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
package com.mandi.system.controller;
 
import java.util.Map;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.mandi.common.Jacksonmethod;
import com.mandi.common.RequestParam;
import com.mandi.common.SessionMethod;
import com.mandi.dao.common.ObjectResult;
import com.mandi.dao.common.PageRequest;
import com.mandi.dao.common.PageResult;
import com.mandi.springmvc.logs.OpLogs;
import com.mandi.system.persist.Login;
import com.mandi.system.persist.ModuleEnum;
import com.mandi.system.persist.User;
import com.mandi.system.persist.UserType;
import com.mandi.system.service.IFdUserService;
 
 
@Controller("fdusercon")
@RequestMapping(value="/user",method={RequestMethod.POST})
public class FdUserCon {
    
    @Resource
    private IFdUserService user;
    
    @RequestMapping(value="/saveState.htm",method={RequestMethod.POST})
    @OpLogs(module=ModuleEnum.人员管理,name="修改用户状态")
    @ResponseBody
    public String saveState(HttpServletRequest r,HttpServletResponse re){
        String id=RequestParam.getSqlString(r, "id");
        boolean state=RequestParam.getBool(r, "state");
        ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
        Login lg=SessionMethod.getlogin(r.getSession());
        try {
            orr=user.saveState(id, state, lg);
        } catch (Exception e) {
            e.printStackTrace();
            orr.setCode(1);
            orr.setErrmsg(StringUtils.isEmpty(e.getMessage())?"修改用户状态出错!":e.getMessage());
        }
        String str=Jacksonmethod.tojson(orr, false);
        SessionMethod.writeresp(re, str);
        return null;
    }
    @RequestMapping(value="/saveItem.htm",method={RequestMethod.POST})
    @OpLogs(module=ModuleEnum.人员管理,name="编辑用户")
    @ResponseBody
    public String saveItem(HttpServletRequest r,HttpServletResponse re){
        String id=RequestParam.getSqlString(r, "id");
        User u=new User();
        UserType utype=RequestParam.getenum(r, "utype", UserType.class);
        u=RequestParam.getobj(r, u);
        u.setId(id);
        u.setUtype(utype);
        ObjectResult<User> orr=new ObjectResult<User>();
        Login lg=SessionMethod.getlogin(r.getSession());
        try {
            orr=user.saveUser(u, lg);
        } catch (Exception e) {
            e.printStackTrace();
            orr.setCode(1);
            orr.setErrmsg(StringUtils.isEmpty(e.getMessage())?"用户保存编辑出错!":e.getMessage());
        }
        
        String str=Jacksonmethod.tojson(orr, false);
        SessionMethod.writeresp(re, str);
        return null;
    }
    @RequestMapping(value="/getList.htm",method={RequestMethod.POST})
    @ResponseBody
    public String getList(HttpServletRequest r,HttpServletResponse re){
        String searchword=RequestParam.getSqlString(r, "searchword");
        String companyNo=RequestParam.getSqlString(r, "companyNo");
        int page=RequestParam.getInt(r, "page");
        int pagesize=RequestParam.getInt(r, "pagesize");
        int pages=RequestParam.getInt(r, "pages");
        PageRequest pr=new PageRequest(page, pagesize, null);
        if(pages>0)
            pr.setNeedPages(true);
        else
            pr.setNeedPages(false);
        PageResult<Map<String, Object>> prr=user.getUserMlist(searchword, companyNo, pr);
        
        String str=Jacksonmethod.tojson(prr, false);
        SessionMethod.writeresp(re, str);
        return null;
    }
    
    @RequestMapping(value="/delItem.htm",method={RequestMethod.POST})
    @OpLogs(module=ModuleEnum.人员管理,name="删除用户")
    @ResponseBody
    public String delItem(HttpServletRequest r,HttpServletResponse re){
        String id=RequestParam.getSqlString(r, "id");
        ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
        Login lg=SessionMethod.getlogin(r.getSession());
        try {
            orr=user.delUser(id,lg);
        } catch (Exception e) {
            e.printStackTrace();
            orr.setCode(1);
            orr.setErrmsg(StringUtils.isEmpty(e.getMessage())?"删除用户出错!":e.getMessage());
        }
        
        String str=Jacksonmethod.tojson(orr, false);
        SessionMethod.writeresp(re, str);
        return null;
    }
    @RequestMapping(value="/getItem.htm",method={RequestMethod.POST})
    @ResponseBody
    public String getItem(HttpServletRequest r,HttpServletResponse re){
        String id=RequestParam.getSqlString(r, "id");
        ObjectResult<User> orr=user.getUser(id);
        String str=Jacksonmethod.tojson(orr, false);
        SessionMethod.writeresp(re, str);
        return null;
    }
}