| package com.matrix.system.hive.action; | 
|   | 
| import com.matrix.core.anotations.RemoveRequestToken; | 
| import com.matrix.core.anotations.SaveRequestToken; | 
| import com.matrix.core.constance.MatrixConstance; | 
| import com.matrix.core.pojo.AjaxResult; | 
| import com.matrix.core.pojo.PaginationVO; | 
| import com.matrix.core.tools.WebUtil; | 
| import com.matrix.system.common.bean.SysUsers; | 
| import com.matrix.system.hive.bean.SysGoods; | 
| import com.matrix.system.hive.service.SysGoodsService; | 
| import org.springframework.stereotype.Controller; | 
| import org.springframework.web.bind.annotation.RequestMapping; | 
| import org.springframework.web.bind.annotation.ResponseBody; | 
|   | 
| import javax.annotation.Resource; | 
|  /* | 
|  *  | 
|  * @author jiangyouyao | 
|  * @date 2016-07-12 | 
|  */ | 
| @Controller | 
| @RequestMapping(value = "admin/goods") | 
| public class GoodsController extends BaseController { | 
|     @Resource | 
|     private SysGoodsService currentService; | 
|   | 
|   | 
|   | 
|     /** | 
|      * 列表显示 | 
|      */ | 
|     @RequestMapping(value = "/showList") | 
|     public @ResponseBody | 
|     AjaxResult showList(SysGoods sysGoods, PaginationVO pageVo) { | 
|         SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); | 
|         sysGoods.setShopId(users.getShopId()); | 
|         sysGoods.setCompanyId(users.getCompanyId()); | 
|   | 
|         return showList(currentService, sysGoods, pageVo); | 
|     } | 
|   | 
|      @RequestMapping(value = "/showListForSelect") | 
|      public @ResponseBody | 
|      AjaxResult showListForSelect(SysGoods sysGoods, PaginationVO pageVo) { | 
|         if(sysGoods.getShopId() == null) { | 
|             return AjaxResult.buildFailInstance("未输入店铺"); | 
|         } | 
|   | 
|          SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); | 
|          sysGoods.setCompanyId(users.getCompanyId()); | 
|   | 
|          return showList(currentService, sysGoods, pageVo); | 
|      } | 
|   | 
|   | 
|      /** | 
|      * 新增或修改页面 | 
|      */ | 
|     @RequestMapping(value = "/addOrModify") | 
|     @RemoveRequestToken | 
|     public @ResponseBody AjaxResult addOrModify(SysGoods sysGoods) { | 
|         SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); | 
|         if (sysGoods.getId() != null) { | 
|   | 
|             return modify(currentService, sysGoods, "产品"); | 
|         } else { | 
|             sysGoods.setShopId(users.getShopId()); | 
|             sysGoods.setCompanyId(users.getCompanyId()); | 
|             return add(currentService, sysGoods, "产品"); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 进入修改界面 | 
|      */ | 
|     @RequestMapping(value = "/editForm") | 
|     @SaveRequestToken | 
|     public String editForm(Long id) { | 
|         SysGoods sysGoods; | 
|         WebUtil.getRequest().setAttribute("nos", currentService.findAllNo()); | 
|         if (id != null) { | 
|             sysGoods = currentService.findById(id); | 
|             WebUtil.getRequest().setAttribute("obj", sysGoods); | 
|         } | 
|         return "admin/hive/instore/goods-form"; | 
|     } | 
|   | 
|     /** | 
|      * 删除 | 
|      */ | 
|     @RequestMapping(value = "/del") | 
|     public @ResponseBody AjaxResult del(String keys) { | 
|   | 
|         return remove(currentService, keys); | 
|     } | 
|   | 
|     @RequestMapping(value = "/findAllNo") | 
|     public @ResponseBody AjaxResult findAllNo() { | 
|         AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, currentService.findAllNo(), 0); | 
|         return result; | 
|     } | 
|   | 
| } |