Blame view

src/main/java/com/huaheng/api/MaterialApi.java 2.47 KB
tangying authored
1
2
package com.huaheng.api;
3
4
import com.huaheng.common.utils.DataUtils;
import com.huaheng.common.utils.StringUtils;
tangying authored
5
6
7
8
9
10
11
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.general.material.domain.Material;
import com.huaheng.pc.general.material.service.IMaterialService;
12
import com.mchange.lang.IntegerUtils;
tangying authored
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
import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/material")
@Api(tags = {"Material"}, description = "物料接口")
public class MaterialApi  extends BaseController {

    @Autowired
    private IMaterialService materialService;

    /**
     * 新增保存物料
     */
    @RequiresPermissions("api:material:add")
    @Log(title = "物料添加", action = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Material material)
    {
        material.setId(null);
        material.setWarehouseId(ShiroUtils.getWarehouseId());
42
        Map<String, Object> map = materialService.selectFirstMap("id", material);
tangying authored
43
44
45
46
47
48
49
50
51
        material.setWarehouseCode(ShiroUtils.getWarehouseCode());
        material.setCreatedBy(ShiroUtils.getLoginName());
        material.setLastUpdatedBy(ShiroUtils.getLoginName());
        if (map != null && map.size() > 0)
        {
            return AjaxResult.toAjax(materialService.insert(material) > 0);
        }
        else
        {
52
53
            material.setId(DataUtils.getInteger(map.get("id")));
            return AjaxResult.toAjax(materialService.updateByModel(material) > 0);
tangying authored
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
        }
    }

//    /**
//     * 新增保存物料
//     */
//    @RequiresPermissions("api:material:add")
//    @Log(title = "物料添加", action = BusinessType.INSERT)
//    @PostMapping("/add")
//    @ResponseBody
//    public AjaxResult addSave(Material material)
//    {
//        AjaxResult ajaxResult = materialService.addMaterial(material);
//        return ajaxResult;
//    }

}