| package com.matrix.system.shopXcx.action; | 
|   | 
| import com.matrix.core.anotations.RemoveRequestToken; | 
| import com.matrix.core.anotations.SaveRequestToken; | 
| import com.matrix.core.constance.MatrixConstance; | 
| import com.matrix.core.constance.SystemErrorCode; | 
| import com.matrix.core.constance.SystemMessageCode; | 
| import com.matrix.core.exception.GlobleException; | 
| import com.matrix.core.pojo.AjaxResult; | 
| import com.matrix.core.pojo.PaginationVO; | 
| import com.matrix.core.tools.ModelUtils; | 
| import com.matrix.core.tools.StringUtils; | 
| import com.matrix.core.tools.WebUtil; | 
| import com.matrix.system.common.bean.SysUsers; | 
| import com.matrix.system.hive.action.util.QueryUtil; | 
| import com.matrix.system.shopXcx.bean.ShopWxtemplateMsg; | 
| import com.matrix.system.shopXcx.dao.ShopWxtemplateMsgDao; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Controller; | 
| import org.springframework.transaction.annotation.Transactional; | 
| import org.springframework.web.bind.annotation.RequestMapping; | 
| import org.springframework.web.bind.annotation.ResponseBody; | 
| import org.springframework.web.servlet.ModelAndView; | 
|   | 
| import java.util.List; | 
| import java.util.Map; | 
|   | 
| /** | 
|  * @author | 
|  * @description 微信模板消息 | 
|  * @date 2020-01-01 10:57 | 
|  */ | 
| @Controller | 
| @RequestMapping(value = "admin/shopWxtemplateMsg") | 
| public class ShopWxtemplateMsgAction { | 
|   | 
|     @Autowired | 
|     private ShopWxtemplateMsgDao shopWxtemplateMsgDao; | 
|   | 
|     //记录编辑前的值Before_Edit_Value | 
|     public static final String BEV = "ShopWxtemplateMsg_BEV"; | 
|   | 
|   | 
|     /** | 
|      * 列表显示 | 
|      */ | 
|     @RequestMapping(value = "/showList") | 
|     public @ResponseBody | 
|     AjaxResult showList(ShopWxtemplateMsg shopWxtemplateMsg, PaginationVO pageVo) { | 
|         QueryUtil.setQueryLimitCom(shopWxtemplateMsg); | 
|         List<ShopWxtemplateMsg> dataList = shopWxtemplateMsgDao.selectInPage(shopWxtemplateMsg, pageVo); | 
|         AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, | 
|                 shopWxtemplateMsgDao.selectTotalRecord(shopWxtemplateMsg)); | 
|         return result; | 
|     } | 
|   | 
|     /** | 
|      * 新增 | 
|      */ | 
|     @RemoveRequestToken | 
|     @RequestMapping(value = "/addShopWxtemplateMsg") | 
|     public @ResponseBody | 
|     AjaxResult addShopWxtemplateMsg(ShopWxtemplateMsg shopWxtemplateMsg) { | 
|         SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); | 
|         shopWxtemplateMsg.setCreateBy(user.getSuName()); | 
|         shopWxtemplateMsg.setUpdateBy(user.getSuName()); | 
|         QueryUtil.setQueryLimitCom(shopWxtemplateMsg); | 
|         int i = shopWxtemplateMsgDao.insert(shopWxtemplateMsg); | 
|         if (i > 0) { | 
|             return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.ADD_SUCCES, "微信模板消息"); | 
|         } else { | 
|             throw new GlobleException(SystemErrorCode.DATA_ADD_FAIL); | 
|         } | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 修改 | 
|      */ | 
|     @RemoveRequestToken | 
|     @RequestMapping(value = "/modifyShopWxtemplateMsg") | 
|     public @ResponseBody | 
|     AjaxResult modifyShopWxtemplateMsg(ShopWxtemplateMsg newShopWxtemplateMsg) { | 
|   | 
|         int   i = shopWxtemplateMsgDao.updateByModel(newShopWxtemplateMsg); | 
|         WebUtil.removeSessionAttribute(BEV); | 
|         if (i > 0) { | 
|             return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.UPDATE_SUCCES, "微信模板消息"); | 
|         } else { | 
|             throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL); | 
|         } | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 进入修改界面 | 
|      */ | 
|     @SaveRequestToken | 
|     @RequestMapping(value = "/editForm") | 
|     public ModelAndView editForm(Integer id) { | 
|         ShopWxtemplateMsg shopWxtemplateMsg = new ShopWxtemplateMsg(); | 
|         ModelAndView modelAndView = new ModelAndView("admin/shop/templateMsg-form"); | 
|         if (id != null) { | 
|             shopWxtemplateMsg = shopWxtemplateMsgDao.selectById(id); | 
|             WebUtil.setSessionAttribute(BEV, shopWxtemplateMsg); | 
|         } | 
|         modelAndView.addObject("obj", shopWxtemplateMsg); | 
|         return modelAndView; | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 删除 | 
|      */ | 
|     @RequestMapping(value = "/del") | 
|     public @ResponseBody | 
|     AjaxResult del(String keys) { | 
|         List<String> ids = StringUtils.strToCollToString(keys, ","); | 
|         int i = shopWxtemplateMsgDao.deleteByIds(ids); | 
|         if (i > 0) { | 
|             return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.DELETE_SUCCES, i); | 
|         } else { | 
|             throw new GlobleException(SystemErrorCode.DATA_DELETE_FAIL); | 
|         } | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 批量启用 | 
|      */ | 
|     @RequestMapping(value = "/startUsing") | 
|     @Transactional(rollbackFor = Exception.class) | 
|     public @ResponseBody | 
|     AjaxResult startUsing(String keys) { | 
|         List<String> ids = StringUtils.strToCollToString(keys, ","); | 
|         int i = shopWxtemplateMsgDao.updateStateByStateAndIds(ids, ShopWxtemplateMsg.STATUS.ENABLE.getCode()); | 
|         if (i > 0) { | 
|             return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.UPDATE_SUCCES, i); | 
|         } else { | 
|             throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL); | 
|         } | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 批量停用 | 
|      */ | 
|     @Transactional(rollbackFor = Exception.class) | 
|     @RequestMapping(value = "/blockUp") | 
|     public @ResponseBody | 
|     AjaxResult blockUp(String keys) { | 
|         List<String> ids = StringUtils.strToCollToString(keys, ","); | 
|         int i = shopWxtemplateMsgDao.updateStateByStateAndIds(ids, ShopWxtemplateMsg.STATUS.DISABLE.getCode()); | 
|         if (i > 0) { | 
|             return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.UPDATE_SUCCES, i); | 
|         } else { | 
|             throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL); | 
|         } | 
|     } | 
| } |