|
@@ -1,396 +0,0 @@
|
|
|
-package com.caimei.modules.brand.web;
|
|
|
-
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.net.URLDecoder;
|
|
|
-import java.net.URLEncoder;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import javax.servlet.http.HttpSession;
|
|
|
-
|
|
|
-import org.apache.commons.collections.CollectionUtils;
|
|
|
-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.bind.annotation.ResponseBody;
|
|
|
-import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
-
|
|
|
-import com.caimei.modules.brand.entity.BrandAgent;
|
|
|
-import com.caimei.modules.brand.entity.BrandProduct;
|
|
|
-import com.caimei.modules.brand.entity.BrandPurchaser;
|
|
|
-import com.caimei.modules.brand.entity.BrandSupplier;
|
|
|
-import com.caimei.modules.brand.model.ProductModel;
|
|
|
-import com.caimei.modules.brand.service.BrandProductService;
|
|
|
-import com.caimei.modules.brand.service.BrandSupplierService;
|
|
|
-import com.caimei.modules.brand.service.ProductModelService;
|
|
|
-import com.google.common.collect.Lists;
|
|
|
-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;
|
|
|
-
|
|
|
-/**
|
|
|
- * 品牌联盟商品Controller
|
|
|
- * @author LG
|
|
|
- * @version 2016-05-13
|
|
|
- */
|
|
|
-@Controller
|
|
|
-@RequestMapping(value = "${adminPath}/brand/brandProduct")
|
|
|
-public class BrandProductController extends BaseController {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private BrandProductService brandProductService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private BrandSupplierService brandSupplierService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ProductModelService productModelService;
|
|
|
-
|
|
|
- @ModelAttribute
|
|
|
- public BrandProduct get(@RequestParam(required=false) String id) {
|
|
|
- BrandProduct entity = null;
|
|
|
- if (StringUtils.isNotBlank(id)){
|
|
|
- entity = brandProductService.get(id);
|
|
|
- }
|
|
|
- if (entity == null){
|
|
|
- entity = new BrandProduct();
|
|
|
- }
|
|
|
- return entity;
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("brand:brandProduct:view")
|
|
|
- @RequestMapping(value = {"list", ""})
|
|
|
- public String list(BrandProduct brandProduct, HttpSession session,HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
- session.removeAttribute("brandProduct_session_edit");
|
|
|
- session.removeAttribute("brandProduct_session");
|
|
|
- Page<BrandProduct> page = brandProductService.findPage(new Page<BrandProduct>(request, response), brandProduct);
|
|
|
- List<BrandProduct> list = page.getList();
|
|
|
- List<BrandProduct> list1=Lists.newArrayList();
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
- brandProduct=brandProductService.get(list.get(i).getId());
|
|
|
- list1.add(i, brandProduct);
|
|
|
- }
|
|
|
- }
|
|
|
- page.setList(list1);
|
|
|
- model.addAttribute("page", page);
|
|
|
- return "modules/brand/brandProductList";
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("brand:brandProduct:view")
|
|
|
- @RequestMapping(value = "form")
|
|
|
- public String form(BrandProduct brandProduct, Model model,HttpSession session, @RequestParam(defaultValue="-1") Integer drawboardType, String bid,String bname) {
|
|
|
- if(drawboardType > -1 && bid != null && bid.trim().length() > 0 && !bid.equals("0")) {
|
|
|
- BrandProduct bp = (BrandProduct) session.getAttribute("brandProduct_session_edit");
|
|
|
- if(null!=bp)brandProduct=bp;
|
|
|
- session.removeAttribute("brandProduct_session_edit");
|
|
|
- switch (drawboardType) {
|
|
|
- case 0:
|
|
|
- BrandSupplier brandSupplier = new BrandSupplier();
|
|
|
- brandSupplier.setId(bid+"");
|
|
|
- brandSupplier.setName(bname);
|
|
|
- brandProduct.setBrandSupplier(brandSupplier);
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- BrandAgent brandAgent = new BrandAgent();
|
|
|
- brandAgent.setId(bid+"");
|
|
|
- brandAgent.setName(bname);
|
|
|
- brandProduct.setBrandAgent(brandAgent);
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- BrandPurchaser brandPurchaser = new BrandPurchaser();
|
|
|
- brandPurchaser.setId(bid+"");
|
|
|
- brandPurchaser.setName(bname);
|
|
|
- brandProduct.setBrandPurchaser(brandPurchaser);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- session.setAttribute("brandProduct_session_edit", brandProduct);
|
|
|
- session.setMaxInactiveInterval(10*60);// 以秒为单位
|
|
|
- }
|
|
|
- model.addAttribute("brandProduct", brandProduct);
|
|
|
- if(StringUtils.isNotBlank(brandProduct.getId())){
|
|
|
- ProductModel productModel = productModelService.get(brandProduct.getProductID()+"");
|
|
|
- model.addAttribute("productModel", productModel);
|
|
|
- return "modules/brand/brandProductEdit";
|
|
|
- }
|
|
|
-
|
|
|
- return "modules/brand/brandProductForm";
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("brand:brandProduct:edit")
|
|
|
- @RequestMapping(value = "save")
|
|
|
- public String save(BrandProduct brandProduct,Model model, HttpSession session,RedirectAttributes redirectAttributes, HttpServletRequest request) {
|
|
|
- if(StringUtils.isNotBlank(brandProduct.getId())){
|
|
|
- BrandProduct bp = (BrandProduct) session.getAttribute("brandProduct_session_edit");
|
|
|
- if(null!=bp){brandProduct=bp;}
|
|
|
- }
|
|
|
- session.removeAttribute("brandProduct_session_edit");
|
|
|
-
|
|
|
- String save="";
|
|
|
- try {
|
|
|
- save = brandProductService.save(brandProduct,request);
|
|
|
- addMessage(redirectAttributes, "保存品牌联盟商品成功");
|
|
|
- } catch (Exception e) {
|
|
|
- logger.error(e.toString(),e);
|
|
|
- addMessage(redirectAttributes, "图片上传错误:"+save);
|
|
|
- }
|
|
|
-
|
|
|
- return "redirect:"+Global.getAdminPath()+"/brand/brandProduct/?repage";
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("brand:brandProduct:edit")
|
|
|
- @RequestMapping(value = "delete")
|
|
|
- public String delete(BrandProduct brandProduct, RedirectAttributes redirectAttributes) {
|
|
|
- brandProductService.delete(brandProduct);
|
|
|
- addMessage(redirectAttributes, "删除品牌联盟商品成功");
|
|
|
- return "redirect:"+Global.getAdminPath()+"/brand/brandProduct/?repage";
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 商品-厂商 单选窗口
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @param model
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = { "productList_singleselect" })
|
|
|
- public String listAllSingle(ProductModel productModel,HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
- Page<ProductModel> page = productModelService.findPage(new Page<ProductModel>(request, response), productModel);
|
|
|
- model.addAttribute("page", page);
|
|
|
- return "modules/brand/productList_singleselect";
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- * <p>Description: 新增同类商品</p>
|
|
|
- * <p>Company: caimei365</p>
|
|
|
- * @author xun.zhang
|
|
|
- * @date 2016年5月18日 上午10:31:01
|
|
|
- * @param brandProduct
|
|
|
- * @param model
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequiresPermissions("brand:brandProduct:view")
|
|
|
- @RequestMapping(value = "sameProductForm")
|
|
|
- public String sameProductForm(BrandProduct brandProduct, Model model, HttpSession session, @RequestParam(defaultValue="-1") Integer drawboardType, @RequestParam(defaultValue="") String bid, @RequestParam(defaultValue="") String bname) {
|
|
|
- if(drawboardType > -1 && bid != null && bid.trim().length() > 0 && !bid.equals("0")) {
|
|
|
- brandProduct = (BrandProduct) session.getAttribute("brandProduct_session");
|
|
|
- try {
|
|
|
- bname = URLDecoder.decode(bname, "utf8");
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- if("0".equals(bid)) {
|
|
|
- bid = "";
|
|
|
- }
|
|
|
- if(drawboardType == 0) {
|
|
|
- BrandSupplier brandSupplier = new BrandSupplier();
|
|
|
- brandSupplier.setId(bid+"");
|
|
|
- brandSupplier.setName(bname);
|
|
|
- brandProduct.setBrandSupplier(brandSupplier);
|
|
|
- }else if(drawboardType == 1) {
|
|
|
- BrandAgent brandAgent = new BrandAgent();
|
|
|
- brandAgent.setId(bid+"");
|
|
|
- brandAgent.setName(bname);
|
|
|
- brandProduct.setBrandAgent(brandAgent);
|
|
|
- }else if(drawboardType == 2) {
|
|
|
- BrandPurchaser brandPurchaser = new BrandPurchaser();
|
|
|
- brandPurchaser.setId(bid+"");
|
|
|
- brandPurchaser.setName(bname);
|
|
|
- brandProduct.setBrandPurchaser(brandPurchaser);
|
|
|
- }
|
|
|
- }else {
|
|
|
- brandProduct.setBrandAgent(null);
|
|
|
- brandProduct.setBrandPurchaser(null);
|
|
|
- brandProduct.setSn(null);
|
|
|
- brandProduct.setShowAgent("0");
|
|
|
- brandProduct.setShowPurchaser("0");
|
|
|
- }
|
|
|
- brandProduct.setFileNumber(null);
|
|
|
- model.addAttribute("brandProduct", brandProduct);
|
|
|
- return "modules/brand/brandSameProductForm";
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- * <p>Description: 中途去编辑供应商信息、代理商信息、购买者信息的跳板</p>
|
|
|
- * <p>Company: caimei365</p>
|
|
|
- * @author xun.zhang
|
|
|
- * @date 2016年5月18日 上午10:37:20
|
|
|
- * @param brandProduct
|
|
|
- * @param model
|
|
|
- * @param drawboardType 跳转到相应的编辑页面(0 供应商,1 代理商,2 购买者)
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "drawboard")
|
|
|
- public String drawboard(BrandProduct brandProduct,
|
|
|
- Model model,
|
|
|
- HttpSession session,
|
|
|
- Integer drawboardType,
|
|
|
- @RequestParam(defaultValue="") String bid,
|
|
|
- @RequestParam(defaultValue="0") String showAgent,
|
|
|
- @RequestParam(defaultValue="0") String showPurchaser) {
|
|
|
- brandProduct.setFileNumber(null);
|
|
|
- brandProduct.setShowAgent(showAgent);
|
|
|
- brandProduct.setShowPurchaser(showPurchaser);
|
|
|
- session.setAttribute("brandProduct_session", brandProduct);
|
|
|
- session.setMaxInactiveInterval(10*60);// 以秒为单位
|
|
|
- String redirectUrl = "";
|
|
|
- if(drawboardType == 0) {
|
|
|
- redirectUrl = "/brand/brandSupplier/form";
|
|
|
- }else if(drawboardType == 1) {
|
|
|
- redirectUrl = "/brand/brandAgent/form";
|
|
|
- }else if(drawboardType == 2) {
|
|
|
- redirectUrl = "/brand/brandPurchaser/form";
|
|
|
- }
|
|
|
- try {
|
|
|
- redirectUrl += "?drawboardType="+drawboardType+"&redirectUrl="+URLEncoder.encode("/brand/brandProduct/sameProductForm", "utf8");
|
|
|
- if(!"".equals(bid)) {
|
|
|
- redirectUrl += "&id=" + bid;
|
|
|
- }
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return "redirect:"+Global.getAdminPath()+redirectUrl;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 编辑商品
|
|
|
- * <p>Description: 中途去编辑供应商信息、代理商信息、购买者信息的跳板</p>
|
|
|
- * <p>Company: caimei365</p>
|
|
|
- * @author xun.zhang
|
|
|
- * @date 2016年5月18日 上午10:37:20
|
|
|
- * @param brandProduct
|
|
|
- * @param model
|
|
|
- * @param drawboardType 跳转到相应的编辑页面(0 供应商,1 代理商,2 购买者)
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "drawboardEdit")
|
|
|
- public String drawboardEdit(BrandProduct brandProduct, Model model, HttpSession session, Integer drawboardType,String bid) {
|
|
|
- //brandProduct.setFileNumber(null);
|
|
|
- BrandProduct bp = (BrandProduct) session.getAttribute("brandProduct_session_edit");
|
|
|
- if(null!=bp){
|
|
|
- brandProduct=bp;
|
|
|
- }else{
|
|
|
- session.setAttribute("brandProduct_session_edit", brandProduct);
|
|
|
- session.setMaxInactiveInterval(10*60);// 以秒为单位
|
|
|
- }
|
|
|
- String redirectUrl = "";
|
|
|
- if(drawboardType == 0) {
|
|
|
- redirectUrl = "/brand/brandSupplier/form";
|
|
|
- }else if(drawboardType == 1) {
|
|
|
- redirectUrl = "/brand/brandAgent/form";
|
|
|
- }else if(drawboardType == 2) {
|
|
|
- redirectUrl = "/brand/brandPurchaser/form";
|
|
|
- }
|
|
|
- redirectUrl += "?id="+bid+"&drawboardType="+drawboardType+"&redirectUrl=/brand/brandProduct/form";
|
|
|
- return "redirect:"+Global.getAdminPath()+redirectUrl;
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("brand:brandProduct:edit")
|
|
|
- @RequestMapping(value = "sameProductSave")
|
|
|
- public String sameProductSave(BrandProduct brandProduct, RedirectAttributes redirectAttributes, Model model, HttpServletRequest request) {
|
|
|
- brandProduct.setId(null);
|
|
|
- brandProduct.setFileNumber(null);
|
|
|
- brandProductService.sameProductSave(brandProduct, request);
|
|
|
- addMessage(redirectAttributes, "保存品牌联盟商品成功");
|
|
|
- return "redirect:"+Global.getAdminPath()+"/brand/brandProduct/?repage";
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("brand:brandProduct:edit")
|
|
|
- @RequestMapping(value = "changeStatus")
|
|
|
- public String changeStatus(BrandProduct brandProduct, RedirectAttributes redirectAttributes) {
|
|
|
- brandProductService.changeStatus(brandProduct);
|
|
|
- if(StringUtils.equals("1", brandProduct.getEnabledStatus())){
|
|
|
- String [] supplierIDs=new String[1];
|
|
|
- supplierIDs[0]=brandProduct.getBrandSupplier().getId();
|
|
|
- brandSupplierService.updateEnabledStatusByIds(brandProduct.getEnabledStatus(),supplierIDs);
|
|
|
- }
|
|
|
- addMessage(redirectAttributes, "更新品牌联盟商品状态成功");
|
|
|
- return "redirect:"+Global.getAdminPath()+"/brand/brandProduct/?repage";
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量修改启用、停用状态
|
|
|
- * @param enabledStatus
|
|
|
- * @param ids
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequiresPermissions("brand:brandProduct:edit")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping(value="updateEnabledStatus")
|
|
|
- public Map<String, Object> updateEnabledStatus(String enabledStatus,String[] ids,String [] supplierIDs,HttpServletRequest request,HttpServletResponse response){
|
|
|
- Map<String, Object> map =Maps.newLinkedHashMap();
|
|
|
- try {
|
|
|
- brandProductService.updateEnabledStatusByIds(enabledStatus,ids);
|
|
|
- if(StringUtils.equals("1",enabledStatus)){
|
|
|
- brandSupplierService.updateEnabledStatusByIds(enabledStatus,supplierIDs);
|
|
|
- }
|
|
|
- map.put("success",true);
|
|
|
- map.put("msg", "修改成功");
|
|
|
- } catch (Exception e) {
|
|
|
- logger.debug(e.toString(),e);
|
|
|
- map.put("success",false);
|
|
|
- map.put("msg", "修改失败");
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改显示项
|
|
|
- * @param brandProduct
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequiresPermissions("brand:brandProduct:edit")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping(value="updateShow")
|
|
|
- public Map<String, Object> updateShow(BrandProduct brandProduct,HttpServletRequest request,HttpServletResponse response){
|
|
|
- Map<String, Object> map =Maps.newLinkedHashMap();
|
|
|
- try {
|
|
|
- brandProductService.save(brandProduct);
|
|
|
- map.put("success",true);
|
|
|
- map.put("msg", "修改成功");
|
|
|
- } catch (Exception e) {
|
|
|
- logger.debug(e.toString(),e);
|
|
|
- map.put("success",false);
|
|
|
- map.put("msg", "修改失败");
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 验证Sn码是否存在
|
|
|
- * @param mobileNo
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping(value = "checkSn")
|
|
|
- public String checkSn(String sn,String oldSn) {
|
|
|
- if(StringUtils.equals(sn, oldSn)){
|
|
|
- return "true";
|
|
|
- }
|
|
|
- BrandProduct brandProduct=new BrandProduct();
|
|
|
- brandProduct.setSn(sn);
|
|
|
- List<BrandProduct> list = brandProductService.findList(brandProduct);
|
|
|
- if(CollectionUtils.isEmpty(list)){
|
|
|
- return "true";
|
|
|
- }
|
|
|
- return "false";
|
|
|
- }
|
|
|
-
|
|
|
-}
|