package com.dy.pmsPlatform.material; 
 | 
  
 | 
import com.alibaba.fastjson2.JSON; 
 | 
import com.dy.common.aop.SsoPowerAop; 
 | 
import com.dy.common.webUtil.BaseResponse; 
 | 
import com.dy.common.webUtil.BaseResponseUtils; 
 | 
import com.dy.common.webUtil.QueryResultVo; 
 | 
import com.dy.pmsGlobal.aop.Log; 
 | 
import com.dy.pmsGlobal.pojoPlt.PltMaterial; 
 | 
import jakarta.validation.Valid; 
 | 
import lombok.extern.slf4j.Slf4j; 
 | 
import org.springframework.beans.factory.annotation.Autowired; 
 | 
import org.springframework.web.bind.annotation.*; 
 | 
  
 | 
import java.util.List; 
 | 
  
 | 
/** 
 | 
 * 物料管理 
 | 
 */ 
 | 
@Slf4j 
 | 
@RestController 
 | 
@RequestMapping(path="material") 
 | 
@SuppressWarnings("unchecked") 
 | 
public class MaterialCtrl { 
 | 
    private MaterialSv sv; 
 | 
    @Autowired 
 | 
    public MaterialCtrl(MaterialSv sv){ 
 | 
        this.sv = sv; 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 保存物料信息 
 | 
     * @param material 
 | 
     * @return 
 | 
     */ 
 | 
    @PostMapping(path="save") 
 | 
    @SsoPowerAop(power = "10300001") 
 | 
    @Log("保存物料信息") 
 | 
    public BaseResponse<PltMaterial> save(@RequestBody @Valid PltMaterial material){ 
 | 
        material.deleted = false; 
 | 
        int count = sv.save(material); 
 | 
        if (count <= 0) { 
 | 
            return BaseResponseUtils.buildFail("数据库存储失败"); 
 | 
        } else { 
 | 
            return BaseResponseUtils.buildSuccess(true); 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 更新物料信息 
 | 
     * @param material 
 | 
     * @return 
 | 
     */ 
 | 
    @PostMapping(path="update") 
 | 
    @SsoPowerAop(power = "10300001") 
 | 
    @Log("更新物料信息") 
 | 
    public BaseResponse<PltMaterial> update(@RequestBody @Valid PltMaterial material){ 
 | 
        int count = sv.update(material); 
 | 
        if (count <= 0) { 
 | 
            return BaseResponseUtils.buildFail("数据库存储失败"); 
 | 
        } else { 
 | 
            return BaseResponseUtils.buildSuccess(true); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 删除物料信息 
 | 
     * @param id 
 | 
     * @return 
 | 
     */ 
 | 
    @GetMapping(path="delete") 
 | 
    @SsoPowerAop(power = "10300001") 
 | 
    @Log("删除物料信息") 
 | 
    public BaseResponse<PltMaterial> delete(String id){ 
 | 
        int count = sv.delete(Long.parseLong(id)); 
 | 
        if (count <= 0) { 
 | 
            return BaseResponseUtils.buildFail("数据库存储失败"); 
 | 
        } else { 
 | 
            return BaseResponseUtils.buildSuccess(true); 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
    /** 
 | 
     * 根据ID查询物料信息 
 | 
     * @return 
 | 
     */ 
 | 
    @GetMapping(path="one") 
 | 
    @SsoPowerAop(power = "10300000") //登录与权限同时验证 
 | 
    @Log("根据ID查询物料信息") 
 | 
    public BaseResponse<PltMaterial> one(String id){ 
 | 
        PltMaterial material=sv.selectById(id); 
 | 
        return BaseResponseUtils.buildSuccess(JSON.toJSON(material)); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 查询物料信息 
 | 
     * @param vo 
 | 
     * @return 
 | 
     */ 
 | 
    @PostMapping(path="some") 
 | 
    @SsoPowerAop(power = "10300000") 
 | 
    @Log("查询物料信息") 
 | 
    public BaseResponse<QueryResultVo<List<PltMaterial>>> some(@RequestBody QueryVo vo){ 
 | 
        QueryResultVo<List<PltMaterial>> list = sv.selectSome(vo) ; 
 | 
        return BaseResponseUtils.buildSuccess(list); 
 | 
    } 
 | 
  
 | 
} 
 |