Commit 3386692a by XiaHou

查询展览纪念馆

parent 29e19a4b
package com.atlgroupasia.servicecenter.common;
import com.github.pagehelper.PageInfo;
import org.springframework.data.domain.Page;
import java.util.List;
/**
* 分页数据封装类
* Created by macro on 2019/4/19.
*/
public class CommonPage<T> {
private Integer pageNum;
private Integer pageSize;
private Integer totalPage;
private Long total;
private List<T> list;
/**
* 将PageHelper分页后的list转为分页信息
*/
public static <T> CommonPage<T> restPage(List<T> list) {
CommonPage<T> result = new CommonPage<T>();
PageInfo<T> pageInfo = new PageInfo<T>(list);
result.setTotalPage(pageInfo.getPages());
result.setPageNum(pageInfo.getPageNum());
result.setPageSize(pageInfo.getPageSize());
result.setTotal(pageInfo.getTotal());
result.setList(pageInfo.getList());
return result;
}
/**
* 将SpringData分页后的list转为分页信息
*/
public static <T> CommonPage<T> restPage(Page<T> pageInfo) {
CommonPage<T> result = new CommonPage<T>();
result.setTotalPage(pageInfo.getTotalPages());
result.setPageNum(pageInfo.getNumber());
result.setPageSize(pageInfo.getSize());
result.setTotal(pageInfo.getTotalElements());
result.setList(pageInfo.getContent());
return result;
}
public Integer getPageNum() {
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Integer getTotalPage() {
return totalPage;
}
public void setTotalPage(Integer totalPage) {
this.totalPage = totalPage;
}
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
public Long getTotal() {
return total;
}
public void setTotal(Long total) {
this.total = total;
}
}
package com.atlgroupasia.servicecenter.common;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author chenwf
* @date 2020/4/2
*/
@Data
public class Page {
@ApiModelProperty("页码")
private Integer pageNum;
@ApiModelProperty("页数")
private Integer pageSize;
public Page() {
}
public Page(Integer pageNum, Integer pageSize) {
this.pageNum = pageNum;
this.pageSize = pageSize;
}
}
package com.atlgroupasia.servicecenter.controller;
import com.atlgroupasia.servicecenter.common.Page;
import com.atlgroupasia.servicecenter.operation.exhibit.pojo.QueryExhibitParam;
import com.atlgroupasia.servicecenter.operation.exhibit.service.IOshExhibitService;
import com.atlgroupasia.servicecenter.utils.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @Author xh
* @Date 2020/12/2
* description:
*/
@Controller
@Api(tags = "展览纪念馆相关接口", description = "展览纪念馆控制器")
@RequestMapping("/oshExhibit")
public class OshExhibitController {
@Autowired
private IOshExhibitService oshExhibitService;
@ApiOperation("分页查询展览纪念馆")
@RequestMapping(value = "/selectExhibitListByOther", method = RequestMethod.GET)
@ResponseBody
public JsonResult selectExhibitListByOther(@ModelAttribute Page page,
@ModelAttribute QueryExhibitParam queryExhibitParam) {
return JsonResult.success("查询成功", this.oshExhibitService.selectExhibitListByOther(queryExhibitParam, page));
}
}
...@@ -14,27 +14,5 @@ import java.util.Date; ...@@ -14,27 +14,5 @@ import java.util.Date;
@Data @Data
public class QueryExhibitParam implements Serializable { public class QueryExhibitParam implements Serializable {
@ApiModelProperty(value = "展览纪念馆id")
private Integer id;
@ApiModelProperty(value = "寺庙id")
private Integer templeId;
@ApiModelProperty(value = "参观开始时间")
private String phone;
@ApiModelProperty(value = "参观开始时间")
private String joinStartTime;
@ApiModelProperty(value = "参观结束时间")
private String joinEndTime;
@ApiModelProperty(value = "报名开始时间")
private String applyStartTime;
@ApiModelProperty(value = "报名结束时间")
private String applyEndTime;
@ApiModelProperty(value = "最大报名人数")
private Integer totalNumber;
@ApiModelProperty(value = "已报名人数")
private Integer appNumber;
@ApiModelProperty(value = "寺庙名称")
private String templeName;
} }
package com.atlgroupasia.servicecenter.operation.exhibit.pojo; package com.atlgroupasia.servicecenter.operation.exhibit.pojo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
...@@ -12,6 +13,26 @@ import java.io.Serializable; ...@@ -12,6 +13,26 @@ import java.io.Serializable;
@Data @Data
public class QueryExhibitVO implements Serializable { public class QueryExhibitVO implements Serializable {
@ApiModelProperty(value = "展览纪念馆id")
private Integer id;
@ApiModelProperty(value = "寺庙id")
private Integer templeId;
@ApiModelProperty(value = "参观开始时间")
private String phone;
@ApiModelProperty(value = "参观开始时间")
private String joinStartTime;
@ApiModelProperty(value = "参观结束时间")
private String joinEndTime;
@ApiModelProperty(value = "报名开始时间")
private String applyStartTime;
@ApiModelProperty(value = "报名结束时间")
private String applyEndTime;
@ApiModelProperty(value = "最大报名人数")
private Integer totalNumber;
@ApiModelProperty(value = "已报名人数")
private Integer appNumber;
@ApiModelProperty(value = "寺庙名称")
private String templeName;
} }
package com.atlgroupasia.servicecenter.operation.exhibit.service; package com.atlgroupasia.servicecenter.operation.exhibit.service;
import com.atlgroupasia.servicecenter.common.CommonPage;
import com.atlgroupasia.servicecenter.common.Page;
import com.atlgroupasia.servicecenter.operation.exhibit.pojo.QueryExhibitParam;
import com.atlgroupasia.servicecenter.operation.exhibit.pojo.QueryExhibitVO;
/** /**
* @Author xh * @Author xh
* @Date 2021/4/15 * @Date 2021/4/15
* description: * description:
*/ */
public interface IOshExhibitService { public interface IOshExhibitService {
/**
* 分页查询 可展览机娘
* @param queryExhibitParam
* @param page
* @return
*/
CommonPage<QueryExhibitVO> selectExhibitListByOther(QueryExhibitParam queryExhibitParam, Page page);
} }
package com.atlgroupasia.servicecenter.operation.exhibit.service.impl; package com.atlgroupasia.servicecenter.operation.exhibit.service.impl;
import com.atlgroupasia.servicecenter.common.CommonPage;
import com.atlgroupasia.servicecenter.common.Page;
import com.atlgroupasia.servicecenter.mbg.mapper.OshExhibitMapper; import com.atlgroupasia.servicecenter.mbg.mapper.OshExhibitMapper;
import com.atlgroupasia.servicecenter.operation.exhibit.dao.OshExhibitDao; import com.atlgroupasia.servicecenter.operation.exhibit.dao.OshExhibitDao;
import com.atlgroupasia.servicecenter.operation.exhibit.pojo.QueryExhibitParam;
import com.atlgroupasia.servicecenter.operation.exhibit.pojo.QueryExhibitVO;
import com.atlgroupasia.servicecenter.operation.exhibit.service.IOshExhibitService; import com.atlgroupasia.servicecenter.operation.exhibit.service.IOshExhibitService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* @Author xh * @Author xh
...@@ -21,4 +29,29 @@ public class OshExhibitServiceImpl implements IOshExhibitService { ...@@ -21,4 +29,29 @@ public class OshExhibitServiceImpl implements IOshExhibitService {
private OshExhibitDao oshExhibitDao; private OshExhibitDao oshExhibitDao;
/**
* 分页查询 可展览机娘
* @param queryExhibitParam
* @param page
* @return
*/
@Override
public CommonPage<QueryExhibitVO> selectExhibitListByOther(QueryExhibitParam queryExhibitParam, Page page){
if (page != null && page.getPageNum() != null && page.getPageSize() != null) {
PageHelper.startPage(page.getPageNum(), page.getPageSize());
}
List<QueryExhibitVO> queryExhibitVOList = this.oshExhibitDao.selectExhibitListByOther(queryExhibitParam);
//记录下 pagehelper第一次分页查询的 返回得总条数 等信息
PageInfo<QueryExhibitVO> pageInfo = new PageInfo<>(queryExhibitVOList);
//因为进行了第二次查询 所以pageHelp得分页总数得到了变化 导致不准确 因此我们需要手动校准一下
CommonPage<QueryExhibitVO> result = new CommonPage<QueryExhibitVO>();
result.setTotalPage(pageInfo.getPages());
result.setPageNum(pageInfo.getPageNum());
result.setPageSize(pageInfo.getPageSize());
result.setTotal(pageInfo.getTotal());
result.setList(queryExhibitVOList);
return result;
}
} }
...@@ -7,9 +7,14 @@ ...@@ -7,9 +7,14 @@
<select id="selectExhibitListByOther" parameterType="com.atlgroupasia.servicecenter.operation.exhibit.pojo.QueryExhibitParam" resultType="com.atlgroupasia.servicecenter.operation.exhibit.pojo.QueryExhibitVO"> <select id="selectExhibitListByOther" parameterType="com.atlgroupasia.servicecenter.operation.exhibit.pojo.QueryExhibitParam" resultType="com.atlgroupasia.servicecenter.operation.exhibit.pojo.QueryExhibitVO">
select select
a.id,a.temple_id templeId a.id,a.temple_id templeId,a.phone,a.join_start_time joinStartTime,
a.join_end_time joinEndTime,a.apply_start_time applyStartTime,a.apply_end_time applyEndTime,
a.total_number totalNumber,a.app_number appNumber,
b.name templeName
from osh_exhibit a from osh_exhibit a
left join mis_temple b ON a.temple_id = b.id left join mis_temple b ON a.temple_id = b.id
where 1= 1
</select> </select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment