提交 | 用户 | 时间
|
58d006
|
1 |
package com.mandi.system.controller; |
A |
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import javax.annotation.Resource; |
|
6 |
import javax.servlet.http.HttpServletRequest; |
|
7 |
import javax.servlet.http.HttpServletResponse; |
|
8 |
|
|
9 |
import org.apache.commons.lang3.StringUtils; |
|
10 |
import org.springframework.stereotype.Controller; |
|
11 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
12 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
13 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
14 |
|
|
15 |
import com.mandi.common.Jacksonmethod; |
|
16 |
import com.mandi.common.RequestParam; |
|
17 |
import com.mandi.common.SessionMethod; |
|
18 |
import com.mandi.dao.common.ObjectResult; |
|
19 |
import com.mandi.dao.common.PageRequest; |
|
20 |
import com.mandi.dao.common.PageResult; |
|
21 |
import com.mandi.springmvc.logs.OpLogs; |
|
22 |
import com.mandi.system.persist.Login; |
|
23 |
import com.mandi.system.persist.ModuleEnum; |
|
24 |
import com.mandi.system.persist.User; |
|
25 |
import com.mandi.system.persist.UserType; |
|
26 |
import com.mandi.system.service.IFdUserService; |
|
27 |
|
|
28 |
|
|
29 |
@Controller("fdusercon") |
|
30 |
@RequestMapping(value="/user",method={RequestMethod.POST}) |
|
31 |
public class FdUserCon { |
|
32 |
|
|
33 |
@Resource |
|
34 |
private IFdUserService user; |
|
35 |
|
|
36 |
@RequestMapping(value="/saveState.htm",method={RequestMethod.POST}) |
|
37 |
@OpLogs(module=ModuleEnum.人员管理,name="修改用户状态") |
|
38 |
@ResponseBody |
|
39 |
public String saveState(HttpServletRequest r,HttpServletResponse re){ |
|
40 |
String id=RequestParam.getSqlString(r, "id"); |
|
41 |
boolean state=RequestParam.getBool(r, "state"); |
|
42 |
ObjectResult<Boolean> orr=new ObjectResult<Boolean>(); |
|
43 |
Login lg=SessionMethod.getlogin(r.getSession()); |
|
44 |
try { |
|
45 |
orr=user.saveState(id, state, lg); |
|
46 |
} catch (Exception e) { |
|
47 |
e.printStackTrace(); |
|
48 |
orr.setCode(1); |
|
49 |
orr.setErrmsg(StringUtils.isEmpty(e.getMessage())?"修改用户状态出错!":e.getMessage()); |
|
50 |
} |
|
51 |
String str=Jacksonmethod.tojson(orr, false); |
|
52 |
SessionMethod.writeresp(re, str); |
|
53 |
return null; |
|
54 |
} |
|
55 |
@RequestMapping(value="/saveItem.htm",method={RequestMethod.POST}) |
|
56 |
@OpLogs(module=ModuleEnum.人员管理,name="编辑用户") |
|
57 |
@ResponseBody |
|
58 |
public String saveItem(HttpServletRequest r,HttpServletResponse re){ |
|
59 |
String id=RequestParam.getSqlString(r, "id"); |
|
60 |
User u=new User(); |
|
61 |
UserType utype=RequestParam.getenum(r, "utype", UserType.class); |
|
62 |
u=RequestParam.getobj(r, u); |
|
63 |
u.setId(id); |
|
64 |
u.setUtype(utype); |
|
65 |
ObjectResult<User> orr=new ObjectResult<User>(); |
|
66 |
Login lg=SessionMethod.getlogin(r.getSession()); |
|
67 |
try { |
|
68 |
orr=user.saveUser(u, lg); |
|
69 |
} catch (Exception e) { |
|
70 |
e.printStackTrace(); |
|
71 |
orr.setCode(1); |
|
72 |
orr.setErrmsg(StringUtils.isEmpty(e.getMessage())?"用户保存编辑出错!":e.getMessage()); |
|
73 |
} |
|
74 |
|
|
75 |
String str=Jacksonmethod.tojson(orr, false); |
|
76 |
SessionMethod.writeresp(re, str); |
|
77 |
return null; |
|
78 |
} |
|
79 |
@RequestMapping(value="/getList.htm",method={RequestMethod.POST}) |
|
80 |
@ResponseBody |
|
81 |
public String getList(HttpServletRequest r,HttpServletResponse re){ |
|
82 |
String searchword=RequestParam.getSqlString(r, "searchword"); |
|
83 |
String companyNo=RequestParam.getSqlString(r, "companyNo"); |
|
84 |
int page=RequestParam.getInt(r, "page"); |
|
85 |
int pagesize=RequestParam.getInt(r, "pagesize"); |
|
86 |
int pages=RequestParam.getInt(r, "pages"); |
|
87 |
PageRequest pr=new PageRequest(page, pagesize, null); |
|
88 |
if(pages>0) |
|
89 |
pr.setNeedPages(true); |
|
90 |
else |
|
91 |
pr.setNeedPages(false); |
|
92 |
PageResult<Map<String, Object>> prr=user.getUserMlist(searchword, companyNo, pr); |
|
93 |
|
|
94 |
String str=Jacksonmethod.tojson(prr, false); |
|
95 |
SessionMethod.writeresp(re, str); |
|
96 |
return null; |
|
97 |
} |
|
98 |
|
|
99 |
@RequestMapping(value="/delItem.htm",method={RequestMethod.POST}) |
|
100 |
@OpLogs(module=ModuleEnum.人员管理,name="删除用户") |
|
101 |
@ResponseBody |
|
102 |
public String delItem(HttpServletRequest r,HttpServletResponse re){ |
|
103 |
String id=RequestParam.getSqlString(r, "id"); |
|
104 |
ObjectResult<Boolean> orr=new ObjectResult<Boolean>(); |
|
105 |
Login lg=SessionMethod.getlogin(r.getSession()); |
|
106 |
try { |
|
107 |
orr=user.delUser(id,lg); |
|
108 |
} catch (Exception e) { |
|
109 |
e.printStackTrace(); |
|
110 |
orr.setCode(1); |
|
111 |
orr.setErrmsg(StringUtils.isEmpty(e.getMessage())?"删除用户出错!":e.getMessage()); |
|
112 |
} |
|
113 |
|
|
114 |
String str=Jacksonmethod.tojson(orr, false); |
|
115 |
SessionMethod.writeresp(re, str); |
|
116 |
return null; |
|
117 |
} |
|
118 |
@RequestMapping(value="/getItem.htm",method={RequestMethod.POST}) |
|
119 |
@ResponseBody |
|
120 |
public String getItem(HttpServletRequest r,HttpServletResponse re){ |
|
121 |
String id=RequestParam.getSqlString(r, "id"); |
|
122 |
ObjectResult<User> orr=user.getUser(id); |
|
123 |
String str=Jacksonmethod.tojson(orr, false); |
|
124 |
SessionMethod.writeresp(re, str); |
|
125 |
return null; |
|
126 |
} |
|
127 |
} |