package com.yuanchu.mom.controller; import com.yuanchu.mom.pojo.RawInsProduct; import com.yuanchu.mom.service.DeviceService; import com.yuanchu.mom.utils.Jwt; import com.yuanchu.mom.vo.Result; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.yuanchu.mom.service.RawInsProductService; import javax.annotation.Resource; import java.util.Map; /** * 原材料申请单中的项目列表(RawInsProduct)表控制层 * * @author zss * @since 2023-08-01 13:52:30 */ @Api(tags = "QMS管理-->原材料检验-->检验项目") @RestController @RequestMapping("/rawInsProduct") public class RawInsProductController { @Autowired private RawInsProductService rawInsProductService; @Resource DeviceService deviceService; @Resource Jwt jwt; @ApiOperation(value = "查询所有设备") @GetMapping("/selectDevice") public Result selectDevice() { return Result.success(deviceService.selectDevice()); } @ApiOperation("选择设备信息") @ApiImplicitParams(value = { @ApiImplicitParam(name = "id", value = "设备ID", dataTypeClass = Integer.class, required = true), }) @GetMapping("/selectDeviceById") public Result selectDeviceById(Integer id) { return Result.success( deviceService.getDeviceNameById(id)); } @ApiOperation(value = "更新检验项目") @PostMapping("/updaterawInsProduct") public Result updaterawInsProduct(@RequestHeader("token") String token, @RequestBody RawInsProduct rawInsProduct) throws Exception { Map map = jwt.readJWT(token); String data = map.get("data"); JSONObject jsonObject = new JSONObject(data); int userId = Integer.parseInt(jsonObject.getString("id")); rawInsProductService.updaterawInsProduct(userId,rawInsProduct); return Result.success(); } }