2 changed files with 121 additions and 0 deletions
-
74src/main/java/com/iflytop/sgs/app/controller/SolutionsController.java
-
47src/main/java/com/iflytop/sgs/app/controller/TrayController.java
@ -0,0 +1,74 @@ |
|||||
|
package com.iflytop.sgs.app.controller; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.iflytop.sgs.app.model.entity.Solutions; |
||||
|
import com.iflytop.sgs.app.service.api.SolutionsService; |
||||
|
import com.iflytop.sgs.common.base.BasePageQuery; |
||||
|
import com.iflytop.sgs.common.result.PageResult; |
||||
|
import com.iflytop.sgs.common.result.Result; |
||||
|
import com.iflytop.sgs.common.result.ResultCode; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.Parameter; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import jakarta.validation.Valid; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
@Tag(name = "溶液管理") |
||||
|
@RestController |
||||
|
@RequestMapping("/api/sols") |
||||
|
@RequiredArgsConstructor |
||||
|
@Slf4j |
||||
|
public class SolutionsController { |
||||
|
private final SolutionsService solutionsService; |
||||
|
|
||||
|
@Operation(summary = "溶液列表") |
||||
|
@GetMapping("/list") |
||||
|
public PageResult<Solutions> getAllSols(BasePageQuery pageQuery) { |
||||
|
IPage<Solutions> result = solutionsService.page(new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize()), null); |
||||
|
return PageResult.success(result); |
||||
|
} |
||||
|
|
||||
|
@Operation(summary = "添加新溶液") |
||||
|
@PostMapping("") |
||||
|
public Result<String> addSolutions(@Valid @RequestBody Solutions solutions) { |
||||
|
Solutions existingSolutions = solutionsService.findByName(solutions.getName()); |
||||
|
if (existingSolutions == null) { |
||||
|
boolean isSuccess = solutionsService.addSolutions(solutions); |
||||
|
if (isSuccess) { |
||||
|
return Result.success(); |
||||
|
} |
||||
|
} else { |
||||
|
return Result.failed(ResultCode.DATA_ALREADY_EXISTS); |
||||
|
} |
||||
|
return Result.failed(); |
||||
|
} |
||||
|
|
||||
|
@Operation(summary = "更新溶液") |
||||
|
@PutMapping("") |
||||
|
public Result<String> updateSolutions(@Valid @RequestBody Solutions solutions) { |
||||
|
Solutions existingSolutions = solutionsService.findByName(solutions.getName()); |
||||
|
if (existingSolutions == null) { |
||||
|
boolean isSuccess = solutionsService.updateSolutions(solutions); |
||||
|
if (isSuccess) { |
||||
|
return Result.success(); |
||||
|
} |
||||
|
} else { |
||||
|
return Result.failed(ResultCode.DATA_ALREADY_EXISTS); |
||||
|
} |
||||
|
return Result.failed(); |
||||
|
} |
||||
|
|
||||
|
@Operation(summary = "删除溶液") |
||||
|
@DeleteMapping("/{ids}") |
||||
|
public Result<String> delete(@Parameter(description = "溶液ID,多个以英文逗号(,)分割") @PathVariable String ids) { |
||||
|
boolean isSuccess = solutionsService.deleteSolutions(ids); |
||||
|
if (isSuccess) { |
||||
|
return Result.success(); |
||||
|
} |
||||
|
return Result.failed(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,47 @@ |
|||||
|
package com.iflytop.sgs.app.controller; |
||||
|
|
||||
|
import com.iflytop.sgs.app.model.bo.status.device.TrayState; |
||||
|
import com.iflytop.sgs.app.model.vo.SetTrayTubeVO; |
||||
|
import com.iflytop.sgs.app.service.api.TrayService; |
||||
|
import com.iflytop.sgs.common.result.Result; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* 托盘控制 |
||||
|
*/ |
||||
|
@Tag(name = "托盘控制") |
||||
|
@RestController |
||||
|
@RequestMapping("/api/tray") |
||||
|
@RequiredArgsConstructor |
||||
|
@Slf4j |
||||
|
public class TrayController { |
||||
|
private final TrayService trayService; |
||||
|
|
||||
|
@Operation(summary = "放入新托盘") |
||||
|
@PostMapping("/in") |
||||
|
public Result<TrayState> trayIn() { |
||||
|
return Result.success(trayService.trayIn()); |
||||
|
} |
||||
|
|
||||
|
@Operation(summary = "拿走托盘") |
||||
|
@PostMapping("/out") |
||||
|
public Result<?> trayOut() { |
||||
|
trayService.trayOut(); |
||||
|
return Result.success(); |
||||
|
} |
||||
|
|
||||
|
@Operation(summary = "设置托盘试管") |
||||
|
@PostMapping("/tube") |
||||
|
public Result<?> setTrayTube(@RequestBody SetTrayTubeVO setTrayTubeVO) { |
||||
|
trayService.setTrayTube(setTrayTubeVO); |
||||
|
return Result.success(); |
||||
|
} |
||||
|
|
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue