| package com.matrix.system.shopXcx.action; | 
|   | 
| import com.matrix.core.constance.MatrixConstance; | 
| import com.matrix.core.constance.SystemMessageCode; | 
| import com.matrix.core.pojo.PaginationVO; | 
| import com.matrix.core.tools.StringUtils; | 
| import com.matrix.core.constance.SystemErrorCode; | 
| import com.matrix.core.anotations.RemoveRequestToken; | 
| import com.matrix.system.common.bean.SysUsers; | 
| import com.matrix.system.shopXcx.dao.ShopParamValueDao; | 
| import org.apache.commons.collections.CollectionUtils; | 
| import org.springframework.stereotype.Controller; | 
| import com.matrix.core.exception.GlobleException; | 
| import org.springframework.web.bind.annotation.RequestMapping; | 
| import org.springframework.web.bind.annotation.ResponseBody; | 
| import com.matrix.core.anotations.SaveRequestToken; | 
| import com.matrix.core.pojo.AjaxResult; | 
| import com.matrix.core.tools.WebUtil; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
|   | 
| import java.util.List; | 
|   | 
| import com.matrix.system.shopXcx.bean.ShopParamValue; | 
| import org.springframework.web.servlet.ModelAndView; | 
|   | 
| /** | 
|  * @description 商品参数值表 | 
|  * @author pengliang | 
|  * @date 2019-06-05 17:27 | 
|  */ | 
| @Controller | 
| @RequestMapping(value = "admin/shopParamValue") | 
| public class ShopParamValueAction { | 
|   | 
|     @Autowired | 
|     private ShopParamValueDao shopParamValueDao; | 
|      | 
|     //记录编辑前的值Before_Edit_Value | 
|     public static final String BEV="ShopParamValue_BEV"; | 
|      | 
|      | 
|     /** | 
|      * 列表显示 | 
|      */ | 
|     @RequestMapping(value =  "/showList") | 
|     public @ResponseBody AjaxResult showList(ShopParamValue shopParamValue, PaginationVO pageVo) { | 
|   | 
|         List<ShopParamValue> dataList = shopParamValueDao.selectInPage(shopParamValue, pageVo); | 
|         AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, | 
|                 shopParamValueDao.selectTotalRecord(shopParamValue)); | 
|         return result; | 
|     } | 
|         | 
|     /** | 
|      * 新增 | 
|      */    | 
|     @RemoveRequestToken     | 
|        @RequestMapping(value =  "/addShopParamValue") | 
|     public @ResponseBody AjaxResult addShopParamValue(ShopParamValue shopParamValue) { | 
|         SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); | 
|         shopParamValue.setCreateBy(user.getSuName()); | 
|         shopParamValue.setUpdateBy(user.getSuName()); | 
|         List<ShopParamValue> shopParamValues = shopParamValueDao.selectByParamValues(shopParamValue.getParamId(),shopParamValue.getParamValue()); | 
|         if(CollectionUtils.isNotEmpty(shopParamValues)){ | 
|             return new AjaxResult(AjaxResult.STATUS_FAIL,"该参数值已存在"); | 
|         } | 
|         int i=shopParamValueDao.insert(shopParamValue); | 
|          if(i > 0){ | 
|              return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.ADD_SUCCES, "商品参数值表"); | 
|          }else { | 
|             throw new GlobleException(SystemErrorCode.DATA_ADD_FAIL); | 
|         } | 
|     } | 
|      | 
|      | 
|      | 
|      | 
|      | 
|     /** | 
|      * 修改 | 
|      */    | 
|     @RemoveRequestToken     | 
|        @RequestMapping(value =  "/modifyShopParamValue") | 
|     public @ResponseBody AjaxResult modifyShopParamValue(ShopParamValue newShopParamValue) { | 
|         List<ShopParamValue> shopParamValues = shopParamValueDao.selectByParamValues(newShopParamValue.getParamId(),newShopParamValue.getParamValue()); | 
|            if(CollectionUtils.isNotEmpty(shopParamValues)){ | 
|                return new AjaxResult(AjaxResult.STATUS_FAIL,"该参数值已经存在"); | 
|         } | 
|         int i = shopParamValueDao.updateByModel(newShopParamValue); | 
|         WebUtil.removeSessionAttribute(BEV); | 
|         if (i > 0) { | 
|             return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.UPDATE_SUCCES, "商品参数值表"); | 
|         } else { | 
|             throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 进入参数列表页面 | 
|      * @return | 
|      */ | 
|     @SaveRequestToken | 
|     @RequestMapping(value =  "/editParamValue") | 
|     public ModelAndView editParamValue(String id){ | 
|         ModelAndView modelAndView = new ModelAndView("admin/shop/shopParamValue-list"); | 
|         modelAndView.addObject("paramId",id); | 
|         return modelAndView; | 
|     } | 
|      | 
|      | 
|        /** | 
|      * 进入修改界面 | 
|      */    | 
|     @SaveRequestToken | 
|        @RequestMapping(value =  "/editForm") | 
|     public ModelAndView editForm(Integer id,Integer ptype) { | 
|         ShopParamValue shopParamValue = new ShopParamValue(); | 
|         ModelAndView modelAndView = new ModelAndView("admin/shop/shopParamValue-form"); | 
|         //0表示新增,1表示修改 | 
|         if (id != null && 1 == ptype) { | 
|             shopParamValue = shopParamValueDao.selectById(id); | 
|             WebUtil.setSessionAttribute(BEV, shopParamValue); | 
|         }else{ | 
|             shopParamValue.setParamId(id); | 
|         } | 
|         modelAndView.addObject("obj",shopParamValue); | 
|         return modelAndView; | 
|     } | 
|         | 
|         | 
|        /** | 
|      * 删除 | 
|      */   | 
|      @RequestMapping(value = "/del") | 
|     public @ResponseBody AjaxResult del(String keys) { | 
|         List<String> ids = StringUtils.strToCollToString(keys, ","); | 
|         int i =  shopParamValueDao.deleteByIds(ids); | 
|         if (i > 0) { | 
|             return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.DELETE_SUCCES, i); | 
|         } else { | 
|             throw new GlobleException(SystemErrorCode.DATA_DELETE_FAIL); | 
|         } | 
|     } | 
|    | 
| } |