¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.MetricalInformation; |
| | | import com.yuanchu.limslaboratory.pojo.dto.UpdateMetricalInformationDto; |
| | | import com.yuanchu.limslaboratory.service.MetricalInformationService; |
| | | import com.yuanchu.limslaboratory.service.UserService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | 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 org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-07-20 |
| | | */ |
| | | @Api(tags = "å®éªå®¤-->1ã设å¤å°è´¦-->4ã计éä¿¡æ¯") |
| | | @RestController |
| | | @RequestMapping("/metrical-information") |
| | | public class MetricalInformationController { |
| | | |
| | | @Autowired |
| | | private MetricalInformationService metricalInformationService; |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @ApiOperation("æ·»å 计éä¿¡æ¯") |
| | | @PostMapping("/add") |
| | | public Result<?> addMetricalInformation(MetricalInformation metricalInformation, |
| | | @RequestPart(value = "file", required = false) MultipartFile file) { |
| | | Integer isInsertSuccess = metricalInformationService.addEquipmentPointInformation(metricalInformation, file); |
| | | if (isInsertSuccess == 1){ |
| | | return Result.success("æ·»å ã"+ metricalInformation.getMeasurementUnit() +"ãæåï¼"); |
| | | } |
| | | return Result.fail("æ·»å ã"+ metricalInformation.getMeasurementUnit() +"ã失败ï¼è®¾å¤ç ç¹ç¼ç éå¤ï¼"); |
| | | } |
| | | |
| | | @ApiOperation("æ¥è¯¢ææè®¡éä¿¡æ¯æ°æ®") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "InstrumentId", value = "ä»ªå¨æ¨¡åId", dataTypeClass = String.class, required = true) |
| | | }) |
| | | @GetMapping("/list") |
| | | public Result<?> getListMetricalInformation(String InstrumentId) { |
| | | List<Map<String, Object>> list = metricalInformationService.getListEquipmentPointInformation(InstrumentId); |
| | | return Result.success(list); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®è®¡éä¿¡æ¯Idå 餿°æ®") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "metricalInformationId", value = "计éä¿¡æ¯Id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @DeleteMapping("/delete") |
| | | public Result<?> deleteMetricalInformation(Integer metricalInformationId) { |
| | | Integer isDeleteSuccess = metricalInformationService.deleteMetricalInformation(metricalInformationId); |
| | | if (isDeleteSuccess == 1){ |
| | | return Result.success("å 餿åï¼"); |
| | | } |
| | | return Result.fail("å é¤å¤±è´¥ï¼"); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®è®¡éä¿¡æ¯Idæ´æ°æ°æ®") |
| | | @PutMapping("/update") |
| | | public Result<?> updateMetricalInformation(UpdateMetricalInformationDto updateMetricalInformationDto, |
| | | @RequestPart(value = "file", required = false) MultipartFile file) throws Exception { |
| | | MetricalInformation metricalInformation = JackSonUtil.unmarshal(JackSonUtil.marshal(updateMetricalInformationDto), MetricalInformation.class); |
| | | Integer isUpdateSuccess = metricalInformationService.updateMetricalInformation(metricalInformation, file); |
| | | if (isUpdateSuccess == 1){ |
| | | return Result.success("æ´æ°æåï¼"); |
| | | } |
| | | return Result.fail("æ´æ°å¤±è´¥ï¼"); |
| | | } |
| | | |
| | | @ApiOperation("æ·»å 计éä¿¡æ¯æ¶è´è´£äººä¸ææ¡æ°æ®") |
| | | @GetMapping("/get_user") |
| | | public Result<?> getMapUserInformation() { |
| | | return Result.success(userService.getUserNameAndId()); |
| | | } |
| | | } |