Merge branch 'main' of https://git.ngsk.tech/linweidong/besure_server
commit
0f450424ab
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device.vo;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 单设备监控 Resp VO")
|
||||
@Data
|
||||
public class SingleDeviceRespVO {
|
||||
|
||||
@Schema(description = "点位名称", example = "26404")
|
||||
private String pointName;
|
||||
|
||||
@Schema(description = "点位值", example = "26404")
|
||||
private String pointValue;
|
||||
|
||||
@Schema(description = "采集时间")
|
||||
private String collectTime;
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.recipe;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.recipe.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.recipe.RecipeDO;
|
||||
import cn.iocoder.yudao.module.iot.service.recipe.RecipeService;
|
||||
|
||||
@Tag(name = "管理后台 - 配方管理主")
|
||||
@RestController
|
||||
@RequestMapping("/iot/recipe")
|
||||
@Validated
|
||||
public class RecipeController {
|
||||
|
||||
@Resource
|
||||
private RecipeService recipeService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建配方管理主")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe:create')")
|
||||
public CommonResult<Long> createRecipe(@Valid @RequestBody RecipeSaveReqVO createReqVO) {
|
||||
return success(recipeService.createRecipe(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新配方管理主")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe:update')")
|
||||
public CommonResult<Boolean> updateRecipe(@Valid @RequestBody RecipeSaveReqVO updateReqVO) {
|
||||
recipeService.updateRecipe(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除配方管理主")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe:delete')")
|
||||
public CommonResult<Boolean> deleteRecipe(@RequestParam("id") Long id) {
|
||||
recipeService.deleteRecipe(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得配方管理主")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe:query')")
|
||||
public CommonResult<RecipeRespVO> getRecipe(@RequestParam("id") Long id) {
|
||||
RecipeDO recipe = recipeService.getRecipe(id);
|
||||
return success(BeanUtils.toBean(recipe, RecipeRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得配方管理主分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe:query')")
|
||||
public CommonResult<PageResult<RecipeRespVO>> getRecipePage(@Valid RecipePageReqVO pageReqVO) {
|
||||
PageResult<RecipeDO> pageResult = recipeService.getRecipePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, RecipeRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出配方管理主 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportRecipeExcel(@Valid RecipePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<RecipeDO> list = recipeService.getRecipePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "配方管理主.xls", "数据", RecipeRespVO.class,
|
||||
BeanUtils.toBean(list, RecipeRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.recipepoint;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.recipepoint.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.recipepoint.RecipePointDO;
|
||||
import cn.iocoder.yudao.module.iot.service.recipepoint.RecipePointService;
|
||||
|
||||
@Tag(name = "管理后台 - 配方点位配置表(配方与设备点位关联)")
|
||||
@RestController
|
||||
@RequestMapping("/iot/recipe-point")
|
||||
@Validated
|
||||
public class RecipePointController {
|
||||
|
||||
@Resource
|
||||
private RecipePointService recipePointService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建配方点位配置表(配方与设备点位关联)")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe-point:create')")
|
||||
public CommonResult<Long> createRecipePoint(@Valid @RequestBody RecipePointSaveReqVO createReqVO) {
|
||||
return success(recipePointService.createRecipePoint(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新配方点位配置表(配方与设备点位关联)")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe-point:update')")
|
||||
public CommonResult<Boolean> updateRecipePoint(@Valid @RequestBody RecipePointSaveReqVO updateReqVO) {
|
||||
recipePointService.updateRecipePoint(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除配方点位配置表(配方与设备点位关联)")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe-point:delete')")
|
||||
public CommonResult<Boolean> deleteRecipePoint(@RequestParam("id") Long id) {
|
||||
recipePointService.deleteRecipePoint(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得配方点位配置表(配方与设备点位关联)")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe-point:query')")
|
||||
public CommonResult<RecipePointRespVO> getRecipePoint(@RequestParam("id") Long id) {
|
||||
RecipePointDO recipePoint = recipePointService.getRecipePoint(id);
|
||||
return success(BeanUtils.toBean(recipePoint, RecipePointRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得配方点位配置表(配方与设备点位关联)分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe-point:query')")
|
||||
public CommonResult<PageResult<RecipePointRespVO>> getRecipePointPage(@Valid RecipePointPageReqVO pageReqVO) {
|
||||
PageResult<RecipePointDO> pageResult = recipePointService.getRecipePointPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, RecipePointRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出配方点位配置表(配方与设备点位关联) Excel")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe-point:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportRecipePointExcel(@Valid RecipePointPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<RecipePointDO> list = recipePointService.getRecipePointPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "配方点位配置表(配方与设备点位关联).xls", "数据", RecipePointRespVO.class,
|
||||
BeanUtils.toBean(list, RecipePointRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.recipetype;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.recipetype.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.recipetype.RecipeTypeDO;
|
||||
import cn.iocoder.yudao.module.iot.service.recipetype.RecipeTypeService;
|
||||
|
||||
@Tag(name = "管理后台 - 配方类型表(基础字典)")
|
||||
@RestController
|
||||
@RequestMapping("/iot/recipe-type")
|
||||
@Validated
|
||||
public class RecipeTypeController {
|
||||
|
||||
@Resource
|
||||
private RecipeTypeService recipeTypeService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建配方类型表(基础字典)")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe-type:create')")
|
||||
public CommonResult<Long> createRecipeType(@Valid @RequestBody RecipeTypeSaveReqVO createReqVO) {
|
||||
return success(recipeTypeService.createRecipeType(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新配方类型表(基础字典)")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe-type:update')")
|
||||
public CommonResult<Boolean> updateRecipeType(@Valid @RequestBody RecipeTypeSaveReqVO updateReqVO) {
|
||||
recipeTypeService.updateRecipeType(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除配方类型表(基础字典)")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe-type:delete')")
|
||||
public CommonResult<Boolean> deleteRecipeType(@RequestParam("id") Long id) {
|
||||
recipeTypeService.deleteRecipeType(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得配方类型表(基础字典)")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe-type:query')")
|
||||
public CommonResult<RecipeTypeRespVO> getRecipeType(@RequestParam("id") Long id) {
|
||||
RecipeTypeDO recipeType = recipeTypeService.getRecipeType(id);
|
||||
return success(BeanUtils.toBean(recipeType, RecipeTypeRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得配方类型表(基础字典)分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe-type:query')")
|
||||
public CommonResult<PageResult<RecipeTypeRespVO>> getRecipeTypePage(@Valid RecipeTypePageReqVO pageReqVO) {
|
||||
PageResult<RecipeTypeDO> pageResult = recipeTypeService.getRecipeTypePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, RecipeTypeRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出配方类型表(基础字典) Excel")
|
||||
@PreAuthorize("@ss.hasPermission('iot:recipe-type:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportRecipeTypeExcel(@Valid RecipeTypePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<RecipeTypeDO> list = recipeTypeService.getRecipeTypePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "配方类型表(基础字典).xls", "数据", RecipeTypeRespVO.class,
|
||||
BeanUtils.toBean(list, RecipeTypeRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.recipetype.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 配方类型表(基础字典)分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class RecipeTypePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "类型编码(唯一标识)")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "类型名称", example = "张三")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "关联工序")
|
||||
private String process;
|
||||
|
||||
@Schema(description = "配方类型描述", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序字段")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.recipetype.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 配方类型表(基础字典) Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class RecipeTypeRespVO {
|
||||
|
||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21350")
|
||||
@ExcelProperty("主键ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "类型编码(唯一标识)")
|
||||
@ExcelProperty("类型编码(唯一标识)")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "类型名称", example = "张三")
|
||||
@ExcelProperty("类型名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "关联工序")
|
||||
@ExcelProperty("关联工序")
|
||||
private String process;
|
||||
|
||||
@Schema(description = "配方类型描述", example = "你说的对")
|
||||
@ExcelProperty("配方类型描述")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序字段", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("排序字段")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.recipetype.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 配方类型表(基础字典)新增/修改 Request VO")
|
||||
@Data
|
||||
public class RecipeTypeSaveReqVO {
|
||||
|
||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21350")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "类型编码(唯一标识)")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "类型名称", example = "张三")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "关联工序")
|
||||
private String process;
|
||||
|
||||
@Schema(description = "配方类型描述", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序字段", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "排序字段不能为空")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.iot.dal.mysql.recipe;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.recipe.RecipeDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.recipe.vo.*;
|
||||
|
||||
/**
|
||||
* 配方管理主 Mapper
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
@Mapper
|
||||
public interface RecipeMapper extends BaseMapperX<RecipeDO> {
|
||||
|
||||
default PageResult<RecipeDO> selectPage(RecipePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<RecipeDO>()
|
||||
.likeIfPresent(RecipeDO::getName, reqVO.getName())
|
||||
.eqIfPresent(RecipeDO::getRecipeCode, reqVO.getRecipeCode())
|
||||
.eqIfPresent(RecipeDO::getRecipeType, reqVO.getRecipeType())
|
||||
.likeIfPresent(RecipeDO::getProductName, reqVO.getProductName())
|
||||
.eqIfPresent(RecipeDO::getMachineId, reqVO.getMachineId())
|
||||
.eqIfPresent(RecipeDO::getMachineCode, reqVO.getMachineCode())
|
||||
.likeIfPresent(RecipeDO::getMachineName, reqVO.getMachineName())
|
||||
.eqIfPresent(RecipeDO::getRecipeDesc, reqVO.getRecipeDesc())
|
||||
.eqIfPresent(RecipeDO::getIsEnable, reqVO.getIsEnable())
|
||||
.betweenIfPresent(RecipeDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(RecipeDO::getDataUnit, reqVO.getDataUnit())
|
||||
.orderByDesc(RecipeDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.iot.service.recipe;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.recipe.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.recipe.RecipeDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 配方管理主 Service 接口
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
public interface RecipeService {
|
||||
|
||||
/**
|
||||
* 创建配方管理主
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createRecipe(@Valid RecipeSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新配方管理主
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateRecipe(@Valid RecipeSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除配方管理主
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteRecipe(Long id);
|
||||
|
||||
/**
|
||||
* 获得配方管理主
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 配方管理主
|
||||
*/
|
||||
RecipeDO getRecipe(Long id);
|
||||
|
||||
/**
|
||||
* 获得配方管理主分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 配方管理主分页
|
||||
*/
|
||||
PageResult<RecipeDO> getRecipePage(RecipePageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.iot.service.recipe;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.recipe.vo.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.recipe.RecipeDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.dal.mysql.recipe.RecipeMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 配方管理主 Service 实现类
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class RecipeServiceImpl implements RecipeService {
|
||||
|
||||
@Resource
|
||||
private RecipeMapper recipeMapper;
|
||||
|
||||
@Override
|
||||
public Long createRecipe(RecipeSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
RecipeDO recipe = BeanUtils.toBean(createReqVO, RecipeDO.class);
|
||||
recipeMapper.insert(recipe);
|
||||
// 返回
|
||||
return recipe.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRecipe(RecipeSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateRecipeExists(updateReqVO.getId());
|
||||
// 更新
|
||||
RecipeDO updateObj = BeanUtils.toBean(updateReqVO, RecipeDO.class);
|
||||
recipeMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRecipe(Long id) {
|
||||
// 校验存在
|
||||
validateRecipeExists(id);
|
||||
// 删除
|
||||
recipeMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateRecipeExists(Long id) {
|
||||
if (recipeMapper.selectById(id) == null) {
|
||||
throw exception(RECIPE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeDO getRecipe(Long id) {
|
||||
return recipeMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<RecipeDO> getRecipePage(RecipePageReqVO pageReqVO) {
|
||||
return recipeMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue