Commit be2762d5 authored by ysongq's avatar ysongq

条件分页查询数据列表

parent 2be7919f
...@@ -7,16 +7,15 @@ import com.jz.common.constant.Constants; ...@@ -7,16 +7,15 @@ import com.jz.common.constant.Constants;
import com.jz.common.entity.DataGoods; import com.jz.common.entity.DataGoods;
import com.jz.manage.moduls.controller.BaseController; import com.jz.manage.moduls.controller.BaseController;
import com.jz.manage.moduls.controller.goods.bean.dto.DataGoodsDto; import com.jz.manage.moduls.controller.goods.bean.dto.DataGoodsDto;
import com.jz.manage.moduls.controller.goods.bean.dto.DataGoodsListDto;
import com.jz.manage.moduls.controller.goods.bean.request.DataGoodsListRequest;
import com.jz.manage.moduls.controller.goods.bean.request.DataGoodsRequest; import com.jz.manage.moduls.controller.goods.bean.request.DataGoodsRequest;
import com.jz.manage.moduls.service.DataGoodsService; import com.jz.manage.moduls.service.DataGoodsService;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/** /**
* 数据商品(dataGoods)表控制层 * 数据商品(dataGoods)表控制层
...@@ -34,14 +33,14 @@ public class DataGoodsController extends BaseController { ...@@ -34,14 +33,14 @@ public class DataGoodsController extends BaseController {
private DataGoodsService dataGoodsService; private DataGoodsService dataGoodsService;
/**列表查询数据商品 /**列表查询数据商品
* @param DataGoodsRequest * @param dataGoodsListRequest
* @return * @return
*/ */
@RequestMapping(method = RequestMethod.POST, value = "/findList") @PostMapping(value = "/findList")
public PageInfoResponse<DataGoodsDto> findList(@RequestBody DataGoodsRequest DataGoodsRequest, HttpServletRequest httpRequest){ public PageInfoResponse<DataGoodsListDto> findList(@RequestBody DataGoodsListRequest dataGoodsListRequest, HttpServletRequest httpRequest){
PageInfoResponse<DataGoodsDto> pageInfo = new PageInfoResponse<DataGoodsDto>(); PageInfoResponse<DataGoodsListDto> pageInfo = new PageInfoResponse<>();
try { try {
pageInfo = dataGoodsService.findList(DataGoodsRequest, httpRequest); pageInfo = dataGoodsService.findList(dataGoodsListRequest, httpRequest);
} catch (Exception e) { } catch (Exception e) {
pageInfo.setMessage("查询失败"); pageInfo.setMessage("查询失败");
pageInfo.setCode(Constants.FAILURE_CODE); pageInfo.setCode(Constants.FAILURE_CODE);
......
package com.jz.manage.moduls.controller.goods.bean.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.util.Date;
/**
* @ClassName: 商品列表返回对象
* @Author: Carl
* @Date: 2020/12/14
* @Version:
*/
@ApiModel(value = "商品列表", description = "商品列表参数对象")
public class DataGoodsListDto {
/**
* 数据商品id
*/
@ApiModelProperty(value = "数据商品id")
private Long dataGoodsId;
/**
* 数据名称
*/
@ApiModelProperty(value = "数据名称")
private String dataName;
/**
* 数据类型
*/
@ApiModelProperty(value = "数据类型")
private String dataType;
/**
* 数据行业
*/
@ApiModelProperty(value = "数据行业")
private Long categoryId;
/**
* 分类名称
*/
@ApiModelProperty(value = "分类名称")
private String categoryName;
/**
* 上传时间
*/
@ApiModelProperty(value = "上传时间")
private Date uptTime;
/**
* 数据状态
*/
@ApiModelProperty(value = "数据状态")
private String dataStatus;
public Long getDataGoodsId() {
return dataGoodsId;
}
public void setDataGoodsId(Long dataGoodsId) {
this.dataGoodsId = dataGoodsId;
}
public String getDataName() {
return dataName;
}
public void setDataName(String dataName) {
this.dataName = dataName;
}
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public Long getCategoryId() {
return categoryId;
}
public void setCategoryId(Long categoryId) {
this.categoryId = categoryId;
}
public Date getUptTime() {
return uptTime;
}
public void setUptTime(Date uptTime) {
this.uptTime = uptTime;
}
public String getDataStatus() {
return dataStatus;
}
public void setDataStatus(String dataStatus) {
this.dataStatus = dataStatus;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
}
package com.jz.manage.moduls.controller.goods.bean.request;
import com.jz.common.bean.BasePageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
* @ClassName: 后台--数据商品列表参数对象
* @Author: Carl
* @Date: 2020/12/14
* @Version:
*/
@ApiModel(value = "数据集市--数据商品列表参数对象", description = "数据商品列表参数对象")
public class DataGoodsListRequest extends BasePageBean {
/**
* 数据名称
*/
@ApiModelProperty(value = "数据名称")
private String dataName;
/**
* 数据状态
*/
@ApiModelProperty(value = "数据状态")
private String dataStatus;
/**
* 数据行业
*/
@ApiModelProperty(value = "数据行业")
private Long categoryId;
/**
* 数据商品id
*/
@ApiModelProperty(value = "数据商品id")
private Long dataGoodsId;
/**
* 数据类型
*/
@ApiModelProperty(value = "数据类型")
private String dataType;
public String getDataName() {
return dataName;
}
public void setDataName(String dataName) {
this.dataName = dataName;
}
public String getDataStatus() {
return dataStatus;
}
public void setDataStatus(String dataStatus) {
this.dataStatus = dataStatus;
}
public Long getCategoryId() {
return categoryId;
}
public void setCategoryId(Long categoryId) {
this.categoryId = categoryId;
}
public Long getDataGoodsId() {
return dataGoodsId;
}
public void setDataGoodsId(Long dataGoodsId) {
this.dataGoodsId = dataGoodsId;
}
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
}
...@@ -6,6 +6,7 @@ import java.util.Map; ...@@ -6,6 +6,7 @@ import java.util.Map;
import com.jz.common.base.BaseMapper; import com.jz.common.base.BaseMapper;
import com.jz.common.entity.DataGoods; import com.jz.common.entity.DataGoods;
import com.jz.manage.moduls.controller.goods.bean.dto.DataGoodsDto; import com.jz.manage.moduls.controller.goods.bean.dto.DataGoodsDto;
import com.jz.manage.moduls.controller.goods.bean.dto.DataGoodsListDto;
/** /**
* 数据商品(DataGoods)表数据库访问层 * 数据商品(DataGoods)表数据库访问层
...@@ -55,7 +56,7 @@ public interface DataGoodsDao extends BaseMapper<DataGoods> { ...@@ -55,7 +56,7 @@ public interface DataGoodsDao extends BaseMapper<DataGoods> {
* @return * @return
* @throws Exception * @throws Exception
*/ */
public List<DataGoodsDto> findList(Map<String, Object> param)throws Exception; public List<DataGoodsListDto> findList(Map<String, Object> param)throws Exception;
/**主键查询数据商品 /**主键查询数据商品
* @param DataGoodsId * @param DataGoodsId
......
...@@ -7,6 +7,8 @@ import com.jz.common.bean.BaseResponse; ...@@ -7,6 +7,8 @@ import com.jz.common.bean.BaseResponse;
import com.jz.common.bean.PageInfoResponse; import com.jz.common.bean.PageInfoResponse;
import com.jz.common.entity.DataGoods; import com.jz.common.entity.DataGoods;
import com.jz.manage.moduls.controller.goods.bean.dto.DataGoodsDto; import com.jz.manage.moduls.controller.goods.bean.dto.DataGoodsDto;
import com.jz.manage.moduls.controller.goods.bean.dto.DataGoodsListDto;
import com.jz.manage.moduls.controller.goods.bean.request.DataGoodsListRequest;
import com.jz.manage.moduls.controller.goods.bean.request.DataGoodsRequest; import com.jz.manage.moduls.controller.goods.bean.request.DataGoodsRequest;
/** /**
...@@ -18,12 +20,12 @@ import com.jz.manage.moduls.controller.goods.bean.request.DataGoodsRequest; ...@@ -18,12 +20,12 @@ import com.jz.manage.moduls.controller.goods.bean.request.DataGoodsRequest;
public interface DataGoodsService { public interface DataGoodsService {
/**条件查询所有数据商品 /**条件查询所有数据商品
* @param DataGoodsRequest * @param dataGoodsListRequest
* @param httpRequest * @param httpRequest
* @return * @return
* @throws Exception * @throws Exception
*/ */
public PageInfoResponse<DataGoodsDto> findList(DataGoodsRequest dataGoodsRequest, HttpServletRequest httpRequest)throws Exception; public PageInfoResponse<DataGoodsListDto> findList(DataGoodsListRequest dataGoodsListRequest, HttpServletRequest httpRequest)throws Exception;
/**新增数据商品 /**新增数据商品
......
...@@ -8,6 +8,8 @@ import com.jz.common.bean.PageInfoResponse; ...@@ -8,6 +8,8 @@ import com.jz.common.bean.PageInfoResponse;
import com.jz.common.constant.Constants; import com.jz.common.constant.Constants;
import com.jz.common.entity.DataGoods; import com.jz.common.entity.DataGoods;
import com.jz.manage.moduls.controller.goods.bean.dto.DataGoodsDto; import com.jz.manage.moduls.controller.goods.bean.dto.DataGoodsDto;
import com.jz.manage.moduls.controller.goods.bean.dto.DataGoodsListDto;
import com.jz.manage.moduls.controller.goods.bean.request.DataGoodsListRequest;
import com.jz.manage.moduls.controller.goods.bean.request.DataGoodsRequest; import com.jz.manage.moduls.controller.goods.bean.request.DataGoodsRequest;
import com.jz.manage.moduls.mapper.DataGoodsDao; import com.jz.manage.moduls.mapper.DataGoodsDao;
import com.jz.manage.moduls.service.DataGoodsService; import com.jz.manage.moduls.service.DataGoodsService;
...@@ -16,14 +18,12 @@ import java.util.Date; ...@@ -16,14 +18,12 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
...@@ -37,132 +37,42 @@ public class DataGoodsServiceImpl implements DataGoodsService { ...@@ -37,132 +37,42 @@ public class DataGoodsServiceImpl implements DataGoodsService {
@Autowired @Autowired
private DataGoodsDao dataGoodsDao; private DataGoodsDao dataGoodsDao;
/**
* 条件分页查询数据列表
* @param goodsListRequest
* @param httpRequest
* @return
* @throws Exception
*/
@Override @Override
public PageInfoResponse<DataGoodsDto> findList(DataGoodsRequest dataGoodsRequest, HttpServletRequest httpRequest) public PageInfoResponse<DataGoodsListDto> findList(DataGoodsListRequest goodsListRequest, HttpServletRequest httpRequest) throws Exception {
throws Exception { PageInfoResponse<DataGoodsListDto> pageInfoResponse = new PageInfoResponse<>();
PageInfoResponse<DataGoodsDto> pageInfoResponse = new PageInfoResponse<>();
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
//数据商品id //数据商品id
if (dataGoodsRequest.getDataGoodsId() != null) { if (goodsListRequest.getDataGoodsId() != null) {
param.put("dataGoodsId", dataGoodsRequest.getDataGoodsId()); param.put("dataGoodsId", goodsListRequest.getDataGoodsId());
} }
//商品分类id(行业) //商品分类id(行业)
if (dataGoodsRequest.getCategoryId() != null) { if (goodsListRequest.getCategoryId() != null) {
param.put("categoryId", dataGoodsRequest.getCategoryId()); param.put("categoryId", goodsListRequest.getCategoryId());
}
//数据商户id
if (dataGoodsRequest.getUserId() != null) {
param.put("userId", dataGoodsRequest.getUserId());
} }
//数据商品名称 //数据商品名称
if (!StringUtils.isEmpty(dataGoodsRequest.getDataName())) { if (!StringUtils.isEmpty(goodsListRequest.getDataName())) {
param.put("dataName", dataGoodsRequest.getDataName()); param.put("dataName", goodsListRequest.getDataName());
} }
//数据类型:01api,02数据包 //数据类型:01api,02数据包
if (!StringUtils.isEmpty(dataGoodsRequest.getDataType())) { if (!StringUtils.isEmpty(goodsListRequest.getDataType())) {
param.put("dataType", dataGoodsRequest.getDataType()); param.put("dataType", goodsListRequest.getDataType());
}
//数据商品标签
if (!StringUtils.isEmpty(dataGoodsRequest.getDataLabel())) {
param.put("dataLabel", dataGoodsRequest.getDataLabel());
}
//数据商品图片
if (!StringUtils.isEmpty(dataGoodsRequest.getDataPicture())) {
param.put("dataPicture", dataGoodsRequest.getDataPicture());
}
//数据商品价格
if (dataGoodsRequest.getDataPrice() != null) {
param.put("dataPrice", dataGoodsRequest.getDataPrice());
}
//优惠价格
if (dataGoodsRequest.getDiscountPrice() != null) {
param.put("discountPrice", dataGoodsRequest.getDiscountPrice());
}
//价格类型:01免费,02收费
if (!StringUtils.isEmpty(dataGoodsRequest.getPriceType())) {
param.put("priceType", dataGoodsRequest.getPriceType());
}
//商品规格
if (!StringUtils.isEmpty(dataGoodsRequest.getGoodsStandards())) {
param.put("goodsStandards", dataGoodsRequest.getGoodsStandards());
} }
//数据状态:01预售,02在售中,03下架,04上架 //数据状态:01预售,02在售中,03下架,04上架
if (!StringUtils.isEmpty(dataGoodsRequest.getDataStatus())) { if (!StringUtils.isEmpty(goodsListRequest.getDataStatus())) {
param.put("dataStatus", dataGoodsRequest.getDataStatus()); param.put("dataStatus", goodsListRequest.getDataStatus());
}
//审核状态:01待审核,02已审核,03未通过
if (!StringUtils.isEmpty(dataGoodsRequest.getAuditStatus())) {
param.put("auditStatus", dataGoodsRequest.getAuditStatus());
}
//清洗规则(脱敏校验)
if (!StringUtils.isEmpty(dataGoodsRequest.getCleanRule())) {
param.put("cleanRule", dataGoodsRequest.getCleanRule());
}
//驳回原因
if (!StringUtils.isEmpty(dataGoodsRequest.getRejectReason())) {
param.put("rejectReason", dataGoodsRequest.getRejectReason());
}
//审核人
if (!StringUtils.isEmpty(dataGoodsRequest.getAuditPerson())) {
param.put("auditPerson", dataGoodsRequest.getAuditPerson());
}
//审核时间起
if (dataGoodsRequest.getAuditTimeStart() != null) {
param.put("auditTimeStart", dataGoodsRequest.getAuditTimeStart());
}
//审核时间止
if (dataGoodsRequest.getAuditTimeEnd() != null) {
param.put("auditTimeEnd", dataGoodsRequest.getAuditTimeEnd());
}
//创建时间起
if (dataGoodsRequest.getCreTimeStart() != null) {
param.put("creTimeStart", dataGoodsRequest.getCreTimeStart());
}
//创建时间止
if (dataGoodsRequest.getCreTimeEnd() != null) {
param.put("creTimeEnd", dataGoodsRequest.getCreTimeEnd());
}
//创建人
if (!StringUtils.isEmpty(dataGoodsRequest.getCrePerson())) {
param.put("crePerson", dataGoodsRequest.getCrePerson());
}
//更新时间起
if (dataGoodsRequest.getUptTimeStart() != null) {
param.put("uptTimeStart", dataGoodsRequest.getUptTimeStart());
}
//更新时间止
if (dataGoodsRequest.getUptTimeEnd() != null) {
param.put("uptTimeEnd", dataGoodsRequest.getUptTimeEnd());
}
//更新人
if (!StringUtils.isEmpty(dataGoodsRequest.getUptPerson())) {
param.put("uptPerson", dataGoodsRequest.getUptPerson());
}
//删除标识
if (!StringUtils.isEmpty(dataGoodsRequest.getDelFlag())) {
param.put("delFlag", dataGoodsRequest.getDelFlag());
}
//年(元)
if (dataGoodsRequest.getYearType() != null) {
param.put("yearType", dataGoodsRequest.getYearType());
}
//季(元)
if (dataGoodsRequest.getSeasonType() != null) {
param.put("seasonType", dataGoodsRequest.getSeasonType());
}
//月(元)
if (dataGoodsRequest.getMonthType() != null) {
param.put("monthType", dataGoodsRequest.getMonthType());
}
//次(元)
if (dataGoodsRequest.getSecondType() != null) {
param.put("secondType", dataGoodsRequest.getSecondType());
} }
PageHelper.startPage(dataGoodsRequest.getPageNum(), dataGoodsRequest.getPageSize()); PageHelper.startPage(goodsListRequest.getPageNum(), goodsListRequest.getPageSize());
List<DataGoodsDto> list = dataGoodsDao.findList(param); List<DataGoodsListDto> list = dataGoodsDao.findList(param);
PageInfo<DataGoodsDto> pageInfo = new PageInfo<>(list); PageInfo<DataGoodsListDto> pageInfo = new PageInfo<>(list);
pageInfoResponse.setCode(Constants.SUCCESS_CODE); pageInfoResponse.setCode(Constants.SUCCESS_CODE);
pageInfoResponse.setMessage("查询成功"); pageInfoResponse.setMessage("查询成功");
......
...@@ -48,92 +48,39 @@ ...@@ -48,92 +48,39 @@
</select> </select>
<!--通过实体作为筛选条件查询--> <!--通过实体作为筛选条件查询-->
<select id="queryAll" resultMap="TDataGoodsMap"> <select id="findList" resultType="com.jz.manage.moduls.controller.goods.bean.dto.DataGoodsListDto" parameterType="map">
select SELECT
data_goods_id, category_id, user_id, data_name, data_type, data_label, data_picture, data_price, discount_price, t1.data_goods_id as dataGoodsId,
price_type, goods_standards, data_status, audit_status, clean_rule, reject_reason, audit_person, audit_time, t1.data_name as dataName,
cre_time, cre_person, upt_time, upt_person, del_flag, year_type, season_type, month_type, second_type (CASE WHEN t1.data_type = '01' then 'api' WHEN t1.data_type = '02' then '数据包' end) dataType,
from t_data_goods t1.category_id as categoryId,
<where> t2.category_name as categoryName,
t1.upt_time as uptTime,
(CASE WHEN t1.data_status = '01' then '预售'
WHEN t1.data_status = '02' then '在售中'
WHEN t1.data_status = '02' then '下架'
WHEN t1.data_status = '02' then '上架' end) dataStatus
FROM
t_data_goods t1 INNER JOIN t_data_goods_category t2 ON t1.category_id = t2. category_id
where
1= 1 and
t1.del_flag = 'N' and
t1.audit_status = '02'
<if test="dataGoodsId != null"> <if test="dataGoodsId != null">
and data_goods_id = #{dataGoodsId} and data_goods_id = #{dataGoodsId}
</if> </if>
<if test="categoryId != null"> <if test="categoryId != null">
and category_id = #{categoryId} and category_id = #{categoryId}
</if> </if>
<if test="userId != null">
and user_id = #{userId}
</if>
<if test="dataName != null and dataName != ''"> <if test="dataName != null and dataName != ''">
and data_name = #{dataName} and data_name like concat('%',#{dataName},'%')
</if> </if>
<if test="dataType != null and dataType != ''"> <if test="dataType != null and dataType != ''">
and data_type = #{dataType} and data_type = #{dataType}
</if> </if>
<if test="dataLabel != null and dataLabel != ''">
and data_label = #{dataLabel}
</if>
<if test="dataPicture != null and dataPicture != ''">
and data_picture = #{dataPicture}
</if>
<if test="dataPrice != null">
and data_price = #{dataPrice}
</if>
<if test="discountPrice != null">
and discount_price = #{discountPrice}
</if>
<if test="priceType != null and priceType != ''">
and price_type = #{priceType}
</if>
<if test="goodsStandards != null and goodsStandards != ''">
and goods_standards = #{goodsStandards}
</if>
<if test="dataStatus != null and dataStatus != ''"> <if test="dataStatus != null and dataStatus != ''">
and data_status = #{dataStatus} and data_status = #{dataStatus}
</if> </if>
<if test="auditStatus != null and auditStatus != ''">
and audit_status = #{auditStatus}
</if>
<if test="cleanRule != null and cleanRule != ''">
and clean_rule = #{cleanRule}
</if>
<if test="rejectReason != null and rejectReason != ''">
and reject_reason = #{rejectReason}
</if>
<if test="auditPerson != null and auditPerson != ''">
and audit_person = #{auditPerson}
</if>
<if test="auditTime != null">
and audit_time = #{auditTime}
</if>
<if test="creTime != null">
and cre_time = #{creTime}
</if>
<if test="crePerson != null and crePerson != ''">
and cre_person = #{crePerson}
</if>
<if test="uptTime != null">
and upt_time = #{uptTime}
</if>
<if test="uptPerson != null and uptPerson != ''">
and upt_person = #{uptPerson}
</if>
<if test="delFlag != null and delFlag != ''">
and del_flag = #{delFlag}
</if>
<if test="yearType != null">
and year_type = #{yearType}
</if>
<if test="seasonType != null">
and season_type = #{seasonType}
</if>
<if test="monthType != null">
and month_type = #{monthType}
</if>
<if test="secondType != null">
and second_type = #{secondType}
</if>
</where>
</select> </select>
<!--新增所有列--> <!--新增所有列-->
......
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