Helius
2021-01-25 89e17a219d8a6d208e4cb32a43e90abb89b3c93b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package com.matrix.system.hive.action;
 
import com.matrix.core.pojo.AjaxResult;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.hive.action.util.QueryUtil;
import com.matrix.system.hive.bean.ShoppingGoodsCategory;
import com.matrix.system.hive.bean.SysShopInfo;
import com.matrix.system.hive.dao.SysShopInfoDao;
import com.matrix.system.hive.service.ShoppingGoodsCategoryService;
import org.apache.poi.ss.formula.functions.T;
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 javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;
 
 
/**
 * @author jyy
 * @description 商品目录管理
 * @email 820786562@qqcom
 * @date 2016-08-21
 */
@Controller
@RequestMapping(value = "/admin/shoppinggoodscategory")
public class ShoppingGoodsCategoryController extends BaseController {
 
 
    @Autowired
    private ShoppingGoodsCategoryService goodsCategoryService;
 
    @Autowired
    private SysShopInfoDao shopInfoDao;
 
 
    /**
     * 新增或修改页面
     */
    @RequestMapping(value = "/addOrModify")
    public @ResponseBody
    AjaxResult addOrModify(ShoppingGoodsCategory shoppingGoodsCategory) {
        if (shoppingGoodsCategory.getId() != null) {
 
            return modify(goodsCategoryService, shoppingGoodsCategory, "商品类型");
        } else {
            QueryUtil.setQueryLimit(shoppingGoodsCategory);
            return add(goodsCategoryService, shoppingGoodsCategory, "商品类型");
        }
    }
 
 
    @RequestMapping(value = "/editForm")
    public String editForm(Long id, HttpServletRequest request) {
        ShoppingGoodsCategory shoppingGoodsCategory;
        if (id != null) {
            shoppingGoodsCategory = goodsCategoryService.findById(id);
            request.setAttribute("obj", shoppingGoodsCategory);
        }
        return "admin/hive/shopping/goodsCategory-form";
    }
 
    @RequestMapping(value = "/editFormUderline")
    public String editFormUderline(Long id, HttpServletRequest request) {
 
        ShoppingGoodsCategory shoppingGoodsCategory;
        if (id != null) {
            shoppingGoodsCategory = goodsCategoryService.findById(id);
 
 
            request.setAttribute("obj", shoppingGoodsCategory);
        }
        return "admin/hive/products/goodsCategory-form";
    }
 
 
    @RequestMapping(value = "/del")
    public @ResponseBody
    AjaxResult del(Long keys) {
 
        int i = goodsCategoryService.removeById(keys);
        if (i > 0) {
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, "成功删除" + i + "条数据");
        } else {
            return new AjaxResult(AjaxResult.STATUS_FAIL, "删除失败");
        }
    }
 
    @RequestMapping(value = "/findById")
    public @ResponseBody
    AjaxResult findById(Long id) {
 
        ShoppingGoodsCategory shoppingGoodsCategory = super.findById(goodsCategoryService, id);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, Arrays.asList(shoppingGoodsCategory), 0);
    }
 
    /**
     * =======================================================
     * *******************公共的数据访问方法********************
     * =======================================================
     */
 
    /**
     * 如果客户端没有指定加载特定门店则当前登录用户所在门店
     * @param shoppingGoodsCategory
     * @return
     */
    @RequestMapping(value = "/all")
    public @ResponseBody
    AjaxResult all(ShoppingGoodsCategory shoppingGoodsCategory) {
//        SysUsers user = getMe();
//        if(shoppingGoodsCategory.getShopId()==null){
//            shoppingGoodsCategory.setShopId(user.getShopId());
//        }
//        shoppingGoodsCategory.setCompanyId(user.getCompanyId());
        SysShopInfo zbShop = shopInfoDao.selectZbShop(getMe().getCompanyId());
        shoppingGoodsCategory.setShopId(zbShop.getId());
        QueryUtil.setQueryLimitCom(shoppingGoodsCategory);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, goodsCategoryService.findByModel(shoppingGoodsCategory), 0);
    }
 
 
    /**
     * 获取总部商品分类
     *
     * @param shoppingGoodsCategory
     * @return
     */
    @RequestMapping(value = "/getZbCategory")
    public @ResponseBody
    AjaxResult getZbCategory(ShoppingGoodsCategory shoppingGoodsCategory) {
        SysShopInfo zbShop = shopInfoDao.selectZbShop(getMe().getCompanyId());
        shoppingGoodsCategory.setShopId(zbShop.getId());
        QueryUtil.setQueryLimitCom(shoppingGoodsCategory);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, goodsCategoryService.findByModel(shoppingGoodsCategory), 0);
    }
 
 
}