1310 lines
36 KiB
Plaintext
1310 lines
36 KiB
Plaintext
package com.bonus.sys.controller;
|
||
|
||
import java.io.File;
|
||
import java.io.FileInputStream;
|
||
import java.io.InputStream;
|
||
import java.net.URLEncoder;
|
||
import java.util.ArrayList;
|
||
import java.util.Date;
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
import java.util.regex.Matcher;
|
||
import java.util.regex.Pattern;
|
||
|
||
import javax.servlet.ServletOutputStream;
|
||
import javax.servlet.http.HttpServletRequest;
|
||
import javax.servlet.http.HttpServletResponse;
|
||
import javax.servlet.http.HttpSession;
|
||
|
||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||
import org.apache.poi.ss.usermodel.Cell;
|
||
import org.apache.poi.ss.usermodel.Row;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.stereotype.Controller;
|
||
import org.springframework.ui.Model;
|
||
import org.springframework.web.bind.annotation.RequestBody;
|
||
import org.springframework.web.bind.annotation.RequestMapping;
|
||
import org.springframework.web.bind.annotation.RequestMethod;
|
||
import org.springframework.web.bind.annotation.RequestParam;
|
||
import org.springframework.web.bind.annotation.ResponseBody;
|
||
import org.springframework.web.multipart.MultipartFile;
|
||
|
||
import com.bonus.core.StringHelper;
|
||
import com.bonus.sys.AjaxRes;
|
||
import com.bonus.sys.BaseController;
|
||
import com.bonus.sys.GlobalConst;
|
||
import com.bonus.sys.Page;
|
||
import com.bonus.sys.UserShiroHelper;
|
||
import com.bonus.sys.beans.CheckCard;
|
||
import com.bonus.sys.beans.NewRoleBean;
|
||
import com.bonus.sys.beans.RoleBean;
|
||
import com.bonus.sys.beans.UserBean;
|
||
import com.bonus.sys.beans.ZNode;
|
||
import com.bonus.sys.service.NewRoleService;
|
||
import com.bonus.sys.service.RoleService;
|
||
import com.bonus.sys.service.UserService;
|
||
|
||
@Controller
|
||
@RequestMapping("/backstage/user/")
|
||
public class UserController extends BaseController<UserBean> {
|
||
|
||
@Autowired
|
||
private UserService service;
|
||
|
||
@Autowired
|
||
private RoleService roleService;
|
||
|
||
@Autowired
|
||
private NewRoleService nrService;
|
||
|
||
@Autowired
|
||
UserService usiService;
|
||
|
||
@RequestMapping("list")
|
||
public String index(Model model) {
|
||
return "/sys/userlist";
|
||
}
|
||
|
||
@RequestMapping("managementList")
|
||
public String managementList(Model model) {
|
||
|
||
return "/sys/userManagement";
|
||
}
|
||
|
||
@RequestMapping("brother")
|
||
public String brotherUser(Model model) {
|
||
model.addAttribute("types", getDictListByTypeId(31));
|
||
return "/sys/brotherManagement";
|
||
}
|
||
|
||
@RequestMapping("clientManagement")
|
||
public String beforelist(Model model) {
|
||
model.addAttribute("types", getDictListByTypeId(31));
|
||
return "/sys/clientManagement";
|
||
}
|
||
|
||
@RequestMapping("toResetPasswordPage")
|
||
public String toResetPasswordPage(Model model) {
|
||
|
||
return "/sys/resetPasswordPage";
|
||
}
|
||
|
||
@RequestMapping("select")
|
||
public String select(Model model) {
|
||
return "/newInput/selectPerson";
|
||
}
|
||
|
||
@RequestMapping("userTree")
|
||
public String userTree(Model model) {
|
||
return "/sys/userTree";
|
||
}
|
||
|
||
@RequestMapping("keeperTree")
|
||
public String keeperTree(Model model) {
|
||
return "/sys/keeperTree";
|
||
}
|
||
|
||
@RequestMapping("repairTeamTree")
|
||
public String repairTeamTree(Model model) {
|
||
return "/sys/repairTeamTree";
|
||
}
|
||
|
||
@RequestMapping("findAllPerson")
|
||
public String findAllPerson(Model model) {
|
||
return "/newInput/findAllPerson";
|
||
}
|
||
|
||
@RequestMapping("personalCenter")
|
||
public String personalCenter(Model model) {
|
||
return "/personalCenter/personalCenter";
|
||
}
|
||
|
||
@RequestMapping("clientUnitTree")
|
||
public String clientUnitTree(Model model) {
|
||
return "/sys/clientUnitTree";
|
||
}
|
||
|
||
@RequestMapping("userAddPage")
|
||
public String userAddPage(Model model) {
|
||
try {
|
||
List<NewRoleBean> roles = nrService.findRoleList();
|
||
model.addAttribute("roles", roles);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
return "/sys/userAddForm";
|
||
}
|
||
|
||
@RequestMapping("toEditUser")
|
||
public String toEditUser(Model model, UserBean o) {
|
||
try {
|
||
o = service.findUserInfoById(o);
|
||
List<NewRoleBean> roles2 = o.getRoles();
|
||
Map<String, String> map = new HashMap<String, String>();
|
||
for (NewRoleBean newRoleBean : roles2) {
|
||
map.put("r" + newRoleBean.getId(), "1");
|
||
}
|
||
List<NewRoleBean> roles = nrService.findRoleList();
|
||
model.addAttribute("roles", roles);
|
||
model.addAttribute("user", o);
|
||
model.addAttribute("rmap", map);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
return "/sys/userAddForm";
|
||
}
|
||
|
||
@RequestMapping("toViewUser")
|
||
public String toViewUser(Model model, UserBean o) {
|
||
try {
|
||
o = service.findUserInfoById(o);
|
||
List<NewRoleBean> roles2 = o.getRoles();
|
||
Map<String, String> map = new HashMap<String, String>();
|
||
for (NewRoleBean newRoleBean : roles2) {
|
||
map.put("r" + newRoleBean.getId(), "1");
|
||
}
|
||
List<NewRoleBean> roles = nrService.findRoleList();
|
||
model.addAttribute("roles", roles);
|
||
model.addAttribute("user", o);
|
||
model.addAttribute("rmap", map);
|
||
model.addAttribute("opt", "view");
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
return "/sys/userAddForm";
|
||
}
|
||
|
||
/**
|
||
*
|
||
* @param req
|
||
* @return 员工树
|
||
*/
|
||
@RequestMapping(value = "allUserTree")
|
||
public String allUserTree() {
|
||
return "/sys/deptUserTree";
|
||
}
|
||
|
||
@RequestMapping("newRoleTree")
|
||
public String newRoleTree(Model model) {
|
||
return "/sys/newRoleTree";
|
||
}
|
||
|
||
@RequestMapping(value = "findByPage", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes findByPage(Page<UserBean> page, UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
if (ar.setNoAuth(doSecurityIntercept(GlobalConst.RESOURCES_TYPE_MENU, "/backstage/user/list"))) {
|
||
try {
|
||
Page<UserBean> accounts = service.findByPage(o, page);
|
||
Map<String, Object> p = new HashMap<String, Object>();
|
||
p.put("list", accounts);
|
||
ar.setSucceed(p);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "findByPageOfNew", method = RequestMethod.POST)
|
||
public String findByPageOfNew(@RequestBody Page<UserBean> page, UserBean o, Model model) {
|
||
try {
|
||
o = page.getObj();
|
||
page = service.findByPageOfNew(o, page);
|
||
model.addAttribute("page", page);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
e.printStackTrace();
|
||
}
|
||
return "/sys/newUserList";
|
||
}
|
||
|
||
/**
|
||
* 导入模板统一下载接口
|
||
*
|
||
* @param request
|
||
* @param response
|
||
* @param type
|
||
*/
|
||
@RequestMapping(value = "downloadExcel")
|
||
public void downloadExcel(HttpServletRequest request, HttpServletResponse response, String type) {
|
||
try {
|
||
String fileName = "";
|
||
if (type.equals("1")) {
|
||
fileName = "人员信息导入模板.xls";
|
||
} else if (type.equals("2")) {
|
||
fileName = "报名人员导入.xls";
|
||
} else {
|
||
fileName = "题库导入模板.xls";
|
||
}
|
||
String path = request.getSession().getServletContext().getRealPath("/static/js/model/");
|
||
File file = new File(path + fileName);
|
||
InputStream is = new FileInputStream(file);
|
||
response.setCharacterEncoding("utf-8");
|
||
response.setContentType("application/msword");
|
||
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
||
ServletOutputStream outs = response.getOutputStream();
|
||
byte[] buffer = new byte[512]; // 缓冲区
|
||
int bytesToRead = -1;
|
||
// 通过循环将读入的文件的内容输出到浏览器中
|
||
while ((bytesToRead = is.read(buffer)) != -1) {
|
||
outs.write(buffer, 0, bytesToRead);
|
||
}
|
||
if (is != null) {
|
||
is.close();
|
||
outs.close();
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
@RequestMapping(value = "findByPageOfWebUser", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes findByPageOfWebUser(Page<UserBean> page, UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
Page<UserBean> accounts = service.findByPageOfWebUser(o, page);
|
||
Map<String, Object> p = new HashMap<String, Object>();
|
||
p.put("list", accounts);
|
||
ar.setSucceed(p);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "findByPageOfBrotherUser", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes findByPageOfBrotherUser(Page<UserBean> page, UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
if (ar.setNoAuth(doSecurityIntercept(GlobalConst.RESOURCES_TYPE_MENU, "/backstage/user/list"))) {
|
||
try {
|
||
Page<UserBean> accounts = service.findByPageOfBrotherUser(o, page);
|
||
Map<String, Object> p = new HashMap<String, Object>();
|
||
p.put("list", accounts);
|
||
ar.setSucceed(p);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "findAllByRole", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes findAllByRole(UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
if (ar.setNoAuth(doSecurityIntercept(GlobalConst.RESOURCES_TYPE_MENU, "/backstage/user/list"))) {
|
||
try {
|
||
List<UserBean> accounts = service.findAllByRole(o);
|
||
Map<String, Object> p = new HashMap<String, Object>();
|
||
p.put("list", accounts);
|
||
ar.setSucceed(p);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "checkLoginNameIsExist", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes checkLoginNameIsExist(@RequestBody UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
UserBean u = service.findUserBeanByLoginName(o.getLoginName());
|
||
if (u != null) {
|
||
ar.setObj(u);
|
||
ar.setRes(2);
|
||
} else {
|
||
ar.setSucceed("登录名可用!");
|
||
}
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg("登录名查重错误,请软件管理员!");
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "findByOrg", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes findByOrg(UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
List<UserBean> accounts = service.findByOrg(o);
|
||
Map<String, Object> p = new HashMap<String, Object>();
|
||
p.put("list", accounts);
|
||
ar.setSucceed(p);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "orgTree", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes roleTree() {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
|
||
List<ZNode> list = service.getOrgBeans();
|
||
ar.setSucceed(list);
|
||
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "findPerson", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes findPerson(UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
List<ZNode> list = service.findPerson(o);
|
||
ar.setSucceed(list);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "findRepairTeam", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes findRepairTeam(UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
List<ZNode> list = service.findRepairTeam(o);
|
||
ar.setSucceed(list);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "findNewRole", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes findNewRole(UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
List<ZNode> list = service.findNewRole(o);
|
||
ar.setSucceed(list);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "clientUnitTree", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes clientUnitTree(UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
List<ZNode> list = service.clientUnitTree(o);
|
||
ar.setSucceed(list);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "find", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes find(UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
List<UserBean> list = service.find(o);
|
||
if (list != null && list.size() > 0) {
|
||
UserBean acount = list.get(0);
|
||
ar.setSucceed(acount);
|
||
} else {
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "updateUsers", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes updateUsers(int roleId, String chks) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
service.updateUsers(roleId, chks);
|
||
ar.setSucceedMsg(GlobalConst.SAVE_SUCCEED);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.SAVE_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "update", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes update(UserBean o) {
|
||
logger.info(o.toString());
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
NewRoleBean nrBean = new NewRoleBean();
|
||
List<NewRoleBean> list = new ArrayList<NewRoleBean>();
|
||
o.setUpdateTime(new Date());
|
||
String newRoleIds = o.getNewRoleId();
|
||
if (StringHelper.isNotEmpty(newRoleIds)) {
|
||
String[] newRoleId = newRoleIds.split(",");
|
||
for (int i = 0; i < newRoleId.length; i++) {
|
||
nrBean.setId(Integer.parseInt(newRoleId[i]));
|
||
nrBean.setUserId(o.getId());
|
||
list = nrService.findNewRoleInfo(nrBean);
|
||
if (list != null && list.size() > 0 && o.getDelFlag() == 0) {
|
||
System.err.println("已存在!");
|
||
}
|
||
if (o.getDelFlag() == 0) {
|
||
nrService.insertRole(nrBean);
|
||
}
|
||
if (o.getDelFlag() == 1) {
|
||
nrService.delRole(nrBean);
|
||
}
|
||
}
|
||
}
|
||
service.update(o);
|
||
ar.setSucceedMsg(GlobalConst.UPDATE_SUCCEED);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.UPDATE_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "add", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes add(UserBean o) {
|
||
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
// 查询后台是否有重复的用户名
|
||
// int res = service.insertUser(o);
|
||
NewRoleBean nrBean = new NewRoleBean();
|
||
List<NewRoleBean> list = new ArrayList<NewRoleBean>();
|
||
UserBean bean = service.selectUser(o.getLoginName());
|
||
String newRoleIds = o.getNewRoleId();
|
||
if (bean == null) {
|
||
|
||
RoleBean roleBean = new RoleBean();
|
||
roleBean.setName(o.getName());
|
||
roleBean.setIsActive("1");
|
||
roleService.insert(roleBean);
|
||
o.setId(1);
|
||
o.setRoleId(roleBean.getId());
|
||
o.setInternalEmp(1);
|
||
service.insertBean(o);
|
||
ar.setSucceed(o);
|
||
if (StringHelper.isNotEmpty(newRoleIds)) {
|
||
String[] newRoleId = newRoleIds.split(",");
|
||
for (int i = 0; i < newRoleId.length; i++) {
|
||
nrBean.setId(Integer.parseInt(newRoleId[i]));
|
||
nrBean.setUserId(o.getId());
|
||
list = nrService.findNewRoleInfo(nrBean);
|
||
if (list != null && list.size() > 0 && o.getDelFlag() == 0) {
|
||
System.err.println("已存在!");
|
||
}
|
||
if (o.getDelFlag() == 0) {
|
||
nrService.insertRole(nrBean);
|
||
}
|
||
if (o.getDelFlag() == 1) {
|
||
nrService.delRole(nrBean);
|
||
}
|
||
}
|
||
}
|
||
ar.setSucceedMsg(GlobalConst.SAVE_SUCCEED);
|
||
} else {
|
||
|
||
ar.setFailMsg("登录名已存在");
|
||
}
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.SAVE_FAIL);
|
||
}
|
||
return ar;
|
||
|
||
}
|
||
|
||
@RequestMapping(value = "insertBrother", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes insertBrother(UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
UserBean bean = service.selectUser(o.getLoginName());
|
||
Integer brother = o.getBrother();
|
||
if (brother == 0) {
|
||
if (bean == null) {
|
||
o.setInternalEmp(0);
|
||
service.insertBean(o);
|
||
ar.setSucceedMsg(GlobalConst.SAVE_SUCCEED);
|
||
} else {
|
||
ar.setFailMsg("登录名已存在");
|
||
}
|
||
} else {
|
||
if (bean == null) {
|
||
o.setInternalEmp(0);
|
||
service.insertBean(o);
|
||
ar.setSucceedMsg(GlobalConst.SAVE_SUCCEED);
|
||
} else {
|
||
ar.setFailMsg("登录名已存在");
|
||
}
|
||
}
|
||
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.SAVE_FAIL);
|
||
}
|
||
return ar;
|
||
|
||
}
|
||
|
||
@RequestMapping(value = "del", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes del(UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
service.delete(o);
|
||
ar.setSucceedMsg(GlobalConst.DEL_SUCCEED);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DEL_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@SuppressWarnings("resource")
|
||
@RequestMapping(value = "import", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes export(@RequestParam("file") MultipartFile file) {
|
||
AjaxRes ar = getAjaxRes();
|
||
AjaxRes ars = getAjaxRes();
|
||
Integer result = 0;
|
||
int errorNum = 0;
|
||
String zhuanyeid = "";
|
||
try {
|
||
InputStream inputStream = file.getInputStream();
|
||
POIFSFileSystem poifsFileSystem = new POIFSFileSystem(inputStream);
|
||
HSSFWorkbook wb = new HSSFWorkbook(poifsFileSystem);
|
||
HSSFSheet hssfSheet = wb.getSheetAt(0); // 读取页脚sheet
|
||
// 判断Sheet是否为空
|
||
if (hssfSheet != null) {
|
||
// 遍历行row,continue只是终止本次循环,接着还执行后面的循环
|
||
int rowNum = hssfSheet.getLastRowNum();
|
||
for (int rownum = 2; rownum <= rowNum; rownum++) { // 从第三行开始
|
||
// 获取到每一行
|
||
errorNum = rownum;
|
||
HSSFRow sheetRow = hssfSheet.getRow(rownum);
|
||
// 获得第i行对象
|
||
Row row = hssfSheet.getRow(rownum);
|
||
// HSSFCell cell = hssfSheet.getRow(rownum).getCell(0);
|
||
// String value = getValue(cell);
|
||
if (sheetRow != null && !isRowEmpty(sheetRow)) {
|
||
// 先去判断
|
||
ars = compareSaveData(sheetRow, rownum + 1);
|
||
if (ars.getRes() == 2) {
|
||
ar.setFailMsg(ars.getResMsg());
|
||
result = 2;
|
||
break;
|
||
}
|
||
if (ars.getRes() == 3) {
|
||
ar.setFailMsg(ars.getResMsg());
|
||
result = 3;
|
||
break;
|
||
}
|
||
if (ars.getRes() == 4) {
|
||
ar.setFailMsg(ars.getResMsg());
|
||
result = 4;
|
||
break;
|
||
}
|
||
if (ars.getRes() == 5) {
|
||
ar.setFailMsg(ars.getResMsg());
|
||
result = 5;
|
||
break;
|
||
}
|
||
if (ars.getRes() == 6) {
|
||
ar.setFailMsg(ars.getResMsg());
|
||
result = 6;
|
||
break;
|
||
}
|
||
// 获取专业id int类型的值转换为string类型再由对象接收转换后的值
|
||
if (row.getCell(4) != null) {
|
||
row.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
|
||
zhuanyeid = (row.getCell(4).getStringCellValue());
|
||
}
|
||
if (zhuanyeid.isEmpty()) {
|
||
result = 5;
|
||
ar.setFailMsg("第" + (errorNum + 1) + "行专业id字段为空,导入失败");
|
||
break;
|
||
}
|
||
|
||
boolean isRule = isZhuanyeidRule(zhuanyeid);
|
||
|
||
if (!isRule) {
|
||
ar.setSucceedMsg("第" + (errorNum + 1) + "行专业id不符合规则,请更改");
|
||
result = 3;
|
||
break;
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
if (result != 2 && result != 3 && result != 4 && result != 5 && result != 6) {
|
||
for (int rownums = 2; rownums <= rowNum; rownums++) {
|
||
HSSFRow sheetRows = hssfSheet.getRow(rownums);
|
||
if (sheetRows != null && !isRowEmpty(sheetRows)) {
|
||
ar = addSaveData(sheetRows);
|
||
if (ar.getRes() == 0) {
|
||
return ar;
|
||
}
|
||
}
|
||
}
|
||
ar.setSucceedMsg(GlobalConst.IMP_SUCCEED);
|
||
} else if (result == 2) {
|
||
ar.setFailMsg("第" + (errorNum + 1) + "行姓名字段有误,导入失败");
|
||
} else if (result == 3) {
|
||
ar.setFailMsg("第" + (errorNum + 1) + "行身份证字段有误,导入失败");
|
||
} else if (result == 4) {
|
||
ar.setFailMsg("第" + (errorNum + 1) + "行性别字段有误,导入失败");
|
||
} else if (result == 5) {
|
||
ar.setFailMsg("第" + (errorNum + 1) + "行专业id字段有误,导入失败");
|
||
} else if (result == 6) {
|
||
ar.setFailMsg("第" + (errorNum + 1) + "行身份证号码已经存在,请勿重复导入");
|
||
}
|
||
}
|
||
if (wb != null) {
|
||
wb.close();
|
||
}
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg("第" + (errorNum + 1) + "行导入失败");
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
/**
|
||
* 判断专业id是否符合规则
|
||
*
|
||
* @param specialty
|
||
* @return
|
||
*/
|
||
private boolean isZhuanyeidRule(String zhuanyeid) {
|
||
boolean tf = true;
|
||
try {
|
||
switch (zhuanyeid) {
|
||
case "67":
|
||
case "69":
|
||
case "80":
|
||
case "81":
|
||
case "82":
|
||
case "84":
|
||
case "85":
|
||
case "86":
|
||
case "88":
|
||
case "89":
|
||
case "92":
|
||
case "93":
|
||
case "94":
|
||
case "96":
|
||
case "97":
|
||
case "98":
|
||
case "100":
|
||
case "101":
|
||
case "104":
|
||
case "105":
|
||
case "106":
|
||
case "108":
|
||
case "109":
|
||
case "110":
|
||
case "112":
|
||
case "113":
|
||
case "116":
|
||
case "117":
|
||
case "118":
|
||
case "120":
|
||
case "121":
|
||
case "122":
|
||
case "124":
|
||
case "125":
|
||
case "128":
|
||
case "129":
|
||
case "130":
|
||
case "132":
|
||
case "133":
|
||
case "134":
|
||
case "136":
|
||
case "137":
|
||
case "140":
|
||
case "141":
|
||
case "142":
|
||
case "144":
|
||
case "145":
|
||
case "146":
|
||
case "148":
|
||
case "149":
|
||
case "152":
|
||
case "153":
|
||
case "154":
|
||
case "156":
|
||
case "157":
|
||
case "158":
|
||
case "160":
|
||
case "161":
|
||
case "164":
|
||
case "165":
|
||
case "166":
|
||
case "168":
|
||
case "169":
|
||
case "170":
|
||
case "172":
|
||
case "173":
|
||
case "176":
|
||
case "177":
|
||
case "178":
|
||
case "180":
|
||
case "181":
|
||
case "182":
|
||
case "184":
|
||
case "185":
|
||
case "188":
|
||
case "189":
|
||
case "190":
|
||
case "192":
|
||
case "193":
|
||
case "194":
|
||
case "196":
|
||
case "197":
|
||
case "200":
|
||
case "201":
|
||
case "204":
|
||
case "205":
|
||
case "206":
|
||
case "208":
|
||
case "209":
|
||
case "218":
|
||
case "219":
|
||
case "220":
|
||
case "221":
|
||
case "222":
|
||
case "223":
|
||
case "224":
|
||
case "225":
|
||
case "228":
|
||
case "229":
|
||
case "230":
|
||
case "231":
|
||
tf = true;
|
||
break;
|
||
default:
|
||
tf = false;
|
||
break;
|
||
}
|
||
} catch (Exception e) {
|
||
logger.error(e.toString());
|
||
}
|
||
return tf;
|
||
}
|
||
|
||
private AjaxRes compareSaveData(HSSFRow sheetRow, int rownum) throws Exception {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
String name = getValue(sheetRow.getCell(0)); // 姓名
|
||
String loginName = change(getValue(sheetRow.getCell(1))); // 身份证号
|
||
CheckCard card = new CheckCard();
|
||
boolean checkIdcard = card.verify(loginName); // 身份证校验
|
||
String sex = getValue(sheetRow.getCell(2)); // 性别
|
||
String orgIdStr = change(getValue(sheetRow.getCell(4)));
|
||
UserBean o = null;
|
||
if(StringHelper.isNotEmpty(orgIdStr)){
|
||
Integer orgId = Integer.parseInt(orgIdStr);
|
||
o = service.findOrgId(orgId);
|
||
}
|
||
int chachong1 = usiService.findCountByLoginName(loginName);
|
||
if (chachong1 > 0) {
|
||
ar.setFailMsg("身份证字段有重复,导入失败");
|
||
ar.setRes(6);
|
||
return ar;
|
||
}
|
||
if (!(name != null && name.replace(" ", "") != "")) {
|
||
ar.setFailMsg("第" + rownum + "行姓名字段有误,导入失败");
|
||
ar.setRes(2);
|
||
return ar;
|
||
}
|
||
if (checkIdcard == false) {
|
||
ar.setFailMsg("第" + rownum + "行身份证字段有误,导入失败");
|
||
ar.setRes(3);
|
||
return ar;
|
||
}
|
||
if (sex != null && sex != "") {
|
||
if (!(sex.equals("男") || sex.equals("女"))) {
|
||
ar.setFailMsg("第" + rownum + "行性别字段有误,导入失败");
|
||
ar.setRes(4);
|
||
return ar;
|
||
}
|
||
} else {
|
||
ar.setFailMsg("第" + rownum + "行性别字段有误,导入失败");
|
||
ar.setRes(4);
|
||
return ar;
|
||
}
|
||
if (o == null) {
|
||
ar.setFailMsg("第" + rownum + "行专业id字段有误,导入失败");
|
||
ar.setRes(5);
|
||
return ar;
|
||
}
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg("第" + rownum + "行数据有误,导入失败");
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
private AjaxRes addSaveData(HSSFRow sheetRow) throws Exception {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
UserBean bean = new UserBean();
|
||
String name = getValue(sheetRow.getCell(0));
|
||
bean.setName(name);
|
||
String loginName = change(getValue(sheetRow.getCell(1)));
|
||
bean.setLoginName(loginName);
|
||
String sex = getValue(sheetRow.getCell(2));
|
||
if (sex != null && sex.equals("男")) {
|
||
bean.setSex("1");
|
||
}
|
||
if (sex != null && sex.equals("女")) {
|
||
bean.setSex("0");
|
||
}
|
||
String telphone = change(getValue(sheetRow.getCell(3)));
|
||
bean.setTelphone(telphone);
|
||
Integer orgId = Integer.parseInt(change(getValue(sheetRow.getCell(4))));
|
||
bean.setOrgId(orgId);
|
||
String greenScore = getValue(sheetRow.getCell(5));
|
||
bean.setGreenScore(greenScore);
|
||
bean.setMail("ddd@163.com"); // 默认邮箱
|
||
bean.setIfPermiss("0"); // 是否能进入后台
|
||
NewRoleBean nrbean = new NewRoleBean();
|
||
NewRoleBean[] roles = { nrbean };
|
||
nrbean.setId(30); // 考试人员角色
|
||
bean.setRoleArr(roles);
|
||
ar = service.addUser(bean);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.IMP_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
// 判断该行是否为空
|
||
public static boolean isRowEmpty(Row row) {
|
||
int count = 0;
|
||
for (int c = row.getFirstCellNum(); c < row.getLastCellNum(); c++) {
|
||
Cell cell = row.getCell(c);
|
||
if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
|
||
count++;
|
||
}
|
||
}
|
||
if (count >= 1) { // 表示是有效数据行
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public static boolean isNumeric(String str) { // 判断字符串为数字(包括小数)
|
||
Pattern pattern = Pattern.compile("[0-9]*\\.?[0-9]+");
|
||
Matcher isNum = pattern.matcher(str);
|
||
if (!isNum.matches()) {
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
private static String getValue(HSSFCell hssfCell) {
|
||
if (hssfCell == null) {
|
||
return "";
|
||
} else {
|
||
if (hssfCell.getCellType() == HSSFCell.CELL_TYPE_BOOLEAN) {
|
||
return String.valueOf(hssfCell.getBooleanCellValue());
|
||
} else if (hssfCell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
|
||
return String.valueOf(hssfCell.getNumericCellValue());
|
||
} else {
|
||
return String.valueOf(hssfCell.getStringCellValue());
|
||
}
|
||
}
|
||
}
|
||
|
||
// 将double类型字符串转化为整型
|
||
private static String change(String str) {
|
||
if (str.indexOf('.') != -1) {
|
||
return str.substring(0, str.indexOf('.'));
|
||
} else {
|
||
return str;
|
||
}
|
||
}
|
||
|
||
@RequestMapping(value = "delBatch", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes delBatch(String chks) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
service.deleteBatch(chks);
|
||
ar.setSucceedMsg(GlobalConst.DEL_SUCCEED);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DEL_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "getPerData", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes getPerData() {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
UserBean account = UserShiroHelper.getRealCurrentUser();
|
||
ar.setSucceed(account);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "setPerData", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes setPerData(UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
service.setPerData(o);
|
||
ar.setSucceedMsg(GlobalConst.UPDATE_SUCCEED);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.UPDATE_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "setSetting", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes setSetting(String skin) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
service.setSetting(skin);
|
||
ar.setSucceedMsg(GlobalConst.UPDATE_SUCCEED);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.UPDATE_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "preResetPWD", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes resetPwd(String opwd, String npwd, String qpwd) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
int res = service.preResetPwd(opwd, npwd, qpwd);
|
||
if (res == 1)
|
||
ar.setSucceedMsg(GlobalConst.UPDATE_SUCCEED);
|
||
else if (res == 2)
|
||
ar.setFailMsg("密码不正确");
|
||
else if (res == 3)
|
||
ar.setFailMsg("两次密码不一致");
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.UPDATE_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "resetPwd", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes resetPwd(UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
|
||
try {
|
||
o.setPasswd(getPageData().getString("pwd"));
|
||
int res = service.sysResetPwd(o);
|
||
if (res == 1)
|
||
ar.setSucceedMsg(GlobalConst.UPDATE_SUCCEED);
|
||
else
|
||
ar.setFailMsg(GlobalConst.UPDATE_FAIL);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.UPDATE_FAIL);
|
||
}
|
||
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "webResetPwd")
|
||
@ResponseBody
|
||
public AjaxRes webResetPwd(HttpServletRequest req, HttpSession session) {
|
||
AjaxRes ar = getAjaxRes();
|
||
String phone = req.getParameter("phone");
|
||
String code = req.getParameter("code");
|
||
String pwd = req.getParameter("pwd");
|
||
try {
|
||
// 查询验证码是否正确
|
||
String resetPhone = session.getAttribute("resetPhone").toString();
|
||
String resetPasswordCode = session.getAttribute("resetPasswordCode").toString();
|
||
|
||
if (resetPhone.equals(phone)) {
|
||
if (resetPasswordCode.equals(code)) {
|
||
// 查询用户名是否重复
|
||
List<UserBean> users = service.findListByPhone(phone);
|
||
if (users != null && users.size() > 0) {
|
||
users.get(0).setPasswd(pwd);
|
||
int res = service.webResetPwd(users.get(0));
|
||
if (res == 1) {
|
||
ar.setSucceedMsg("重置密码成功!");
|
||
} else {
|
||
ar.setFailMsg("重置密码失败!");
|
||
}
|
||
} else {
|
||
ar.setFailMsg("重置密码失败,用户不存在!");
|
||
}
|
||
} else {
|
||
ar.setFailMsg("重置密码失败,验证码错误!");
|
||
}
|
||
} else {
|
||
ar.setFailMsg("重置密码失败,验证手机号码不可更换!");
|
||
}
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg("注册失败!");
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "findAllUser", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes findAllUser() {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
List<UserBean> accounts = service.findAllUser();
|
||
Map<String, Object> p = new HashMap<String, Object>();
|
||
p.put("list", accounts);
|
||
ar.setSucceed(p);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "findAllPerson", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes findAllPerson() {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
List<UserBean> accounts = service.findAllPerson();
|
||
Map<String, Object> p = new HashMap<String, Object>();
|
||
p.put("list", accounts);
|
||
ar.setSucceed(p);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "findByRepair", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes findByRepair() {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
List<UserBean> accounts = service.findByRepair();
|
||
Map<String, Object> p = new HashMap<String, Object>();
|
||
p.put("list", accounts);
|
||
ar.setSucceed(p);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "VerificationLogin", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes VerificationLogin(UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
|
||
try {
|
||
o.setPasswd(getPageData().getString("pwd"));
|
||
int res = service.sysResetPwd(o);
|
||
if (res == 1)
|
||
ar.setSucceedMsg(GlobalConst.UPDATE_SUCCEED);
|
||
else
|
||
ar.setFailMsg(GlobalConst.UPDATE_FAIL);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.UPDATE_FAIL);
|
||
}
|
||
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "addWebPortalUser", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes addWebPortalUser(UserBean o, HttpSession session) {
|
||
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
// 查询验证码是否正确
|
||
String regCode = session.getAttribute("regCode").toString();
|
||
String regPhone = session.getAttribute("regPhone").toString();
|
||
|
||
if (regPhone.equals(o.getTelphone())) {
|
||
if (regCode.equals(o.getYzm())) {
|
||
// 查询用户名是否重复
|
||
UserBean getloginName = service.findUserBeanByLoginName(o.getLoginName());
|
||
if (getloginName == null) {
|
||
o.setBrother(0);
|
||
int res = service.webInsertBean(o);
|
||
if (res == 1) {
|
||
ar.setSucceedMsg("注册成功!");
|
||
} else {
|
||
ar.setFailMsg("注册失败!");
|
||
}
|
||
} else {
|
||
ar.setFailMsg("注册失败,登录名重复!");
|
||
}
|
||
} else {
|
||
ar.setFailMsg("注册失败,验证码错误!");
|
||
}
|
||
} else {
|
||
ar.setFailMsg("注册失败,验证手机号码不可更换!");
|
||
}
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg("注册失败!");
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
/**
|
||
* @Author 无畏
|
||
* @Date 2019-08-01
|
||
* @function 检查手机号码是否注册过
|
||
* @param o
|
||
* @return
|
||
*/
|
||
@SuppressWarnings("unused")
|
||
private Boolean checkPhoneIsReged(String phone) {
|
||
Boolean reged = false;
|
||
try {
|
||
List<UserBean> users = service.findListByPhone(phone);
|
||
if (users.size() > 0) {
|
||
reged = true;
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
return reged;
|
||
}
|
||
|
||
/**
|
||
* @Author 无畏
|
||
* @Date 2019-07-19
|
||
* @function 新增班级
|
||
* @param o
|
||
* @return
|
||
*/
|
||
@RequestMapping("getDeptEmp")
|
||
@ResponseBody
|
||
public AjaxRes getDeptEmpByDeptId(@RequestBody UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
List<UserBean> emps = service.getDeptEmpByDeptId(o);
|
||
ar.setObj(emps);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
ar.setFailMsg("获取员工失败!");
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
/**
|
||
* @Author 无畏
|
||
* @Date 2019-07-19
|
||
* @function 新增班级
|
||
* @param o
|
||
* @return
|
||
*/
|
||
@RequestMapping("getRepairEmpList")
|
||
@ResponseBody
|
||
public AjaxRes getRepairEmpList(Integer id) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
|
||
List<ZNode> emps = service.getRepairEmpList(id);
|
||
|
||
ar.setObj(emps);
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
ar.setFailMsg("获取员工失败!");
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
/**
|
||
* @Author 无畏
|
||
* @Date 2020-03-06
|
||
* @function 新增班级
|
||
* @param o
|
||
* @return
|
||
*/
|
||
@RequestMapping("addUser")
|
||
@ResponseBody
|
||
public AjaxRes addUser(@RequestBody UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
ar = service.addUser(o);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
ar.setFailMsg("添加员工失败!");
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
/**
|
||
* @Author 无畏
|
||
* @Date 2020-03-06
|
||
* @function 新增班级
|
||
* @param o
|
||
* @return
|
||
*/
|
||
@RequestMapping("updateUser")
|
||
@ResponseBody
|
||
public AjaxRes updateUser(@RequestBody UserBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
ar = service.updateUser(o);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
ar.setFailMsg("员工信息更新失败!");
|
||
}
|
||
return ar;
|
||
}
|
||
}
|