fix (farm): 管理后台 - 病虫草害库维护
- 删除冗余代码
This commit is contained in:
@@ -1,99 +0,0 @@
|
||||
package cn.iocoder.yudao.module.farm.dal.dataobject.pestdiseaseweedlibrary;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
|
||||
|
||||
/**
|
||||
* 病虫草害库维护 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("farm_pest_disease_weed_library")
|
||||
@KeySequence("farm_pest_disease_weed_library_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PestDiseaseWeedLibraryDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 基础id
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String id;
|
||||
/**
|
||||
* 灾害类型
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 灾害名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 灾害描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 防治建议
|
||||
*/
|
||||
private String propose;
|
||||
/**
|
||||
* 图片(数据库存储为逗号分隔的字符串)
|
||||
*/
|
||||
@TableField(value = "images")
|
||||
private String images;
|
||||
|
||||
/**
|
||||
* 图片集合(业务层使用)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<String> imageList;
|
||||
/**
|
||||
* 0=启用,1=停用
|
||||
*/
|
||||
private Integer useStatus;
|
||||
/**
|
||||
* 基地id
|
||||
*/
|
||||
private String baseId;
|
||||
/**
|
||||
* 基地
|
||||
*/
|
||||
private String baseName;
|
||||
/**
|
||||
* 地块ID
|
||||
*/
|
||||
private String plotId;
|
||||
/**
|
||||
* 地块
|
||||
*/
|
||||
private String plotName;
|
||||
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 获取图片集合
|
||||
*/
|
||||
public List<String> getImageList() {
|
||||
if (imageList == null) {
|
||||
imageList = ImageCollectionUtil.toImageList(this.images);
|
||||
}
|
||||
return imageList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置图片集合
|
||||
*/
|
||||
public void setImageList(List<String> imageList) {
|
||||
this.imageList = imageList;
|
||||
this.images = ImageCollectionUtil.toDatabaseString(imageList);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package cn.iocoder.yudao.module.farm.dal.mysql.pestdiseaseweedlibrary;
|
||||
|
||||
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.controller.admin.pestdiseaseweedlibrary.vo.PestDiseaseWeedLibraryPageReqVO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.pestdiseaseweedlibrary.PestDiseaseWeedLibraryDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 病虫草害库维护 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface PestDiseaseWeedLibraryMapper extends BaseMapperX<PestDiseaseWeedLibraryDO> {
|
||||
|
||||
default PageResult<PestDiseaseWeedLibraryDO> selectPage(PestDiseaseWeedLibraryPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<PestDiseaseWeedLibraryDO>()
|
||||
.eqIfPresent(PestDiseaseWeedLibraryDO::getType, reqVO.getType())
|
||||
.likeIfPresent(PestDiseaseWeedLibraryDO::getName, reqVO.getName())
|
||||
.eqIfPresent(PestDiseaseWeedLibraryDO::getDescription, reqVO.getDescription())
|
||||
.eqIfPresent(PestDiseaseWeedLibraryDO::getPropose, reqVO.getPropose())
|
||||
.eqIfPresent(PestDiseaseWeedLibraryDO::getImages, reqVO.getImages())
|
||||
.eqIfPresent(PestDiseaseWeedLibraryDO::getUseStatus, reqVO.getUseStatus())
|
||||
.betweenIfPresent(PestDiseaseWeedLibraryDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(PestDiseaseWeedLibraryDO::getBaseId, reqVO.getBaseId())
|
||||
.likeIfPresent(PestDiseaseWeedLibraryDO::getBaseName, reqVO.getBaseName())
|
||||
.eqIfPresent(PestDiseaseWeedLibraryDO::getPlotId, reqVO.getPlotId())
|
||||
.likeIfPresent(PestDiseaseWeedLibraryDO::getPlotName, reqVO.getPlotName())
|
||||
.eqIfPresent(PestDiseaseWeedLibraryDO::getTenantId, reqVO.getTenantId())
|
||||
.orderByDesc(PestDiseaseWeedLibraryDO::getCreateTime));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package cn.iocoder.yudao.module.farm.service.pestdiseaseweedlibrary;
|
||||
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.pestdiseaseweedlibrary.vo.PestDiseaseWeedLibraryPageReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.pestdiseaseweedlibrary.vo.PestDiseaseWeedLibrarySaveReqVO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.pestdiseaseweedlibrary.PestDiseaseWeedLibraryDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 病虫草害库维护 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface PestDiseaseWeedLibraryService {
|
||||
|
||||
/**
|
||||
* 创建病虫草害库维护
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
String createPestDiseaseWeedLibrary(@Valid PestDiseaseWeedLibrarySaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新病虫草害库维护
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updatePestDiseaseWeedLibrary(@Valid PestDiseaseWeedLibrarySaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除病虫草害库维护
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deletePestDiseaseWeedLibrary(String id);
|
||||
|
||||
/**
|
||||
* 批量删除病虫草害库维护
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deletePestDiseaseWeedLibraryListByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 获得病虫草害库维护
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 病虫草害库维护
|
||||
*/
|
||||
PestDiseaseWeedLibraryDO getPestDiseaseWeedLibrary(String id);
|
||||
|
||||
/**
|
||||
* 获得病虫草害库维护分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 病虫草害库维护分页
|
||||
*/
|
||||
PageResult<PestDiseaseWeedLibraryDO> getPestDiseaseWeedLibraryPage(PestDiseaseWeedLibraryPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
package cn.iocoder.yudao.module.farm.service.pestdiseaseweedlibrary;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.pestdiseaseweedlibrary.vo.PestDiseaseWeedLibraryPageReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.pestdiseaseweedlibrary.vo.PestDiseaseWeedLibrarySaveReqVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.pestdiseaseweedlibrary.PestDiseaseWeedLibraryDO;
|
||||
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.framework.security.core.LoginUser;
|
||||
|
||||
import cn.iocoder.yudao.module.farm.dal.mysql.pestdiseaseweedlibrary.PestDiseaseWeedLibraryMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.PEST_DISEASE_WEED_LIBRARY_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 病虫草害库维护 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PestDiseaseWeedLibraryServiceImpl implements PestDiseaseWeedLibraryService {
|
||||
|
||||
@Resource
|
||||
private PestDiseaseWeedLibraryMapper pestDiseaseWeedLibraryMapper;
|
||||
|
||||
@Override
|
||||
public String createPestDiseaseWeedLibrary(PestDiseaseWeedLibrarySaveReqVO createReqVO) {
|
||||
LoginUser user = getLoginUser();
|
||||
// 插入
|
||||
PestDiseaseWeedLibraryDO pestDiseaseWeedLibrary = BeanUtils.toBean(createReqVO, PestDiseaseWeedLibraryDO.class);
|
||||
pestDiseaseWeedLibrary.setId(IdUtil.fastUUID());
|
||||
pestDiseaseWeedLibrary.setTenantId(String.valueOf(user.getTenantId()));
|
||||
pestDiseaseWeedLibraryMapper.insert(pestDiseaseWeedLibrary);
|
||||
|
||||
// 返回
|
||||
return pestDiseaseWeedLibrary.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePestDiseaseWeedLibrary(PestDiseaseWeedLibrarySaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validatePestDiseaseWeedLibraryExists(updateReqVO.getId());
|
||||
// 更新
|
||||
PestDiseaseWeedLibraryDO updateObj = BeanUtils.toBean(updateReqVO, PestDiseaseWeedLibraryDO.class);
|
||||
pestDiseaseWeedLibraryMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePestDiseaseWeedLibrary(String id) {
|
||||
// 校验存在
|
||||
validatePestDiseaseWeedLibraryExists(id);
|
||||
// 删除
|
||||
pestDiseaseWeedLibraryMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePestDiseaseWeedLibraryListByIds(List<String> ids) {
|
||||
// 删除
|
||||
pestDiseaseWeedLibraryMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
private void validatePestDiseaseWeedLibraryExists(String id) {
|
||||
if (pestDiseaseWeedLibraryMapper.selectById(id) == null) {
|
||||
throw exception(PEST_DISEASE_WEED_LIBRARY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PestDiseaseWeedLibraryDO getPestDiseaseWeedLibrary(String id) {
|
||||
PestDiseaseWeedLibraryDO pestDiseaseWeedLibrary = pestDiseaseWeedLibraryMapper.selectById(id);
|
||||
if (pestDiseaseWeedLibrary != null) {
|
||||
// 触发图片集合转换,确保返回的DO对象包含转换后的图片集合
|
||||
pestDiseaseWeedLibrary.getImageList();
|
||||
}
|
||||
return pestDiseaseWeedLibrary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PestDiseaseWeedLibraryDO> getPestDiseaseWeedLibraryPage(PestDiseaseWeedLibraryPageReqVO pageReqVO) {
|
||||
PageResult<PestDiseaseWeedLibraryDO> pageResult = pestDiseaseWeedLibraryMapper.selectPage(pageReqVO);
|
||||
if (pageResult.getList() != null) {
|
||||
// 触发图片集合转换,确保分页结果中的每个DO对象都包含转换后的图片集合
|
||||
pageResult.getList().forEach(pestDiseaseWeedLibrary -> {
|
||||
if (pestDiseaseWeedLibrary != null) {
|
||||
pestDiseaseWeedLibrary.getImageList();
|
||||
}
|
||||
});
|
||||
}
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?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.pestdiseaseweedlibrary.PestDiseaseWeedLibraryMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user