fix (farm): 微信端/PC端 农业资讯
- 资讯详情
This commit is contained in:
@@ -1,15 +1,30 @@
|
|||||||
package cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews;
|
package cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
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.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationPageRespVO;
|
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.managementcenter.farmnews.vo.FarmInformationPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationRespVO;
|
||||||
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.farm.dal.dataobject.farminformation.FarmInformationDO;
|
||||||
import cn.iocoder.yudao.module.farm.service.farminformation.FarmInformationService;
|
import cn.iocoder.yudao.module.farm.service.farminformation.FarmInformationService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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;
|
||||||
|
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.NEWS_TYPE_MAP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description:
|
* @description:
|
||||||
@@ -28,14 +43,67 @@ public class FarmInformationController {
|
|||||||
this.farmInformationService = farmInformationService;
|
this.farmInformationService = farmInformationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "资讯信息-分页")
|
@Operation(summary = "创建农业资讯")
|
||||||
public CommonResult<PageResult<FarmInformationPageRespVO>> pageInfo() {
|
public CommonResult<String> createFarmInformation(@Valid @RequestBody FarmInformationSaveReqVO createReqVO) {
|
||||||
|
return success(farmInformationService.createFarmInformation(createReqVO));
|
||||||
PageResult<FarmInformationPageRespVO> res = null;
|
|
||||||
return CommonResult.success(res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新农业资讯")
|
||||||
|
public CommonResult<Boolean> updateFarmInformation(@Valid @RequestBody FarmInformationSaveReqVO updateReqVO) {
|
||||||
|
farmInformationService.updateFarmInformation(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除农业资讯")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
public CommonResult<Boolean> deleteFarmInformation(@RequestParam("id") String id) {
|
||||||
|
farmInformationService.deleteFarmInformation(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete-list")
|
||||||
|
@Parameter(name = "ids", description = "编号", required = true)
|
||||||
|
@Operation(summary = "批量删除农业资讯")
|
||||||
|
public CommonResult<Boolean> deleteFarmInformationList(@RequestParam("ids") List<String> ids) {
|
||||||
|
farmInformationService.deleteFarmInformationListByIds(ids);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得农业资讯")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
public CommonResult<FarmInformationRespVO> getFarmInformation(@RequestParam("id") String id) {
|
||||||
|
FarmInformationDO farmInformation = farmInformationService.getFarmInformation(id);
|
||||||
|
FarmInformationRespVO res = BeanUtils.toBean(farmInformation, FarmInformationRespVO.class);
|
||||||
|
res.setInfoTypeName(NEWS_TYPE_MAP.getOrDefault(res.getInfoType(), "其他"));
|
||||||
|
|
||||||
|
return success(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得农业资讯分页")
|
||||||
|
public CommonResult<PageResult<FarmInformationRespVO>> getFarmInformationPage(@Valid FarmInformationPageReqVO pageReqVO) {
|
||||||
|
PageResult<FarmInformationDO> pageResult = farmInformationService.getFarmInformationPage(pageReqVO);
|
||||||
|
PageResult<FarmInformationRespVO> result = BeanUtils.toBean(pageResult, FarmInformationRespVO.class);
|
||||||
|
for (FarmInformationRespVO e : result.getList()) {
|
||||||
|
e.setInfoTypeName(NEWS_TYPE_MAP.getOrDefault(e.getInfoType(), "其他"));
|
||||||
|
}
|
||||||
|
return success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出农业资讯 Excel")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportFarmInformationExcel(@Valid FarmInformationPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<FarmInformationDO> list = farmInformationService.getFarmInformationPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "农业资讯.xls", "数据", FarmInformationRespVO.class,
|
||||||
|
BeanUtils.toBean(list, FarmInformationRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,32 @@
|
|||||||
package cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo;
|
package cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
import lombok.*;
|
||||||
* @description: TODO
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
* @author: binda
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
* @date: 2025/10/13 10:58
|
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
|
@Data
|
||||||
public class FarmInformationPageReqVO extends PageParam {
|
public class FarmInformationPageReqVO extends PageParam {
|
||||||
|
|
||||||
private String id;
|
@Schema(description = "资讯类型 (1: 要闻; 99:其他)", example = "1")
|
||||||
|
private String infoType;
|
||||||
|
|
||||||
|
@Schema(description = "资讯标题")
|
||||||
private String infoTitle;
|
private String infoTitle;
|
||||||
|
|
||||||
}
|
@Schema(description = "资讯正文")
|
||||||
|
private String infoText;
|
||||||
|
|
||||||
|
@Schema(description = "发布状态 (1: 已发布; 0:未发布)", example = "1")
|
||||||
|
private Integer publishStatus;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description: TODO
|
|
||||||
* @author: binda
|
|
||||||
* @date: 2025/9/25 17:09
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class FarmInformationPageRespVO {
|
|
||||||
|
|
||||||
private String id;
|
|
||||||
@Schema(description = "资讯类型 (1: 要闻; 99:其他)")
|
|
||||||
private String infoType;
|
|
||||||
private String infoTypeName;
|
|
||||||
@Schema(description = "资讯标题")
|
|
||||||
private String infoTitle;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import cn.idev.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 农业资讯 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class FarmInformationRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29934")
|
||||||
|
@ExcelProperty("主键id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "资讯类型 (1: 要闻; 99:其他)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
@ExcelProperty("资讯类型 (1: 要闻; 99:其他)")
|
||||||
|
private String infoType;
|
||||||
|
private String infoTypeName;
|
||||||
|
|
||||||
|
@Schema(description = "资讯标题", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("资讯标题")
|
||||||
|
private String infoTitle;
|
||||||
|
|
||||||
|
@Schema(description = "资讯正文", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("资讯正文")
|
||||||
|
private String infoText;
|
||||||
|
|
||||||
|
@Schema(description = "发布状态 (1: 已发布; 0:未发布)", example = "1")
|
||||||
|
@ExcelProperty("发布状态 (1: 已发布; 0:未发布)")
|
||||||
|
private Integer publishStatus;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 农业资讯新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class FarmInformationSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29934")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "资讯类型 (1: 要闻; 99:其他)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
@NotEmpty(message = "资讯类型 (1: 要闻; 99:其他)不能为空")
|
||||||
|
private String infoType;
|
||||||
|
|
||||||
|
@Schema(description = "资讯标题", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "资讯标题不能为空")
|
||||||
|
private String infoTitle;
|
||||||
|
|
||||||
|
@Schema(description = "资讯正文", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "资讯正文不能为空")
|
||||||
|
private String infoText;
|
||||||
|
|
||||||
|
@Schema(description = "发布状态 (1: 已发布; 0:未发布)", example = "1")
|
||||||
|
private Integer publishStatus;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,18 +2,19 @@ package cn.iocoder.yudao.module.farm.controller.admin.wx;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.farm.config.CompanyConf;
|
import cn.iocoder.yudao.module.farm.config.CompanyConf;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.api.vo.DeviceStateRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.api.vo.DeviceStateRespVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.ProductionPlanPage2ReqVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.ProductionPlanPage2ReqVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.ProductionPlanResp2VO;
|
import cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.ProductionPlanResp2VO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.wx.BaseInfoForWxRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.wx.BaseInfoForWxRespVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.wx.RegularPlotInfoRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.baseinfo.vo.wx.RegularPlotInfoRespVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationDetailRespVO;
|
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationPageReqVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationPageReqVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationPageRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationRespVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.wx.vo.*;
|
import cn.iocoder.yudao.module.farm.controller.admin.wx.vo.*;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.baseinfo.BaseInfoDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.baseinfo.BaseInfoDO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.deviceinfo.DeviceInfoDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.deviceinfo.DeviceInfoDO;
|
||||||
|
import cn.iocoder.yudao.module.farm.dal.dataobject.farminformation.FarmInformationDO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO;
|
||||||
import cn.iocoder.yudao.module.farm.service.baseinfo.BaseInfoService;
|
import cn.iocoder.yudao.module.farm.service.baseinfo.BaseInfoService;
|
||||||
import cn.iocoder.yudao.module.farm.service.cropFarmingCenter.CropFarmingCenterService;
|
import cn.iocoder.yudao.module.farm.service.cropFarmingCenter.CropFarmingCenterService;
|
||||||
@@ -41,8 +42,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||||
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.BINDING_STATE_MAP;
|
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.*;
|
||||||
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.DEVICE_STATE_MAP;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 微信端
|
* @description: 微信端
|
||||||
@@ -191,19 +191,26 @@ public class WxController {
|
|||||||
return success(new PageResult<ProductionPlanResp2VO>(resetList,size));
|
return success(new PageResult<ProductionPlanResp2VO>(resetList,size));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "农业资讯")
|
@Operation(summary = "农业资讯-分页")
|
||||||
@GetMapping("/farm-information/page")
|
@GetMapping("/farm-information/page")
|
||||||
public CommonResult<PageResult<FarmInformationPageRespVO>> getFarmInformation(@Valid FarmInformationPageReqVO req) {
|
public CommonResult<PageResult<FarmInformationRespVO>> getFarmInformation(@Valid FarmInformationPageReqVO req) {
|
||||||
PageResult<FarmInformationPageRespVO> result = farmInformationService.getFarmInformationPage(req);
|
PageResult<FarmInformationDO> pageResult = farmInformationService.getFarmInformationPage(req);
|
||||||
return CommonResult.success(result);
|
PageResult<FarmInformationRespVO> result = BeanUtils.toBean(pageResult, FarmInformationRespVO.class);
|
||||||
|
for (FarmInformationRespVO e : result.getList()) {
|
||||||
|
e.setInfoTypeName(NEWS_TYPE_MAP.getOrDefault(e.getInfoType(), "其他"));
|
||||||
|
}
|
||||||
|
return success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "农业资讯-详情页")
|
@Operation(summary = "农业资讯-详情页")
|
||||||
@GetMapping("/farm-information/detail")
|
@GetMapping("/farm-information/detail")
|
||||||
@Parameter(name = "id", description = "咨询ID")
|
@Parameter(name = "id", description = "咨询ID")
|
||||||
public CommonResult<FarmInformationDetailRespVO> getFarmInformationDetail(@RequestParam("id") String id) {
|
public CommonResult<FarmInformationRespVO> getFarmInformationDetail(@RequestParam("id") String id) {
|
||||||
FarmInformationDetailRespVO result = farmInformationService.getFarmInformationDetail(id);
|
FarmInformationDO farmInformation = farmInformationService.getFarmInformation(id);
|
||||||
return CommonResult.success(result);
|
FarmInformationRespVO res = BeanUtils.toBean(farmInformation, FarmInformationRespVO.class);
|
||||||
|
res.setInfoTypeName(NEWS_TYPE_MAP.getOrDefault(res.getInfoType(), "其他"));
|
||||||
|
|
||||||
|
return success(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/message-center/abnormal-state")
|
@GetMapping("/message-center/abnormal-state")
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
package cn.iocoder.yudao.module.farm.dal.dataobject.farminformation;
|
package cn.iocoder.yudao.module.farm.dal.dataobject.farminformation;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.*;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description:
|
* 农业资讯 DO
|
||||||
* @author: binda
|
*
|
||||||
* @date: 2025/9/25 17:22
|
* @author 超级管理
|
||||||
*/
|
*/
|
||||||
@TableName("farm_information")
|
@TableName("farm_information")
|
||||||
|
@KeySequence("farm_information_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@@ -19,11 +22,27 @@ import lombok.*;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class FarmInformationDO extends BaseDO {
|
public class FarmInformationDO extends BaseDO {
|
||||||
|
|
||||||
@TableId
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.INPUT)
|
||||||
private String id;
|
private String id;
|
||||||
|
/**
|
||||||
|
* 资讯类型 (1: 要闻; 99:其他)
|
||||||
|
*/
|
||||||
private String infoType;
|
private String infoType;
|
||||||
|
/**
|
||||||
|
* 资讯标题
|
||||||
|
*/
|
||||||
private String infoTitle;
|
private String infoTitle;
|
||||||
|
/**
|
||||||
|
* 资讯正文
|
||||||
|
*/
|
||||||
private String infoText;
|
private String infoText;
|
||||||
private String tenantId;
|
/**
|
||||||
|
* 发布状态 (1: 已发布; 0:未发布)
|
||||||
|
*/
|
||||||
|
private Integer publishStatus;
|
||||||
|
|
||||||
}
|
|
||||||
|
}
|
||||||
@@ -1,26 +1,29 @@
|
|||||||
package cn.iocoder.yudao.module.farm.dal.mysql.farminformation;
|
package cn.iocoder.yudao.module.farm.dal.mysql.farminformation;
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.companyinfo.vo.CompanyInfoPageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationPageReqVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationPageReqVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationPageRespVO;
|
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.companyinfo.CompanyInfoDO;
|
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.farminformation.FarmInformationDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.farminformation.FarmInformationDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 农业资讯
|
* 农业资讯 Mapper
|
||||||
* @author: binda
|
*
|
||||||
* @data: 2025/9/25 17:20
|
* @author 超级管理
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface FarmInformationMapper extends BaseMapperX<FarmInformationDO> {
|
public interface FarmInformationMapper extends BaseMapperX<FarmInformationDO> {
|
||||||
|
|
||||||
default PageResult<FarmInformationDO> selectPage(FarmInformationPageReqVO reqVO) {
|
default PageResult<FarmInformationDO> selectPage(FarmInformationPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<FarmInformationDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<FarmInformationDO>()
|
||||||
.likeIfPresent(FarmInformationDO::getInfoTitle, reqVO.getInfoTitle())
|
.eqIfPresent(FarmInformationDO::getInfoType, reqVO.getInfoType())
|
||||||
.orderByDesc(FarmInformationDO::getCreateTime));
|
.eqIfPresent(FarmInformationDO::getInfoTitle, reqVO.getInfoTitle())
|
||||||
|
.eqIfPresent(FarmInformationDO::getInfoText, reqVO.getInfoText())
|
||||||
|
.eqIfPresent(FarmInformationDO::getPublishStatus, reqVO.getPublishStatus())
|
||||||
|
.betweenIfPresent(FarmInformationDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(FarmInformationDO::getId));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
@@ -153,4 +153,6 @@ public interface ErrorCodeConstants {
|
|||||||
|
|
||||||
|
|
||||||
ErrorCode ENVIRONMENT_INDICATORS_NOT_EXISTS = new ErrorCode(1_050_048_000, "环境指标不存在");
|
ErrorCode ENVIRONMENT_INDICATORS_NOT_EXISTS = new ErrorCode(1_050_048_000, "环境指标不存在");
|
||||||
|
|
||||||
|
ErrorCode FARM_INFORMATION_NOT_EXISTS = new ErrorCode(1_050_049_000, "农业资讯不存在");
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,62 @@
|
|||||||
package cn.iocoder.yudao.module.farm.service.farminformation;
|
package cn.iocoder.yudao.module.farm.service.farminformation;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationDetailRespVO;
|
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationPageReqVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationPageReqVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationPageRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.farm.dal.dataobject.farminformation.FarmInformationDO;
|
||||||
|
import jakarta.validation.*;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description:
|
* 农业资讯 Service 接口
|
||||||
* @author: binda
|
*
|
||||||
* @date: 2025/9/25 17:27
|
* @author 超级管理
|
||||||
*/
|
*/
|
||||||
public interface FarmInformationService {
|
public interface FarmInformationService {
|
||||||
|
|
||||||
PageResult<FarmInformationPageRespVO> getFarmInformationPage(FarmInformationPageReqVO req);
|
/**
|
||||||
|
* 创建农业资讯
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
String createFarmInformation(@Valid FarmInformationSaveReqVO createReqVO);
|
||||||
|
|
||||||
FarmInformationDetailRespVO getFarmInformationDetail(String id);
|
/**
|
||||||
}
|
* 更新农业资讯
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateFarmInformation(@Valid FarmInformationSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除农业资讯
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteFarmInformation(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除农业资讯
|
||||||
|
*
|
||||||
|
* @param ids 编号
|
||||||
|
*/
|
||||||
|
void deleteFarmInformationListByIds(List<String> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得农业资讯
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 农业资讯
|
||||||
|
*/
|
||||||
|
FarmInformationDO getFarmInformation(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得农业资讯分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 农业资讯分页
|
||||||
|
*/
|
||||||
|
PageResult<FarmInformationDO> getFarmInformationPage(FarmInformationPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,48 +1,80 @@
|
|||||||
package cn.iocoder.yudao.module.farm.service.farminformation;
|
package cn.iocoder.yudao.module.farm.service.farminformation;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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.managementcenter.farmnews.vo.FarmInformationDetailRespVO;
|
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationPageReqVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationPageReqVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationPageRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.managementcenter.farmnews.vo.FarmInformationSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.farminformation.FarmInformationDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.farminformation.FarmInformationDO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.mysql.farminformation.FarmInformationMapper;
|
import cn.iocoder.yudao.module.farm.dal.mysql.farminformation.FarmInformationMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.NEWS_TYPE_MAP;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.FARM_INFORMATION_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description:
|
* 农业资讯 Service 实现类
|
||||||
* @author: binda
|
*
|
||||||
* @date: 2025/9/25 17:27
|
* @author 超级管理
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class FarmInformationServiceImpl implements FarmInformationService{
|
@Validated
|
||||||
|
public class FarmInformationServiceImpl implements FarmInformationService {
|
||||||
|
|
||||||
private final FarmInformationMapper farmInformationMapper;
|
@Resource
|
||||||
|
private FarmInformationMapper farmInformationMapper;
|
||||||
|
|
||||||
public FarmInformationServiceImpl(FarmInformationMapper farmInformationMapper) {
|
@Override
|
||||||
this.farmInformationMapper = farmInformationMapper;
|
public String createFarmInformation(FarmInformationSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
FarmInformationDO farmInformation = BeanUtils.toBean(createReqVO, FarmInformationDO.class);
|
||||||
|
farmInformationMapper.insert(farmInformation);
|
||||||
|
|
||||||
|
// 返回
|
||||||
|
return farmInformation.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<FarmInformationPageRespVO> getFarmInformationPage(FarmInformationPageReqVO req) {
|
public void updateFarmInformation(FarmInformationSaveReqVO updateReqVO) {
|
||||||
PageResult<FarmInformationDO> page = farmInformationMapper.selectPage(req);
|
// 校验存在
|
||||||
PageResult<FarmInformationPageRespVO> result = BeanUtils.toBean(page, FarmInformationPageRespVO.class);
|
validateFarmInformationExists(updateReqVO.getId());
|
||||||
for (FarmInformationPageRespVO e : result.getList()) {
|
// 更新
|
||||||
e.setInfoTypeName(NEWS_TYPE_MAP.getOrDefault(e.getInfoType(), "其他"));
|
FarmInformationDO updateObj = BeanUtils.toBean(updateReqVO, FarmInformationDO.class);
|
||||||
|
farmInformationMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteFarmInformation(String id) {
|
||||||
|
// 校验存在
|
||||||
|
validateFarmInformationExists(id);
|
||||||
|
// 删除
|
||||||
|
farmInformationMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteFarmInformationListByIds(List<String> ids) {
|
||||||
|
// 删除
|
||||||
|
farmInformationMapper.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void validateFarmInformationExists(String id) {
|
||||||
|
if (farmInformationMapper.selectById(id) == null) {
|
||||||
|
throw exception(FARM_INFORMATION_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FarmInformationDetailRespVO getFarmInformationDetail(String id) {
|
public FarmInformationDO getFarmInformation(String id) {
|
||||||
FarmInformationDO farmInformationDO = farmInformationMapper.selectOne(FarmInformationDO::getId, id);
|
return farmInformationMapper.selectById(id);
|
||||||
FarmInformationDetailRespVO res = BeanUtils.toBean(farmInformationDO, FarmInformationDetailRespVO.class);
|
|
||||||
res.setInfoTypeName(NEWS_TYPE_MAP.getOrDefault(res.getInfoType(),"其他"));
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<FarmInformationDO> getFarmInformationPage(FarmInformationPageReqVO pageReqVO) {
|
||||||
|
return farmInformationMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user