设备分类关联环境指标
This commit is contained in:
@@ -0,0 +1,110 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.controller.admin.environmentindicators;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
import cn.iocoder.yudao.module.farm.controller.admin.environmentindicators.vo.EnvironmentIndicatorsPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.farm.controller.admin.environmentindicators.vo.EnvironmentIndicatorsRespVO;
|
||||||
|
import cn.iocoder.yudao.module.farm.controller.admin.environmentindicators.vo.EnvironmentIndicatorsSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.farm.dal.dataobject.environmentindicators.EnvironmentIndicatorsDO;
|
||||||
|
import cn.iocoder.yudao.module.farm.service.environmentindicators.EnvironmentIndicatorsService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 环境指标维护")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/farm/environment-indicators")
|
||||||
|
@Validated
|
||||||
|
public class EnvironmentIndicatorsController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EnvironmentIndicatorsService environmentIndicatorsService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建环境指标维护")
|
||||||
|
@PreAuthorize("@ss.hasPermission('farm:environment-indicators:create')")
|
||||||
|
public CommonResult<Integer> createEnvironmentIndicators(@Valid @RequestBody EnvironmentIndicatorsSaveReqVO createReqVO) {
|
||||||
|
return success(environmentIndicatorsService.createEnvironmentIndicators(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新环境指标维护")
|
||||||
|
@PreAuthorize("@ss.hasPermission('farm:environment-indicators:update')")
|
||||||
|
public CommonResult<Boolean> updateEnvironmentIndicators(@Valid @RequestBody EnvironmentIndicatorsSaveReqVO updateReqVO) {
|
||||||
|
environmentIndicatorsService.updateEnvironmentIndicators(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除环境指标维护")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('farm:environment-indicators:delete')")
|
||||||
|
public CommonResult<Boolean> deleteEnvironmentIndicators(@RequestParam("id") Integer id) {
|
||||||
|
environmentIndicatorsService.deleteEnvironmentIndicators(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete-list")
|
||||||
|
@Parameter(name = "ids", description = "编号", required = true)
|
||||||
|
@Operation(summary = "批量删除环境指标维护")
|
||||||
|
@PreAuthorize("@ss.hasPermission('farm:environment-indicators:delete')")
|
||||||
|
public CommonResult<Boolean> deleteEnvironmentIndicatorsList(@RequestParam("ids") List<Integer> ids) {
|
||||||
|
environmentIndicatorsService.deleteEnvironmentIndicatorsListByIds(ids);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得环境指标维护")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('farm:environment-indicators:query')")
|
||||||
|
public CommonResult<EnvironmentIndicatorsRespVO> getEnvironmentIndicators(@RequestParam("id") Integer id) {
|
||||||
|
EnvironmentIndicatorsDO environmentIndicators = environmentIndicatorsService.getEnvironmentIndicators(id);
|
||||||
|
return success(BeanUtils.toBean(environmentIndicators, EnvironmentIndicatorsRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得环境指标维护分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('farm:environment-indicators:query')")
|
||||||
|
public CommonResult<PageResult<EnvironmentIndicatorsRespVO>> getEnvironmentIndicatorsPage(@Valid EnvironmentIndicatorsPageReqVO pageReqVO) {
|
||||||
|
PageResult<EnvironmentIndicatorsDO> pageResult = environmentIndicatorsService.getEnvironmentIndicatorsPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, EnvironmentIndicatorsRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
@Operation(summary = "根据设备分类获取")
|
||||||
|
@PreAuthorize("@ss.hasPermission('farm:environment-indicators:query')")
|
||||||
|
public CommonResult<List<EnvironmentIndicatorsRespVO>> getEnvironmentIndicatorsList(@Valid EnvironmentIndicatorsPageReqVO pageReqVO) {
|
||||||
|
List<EnvironmentIndicatorsDO> pageResult = environmentIndicatorsService.getEnvironmentIndicatorsList(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, EnvironmentIndicatorsRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出环境指标维护 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('farm:environment-indicators:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportEnvironmentIndicatorsExcel(@Valid EnvironmentIndicatorsPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<EnvironmentIndicatorsDO> list = environmentIndicatorsService.getEnvironmentIndicatorsPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "环境指标维护.xls", "数据", EnvironmentIndicatorsRespVO.class,
|
||||||
|
BeanUtils.toBean(list, EnvironmentIndicatorsRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.controller.admin.environmentindicators.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
|
||||||
|
public class EnvironmentIndicatorsPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "设备分类id", example = "5134")
|
||||||
|
private String deviceCategoryId;
|
||||||
|
|
||||||
|
@Schema(description = "设备分类名称", example = "芋艿")
|
||||||
|
private String deviceCategoryName;
|
||||||
|
|
||||||
|
@Schema(description = "名称", example = "张三")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "单位")
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
@Schema(description = "图片")
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
@Schema(description = "最小值")
|
||||||
|
private String lowerThreshold;
|
||||||
|
|
||||||
|
@Schema(description = "最大值")
|
||||||
|
private String upperThreshold;
|
||||||
|
|
||||||
|
@Schema(description = "说明", example = "你猜")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.controller.admin.environmentindicators.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 cn.idev.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 环境指标维护 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class EnvironmentIndicatorsRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1568")
|
||||||
|
@ExcelProperty("id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Schema(description = "设备分类id", example = "5134")
|
||||||
|
@ExcelProperty("设备分类id")
|
||||||
|
private String deviceCategoryId;
|
||||||
|
|
||||||
|
@Schema(description = "设备分类名称", example = "芋艿")
|
||||||
|
@ExcelProperty("设备分类名称")
|
||||||
|
private String deviceCategoryName;
|
||||||
|
|
||||||
|
@Schema(description = "名称", example = "张三")
|
||||||
|
@ExcelProperty("名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "单位")
|
||||||
|
@ExcelProperty("单位")
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
@Schema(description = "图片")
|
||||||
|
@ExcelProperty("图片")
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
@Schema(description = "最小值")
|
||||||
|
@ExcelProperty("最小值")
|
||||||
|
private String lowerThreshold;
|
||||||
|
|
||||||
|
@Schema(description = "最大值")
|
||||||
|
@ExcelProperty("最大值")
|
||||||
|
private String upperThreshold;
|
||||||
|
|
||||||
|
@Schema(description = "说明", example = "你猜")
|
||||||
|
@ExcelProperty("说明")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.controller.admin.environmentindicators.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 环境指标维护新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class EnvironmentIndicatorsSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1568")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Schema(description = "设备分类id", example = "5134")
|
||||||
|
private String deviceCategoryId;
|
||||||
|
|
||||||
|
@Schema(description = "设备分类名称", example = "芋艿")
|
||||||
|
private String deviceCategoryName;
|
||||||
|
|
||||||
|
@Schema(description = "名称", example = "张三")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "单位")
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
@Schema(description = "图片")
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
@Schema(description = "最小值")
|
||||||
|
private String lowerThreshold;
|
||||||
|
|
||||||
|
@Schema(description = "最大值")
|
||||||
|
private String upperThreshold;
|
||||||
|
|
||||||
|
@Schema(description = "说明", example = "你猜")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.dal.dataobject.environmentindicators;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 环境指标维护 DO
|
||||||
|
*
|
||||||
|
* @author 万懋超级管理
|
||||||
|
*/
|
||||||
|
@TableName("farm_environment_indicators")
|
||||||
|
@KeySequence("farm_environment_indicators_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class EnvironmentIndicatorsDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* 设备分类id
|
||||||
|
*/
|
||||||
|
private String deviceCategoryId;
|
||||||
|
/**
|
||||||
|
* 设备分类名称
|
||||||
|
*/
|
||||||
|
private String deviceCategoryName;
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 单位
|
||||||
|
*/
|
||||||
|
private String unit;
|
||||||
|
/**
|
||||||
|
* 图片
|
||||||
|
*/
|
||||||
|
private String image;
|
||||||
|
/**
|
||||||
|
* 最小值
|
||||||
|
*/
|
||||||
|
private String lowerThreshold;
|
||||||
|
/**
|
||||||
|
* 最大值
|
||||||
|
*/
|
||||||
|
private String upperThreshold;
|
||||||
|
/**
|
||||||
|
* 说明
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.dal.mysql.environmentindicators;
|
||||||
|
|
||||||
|
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.farm.dal.dataobject.environmentindicators.EnvironmentIndicatorsDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.farm.controller.admin.environmentindicators.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 环境指标维护 Mapper
|
||||||
|
*
|
||||||
|
* @author 万懋超级管理
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface EnvironmentIndicatorsMapper extends BaseMapperX<EnvironmentIndicatorsDO> {
|
||||||
|
|
||||||
|
default PageResult<EnvironmentIndicatorsDO> selectPage(EnvironmentIndicatorsPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<EnvironmentIndicatorsDO>()
|
||||||
|
.eqIfPresent(EnvironmentIndicatorsDO::getDeviceCategoryId, reqVO.getDeviceCategoryId())
|
||||||
|
.likeIfPresent(EnvironmentIndicatorsDO::getDeviceCategoryName, reqVO.getDeviceCategoryName())
|
||||||
|
.likeIfPresent(EnvironmentIndicatorsDO::getName, reqVO.getName())
|
||||||
|
.eqIfPresent(EnvironmentIndicatorsDO::getUnit, reqVO.getUnit())
|
||||||
|
.eqIfPresent(EnvironmentIndicatorsDO::getImage, reqVO.getImage())
|
||||||
|
.eqIfPresent(EnvironmentIndicatorsDO::getLowerThreshold, reqVO.getLowerThreshold())
|
||||||
|
.eqIfPresent(EnvironmentIndicatorsDO::getUpperThreshold, reqVO.getUpperThreshold())
|
||||||
|
.eqIfPresent(EnvironmentIndicatorsDO::getDescription, reqVO.getDescription())
|
||||||
|
.betweenIfPresent(EnvironmentIndicatorsDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(EnvironmentIndicatorsDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -134,9 +134,12 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode NOT_EXIST = new ErrorCode(1_050_042_000, "节点不存在或已被删除");
|
ErrorCode NOT_EXIST = new ErrorCode(1_050_042_000, "节点不存在或已被删除");
|
||||||
|
|
||||||
ErrorCode DEVICE_CLASSIFY_NOT_EXISTS = new ErrorCode(1_050_045_000, "设备分类不存在或已被删除");
|
ErrorCode DEVICE_CLASSIFY_NOT_EXISTS = new ErrorCode(1_050_045_000, "设备分类不存在或已被删除");
|
||||||
|
|
||||||
// ========== 图片集合相关 1_050_046_000 ==========
|
// ========== 图片集合相关 1_050_046_000 ==========
|
||||||
ErrorCode IMAGE_COLLECTION_INVALID = new ErrorCode(1_050_046_000, "图片集合格式无效");
|
ErrorCode IMAGE_COLLECTION_INVALID = new ErrorCode(1_050_046_000, "图片集合格式无效");
|
||||||
ErrorCode IMAGE_URL_INVALID = new ErrorCode(1_050_046_001, "图片URL格式无效");
|
ErrorCode IMAGE_URL_INVALID = new ErrorCode(1_050_046_001, "图片URL格式无效");
|
||||||
ErrorCode IMAGE_COLLECTION_TOO_LARGE = new ErrorCode(1_050_046_002, "图片集合过大,最多支持10张图片");
|
ErrorCode IMAGE_COLLECTION_TOO_LARGE = new ErrorCode(1_050_046_002, "图片集合过大,最多支持10张图片");
|
||||||
|
|
||||||
|
|
||||||
|
ErrorCode ENVIRONMENT_INDICATORS_NOT_EXISTS = new ErrorCode(1_050_048_000, "环境指标不存在");
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.service.environmentindicators;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import jakarta.validation.*;
|
||||||
|
import cn.iocoder.yudao.module.farm.controller.admin.environmentindicators.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.farm.dal.dataobject.environmentindicators.EnvironmentIndicatorsDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 环境指标维护 Service 接口
|
||||||
|
*
|
||||||
|
* @author 万懋超级管理
|
||||||
|
*/
|
||||||
|
public interface EnvironmentIndicatorsService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建环境指标维护
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Integer createEnvironmentIndicators(@Valid EnvironmentIndicatorsSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新环境指标维护
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateEnvironmentIndicators(@Valid EnvironmentIndicatorsSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除环境指标维护
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteEnvironmentIndicators(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除环境指标维护
|
||||||
|
*
|
||||||
|
* @param ids 编号
|
||||||
|
*/
|
||||||
|
void deleteEnvironmentIndicatorsListByIds(List<Integer> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得环境指标维护
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 环境指标维护
|
||||||
|
*/
|
||||||
|
EnvironmentIndicatorsDO getEnvironmentIndicators(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得环境指标维护分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 环境指标维护分页
|
||||||
|
*/
|
||||||
|
PageResult<EnvironmentIndicatorsDO> getEnvironmentIndicatorsPage(EnvironmentIndicatorsPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
List<EnvironmentIndicatorsDO> getEnvironmentIndicatorsList(EnvironmentIndicatorsPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.service.environmentindicators;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.farm.controller.admin.environmentindicators.vo.EnvironmentIndicatorsPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.farm.controller.admin.environmentindicators.vo.EnvironmentIndicatorsSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.farm.dal.dataobject.environmentindicators.EnvironmentIndicatorsDO;
|
||||||
|
import cn.iocoder.yudao.module.farm.dal.mysql.environmentindicators.EnvironmentIndicatorsMapper;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.ENVIRONMENT_INDICATORS_NOT_EXISTS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 环境指标维护 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 万懋超级管理
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class EnvironmentIndicatorsServiceImpl implements EnvironmentIndicatorsService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EnvironmentIndicatorsMapper environmentIndicatorsMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer createEnvironmentIndicators(EnvironmentIndicatorsSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
EnvironmentIndicatorsDO environmentIndicators = BeanUtils.toBean(createReqVO, EnvironmentIndicatorsDO.class);
|
||||||
|
environmentIndicatorsMapper.insert(environmentIndicators);
|
||||||
|
|
||||||
|
// 返回
|
||||||
|
return environmentIndicators.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEnvironmentIndicators(EnvironmentIndicatorsSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateEnvironmentIndicatorsExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
EnvironmentIndicatorsDO updateObj = BeanUtils.toBean(updateReqVO, EnvironmentIndicatorsDO.class);
|
||||||
|
environmentIndicatorsMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteEnvironmentIndicators(Integer id) {
|
||||||
|
// 校验存在
|
||||||
|
validateEnvironmentIndicatorsExists(id);
|
||||||
|
// 删除
|
||||||
|
environmentIndicatorsMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteEnvironmentIndicatorsListByIds(List<Integer> ids) {
|
||||||
|
// 删除
|
||||||
|
environmentIndicatorsMapper.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void validateEnvironmentIndicatorsExists(Integer id) {
|
||||||
|
if (environmentIndicatorsMapper.selectById(id) == null) {
|
||||||
|
throw exception(ENVIRONMENT_INDICATORS_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnvironmentIndicatorsDO getEnvironmentIndicators(Integer id) {
|
||||||
|
return environmentIndicatorsMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<EnvironmentIndicatorsDO> getEnvironmentIndicatorsPage(EnvironmentIndicatorsPageReqVO pageReqVO) {
|
||||||
|
return environmentIndicatorsMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EnvironmentIndicatorsDO> getEnvironmentIndicatorsList(EnvironmentIndicatorsPageReqVO pageReqVO) {
|
||||||
|
return environmentIndicatorsMapper.selectList(EnvironmentIndicatorsDO::getDeviceCategoryId, pageReqVO.getDeviceCategoryId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.iocoder.yudao.module.farm.dal.mysql.environmentindicators.EnvironmentIndicatorsMapper">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||||
|
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||||
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||||
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
|
-->
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user