package com.huaheng.api; import com.huaheng.common.utils.DataUtils; import com.huaheng.common.utils.StringUtils; 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; import com.mchange.lang.IntegerUtils; 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()); Map<String, Object> map = materialService.selectFirstMap("id", material); 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 { material.setId(DataUtils.getInteger(map.get("id"))); return AjaxResult.toAjax(materialService.updateByModel(material) > 0); } } // /** // * 新增保存物料 // */ // @RequiresPermissions("api:material:add") // @Log(title = "物料添加", action = BusinessType.INSERT) // @PostMapping("/add") // @ResponseBody // public AjaxResult addSave(Material material) // { // AjaxResult ajaxResult = materialService.addMaterial(material); // return ajaxResult; // } }