|
@@ -1,156 +1,156 @@
|
|
|
-package com.cloudcross.ssp.base.web;
|
|
|
-
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import org.apache.commons.lang.ArrayUtils;
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
-import org.apache.log4j.Logger;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.ui.Model;
|
|
|
-import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
-
|
|
|
-import com.cloudcross.ssp.back.model.User;
|
|
|
-import com.cloudcross.ssp.back.service.IUserService;
|
|
|
-import com.cloudcross.ssp.common.consts.Status;
|
|
|
-import com.cloudcross.ssp.common.utils.LangUtil;
|
|
|
-import com.cloudcross.ssp.common.utils.MD5;
|
|
|
-import com.cloudcross.ssp.common.utils.Pager;
|
|
|
-
|
|
|
-public abstract class UserController extends SimpleController {
|
|
|
- private static final Logger LOG = Logger
|
|
|
- .getLogger(UserController.class);
|
|
|
-
|
|
|
- @Autowired
|
|
|
- protected IUserService userService;
|
|
|
-
|
|
|
- /**
|
|
|
- * @return 返回到广告主管理第一页。
|
|
|
- */
|
|
|
- @RequestMapping
|
|
|
- public String index() {
|
|
|
- return redirect(page("list"));
|
|
|
- }
|
|
|
-
|
|
|
- @RequestMapping("/list")
|
|
|
- public String list(Model model,
|
|
|
- @RequestParam HashMap<String, Object> paramMap,
|
|
|
- @RequestParam(defaultValue="1") int page) {
|
|
|
- paramMap.put("userGroupType", getUserGroupType());
|
|
|
-
|
|
|
- // 搜索条件:账户类型、账户及姓名
|
|
|
- // 查询总行数
|
|
|
- int totalRow = userService.countByParams(paramMap);
|
|
|
-
|
|
|
- Pager pager = new Pager();
|
|
|
- pager.setPage(page);
|
|
|
- pager.setTotalRow(totalRow);
|
|
|
-
|
|
|
- List<User> userList = userService.findByParams(paramMap, pager);
|
|
|
-
|
|
|
- model.addAllAttributes(paramMap);
|
|
|
- model.addAttribute("pager", pager);
|
|
|
- model.addAttribute("userList", userList);
|
|
|
- return page("list");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return 创建广告主账号。
|
|
|
- */
|
|
|
- @RequestMapping("/create")
|
|
|
- public String create() {
|
|
|
- return page("create");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param id
|
|
|
- * 广告主ID
|
|
|
- * @return 广告主编辑页面。
|
|
|
- */
|
|
|
- @RequestMapping("/edit/{id}")
|
|
|
- public String edit(Model model, @PathVariable long id) {
|
|
|
- // 根据id从数据库中查询广告主对象。
|
|
|
- User user = userService.findById(id);
|
|
|
- model.addAttribute("user", user);
|
|
|
- return page("edit");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 单个或者批量启用功能。
|
|
|
- *
|
|
|
- * @return 成功则返回"ok"
|
|
|
- */
|
|
|
- @RequestMapping("enable")
|
|
|
- public @ResponseBody String enable(Long[] id) {
|
|
|
- LOG.debug("Args's value: id=" + Arrays.toString(id));
|
|
|
- if (ArrayUtils.isNotEmpty(id)) {
|
|
|
- userService.updateStatus(LangUtil.array2List(id),
|
|
|
- Status.enable.value);
|
|
|
- }
|
|
|
- return OK;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 单个或者批量禁用功能。
|
|
|
- *
|
|
|
- * @return 成功则返回"ok"
|
|
|
- */
|
|
|
- @RequestMapping("disable")
|
|
|
- public @ResponseBody String disable(Long[] id) {
|
|
|
- LOG.debug("Args's value: id=" + Arrays.toString(id));
|
|
|
- if (ArrayUtils.isNotEmpty(id)) {
|
|
|
- userService.updateStatus(LangUtil.array2List(id),
|
|
|
- Status.disable.value);
|
|
|
- }
|
|
|
- // 将来会被改
|
|
|
- return OK;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 在保存对象前要验证数据是否合法。
|
|
|
- *
|
|
|
- * @return 保存成功返回到广告主管理页面。
|
|
|
- */
|
|
|
- @RequestMapping("/save")
|
|
|
- public String save(
|
|
|
- @ModelAttribute("form") User user,
|
|
|
- @RequestParam(value = "ensurePassword", defaultValue = "") String ensurePassword,
|
|
|
- @RequestParam("userGroupType") String userGroupType) {
|
|
|
- // 校验参数
|
|
|
-
|
|
|
- MD5 md5 = MD5.getInstance();
|
|
|
- String password = user.getPassword();
|
|
|
-
|
|
|
- //添加用户
|
|
|
- if (user.getId() == null) {
|
|
|
- if (null == userGroupType) {
|
|
|
- userGroupType = getUserGroupType();
|
|
|
- }
|
|
|
-
|
|
|
- //加密密码
|
|
|
- user.setPassword(md5.getMD5(password));
|
|
|
-
|
|
|
- userService.add(userGroupType, user);
|
|
|
- } else {
|
|
|
- // 编辑用户
|
|
|
-
|
|
|
- //加密密码
|
|
|
- if (StringUtils.isNotBlank(password)) {
|
|
|
- user.setPassword(md5.getMD5(password));
|
|
|
- }
|
|
|
- userService.edit(user);
|
|
|
- }
|
|
|
- // 跳转到管理页面。
|
|
|
- return redirect(page("list"));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return
|
|
|
- */
|
|
|
- protected abstract String getUserGroupType();
|
|
|
-}
|
|
|
+//package com.cloudcross.ssp.base.web;
|
|
|
+//
|
|
|
+//import java.util.Arrays;
|
|
|
+//import java.util.HashMap;
|
|
|
+//import java.util.List;
|
|
|
+//
|
|
|
+//import org.apache.commons.lang.ArrayUtils;
|
|
|
+//import org.apache.commons.lang.StringUtils;
|
|
|
+//import org.apache.log4j.Logger;
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+//import org.springframework.ui.Model;
|
|
|
+//import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
+//import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+//import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+//import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+//import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+//
|
|
|
+//import com.cloudcross.ssp.back.model.User;
|
|
|
+//import com.cloudcross.ssp.back.service.IUserService;
|
|
|
+//import com.cloudcross.ssp.common.consts.Status;
|
|
|
+//import com.cloudcross.ssp.common.utils.LangUtil;
|
|
|
+//import com.cloudcross.ssp.common.utils.MD5;
|
|
|
+//import com.cloudcross.ssp.common.utils.Pager;
|
|
|
+//
|
|
|
+//public abstract class UserController extends SimpleController {
|
|
|
+// private static final Logger LOG = Logger
|
|
|
+// .getLogger(UserController.class);
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// protected IUserService userService;
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * @return 返回到广告主管理第一页。
|
|
|
+// */
|
|
|
+// @RequestMapping
|
|
|
+// public String index() {
|
|
|
+// return redirect(page("list"));
|
|
|
+// }
|
|
|
+//
|
|
|
+// @RequestMapping("/list")
|
|
|
+// public String list(Model model,
|
|
|
+// @RequestParam HashMap<String, Object> paramMap,
|
|
|
+// @RequestParam(defaultValue="1") int page) {
|
|
|
+// paramMap.put("userGroupType", getUserGroupType());
|
|
|
+//
|
|
|
+// // 搜索条件:账户类型、账户及姓名
|
|
|
+// // 查询总行数
|
|
|
+// int totalRow = userService.countByParams(paramMap);
|
|
|
+//
|
|
|
+// Pager pager = new Pager();
|
|
|
+// pager.setPage(page);
|
|
|
+// pager.setTotalRow(totalRow);
|
|
|
+//
|
|
|
+// List<User> userList = userService.findByParams(paramMap, pager);
|
|
|
+//
|
|
|
+// model.addAllAttributes(paramMap);
|
|
|
+// model.addAttribute("pager", pager);
|
|
|
+// model.addAttribute("userList", userList);
|
|
|
+// return page("list");
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * @return 创建广告主账号。
|
|
|
+// */
|
|
|
+// @RequestMapping("/create")
|
|
|
+// public String create() {
|
|
|
+// return page("create");
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * @param id
|
|
|
+// * 广告主ID
|
|
|
+// * @return 广告主编辑页面。
|
|
|
+// */
|
|
|
+// @RequestMapping("/edit/{id}")
|
|
|
+// public String edit(Model model, @PathVariable long id) {
|
|
|
+// // 根据id从数据库中查询广告主对象。
|
|
|
+// User user = userService.findById(id);
|
|
|
+// model.addAttribute("user", user);
|
|
|
+// return page("edit");
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 单个或者批量启用功能。
|
|
|
+// *
|
|
|
+// * @return 成功则返回"ok"
|
|
|
+// */
|
|
|
+// @RequestMapping("enable")
|
|
|
+// public @ResponseBody String enable(Long[] id) {
|
|
|
+// LOG.debug("Args's value: id=" + Arrays.toString(id));
|
|
|
+// if (ArrayUtils.isNotEmpty(id)) {
|
|
|
+// userService.updateStatus(LangUtil.array2List(id),
|
|
|
+// Status.enable.value);
|
|
|
+// }
|
|
|
+// return OK;
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 单个或者批量禁用功能。
|
|
|
+// *
|
|
|
+// * @return 成功则返回"ok"
|
|
|
+// */
|
|
|
+// @RequestMapping("disable")
|
|
|
+// public @ResponseBody String disable(Long[] id) {
|
|
|
+// LOG.debug("Args's value: id=" + Arrays.toString(id));
|
|
|
+// if (ArrayUtils.isNotEmpty(id)) {
|
|
|
+// userService.updateStatus(LangUtil.array2List(id),
|
|
|
+// Status.disable.value);
|
|
|
+// }
|
|
|
+// // 将来会被改
|
|
|
+// return OK;
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 在保存对象前要验证数据是否合法。
|
|
|
+// *
|
|
|
+// * @return 保存成功返回到广告主管理页面。
|
|
|
+// */
|
|
|
+// @RequestMapping("/save")
|
|
|
+// public String save(
|
|
|
+// @ModelAttribute("form") User user,
|
|
|
+// @RequestParam(value = "ensurePassword", defaultValue = "") String ensurePassword,
|
|
|
+// @RequestParam("userGroupType") String userGroupType) {
|
|
|
+// // 校验参数
|
|
|
+//
|
|
|
+// MD5 md5 = MD5.getInstance();
|
|
|
+// String password = user.getPassword();
|
|
|
+//
|
|
|
+// //添加用户
|
|
|
+// if (user.getId() == null) {
|
|
|
+// if (null == userGroupType) {
|
|
|
+// userGroupType = getUserGroupType();
|
|
|
+// }
|
|
|
+//
|
|
|
+// //加密密码
|
|
|
+// user.setPassword(md5.getMD5(password));
|
|
|
+//
|
|
|
+// userService.add(userGroupType, user);
|
|
|
+// } else {
|
|
|
+// // 编辑用户
|
|
|
+//
|
|
|
+// //加密密码
|
|
|
+// if (StringUtils.isNotBlank(password)) {
|
|
|
+// user.setPassword(md5.getMD5(password));
|
|
|
+// }
|
|
|
+// userService.edit(user);
|
|
|
+// }
|
|
|
+// // 跳转到管理页面。
|
|
|
+// return redirect(page("list"));
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// protected abstract String getUserGroupType();
|
|
|
+//}
|