Commit dc4f8a71 authored by ysongq's avatar ysongq

commit

parent 88ea3b2e
...@@ -41,8 +41,7 @@ public class DataGoodsApiController extends BaseController { ...@@ -41,8 +41,7 @@ public class DataGoodsApiController extends BaseController {
@ApiOperation(value = "点击商品查看商品详情", notes = "api商品") @ApiOperation(value = "点击商品查看商品详情", notes = "api商品")
public Result<DataGoodsApiDto> findById(@PathVariable(value = "id") String id) { public Result<DataGoodsApiDto> findById(@PathVariable(value = "id") String id) {
if (id != null) { if (id != null) {
Long key = Long.valueOf(id); DataGoodsApiDto dataGoodsApi = tDataGoodsApiService.selectById(Long.valueOf(id));
DataGoodsApiDto dataGoodsApi = tDataGoodsApiService.selectById(key);
return new Result<DataGoodsApiDto>(true, "查询商品详情成功!", StatusCode.OK, dataGoodsApi); return new Result<DataGoodsApiDto>(true, "查询商品详情成功!", StatusCode.OK, dataGoodsApi);
} }
return new Result<>(false, "查询商品详情失败!"); return new Result<>(false, "查询商品详情失败!");
......
package com.jz.dm.mall.moduls.controller.goods;
import com.jz.common.base.BaseController;
import com.jz.common.utils.Result;
import com.jz.common.utils.StatusCode;
import com.jz.dm.mall.moduls.controller.goods.bean.dto.MallHotRecommendGoodsDto;
import com.jz.dm.mall.moduls.service.MallHotRecommendGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 热门推荐商品(TMallHotRecommendGoods)表控制层
*
* @author Bellamy
* @since 2020-12-01 10:41:40
*/
@RestController
@RequestMapping("mallHotRecommendGoods")
@Api(tags = "热门商品api")
public class MallHotRecommendGoodsController extends BaseController {
/**
* 服务对象
*/
@Autowired
private MallHotRecommendGoodsService tMallHotRecommendGoodsService;
@GetMapping(value = "/popularApi")
@ApiOperation(value = "热门商品api", notes = "热门商品api展示")
public Result<MallHotRecommendGoodsDto> popularApi() {
MallHotRecommendGoodsDto popularApi = tMallHotRecommendGoodsService.selectByPopularApi();
return new Result<>(true, "查询热门api成功", StatusCode.OK, popularApi);
}
}
\ No newline at end of file
package com.jz.dm.mall.moduls.controller.goods.bean.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @ClassName:
* @Author: Carl
* @Date: 2020/12/9
* @Version:
*/
@ApiModel("热门商品api")
public class MallHotRecommendGoodsDto {
@ApiModelProperty(value = "数据商品id")
private Long dataGoodsId;
@ApiModelProperty(value = "数据商品名称")
private String dataName;
@ApiModelProperty(value = "数据商品类型")
private String dataType;
@ApiModelProperty(value = "数据商品标签")
private String dataLabel;
@ApiModelProperty(value = "数据商品图片")
private String dataPicture;
@ApiModelProperty(value = "数据商品价格")
private String dataPrice;
@ApiModelProperty(value = "优惠价格")
private String discountPrice;
@ApiModelProperty(value = "用户使用人数")
private Long customer;
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 String getDataLabel() {
return dataLabel;
}
public void setDataLabel(String dataLabel) {
this.dataLabel = dataLabel;
}
public String getDataPicture() {
return dataPicture;
}
public void setDataPicture(String dataPicture) {
this.dataPicture = dataPicture;
}
public String getDataPrice() {
return dataPrice;
}
public void setDataPrice(String dataPrice) {
this.dataPrice = dataPrice;
}
public String getDiscountPrice() {
return discountPrice;
}
public void setDiscountPrice(String discountPrice) {
this.discountPrice = discountPrice;
}
public Long getCustomer() {
return customer;
}
public void setCustomer(Long customer) {
this.customer = customer;
}
}
package com.jz.dm.mall.moduls.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import java.io.Serializable;
import java.util.Date;
/**
* 热门推荐商品(TMallHotRecommendGoods)实体类
*
* @author Bellamy
* @since 2020-12-01 10:41:40
*/
@TableName("t_mall_hot_recommend_goods")
@ApiModel
public class MallHotRecommendGoods implements Serializable {
private static final long serialVersionUID = -35734333969077853L;
/**
* 热门推荐商品id
*/
private Long hotRecommendGoods;
/**
* 数据id
*/
private Long dataGoodsId;
/**
* 用户id
*/
private Long customerId;
/**
* 删除标识:Y是,N否
*/
private String delFlag;
/**
* 创建时间
*/
private Date creTime;
public Long getHotRecommendGoods() {
return hotRecommendGoods;
}
public void setHotRecommendGoods(Long hotRecommendGoods) {
this.hotRecommendGoods = hotRecommendGoods;
}
public Long getDataGoodsId() {
return dataGoodsId;
}
public void setDataGoodsId(Long dataGoodsId) {
this.dataGoodsId = dataGoodsId;
}
public Long getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
this.customerId = customerId;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public Date getCreTime() {
return creTime;
}
public void setCreTime(Date creTime) {
this.creTime = creTime;
}
}
\ No newline at end of file
package com.jz.dm.mall.moduls.mapper;
import com.jz.common.base.BaseMapper;
import com.jz.dm.mall.moduls.controller.goods.bean.dto.MallHotRecommendGoodsDto;
import com.jz.dm.mall.moduls.entity.MallHotRecommendGoods;
/**
* 热门推荐商品(TMallHotRecommendGoods)表数据库访问层
*
* @author Bellamy
* @since 2020-12-01 10:41:40
*/
public interface MallHotRecommendGoodsDao extends BaseMapper<MallHotRecommendGoods> {
MallHotRecommendGoodsDto selectByPopularApi();
}
\ No newline at end of file
package com.jz.dm.mall.moduls.service;
import com.jz.dm.mall.moduls.controller.goods.bean.dto.MallHotRecommendGoodsDto;
/**
* 热门推荐商品(TMallHotRecommendGoods)表服务接口
*
* @author Bellamy
* @since 2020-12-01 10:41:40
*/
public interface MallHotRecommendGoodsService {
/**
* 查询热门api数据
* @return
*/
MallHotRecommendGoodsDto selectByPopularApi();
}
\ No newline at end of file
package com.jz.dm.mall.moduls.service.impl;
import com.jz.dm.mall.moduls.controller.goods.bean.dto.MallHotRecommendGoodsDto;
import com.jz.dm.mall.moduls.mapper.MallHotRecommendGoodsDao;
import com.jz.dm.mall.moduls.service.MallHotRecommendGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 热门推荐商品(TMallHotRecommendGoods)表服务实现类
*
* @author Bellamy
* @since 2020-12-01 10:41:40
*/
@Service("mallHotRecommendGoodsService")
public class MallHotRecommendGoodsServiceImpl implements MallHotRecommendGoodsService {
@Autowired
private MallHotRecommendGoodsDao tMallHotRecommendGoodsDao;
/**
* 查询热门api数据
*
* @return
*/
@Override
public MallHotRecommendGoodsDto selectByPopularApi() {
MallHotRecommendGoodsDto popularApi = tMallHotRecommendGoodsDao.selectByPopularApi();
return popularApi;
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jz.dm.mall.moduls.mapper.MallHotRecommendGoodsDao">
<resultMap type="com.jz.dm.mall.moduls.entity.MallHotRecommendGoods" id="TMallHotRecommendGoodsMap">
<result property="hotRecommendGoods" column="hot_recommend_goods" jdbcType="INTEGER"/>
<result property="dataGoodsId" column="data_goods_id" jdbcType="INTEGER"/>
<result property="customerId" column="customer_id" jdbcType="INTEGER"/>
<result property="delFlag" column="del_flag" jdbcType="VARCHAR"/>
<result property="creTime" column="cre_time" jdbcType="TIMESTAMP"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="TMallHotRecommendGoodsMap">
select
hot_recommend_goods, data_goods_id, customer_id, del_flag, cre_time
from t_mall_hot_recommend_goods
where hot_recommend_goods = #{hotRecommendGoods}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="TMallHotRecommendGoodsMap">
select
hot_recommend_goods, data_goods_id, customer_id, del_flag, cre_time
from t_mall_hot_recommend_goods
limit #{offset}, #{limit}
</select>
<!--通过实体作为筛选条件查询-->
<select id="queryAll" resultMap="TMallHotRecommendGoodsMap">
select
hot_recommend_goods, data_goods_id, customer_id, del_flag, cre_time
from t_mall_hot_recommend_goods
<where>
<if test="hotRecommendGoods != null">
and hot_recommend_goods = #{hotRecommendGoods}
</if>
<if test="dataGoodsId != null">
and data_goods_id = #{dataGoodsId}
</if>
<if test="customerId != null">
and customer_id = #{customerId}
</if>
<if test="delFlag != null and delFlag != ''">
and del_flag = #{delFlag}
</if>
<if test="creTime != null">
and cre_time = #{creTime}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="hotRecommendGoods" useGeneratedKeys="true">
insert into t_mall_hot_recommend_goods(data_goods_id, customer_id, del_flag, cre_time)
values (#{dataGoodsId}, #{customerId}, #{delFlag}, #{creTime})
</insert>
<insert id="insertBatch" keyProperty="hotRecommendGoods" useGeneratedKeys="true">
insert into t_mall_hot_recommend_goods(data_goods_id, customer_id, del_flag, cre_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.dataGoodsId}, #{entity.customerId}, #{entity.delFlag}, #{entity.creTime})
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
update t_mall_hot_recommend_goods
<set>
<if test="dataGoodsId != null">
data_goods_id = #{dataGoodsId},
</if>
<if test="customerId != null">
customer_id = #{customerId},
</if>
<if test="delFlag != null and delFlag != ''">
del_flag = #{delFlag},
</if>
<if test="creTime != null">
cre_time = #{creTime},
</if>
</set>
where hot_recommend_goods = #{hotRecommendGoods}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from t_mall_hot_recommend_goods where hot_recommend_goods = #{hotRecommendGoods}
</delete>
<select id="selectByPopularApi" parameterType="map" resultType="com.jz.dm.mall.moduls.controller.goods.bean.dto.DataGoodsApiDto">
SELECT
t1.data_goods_id as dataGoodsId ,
t1.data_name as dataName,
t1.data_type as dataTYpe,
t1.data_label as dataLabel,
t1.data_picture as dataPicture,
t1.data_price as dataPrice,
t1.discount_price as discountPrice,
(CASE when t1.price_type = '01' then '免费' when t1.price_type = '02' then '收费' end) priceType,
count(customer_id) as customer
FROM
t_data_goods t1
INNER JOIN t_mall_hot_recommend_goods t2 ON t1.data_goods_id = t2.data_goods_id
where
1=1 and
t1.del_flag = 'N' and
t1.data_status = '02'
group by t1.data_goods_id
order by customer desc
</select>
</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