¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.pojo.EquipmentPoint; |
| | | import com.yuanchu.limslaboratory.pojo.dto.UpdateEquipmentPointDto; |
| | | import com.yuanchu.limslaboratory.service.EquipmentPointService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | | * å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-20 |
| | | */ |
| | | @Api(tags = "å®éªå®¤-->1ã设å¤å°è´¦-->3ã设å¤ç ç¹") |
| | | @RestController |
| | | @RequestMapping("/equipment-point") |
| | | public class EquipmentPointController { |
| | | |
| | | @Autowired |
| | | private EquipmentPointService equipmentPointService; |
| | | |
| | | @ApiOperation("æ·»å 设å¤ç ç¹") |
| | | @PostMapping("/add") |
| | | public Result<?> addEquipmentPointInformation(@RequestHeader("X-Token") String token, @RequestBody EquipmentPoint equipmentPoint) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | equipmentPoint.setUserId((Integer) unmarshal.get("id")); |
| | | Integer isInsertSuccess = equipmentPointService.addEquipmentPointInformation(equipmentPoint); |
| | | if (isInsertSuccess == 1){ |
| | | return Result.success("æ·»å ã"+ equipmentPoint.getEquipmentPointName() +"ãæåï¼"); |
| | | } |
| | | return Result.fail("æ·»å ã"+ equipmentPoint.getEquipmentPointName() +"ã失败ï¼è®¾å¤ç ç¹ç¼ç éå¤ï¼"); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®ä»ªå¨Idæ¥è¯¢å¯¹åºè®¾å¤ç ç¹æ°æ®") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "InstrumentId", value = "ä»ªå¨æ¨¡åId", dataTypeClass = String.class, required = true) |
| | | }) |
| | | @GetMapping("/list") |
| | | public Result<?> getListEquipmentPointInformation(String InstrumentId) { |
| | | List<Map<String, Object>> list = equipmentPointService.getListEquipmentPointInformation(InstrumentId); |
| | | return Result.success(list); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®ç ç¹Idå 餿°æ®") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "equipmentPointId", value = "设å¤ç ç¹Id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @DeleteMapping("/delete") |
| | | public Result<?> deleteEquipmentPointInformation(Integer equipmentPointId) { |
| | | Integer isDeleteSuccess = equipmentPointService.deleteEquipmentPointInformation(equipmentPointId); |
| | | if (isDeleteSuccess == 1){ |
| | | return Result.success("å 餿åï¼"); |
| | | } |
| | | return Result.fail("å é¤å¤±è´¥ï¼"); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®ç ç¹Idæ´æ°æ°æ®") |
| | | @PutMapping("/update") |
| | | public Result<?> updateEquipmentPointInformation(@RequestHeader("X-Token") String token, @RequestBody UpdateEquipmentPointDto updateEquipmentPointDto) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | EquipmentPoint equipmentPoint = JackSonUtil.unmarshal(JackSonUtil.marshal(updateEquipmentPointDto), EquipmentPoint.class); |
| | | equipmentPoint.setUserId((Integer) unmarshal.get("id")); |
| | | Integer isUpdateSuccess = equipmentPointService.updateEquipmentPointInformation(equipmentPoint); |
| | | if (isUpdateSuccess == 1){ |
| | | return Result.success("æ´æ°æåï¼"); |
| | | } |
| | | return Result.fail("æ´æ°å¤±è´¥ï¼"); |
| | | } |
| | | } |