354798ggg
2023-06-06 c39259bd1486839b25909b4623c24648a34ead49
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
package com.product.base.controller;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import com.product.base.config.BaseErrorCode;
import com.product.base.config.CmnConst;
import com.product.base.service.WarehouseManagerService;
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.module.sys.version.ApiVersion;
import com.product.util.BaseUtil;
 
/**
 *     仓库信息Controller
 * @author 86151
 *
 */
@RequestMapping("/api/warehouseManager")
@RestController
public class WarehouseManagerController extends AbstractBaseController{
 
    @Autowired
    WarehouseManagerService warehouseManagerService;
    
    /**
     *     获取所有仓库信息
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/list/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String listWarehousrInfo(HttpServletRequest request, HttpServletResponse response) {
        try {
            //获取参数
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_PROJECT_BASE_WAREHOUSE);
            
            //判断分页参数是否为空
            if (BaseUtil.strIsNull(fse.getString(CmnConst.CPAGE)) || BaseUtil.strIsNull(fse.getString(CmnConst.PAGESIZE))) {
                return error(BaseErrorCode.SYSTEM_CPAGES_NOT_NULL.getValue(), BaseErrorCode.SYSTEM_CPAGES_NOT_NULL.getText());
            }
            return OK_List(warehouseManagerService.listWarehousrInfo(fse));
        } catch (Exception e) {
            return this.error(BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getText()+e.getMessage());
        }
    }
    
    /**
     *     获取仓库信息
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/get/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String getWarehouseInfo(HttpServletRequest request, HttpServletResponse response) {
        try {
            //获取参数
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_PROJECT_BASE_WAREHOUSE);
            
            //判断uuid是否为空
            if (BaseUtil.strIsNull(fse.getUUID())) {
                return error(BaseErrorCode.SYSTEM_FORM_COUNT.getValue(), BaseErrorCode.SYSTEM_FORM_COUNT.getValue());
            }
            return OK_List(warehouseManagerService.getWarehouseInfo(fse.getUUID()));
        } catch (Exception e) {
            return this.error(BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getText()+e.getMessage());
        }
    }
    
    /**
     *     保存仓库信息
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/save/{version}",method = RequestMethod.POST)
    @ApiVersion(1)
    public String saveWarehousrInfo(HttpServletRequest request, HttpServletResponse response) {
        try {
            //获取参数
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_PROJECT_BASE_WAREHOUSE);
            
            //保存
            boolean succ = warehouseManagerService.saveWarehouseInfo(fse);
            if (succ) {
                return OK();
            }
            return error(BaseErrorCode.PROJECT_BASE_WAREHOUSE_SAVE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_WAREHOUSE_DELETE_FAIL.getText());
        } catch (Exception e) {
            return this.error(BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getText()+e.getMessage());
        }
    }
    
    /**
     *     删除仓库信息
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/delete/{version}",method = RequestMethod.POST)
    @ApiVersion(1)
    public String deleteWarehousrInfo(HttpServletRequest request, HttpServletResponse response) {
        try {
            //获取参数
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_PROJECT_BASE_WAREHOUSE);
            
            //判断uuid是否为空
            if (BaseUtil.strIsNull(fse.getUUID())) {
                return error(BaseErrorCode.SYSTEM_FORM_COUNT.getValue(), BaseErrorCode.SYSTEM_FORM_COUNT.getValue());
            }
            //删除
            boolean succ = warehouseManagerService.deleteWarehouseInfo(fse.getUUID());
            if (succ) {
                return OK();
            }
            return error(BaseErrorCode.PROJECT_BASE_WAREHOUSE_DELETE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_WAREHOUSE_DELETE_FAIL.getText());
        } catch (Exception e) {
            return this.error(BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getValue(), BaseErrorCode.PROJECT_BASE_WAREHOUSE_OPERATE_FAIL.getText()+e.getMessage());
        }
    }
}