Browse Source

农场项目管理 搜索条件实现

zyh
小久哥 3 years ago
parent
commit
a746c1be84
  1. 8
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java
  2. 61
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/vo/ProjectSearchPageReqVO.java
  3. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/project/ProjectMapper.java
  4. 5
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectService.java
  5. 10
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java
  6. 26
      zsw-farm/zsw-farm-impl/src/main/resources/mapper/project/ProjectMapper.xml

8
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java

@ -85,6 +85,14 @@ public class ProjectController {
return success(ProjectConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/pageSearch")
@ApiOperation("获得农场项目搜索分页")
public CommonResult<PageResult<ProjectRespVO>> getProjectSearchPage(@Valid ProjectSearchPageReqVO pageVO) {
System.out.println("进入搜索分页");
PageResult<ProjectDO> resultPage = projectService.getProjectSearchPage(pageVO);
return success(ProjectConvert.INSTANCE.convertPage(resultPage));
}
@GetMapping("/export-excel")
@ApiOperation("导出农场项目 Excel")
@PreAuthorize("@ss.hasPermission('farm:project:export')")

61
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/vo/ProjectSearchPageReqVO.java

@ -0,0 +1,61 @@
package cn.iocoder.yudao.module.farm.controller.admin.project.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel("管理后台 - 农场项目分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProjectSearchPageReqVO extends PageParam {
@ApiModelProperty(value = "")
private String name;
@ApiModelProperty(value = "")
private String content;
@ApiModelProperty(value = "")
private String resources;
@ApiModelProperty(value = "")
private String images;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始")
private LocalDateTime beginPlanStartTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束")
private LocalDateTime endPlanStartTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始")
private LocalDateTime beginPlanEndTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束")
private LocalDateTime endPlanEndTime;
@ApiModelProperty(value = "")
private Integer weight;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束")
private Date endCreateTime;
}

2
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/project/ProjectMapper.java

@ -43,4 +43,6 @@ public interface ProjectMapper extends BaseMapperX<ProjectDO> {
.orderByDesc(ProjectDO::getId));
}
List<ProjectDO> getProjectSearchPage(ProjectSearchPageReqVO reqVO);
}

5
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectService.java

@ -59,6 +59,11 @@ public interface ProjectService {
*/
PageResult<ProjectDO> getProjectPage(ProjectPageReqVO pageReqVO);
/**
* 搜索条件农场项目分页
**/
PageResult<ProjectDO> getProjectSearchPage(ProjectSearchPageReqVO pageReqVO);
/**
* 获得农场项目列表, 用于 Excel 导出
*

10
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java

@ -74,6 +74,16 @@ public class ProjectServiceImpl implements ProjectService {
return projectMapper.selectPage(pageReqVO);
}
@Override
public PageResult<ProjectDO> getProjectSearchPage(ProjectSearchPageReqVO pageReqVO){
pageReqVO.setPageNo(pageReqVO.getPageNo() - 1);
List<ProjectDO> list = projectMapper.getProjectSearchPage(pageReqVO);
PageResult<ProjectDO> result = new PageResult<>();
result.setList(list);
result.setTotal(Long.valueOf(list.size()));
return result;
}
@Override
public List<ProjectDO> getProjectList(ProjectExportReqVO exportReqVO) {
return projectMapper.selectList(exportReqVO);

26
zsw-farm/zsw-farm-impl/src/main/resources/mapper/project/ProjectMapper.xml

@ -9,4 +9,30 @@
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="getProjectSearchPage" resultType="cn.iocoder.yudao.module.farm.dal.dataobject.project.ProjectDO">
SELECT p.* FROM farm_project p
INNER JOIN farm_resource r
ON JSON_CONTAINS(p.resources, CONVERT(r.id, CHAR))
AND 1 = 1
<if test="name != null and name != '' ">
AND p.name like concat('%', #{name}, '%')
</if>
<if test="resources != null and resources != '' ">
AND r.name like concat('%', #{resources}, '%')
</if>
<if test="weight != null">
AND p.weight = #{weight}
</if>
<if test="beginPlanStartTime != null and endPlanStartTime != null">
AND p.plan_start_time <![CDATA[ >= ]]> #{beginPlanStartTime} AND p.plan_start_time <![CDATA[ <= ]]> #{endPlanStartTime}
</if>
<if test="beginPlanEndTime != null and endPlanEndTime != null">
AND p.plan_end_time <![CDATA[ >= ]]> #{beginPlanEndTime} AND p.plan_end_time <![CDATA[ <= ]]> #{endPlanEndTime}
</if>
<if test="beginCreateTime != null and endCreateTime != null">
AND p.create_time <![CDATA[ >= ]]> #{beginCreateTime} AND p.create_time <![CDATA[ <= ]]> #{endCreateTime}
</if>
GROUP BY p.id
LIMIT #{pageNo},#{pageSize}
</select>
</mapper>

Loading…
Cancel
Save