|
@@ -1,23 +1,29 @@
|
|
|
package com.caimei.modules.hehe.web;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
-import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+import com.caimei.modules.hehe.entity.CmHeheActivityProduct;
|
|
|
+import com.caimei.modules.hehe.entity.CmHeheProduct;
|
|
|
+import com.caimei.modules.hehe.entity.CmHeheUser;
|
|
|
+import com.caimei.modules.hehe.service.CmHeheUserService;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import com.thinkgem.jeesite.common.config.Global;
|
|
|
+import com.thinkgem.jeesite.common.persistence.Page;
|
|
|
+import com.thinkgem.jeesite.common.utils.StringUtils;
|
|
|
+import com.thinkgem.jeesite.common.web.BaseController;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
-import com.thinkgem.jeesite.common.config.Global;
|
|
|
-import com.thinkgem.jeesite.common.persistence.Page;
|
|
|
-import com.thinkgem.jeesite.common.web.BaseController;
|
|
|
-import com.thinkgem.jeesite.common.utils.StringUtils;
|
|
|
-import com.caimei.modules.hehe.entity.CmHeheUser;
|
|
|
-import com.caimei.modules.hehe.service.CmHeheUserService;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import static com.caimei.modules.newhome.web.NewPageQualitySupplierController.isInteger;
|
|
|
|
|
|
/**
|
|
|
* 呵呵用户Controller
|
|
@@ -77,10 +83,86 @@ public class CmHeheUserController extends BaseController {
|
|
|
* 呵呵商城所有用户列表
|
|
|
*/
|
|
|
@RequestMapping("/userList")
|
|
|
- public String userList(CmHeheUser cmHeheUser, HttpServletRequest request, HttpServletResponse response, Model model){
|
|
|
+ public String userList(CmHeheUser cmHeheUser, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
Page<CmHeheUser> page = cmHeheUserService.findPage(new Page<CmHeheUser>(request, response), cmHeheUser);
|
|
|
model.addAttribute("page", page);
|
|
|
return "modules/hehe/cmHeheUserAllList";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 分销者活动商品数据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "activityProductList")
|
|
|
+ public String activityProductList(CmHeheActivityProduct activityProduct, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
+ Page<CmHeheActivityProduct> page = cmHeheUserService.activityProductList(new Page<CmHeheActivityProduct>(request, response), activityProduct);
|
|
|
+ model.addAttribute("page", page);
|
|
|
+ model.addAttribute("activityProduct", activityProduct);
|
|
|
+ return "modules/hehe/userActivityProductList";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加活动商品,商品数据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "findProductPage")
|
|
|
+ public String findProductPage(CmHeheProduct product, Integer userId, Model model, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ Page<CmHeheProduct> page = cmHeheUserService.findProductPage(new Page<CmHeheProduct>(request, response), product, userId);
|
|
|
+ model.addAttribute("page", page);
|
|
|
+ model.addAttribute("userId", userId);
|
|
|
+ return "modules/hehe/addUserActivityProduct";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加商品
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "addActivityProducts")
|
|
|
+ @ResponseBody
|
|
|
+ public Map<String, Object> addActivityProducts(Integer userId, String productIds) {
|
|
|
+ cmHeheUserService.addActivityProducts(userId, productIds);
|
|
|
+ HashMap<String, Object> map = new HashMap<>(2);
|
|
|
+ map.put("success", true);
|
|
|
+ map.put("info", "添加活动商品成功");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量更新排序值
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "batchSaveSort")
|
|
|
+ @ResponseBody
|
|
|
+ public Map<String, Object> batchSaveSort(String sortList) {
|
|
|
+ Map<String, Object> map = Maps.newLinkedHashMap();
|
|
|
+ try {
|
|
|
+ String[] newPageLists = sortList.split(",");
|
|
|
+ for (String list : newPageLists) {
|
|
|
+ String[] split = list.split("-");
|
|
|
+ if (split.length == 1 || split.length < 1) {
|
|
|
+ String id = split[0];
|
|
|
+ String sort = null;
|
|
|
+ cmHeheUserService.saveSort(sort, id);
|
|
|
+ } else {
|
|
|
+ String id = split[0];
|
|
|
+ String sort = split[1];
|
|
|
+ if (isInteger(sort)) {
|
|
|
+ if (StringUtils.equals("0", sort)) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("msg", "排序值只能填写大于等于1的整数");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ cmHeheUserService.saveSort(sort, id);
|
|
|
+ } else {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("msg", "排序值只能为数字");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("success", true);
|
|
|
+ map.put("msg", "更新排序成功");
|
|
|
+ return map;
|
|
|
+ } catch (Exception e) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("msg", "更新排序失败");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|