package com.matrix.system.hive.action; import javax.annotation.Resource; 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.action.util.QueryUtil; import com.matrix.system.hive.bean.SysShopInfo; import com.matrix.system.hive.bean.SysSupplierInfo; import com.matrix.system.hive.dao.SysShopInfoDao; import com.matrix.system.hive.service.CodeService; import com.matrix.system.hive.service.SysSupplierInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.matrix.core.anotations.RemoveRequestToken; import com.matrix.core.anotations.SaveRequestToken; /**往来单位 * @author jiangyouyao * @date 2016-07-17 */ @Controller @RequestMapping(value = "admin/supplier") public class SupplierInfoController extends BaseController{ @Resource private SysSupplierInfoService currentService; @Resource private CodeService codeService; @Autowired private SysShopInfoDao shopInfoDao; /** * 列表显示 */ @RequestMapping(value = "/showList") public @ResponseBody AjaxResult showList(PaginationVO pageVo, SysSupplierInfo sysSupplierInfo) { QueryUtil.setQueryLimit(sysSupplierInfo); return showList(currentService, sysSupplierInfo, pageVo); } /** * 新增或修改页面 */ @RequestMapping(value = "/addOrModify") @RemoveRequestToken public @ResponseBody AjaxResult addOrModify(SysSupplierInfo sysSupplierInfo) { SysUsers sysUsers = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); if (sysSupplierInfo.getId() != null) { return modify(currentService, sysSupplierInfo, "往来单位"); } else { sysSupplierInfo.setShopId(sysUsers.getShopId()); sysSupplierInfo.setCompanyId(sysUsers.getCompanyId()); return add(currentService, sysSupplierInfo, "往来单位"); } } /** * 进入修改界面 */ @RequestMapping(value = "/editForm") @SaveRequestToken public String editForm(Long id) { SysSupplierInfo sysSupplierInfo; if (id != null) { sysSupplierInfo = currentService.findById(id); WebUtil.getRequest().setAttribute("obj", sysSupplierInfo); } return "admin/hive/instore/supplierinfo-form"; } /** * 删除 */ @RequestMapping(value = "/del") public @ResponseBody AjaxResult del(String keys) { return remove(currentService, keys); } /**所有 * @param sysSupplierInfo * @return */ @RequestMapping(value = "/all") public @ResponseBody AjaxResult all(SysSupplierInfo sysSupplierInfo) { SysUsers sysUsers = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); SysShopInfo shopInfo = shopInfoDao.selectZbShop(sysUsers.getCompanyId()); sysSupplierInfo.setShopId(shopInfo.getId()); sysSupplierInfo.setCompanyId(shopInfo.getCompanyId()); return new AjaxResult(AjaxResult.STATUS_SUCCESS, currentService.findByModel(sysSupplierInfo), 0); } }