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;
|
}
|
}
|