|
@@ -1,132 +0,0 @@
|
|
-package com.caimei.modules.product.web;
|
|
|
|
-
|
|
|
|
-import com.caimei.modules.product.entity.CmActivity;
|
|
|
|
-import com.caimei.modules.product.entity.Product;
|
|
|
|
-import com.caimei.modules.product.service.CmActivityService;
|
|
|
|
-import com.caimei.modules.product.service.ProductService;
|
|
|
|
-import com.foxinmy.weixin4j.util.StringUtil;
|
|
|
|
-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.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
-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.servlet.mvc.support.RedirectAttributes;
|
|
|
|
-
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * 活动列表Controller
|
|
|
|
- *
|
|
|
|
- * @author plf
|
|
|
|
- * @version 2020-05-18
|
|
|
|
- */
|
|
|
|
-@Controller
|
|
|
|
-@RequestMapping(value = "${adminPath}/product/cmActivity")
|
|
|
|
-public class CmActivityController extends BaseController {
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private CmActivityService cmActivityService;
|
|
|
|
- @Autowired
|
|
|
|
- private ProductService productService;
|
|
|
|
-
|
|
|
|
- @ModelAttribute
|
|
|
|
- public CmActivity get(@RequestParam(required = false) String id) {
|
|
|
|
- CmActivity entity = null;
|
|
|
|
- if (StringUtils.isNotBlank(id)) {
|
|
|
|
- entity = cmActivityService.get(id);
|
|
|
|
- }
|
|
|
|
- if (entity == null) {
|
|
|
|
- entity = new CmActivity();
|
|
|
|
- }
|
|
|
|
- return entity;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @RequiresPermissions("product:product:view")
|
|
|
|
- @RequestMapping(value = {"list", ""})
|
|
|
|
- public String list(CmActivity cmActivity, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
|
- Page<CmActivity> page = cmActivityService.findPage(new Page<CmActivity>(request, response), cmActivity);
|
|
|
|
- model.addAttribute("page", page);
|
|
|
|
- return "modules/product/cmActivityList";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 页面回显
|
|
|
|
- */
|
|
|
|
- @RequiresPermissions("product:product:view")
|
|
|
|
- @RequestMapping(value = "form")
|
|
|
|
- public String form(CmActivity cmActivity, Model model) {
|
|
|
|
- List<Product> list = new ArrayList<>();
|
|
|
|
- if (StringUtil.isNotBlank(cmActivity.getProductIds())) {
|
|
|
|
- if (cmActivity.getProductIds().contains(",")) {
|
|
|
|
- String[] split = cmActivity.getProductIds().split(",");
|
|
|
|
- for (String productId : split) {
|
|
|
|
- if (StringUtil.isNotBlank(productId)) {
|
|
|
|
- Product product = productService.get(productId);
|
|
|
|
- list.add(product);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- Product product = productService.get(cmActivity.getProductIds());
|
|
|
|
- list.add(product);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (StringUtil.isNotBlank(cmActivity.getId())) {
|
|
|
|
- List<Product> products = cmActivityService.findProduct(cmActivity.getId());
|
|
|
|
- list.addAll(products);
|
|
|
|
- }
|
|
|
|
- model.addAttribute("productIds", cmActivity.getProductIds());
|
|
|
|
- model.addAttribute("list", list);
|
|
|
|
- model.addAttribute("cmActivity", cmActivity);
|
|
|
|
- return "modules/product/cmActivityForm";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 保存活动列表
|
|
|
|
- */
|
|
|
|
- @RequestMapping(value = "save")
|
|
|
|
- public String save(CmActivity cmActivity, Model model, RedirectAttributes redirectAttributes) {
|
|
|
|
- if (!beanValidator(model, cmActivity)) {
|
|
|
|
- return form(cmActivity, model);
|
|
|
|
- }
|
|
|
|
- cmActivityService.save(cmActivity);
|
|
|
|
- addMessage(redirectAttributes, "保存活动列表成功");
|
|
|
|
- return "redirect:" + Global.getAdminPath() + "/product/cmActivity/?repage";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 删除活动列表
|
|
|
|
- */
|
|
|
|
- @RequestMapping(value = "delete")
|
|
|
|
- public String delete(CmActivity cmActivity, RedirectAttributes redirectAttributes) {
|
|
|
|
- cmActivityService.delete(cmActivity);
|
|
|
|
- addMessage(redirectAttributes, "删除活动列表成功");
|
|
|
|
- return "redirect:" + Global.getAdminPath() + "/product/cmActivity/?repage";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 删除活动商品
|
|
|
|
- */
|
|
|
|
- @RequestMapping("/deleteProduct")
|
|
|
|
- public void deleteProduct(CmActivity cmActivity) {
|
|
|
|
- cmActivityService.deleteProduct(cmActivity);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 添加商品数据
|
|
|
|
- */
|
|
|
|
- @RequestMapping(value = "toAdd")
|
|
|
|
- public String toAddProduct(Product product, Model model, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
- Page page = cmActivityService.findProductPage(new Page<Product>(request, response), product);
|
|
|
|
- model.addAttribute("page", page);
|
|
|
|
- return "modules/product-new/actSelectProduct";
|
|
|
|
- }
|
|
|
|
-}
|
|
|