|
@@ -0,0 +1,164 @@
|
|
|
+package com.caimei.modules.hehe.web;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import com.caimei.modules.hehe.dao.CmHeheFloorDao;
|
|
|
+import com.caimei.modules.hehe.entity.CmHeheFloor;
|
|
|
+import com.caimei.modules.hehe.entity.CmHeheFloorProduct1;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+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.service.CmHeheFloorService;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import static com.caimei.modules.newhome.web.NewPageQualitySupplierController.isInteger;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 呵呵商品商品楼层Controller
|
|
|
+ * @author Aslee
|
|
|
+ * @version 2021-06-17
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "${adminPath}/hehe/cmHeheFloor")
|
|
|
+public class CmHeheFloorController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CmHeheFloorService cmHeheFloorService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CmHeheFloorDao cmHeheFloorDao;
|
|
|
+
|
|
|
+ @ModelAttribute
|
|
|
+ public CmHeheFloor get(@RequestParam(required=false) String id) {
|
|
|
+ CmHeheFloor entity = null;
|
|
|
+ if (StringUtils.isNotBlank(id)){
|
|
|
+ entity = cmHeheFloorService.get(id);
|
|
|
+ }
|
|
|
+ if (entity == null){
|
|
|
+ entity = new CmHeheFloor();
|
|
|
+ }
|
|
|
+ return entity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
+ public String list(CmHeheFloor cmHeheFloor, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
+ Page<CmHeheFloor> page = cmHeheFloorService.findPage(new Page<CmHeheFloor>(request, response), cmHeheFloor);
|
|
|
+ model.addAttribute("page", page);
|
|
|
+ return "modules/hehe/cmHeheFloorList";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "form")
|
|
|
+ public String form(CmHeheFloor cmHeheFloor, Model model) {
|
|
|
+ model.addAttribute("cmHeheFloor", cmHeheFloor);
|
|
|
+ return "modules/hehe/cmHeheFloorForm";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "save")
|
|
|
+ public String save(CmHeheFloor cmHeheFloor, Model model, RedirectAttributes redirectAttributes) {
|
|
|
+ if (!beanValidator(model, cmHeheFloor)){
|
|
|
+ return form(cmHeheFloor, model);
|
|
|
+ }
|
|
|
+ if (cmHeheFloor.getIsNewRecord()) {
|
|
|
+ cmHeheFloor.setCreateTime(new Date());
|
|
|
+ }
|
|
|
+ cmHeheFloorService.save(cmHeheFloor);
|
|
|
+ addMessage(redirectAttributes, "保存商品楼层成功");
|
|
|
+ return "redirect:"+Global.getAdminPath()+"/hehe/cmHeheFloor/?repage";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "delete")
|
|
|
+ public String delete(CmHeheFloor cmHeheFloor, RedirectAttributes redirectAttributes) {
|
|
|
+ cmHeheFloorService.delete(cmHeheFloor);
|
|
|
+ addMessage(redirectAttributes, "删除商品楼层成功");
|
|
|
+ return "redirect:"+Global.getAdminPath()+"/hehe/cmHeheFloor/?repage";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "updateStatus")
|
|
|
+ @ResponseBody
|
|
|
+ public Map<String,Object> updateStatus(Integer status, Integer floorId) {
|
|
|
+ HashMap<String, Object> result = new HashMap<>(2);
|
|
|
+ cmHeheFloorDao.updateStatusByFloorId(status, floorId);
|
|
|
+ result.put("success", true);
|
|
|
+ result.put("msg", (status == 1 ? "启用" : "停用") + "商品楼层成功");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量更新排序值
|
|
|
+ */
|
|
|
+ @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;
|
|
|
+ cmHeheFloorDao.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;
|
|
|
+ }
|
|
|
+ cmHeheFloorDao.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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 楼层商品列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "productList")
|
|
|
+ public String productList(CmHeheFloorProduct1 floorProduct, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
+ Page<CmHeheFloorProduct1> page = cmHeheFloorService.findProductPage(new Page<CmHeheFloorProduct1>(request, response), floorProduct);
|
|
|
+ model.addAttribute("floorProduct", floorProduct);
|
|
|
+ model.addAttribute("page", page);
|
|
|
+ return "modules/hehe/cmHeheFloorProductList";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加楼层商品
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "addProduct")
|
|
|
+ public void addProduct(Integer floorId, Integer productId) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|