Commit bcac572a authored by 姬鋆屾's avatar 姬鋆屾
parents 76ddda51 06abac86
......@@ -116,3 +116,7 @@ PRIMARY KEY (`id`)
ALTER TABLE mortals_xhx_company ADD COLUMN `background` varchar(256) default '' COMMENT '背景图片';
ALTER TABLE `mortals_xhx_favorites_businesscard` CHANGE `staffId` `bussinesscardId` bigint(20) NOT NULL COMMENT '名片ID, 关联到名片表中的ID,表示这是哪个名片的收藏';
-- ----------------------------
-- 2024-12-26
-- ----------------------------
ALTER TABLE `mortals_xhx_product` ADD COLUMN `shelves` tinyint(1) DEFAULT '1' COMMENT '是否上架(0.否,1.是)';
......@@ -85,6 +85,7 @@ public class ProductApiController extends AbstractBaseController<ProductReq>{
query.setCategoryId(String.valueOf(productReq.getCategoryId()));
}
query.setHot(productReq.getHot());
query.setShelves(1);
query.setOrderColList(Arrays.asList(new OrderCol("publishTime", OrderCol.DESCENDING)));
Result<ProductEntity> result = productService.find(query, pageInfo, context);
List<ProductEntity> collect = result.getList().stream().map(item -> {
......
......@@ -13,11 +13,11 @@ import com.mortals.xhx.module.product.model.vo.ProductVo;
import com.mortals.xhx.module.product.model.ProductQuestionEntity;
import lombok.Data;
/**
* 产品实体对象
*
* @author zxfei
* @date 2023-09-18
*/
* 产品实体对象
*
* @author zxfei
* @date 2024-12-26
*/
@Data
public class ProductEntity extends ProductVo {
private static final long serialVersionUID = 1L;
......@@ -71,6 +71,10 @@ public class ProductEntity extends ProductVo {
* 备注
*/
private String productRemark;
/**
* 是否上架(0.否,1.是)
*/
private Integer shelves;
/**
* 产品常见问题信息
*/
......@@ -111,5 +115,6 @@ public class ProductEntity extends ProductVo {
this.publishTime = new Date();
this.hot = 0;
this.productRemark = "";
this.shelves = 1;
}
}
\ No newline at end of file
......@@ -5,11 +5,11 @@ import java.util.Date;
import java.util.List;
import com.mortals.xhx.module.product.model.ProductEntity;
/**
* 产品查询对象
*
* @author zxfei
* @date 2023-09-18
*/
* 产品查询对象
*
* @author zxfei
* @date 2024-12-26
*/
public class ProductQuery extends ProductEntity {
/** 开始 主键ID,主键,自增长 */
private Long idStart;
......@@ -139,6 +139,21 @@ public class ProductQuery extends ProductEntity {
/** 结束 更新时间 */
private String updateTimeEnd;
/** 开始 是否上架(0.否,1.是) */
private Integer shelvesStart;
/** 结束 是否上架(0.否,1.是) */
private Integer shelvesEnd;
/** 增加 是否上架(0.否,1.是) */
private Integer shelvesIncrement;
/** 是否上架(0.否,1.是)列表 */
private List <Integer> shelvesList;
/** 是否上架(0.否,1.是)排除列表 */
private List <Integer> shelvesNotList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<ProductQuery> orConditionList;
......@@ -887,6 +902,87 @@ public class ProductQuery extends ProductEntity {
this.updateTimeEnd = updateTimeEnd;
}
/**
* 获取 开始 是否上架(0.否,1.是)
* @return shelvesStart
*/
public Integer getShelvesStart(){
return this.shelvesStart;
}
/**
* 设置 开始 是否上架(0.否,1.是)
* @param shelvesStart
*/
public void setShelvesStart(Integer shelvesStart){
this.shelvesStart = shelvesStart;
}
/**
* 获取 结束 是否上架(0.否,1.是)
* @return $shelvesEnd
*/
public Integer getShelvesEnd(){
return this.shelvesEnd;
}
/**
* 设置 结束 是否上架(0.否,1.是)
* @param shelvesEnd
*/
public void setShelvesEnd(Integer shelvesEnd){
this.shelvesEnd = shelvesEnd;
}
/**
* 获取 增加 是否上架(0.否,1.是)
* @return shelvesIncrement
*/
public Integer getShelvesIncrement(){
return this.shelvesIncrement;
}
/**
* 设置 增加 是否上架(0.否,1.是)
* @param shelvesIncrement
*/
public void setShelvesIncrement(Integer shelvesIncrement){
this.shelvesIncrement = shelvesIncrement;
}
/**
* 获取 是否上架(0.否,1.是)
* @return shelvesList
*/
public List<Integer> getShelvesList(){
return this.shelvesList;
}
/**
* 设置 是否上架(0.否,1.是)
* @param shelvesList
*/
public void setShelvesList(List<Integer> shelvesList){
this.shelvesList = shelvesList;
}
/**
* 获取 是否上架(0.否,1.是)
* @return shelvesNotList
*/
public List<Integer> getShelvesNotList(){
return this.shelvesNotList;
}
/**
* 设置 是否上架(0.否,1.是)
* @param shelvesNotList
*/
public void setShelvesNotList(List<Integer> shelvesNotList){
this.shelvesNotList = shelvesNotList;
}
/**
* 设置 主键ID,主键,自增长
* @param id
......@@ -1296,6 +1392,60 @@ public class ProductQuery extends ProductEntity {
}
/**
* 设置 是否上架(0.否,1.是)
* @param shelves
*/
public ProductQuery shelves(Integer shelves){
setShelves(shelves);
return this;
}
/**
* 设置 开始 是否上架(0.否,1.是)
* @param shelvesStart
*/
public ProductQuery shelvesStart(Integer shelvesStart){
this.shelvesStart = shelvesStart;
return this;
}
/**
* 设置 结束 是否上架(0.否,1.是)
* @param shelvesEnd
*/
public ProductQuery shelvesEnd(Integer shelvesEnd){
this.shelvesEnd = shelvesEnd;
return this;
}
/**
* 设置 增加 是否上架(0.否,1.是)
* @param shelvesIncrement
*/
public ProductQuery shelvesIncrement(Integer shelvesIncrement){
this.shelvesIncrement = shelvesIncrement;
return this;
}
/**
* 设置 是否上架(0.否,1.是)
* @param shelvesList
*/
public ProductQuery shelvesList(List<Integer> shelvesList){
this.shelvesList = shelvesList;
return this;
}
/**
* 设置 是否上架(0.否,1.是)
* @param shelvesNotList
*/
public ProductQuery shelvesNotList(List<Integer> shelvesNotList){
this.shelvesNotList = shelvesNotList;
return this;
}
/**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList
......
......@@ -76,7 +76,9 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
//过滤热门与非热门
productList = productList.stream().filter(f -> f.getHot() == hot).collect(Collectors.toList());
}
productList = productList.stream().filter(f -> f.getShelves() == 1).collect(Collectors.toList());
productList = productList.stream().sorted(Comparator.comparing(ProductEntity::getPublishTime).reversed())
.collect(Collectors.toList());
productEntityResult.setList(productList);
productEntityResult.setPageInfo(productCategoryResult.getPageInfo());
productEntityResult.setDict(productCategoryResult.getDict());
......@@ -90,6 +92,9 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
//过滤热门与非热门
productList = productList.stream().filter(f -> f.getHot() == hot).collect(Collectors.toList());
}
productList = productList.stream().filter(f -> f.getShelves() == 1).collect(Collectors.toList());
productList = productList.stream().sorted(Comparator.comparing(ProductEntity::getPublishTime).reversed())
.collect(Collectors.toList());
productEntityResult.setList(productList);
productEntityResult.setPageInfo(companyProductEntityResult.getPageInfo());
productEntityResult.setDict(companyProductEntityResult.getDict());
......@@ -108,6 +113,9 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
//过滤热门与非热门
collect = collect.stream().filter(f -> f.getHot() == hot).collect(Collectors.toList());
}
collect = collect.stream().filter(f -> f.getShelves() == 1).collect(Collectors.toList());
collect = collect.stream().sorted(Comparator.comparing(ProductEntity::getPublishTime).reversed())
.collect(Collectors.toList());
productEntityResult.setList(collect);
pageInfo.setTotalResult(collect.size());
productEntityResult.setPageInfo(pageInfo);
......@@ -150,6 +158,7 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
}
});
}
productList = productList.stream().filter(f -> f.getShelves() == 1).collect(Collectors.toList());
productList = productList.stream().sorted(Comparator.comparing(ProductEntity::getPublishTime).reversed())
.collect(Collectors.toList());
return productList;
......
......@@ -74,6 +74,7 @@ public class ProductController extends BaseCRUDJsonBodyMappingController<Product
this.addDict(model, "hot", YesNoEnum.getEnumMap());
this.addDict(model, "categoryId", categoryService.find(new CategoryQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getName(), (o, n) -> n)));
this.addDict(model, "companyId", companyService.find(new CompanyQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getCompanyName(), (o, n) -> n)));
this.addDict(model, "shelves", YesNoEnum.getEnumMap());
super.init(model, context);
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.product.dao.ibatis.ProductDaoImpl">
<!-- 字段和属性映射 -->
......@@ -22,19 +22,8 @@
<result property="createTime" column="createTime" />
<result property="updateUserId" column="updateUserId" />
<result property="updateTime" column="updateTime" />
<collection property="productQuestionList" column="id" ofType="ProductQuestionEntity" javaType="ArrayList" select="getProductQuestionByProductId"></collection>
<result property="shelves" column="shelves" />
</resultMap>
<resultMap type="ProductQuestionEntity" id="ProductQuestionEntity-Map">
<result property="id" column="id" />
<result property="productId" column="productId" />
<result property="productName" column="productName" />
<result property="question" column="question" />
<result property="answer" column="answer" />
<result property="createTime" column="createTime" />
<result property="createUserId" column="createUserId" />
<result property="updateTime" column="updateTime" />
</resultMap>
<!-- 表所有列 -->
<sql id="_columns">
......@@ -90,6 +79,9 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))">
a.updateTime,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('shelves') or colPickMode == 1 and data.containsKey('shelves')))">
a.shelves,
</if>
</trim>
</sql>
<!-- 子表所有列 -->
......@@ -101,18 +93,18 @@
<!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="ProductEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_xhx_product
(productName,productCode,productSlogan,productLogoPath,productFacePath,productVideoPath,productPicPath,productIntroduction,productDetail,publishTime,hot,productRemark,createUserId,createTime,updateUserId,updateTime)
(productName,productCode,productSlogan,productLogoPath,productFacePath,productVideoPath,productPicPath,productIntroduction,productDetail,publishTime,hot,productRemark,createUserId,createTime,updateUserId,updateTime,shelves)
VALUES
(#{productName},#{productCode},#{productSlogan},#{productLogoPath},#{productFacePath},#{productVideoPath},#{productPicPath},#{productIntroduction},#{productDetail},#{publishTime},#{hot},#{productRemark},#{createUserId},#{createTime},#{updateUserId},#{updateTime})
(#{productName},#{productCode},#{productSlogan},#{productLogoPath},#{productFacePath},#{productVideoPath},#{productPicPath},#{productIntroduction},#{productDetail},#{publishTime},#{hot},#{productRemark},#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{shelves})
</insert>
<!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto">
insert into mortals_xhx_product
(productName,productCode,productSlogan,productLogoPath,productFacePath,productVideoPath,productPicPath,productIntroduction,productDetail,publishTime,hot,productRemark,createUserId,createTime,updateUserId,updateTime)
(productName,productCode,productSlogan,productLogoPath,productFacePath,productVideoPath,productPicPath,productIntroduction,productDetail,publishTime,hot,productRemark,createUserId,createTime,updateUserId,updateTime,shelves)
VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.productName},#{item.productCode},#{item.productSlogan},#{item.productLogoPath},#{item.productFacePath},#{item.productVideoPath},#{item.productPicPath},#{item.productIntroduction},#{item.productDetail},#{item.publishTime},#{item.hot},#{item.productRemark},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime})
(#{item.productName},#{item.productCode},#{item.productSlogan},#{item.productLogoPath},#{item.productFacePath},#{item.productVideoPath},#{item.productPicPath},#{item.productIntroduction},#{item.productDetail},#{item.publishTime},#{item.hot},#{item.productRemark},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime},#{item.shelves})
</foreach>
</insert>
......@@ -179,6 +171,12 @@
<if test="(colPickMode==0 and data.containsKey('updateTime')) or (colPickMode==1 and !data.containsKey('updateTime'))">
a.updateTime=#{data.updateTime},
</if>
<if test="(colPickMode==0 and data.containsKey('shelves')) or (colPickMode==1 and !data.containsKey('shelves'))">
a.shelves=#{data.shelves},
</if>
<if test="(colPickMode==0 and data.containsKey('shelvesIncrement')) or (colPickMode==1 and !data.containsKey('shelvesIncrement'))">
a.shelves=ifnull(a.shelves,0) + #{data.shelvesIncrement},
</if>
</trim>
<trim suffixOverrides="where" suffix="">
where
......@@ -318,6 +316,18 @@
</if>
</foreach>
</trim>
<trim prefix="shelves=(case" suffix="ELSE shelves end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<choose>
<when test="(colPickMode==0 and item.containsKey('shelves')) or (colPickMode==1 and !item.containsKey('shelves'))">
when a.id=#{item.id} then #{item.shelves}
</when>
<when test="(colPickMode==0 and item.containsKey('shelvesIncrement')) or (colPickMode==1 and !item.containsKey('shelvesIncrement'))">
when a.id=#{item.id} then ifnull(a.shelves,0) + #{item.shelvesIncrement}
</when>
</choose>
</foreach>
</trim>
</trim>
where id in
<foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
......@@ -379,13 +389,6 @@
<include refid="_orderCols_"/>
</select>
<!-- 获取子列表 -->
<select id="getProductQuestionByProductId" parameterType="java.lang.Long" resultMap="ProductQuestionEntity-Map">
select <include refid="_columns_sub"/>
from mortals_xhx_product_question as b
<trim suffixOverrides="where" suffix="">
where b.productId = #{id}
</trim>
</select>
......@@ -437,6 +440,10 @@
<!-- 条件映射-代参数 -->
<sql id="_condition_param_">
<bind name="conditionParamRef" value="${_conditionParam_}"/>
<if test="permissionSql != null and permissionSql != ''">
${permissionSql}
</if>
<if test="conditionParamRef.containsKey('id')">
<if test="conditionParamRef.id != null">
${_conditionType_} a.id=#{${_conditionParam_}.id}
......@@ -805,18 +812,115 @@
<if test="conditionParamRef.containsKey('updateTimeEnd') and conditionParamRef.updateTimeEnd != null and conditionParamRef.updateTimeEnd!=''">
${_conditionType_} a.updateTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.updateTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
</if>
<if test="conditionParamRef.containsKey('shelves')">
<if test="conditionParamRef.shelves != null ">
${_conditionType_} a.shelves = #{${_conditionParam_}.shelves}
</if>
<if test="conditionParamRef.shelves == null">
${_conditionType_} a.shelves is null
</if>
</if>
<if test="conditionParamRef.containsKey('shelvesList') and conditionParamRef.shelvesList.size() > 0">
${_conditionType_} a.shelves in
<foreach collection="conditionParamRef.shelvesList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('shelvesNotList') and conditionParamRef.shelvesNotList.size() > 0">
${_conditionType_} a.shelves not in
<foreach collection="conditionParamRef.shelvesNotList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('shelvesStart') and conditionParamRef.shelvesStart != null">
${_conditionType_} a.shelves <![CDATA[ >= ]]> #{${_conditionParam_}.shelvesStart}
</if>
<if test="conditionParamRef.containsKey('shelvesEnd') and conditionParamRef.shelvesEnd != null">
${_conditionType_} a.shelves <![CDATA[ <= ]]> #{${_conditionParam_}.shelvesEnd}
</if>
</sql>
<sql id="_orderCols_">
<if test="orderColList != null and !orderColList.isEmpty()">
order by
<if test="conditionParamRef.containsKey('idList') and conditionParamRef.idList.size() > 0">
field(a.id,
<foreach collection="conditionParamRef.idList" open="" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
,
</if>
<if test="conditionParamRef.containsKey('hotList') and conditionParamRef.hotList.size() > 0">
field(a.hot,
<foreach collection="conditionParamRef.hotList" open="" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
,
</if>
<if test="conditionParamRef.containsKey('createUserIdList') and conditionParamRef.createUserIdList.size() > 0">
field(a.createUserId,
<foreach collection="conditionParamRef.createUserIdList" open="" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
,
</if>
<if test="conditionParamRef.containsKey('updateUserIdList') and conditionParamRef.updateUserIdList.size() > 0">
field(a.updateUserId,
<foreach collection="conditionParamRef.updateUserIdList" open="" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
,
</if>
<if test="conditionParamRef.containsKey('shelvesList') and conditionParamRef.shelvesList.size() > 0">
field(a.shelves,
<foreach collection="conditionParamRef.shelvesList" open="" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
,
</if>
<trim suffixOverrides="," suffix="">
<foreach collection="orderColList" open="" close="" index="index" item="item" separator=",">
${item.colName} ${item.sortKind}
a.${item.colName} ${item.sortKind}
</foreach>
</trim>
</if>
<if test="(orderColList == null or orderColList.isEmpty()) and orderCol != null and !orderCol.isEmpty()">
order by
<if test="conditionParamRef.containsKey('idList') and conditionParamRef.idList.size() > 0">
field(a.id,
<foreach collection="conditionParamRef.idList" open="" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
,
</if>
<if test="conditionParamRef.containsKey('hotList') and conditionParamRef.hotList.size() > 0">
field(a.hot,
<foreach collection="conditionParamRef.hotList" open="" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
,
</if>
<if test="conditionParamRef.containsKey('createUserIdList') and conditionParamRef.createUserIdList.size() > 0">
field(a.createUserId,
<foreach collection="conditionParamRef.createUserIdList" open="" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
,
</if>
<if test="conditionParamRef.containsKey('updateUserIdList') and conditionParamRef.updateUserIdList.size() > 0">
field(a.updateUserId,
<foreach collection="conditionParamRef.updateUserIdList" open="" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
,
</if>
<if test="conditionParamRef.containsKey('shelvesList') and conditionParamRef.shelvesList.size() > 0">
field(a.shelves,
<foreach collection="conditionParamRef.shelvesList" open="" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
,
</if>
<trim suffixOverrides="," suffix="">
<if test="orderCol.containsKey('id')">
a.id
......@@ -903,8 +1007,15 @@
<if test='orderCol.updateTime != null and "DESC".equalsIgnoreCase(orderCol.updateTime)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('shelves')">
a.shelves
<if test='orderCol.shelves != null and "DESC".equalsIgnoreCase(orderCol.shelves)'>DESC</if>
,
</if>
</trim>
</if>
</sql>
<sql id="_group_by_">
<if test="groupList != null and !groupList.isEmpty()">
......
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