|
@ -1,6 +1,7 @@ |
|
|
package com.iflytop.handacid.app.controller; |
|
|
package com.iflytop.handacid.app.controller; |
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
|
|
|
|
import com.iflytop.handacid.app.model.dto.FormulationListDTO; |
|
|
|
|
|
import com.iflytop.handacid.app.model.vo.FormulationListVO; |
|
|
import com.iflytop.handacid.common.base.BasePageQuery; |
|
|
import com.iflytop.handacid.common.base.BasePageQuery; |
|
|
import com.iflytop.handacid.common.model.entity.Formulation; |
|
|
import com.iflytop.handacid.common.model.entity.Formulation; |
|
|
import com.iflytop.handacid.common.model.vo.FormulationVO; |
|
|
import com.iflytop.handacid.common.model.vo.FormulationVO; |
|
@ -12,10 +13,10 @@ import io.swagger.v3.oas.annotations.Operation; |
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
import java.util.Arrays; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 配方 |
|
|
* 配方 |
|
@ -26,23 +27,20 @@ import java.util.Arrays; |
|
|
@RequiredArgsConstructor |
|
|
@RequiredArgsConstructor |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
public class FormulationController { |
|
|
public class FormulationController { |
|
|
@Autowired |
|
|
|
|
|
private FormulationService formulationService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SolutionService solutionService; |
|
|
|
|
|
|
|
|
private final FormulationService formulationService; |
|
|
|
|
|
private final SolutionService solutionService; |
|
|
|
|
|
|
|
|
@PostMapping("/page") |
|
|
@PostMapping("/page") |
|
|
@Operation(summary = "获取分页数据") |
|
|
@Operation(summary = "获取分页数据") |
|
|
public PageResult<FormulationVO> getPage(BasePageQuery query) { |
|
|
|
|
|
|
|
|
public PageResult<FormulationVO> getPage(@RequestBody BasePageQuery query) { |
|
|
return PageResult.success(formulationService.getPage(query)); |
|
|
return PageResult.success(formulationService.getPage(query)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* @GetMapping("/list") |
|
|
|
|
|
|
|
|
@PostMapping("/list") |
|
|
@Operation(summary = "获取List数据") |
|
|
@Operation(summary = "获取List数据") |
|
|
public Result<List<Formulation>> getList( @RequestParam Integer solutionId, @RequestParam String concentration) { |
|
|
|
|
|
List<Formulation> formulations=formulationService.list(new LambdaQueryWrapper<Formulation>().eq(Formulation::getSolutionId, solutionId).eq(Formulation::getConcentration,concentration)); |
|
|
|
|
|
return Result.success(formulations); |
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
public Result<List<FormulationListVO>> getList(@RequestBody(required = false) FormulationListDTO dto) { |
|
|
|
|
|
return Result.success(formulationService.getList(dto)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@GetMapping("/{id}") |
|
|
@GetMapping("/{id}") |
|
|
@Operation(summary = "根据ID获取") |
|
|
@Operation(summary = "根据ID获取") |
|
@ -54,14 +52,14 @@ public class FormulationController { |
|
|
@Operation(summary = "创建配方") |
|
|
@Operation(summary = "创建配方") |
|
|
public Result<String> create(@RequestBody Formulation formulation) { |
|
|
public Result<String> create(@RequestBody Formulation formulation) { |
|
|
boolean flag = formulationService.save(formulation); |
|
|
boolean flag = formulationService.save(formulation); |
|
|
return flag ? Result.success("添加成功") : Result.failed("添加失败"); |
|
|
|
|
|
|
|
|
return flag ? Result.success() : Result.failed(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@PutMapping |
|
|
@PutMapping |
|
|
@Operation(summary = "修改配方") |
|
|
@Operation(summary = "修改配方") |
|
|
public Result<String> update(@RequestBody Formulation formulation) { |
|
|
public Result<String> update(@RequestBody Formulation formulation) { |
|
|
boolean flag = formulationService.saveOrUpdate(formulation); |
|
|
boolean flag = formulationService.saveOrUpdate(formulation); |
|
|
return flag ? Result.success("修改成功") : Result.failed("修改失败"); |
|
|
|
|
|
|
|
|
return flag ? Result.success() : Result.failed(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@DeleteMapping("/{ids}") |
|
|
@DeleteMapping("/{ids}") |
|
@ -70,7 +68,7 @@ public class FormulationController { |
|
|
boolean success = formulationService.removeBatchByIds( |
|
|
boolean success = formulationService.removeBatchByIds( |
|
|
Arrays.stream(ids.split(",")).map(Long::valueOf).toList() |
|
|
Arrays.stream(ids.split(",")).map(Long::valueOf).toList() |
|
|
); |
|
|
); |
|
|
return success ? Result.success("删除成功") : Result.failed("删除失败"); |
|
|
|
|
|
|
|
|
return success ? Result.success() : Result.failed(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* @GetMapping("/concentration/{id}") |
|
|
/* @GetMapping("/concentration/{id}") |
|
|