parent
7f2384fcc6
commit
fedc957502
@ -0,0 +1,148 @@ |
||||
package com.cjy.back.ybsjCommodityManage.controller; |
||||
|
||||
import com.cjy.back.sysUser.entity.SysUser; |
||||
|
||||
import com.cjy.back.ybsjCommodityManage.entity.CommodityInfo; |
||||
import com.cjy.back.ybsjCommodityManage.service.CommodityInfoService; |
||||
import com.cjy.util.ServerResponse; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @author liangjiawei |
||||
* @createDate 2023/8/29 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("commodityInfo") |
||||
public class CommodityInfoController { |
||||
@Autowired |
||||
CommodityInfoService commodityInfoService; |
||||
|
||||
/** |
||||
* 添加商品 |
||||
* |
||||
* @param request |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
@RequestMapping("add") |
||||
public ServerResponse addCommodityInfo(HttpServletRequest request, @RequestBody CommodityInfo commodityInfo) { |
||||
SysUser user = (SysUser) request.getSession().getAttribute("admin"); |
||||
if (user == null) { |
||||
return ServerResponse.createByError("请重新登陆"); |
||||
} |
||||
commodityInfo.setCreateBy(user.getUserid().toString()); |
||||
return commodityInfoService.addCommodityInfo(commodityInfo); |
||||
} |
||||
|
||||
/** |
||||
* 修改商品 |
||||
* |
||||
* @param request |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
@RequestMapping("update") |
||||
public ServerResponse updateCommodityInfo(HttpServletRequest request, @RequestBody CommodityInfo commodityInfo) { |
||||
SysUser user = (SysUser) request.getSession().getAttribute("admin"); |
||||
if (user == null) { |
||||
return ServerResponse.createByError("请重新登陆"); |
||||
} |
||||
commodityInfo.setUpdateBy(user.getUserid().toString()); |
||||
commodityInfo.setUpdateTime(new Date()); |
||||
return commodityInfoService.updateCommodityInfo(commodityInfo); |
||||
} |
||||
|
||||
/** |
||||
* 删除商品 |
||||
* |
||||
* @param request |
||||
* @param commodityId |
||||
* @return |
||||
*/ |
||||
@RequestMapping("delete") |
||||
public ServerResponse deleteCommodityInfo(HttpServletRequest request, String commodityId) { |
||||
SysUser user = (SysUser) request.getSession().getAttribute("admin"); |
||||
if (user == null) { |
||||
return ServerResponse.createByError("请重新登陆"); |
||||
} |
||||
CommodityInfo commodityInfo = new CommodityInfo(); |
||||
commodityInfo.setUpdateBy(user.getUserid().toString()); |
||||
commodityInfo.setUpdateTime(new Date()); |
||||
commodityInfo.setCommodityId(commodityId); |
||||
return commodityInfoService.deleteCommodityInfo(commodityInfo); |
||||
} |
||||
|
||||
/** |
||||
* 通过id获取商品详情 |
||||
* |
||||
* @param request |
||||
* @param commodityId |
||||
* @return |
||||
*/ |
||||
@RequestMapping("getCommodityInfoById") |
||||
public ServerResponse getCommodityInfoById(HttpServletRequest request, String commodityId) { |
||||
SysUser user = (SysUser) request.getSession().getAttribute("admin"); |
||||
if (user == null) { |
||||
return ServerResponse.createByError("请重新登陆"); |
||||
} |
||||
|
||||
return commodityInfoService.getCommodityInfoById(commodityId); |
||||
} |
||||
|
||||
/** |
||||
* 获取商品列表 |
||||
* |
||||
* @param request |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
@RequestMapping("getCommodityInfoList") |
||||
public ServerResponse getCommodityInfoList(HttpServletRequest request, @RequestBody CommodityInfo commodityInfo) { |
||||
SysUser user = (SysUser) request.getSession().getAttribute("admin"); |
||||
if (user == null) { |
||||
return ServerResponse.createByError("请重新登陆"); |
||||
} |
||||
|
||||
return commodityInfoService.getCommodityInfoList(commodityInfo); |
||||
} |
||||
|
||||
/** |
||||
* 修改排序字段 |
||||
* |
||||
* @param request |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
@RequestMapping("updateSort") |
||||
public ServerResponse updateSort(HttpServletRequest request, @RequestBody CommodityInfo commodityInfo) { |
||||
SysUser user = (SysUser) request.getSession().getAttribute("admin"); |
||||
if (user == null) { |
||||
return ServerResponse.createByError("请重新登陆"); |
||||
} |
||||
|
||||
return commodityInfoService.updateSort(commodityInfo); |
||||
} |
||||
|
||||
/** |
||||
* 修改推荐字段 |
||||
* |
||||
* @param request |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
@RequestMapping("updateRecommendState") |
||||
public ServerResponse updateRecommendState(HttpServletRequest request, @RequestBody CommodityInfo commodityInfo) { |
||||
SysUser user = (SysUser) request.getSession().getAttribute("admin"); |
||||
if (user == null) { |
||||
return ServerResponse.createByError("请重新登陆"); |
||||
} |
||||
|
||||
return commodityInfoService.updateRecommendState(commodityInfo); |
||||
} |
||||
} |
@ -0,0 +1,57 @@ |
||||
package com.cjy.back.ybsjCommodityManage.controller; |
||||
|
||||
import com.cjy.back.sysUser.entity.SysUser; |
||||
import com.cjy.back.ybsjCommodityManage.entity.CommodityOpenUrlStatistics; |
||||
import com.cjy.back.ybsjCommodityManage.service.CommodityInfoService; |
||||
import com.cjy.util.ServerResponse; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
|
||||
/** |
||||
* @author liangjiawei |
||||
* @createDate 2023/8/29 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("commodityOpenUrlStatistics") |
||||
public class CommodityOpenUrlStatisticsController { |
||||
@Autowired |
||||
CommodityInfoService commodityInfoService; |
||||
|
||||
/** |
||||
* 统计数据添加 |
||||
* @param request |
||||
* @param commodityId |
||||
* @return |
||||
*/ |
||||
@RequestMapping("add") |
||||
public ServerResponse addCommodityOpenUrlStatistics(HttpServletRequest request,String commodityId) { |
||||
SysUser user = (SysUser) request.getSession().getAttribute("admin"); |
||||
if (user == null) { |
||||
return ServerResponse.createByError("请重新登陆"); |
||||
} |
||||
CommodityOpenUrlStatistics commodityOpenUrlStatistics=new CommodityOpenUrlStatistics(); |
||||
commodityOpenUrlStatistics.setCommodityId(commodityId); |
||||
return commodityInfoService.addCommodityOpenUrlStatistics(commodityOpenUrlStatistics); |
||||
} |
||||
|
||||
/** |
||||
* 搜索 |
||||
* @param request |
||||
* @param commodityOpenUrlStatistics |
||||
* @return |
||||
*/ |
||||
@RequestMapping("getCommodityOpenUrlStatisticsList") |
||||
public ServerResponse getCommodityOpenUrlStatisticsList(HttpServletRequest request,@RequestBody CommodityOpenUrlStatistics commodityOpenUrlStatistics) { |
||||
SysUser user = (SysUser) request.getSession().getAttribute("admin"); |
||||
if (user == null) { |
||||
return ServerResponse.createByError("请重新登陆"); |
||||
} |
||||
|
||||
return commodityInfoService.getCommodityOpenUrlStatisticsList(commodityOpenUrlStatistics); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,106 @@ |
||||
package com.cjy.back.ybsjCommodityManage.dao; |
||||
|
||||
import com.cjy.back.ybsjCommodityManage.entity.CommodityInfo; |
||||
import com.cjy.back.ybsjCommodityManage.entity.CommodityOpenUrlStatistics; |
||||
import com.cjy.common.mybatis.page.PageParameter; |
||||
import com.cjy.util.ServerResponse; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author liangjiawei |
||||
* @createDate 2023/8/29 |
||||
*/ |
||||
public interface CommodityInfoMapper { |
||||
/** |
||||
* 添加商品 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
int addCommodityInfo(CommodityInfo commodityInfo); |
||||
|
||||
/** |
||||
* 修改商品 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
int updateCommodityInfo(CommodityInfo commodityInfo); |
||||
|
||||
/** |
||||
* 删除商品 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
int deleteCommodityInfo(CommodityInfo commodityInfo); |
||||
|
||||
/** |
||||
* 通过id获取商品详情 |
||||
* |
||||
* @param commodityId |
||||
* @return |
||||
*/ |
||||
CommodityInfo getCommodityInfoById(String commodityId); |
||||
|
||||
/** |
||||
* 获取商品列表 |
||||
* |
||||
* @param page |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
List<Map<String, Object>> queryCommodityInfoListByPage(@Param("page") PageParameter page, @Param("commodityInfo") CommodityInfo commodityInfo); |
||||
|
||||
/*** |
||||
* 搜索 |
||||
* @param page |
||||
* @param commodityOpenUrlStatistics |
||||
* @return |
||||
*/ |
||||
List<Map<String, Object>> queryCommodityOpenUrlStatisticsListByPage(@Param("page") PageParameter page, @Param("commodityOpenUrlStatistics") CommodityOpenUrlStatistics commodityOpenUrlStatistics); |
||||
|
||||
/** |
||||
* 修改排序字段 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
int updateSort(CommodityInfo commodityInfo); |
||||
|
||||
/** |
||||
* 修改推荐字段 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
int updateRecommendState(CommodityInfo commodityInfo); |
||||
|
||||
/** |
||||
* 添加统计数据 |
||||
* |
||||
* @param |
||||
* @return |
||||
*/ |
||||
int addCommodityOpenUrlStatistics(CommodityOpenUrlStatistics commodityOpenUrlStatistics); |
||||
|
||||
/** |
||||
* 修改统计数据 |
||||
* |
||||
* @param |
||||
* @return |
||||
*/ |
||||
int updateCommodityOpenUrlStatistics(CommodityOpenUrlStatistics commodityOpenUrlStatistics); |
||||
|
||||
/** |
||||
* 通过商品id和日期判断是否有数据 |
||||
* |
||||
* @param commodityOpenUrlStatistics |
||||
* @return |
||||
*/ |
||||
int getCommodityOpenUrlStatistics(CommodityOpenUrlStatistics commodityOpenUrlStatistics); |
||||
|
||||
} |
@ -0,0 +1,109 @@ |
||||
<?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.cjy.back.ybsjCommodityManage.dao.CommodityInfoMapper"> |
||||
|
||||
<insert id="addCommodityInfo"> |
||||
INSERT INTO ybsj_commodity_info (commodity_id, commodity_name, commodity_price, |
||||
commodity_details, cover_picture, |
||||
create_by, open_url) |
||||
VALUES (#{commodityId}, #{commodityName}, #{commodityPrice}, #{commodityDetails}, #{coverPicture}, #{createBy}, |
||||
#{openUrl}) |
||||
</insert> |
||||
<insert id="addCommodityOpenUrlStatistics"> |
||||
INSERT INTO ybsj_commodity_open_url_statistics(commodity_id) |
||||
VALUES (#{commodityId}); |
||||
</insert> |
||||
<update id="updateCommodityInfo"> |
||||
UPDATE ybsj_commodity_info |
||||
SET commodity_name = #{commodityName}, |
||||
commodity_price = #{commodityPrice}, |
||||
commodity_details = #{commodityDetails}, |
||||
cover_picture = #{coverPicture}, |
||||
update_time = #{updateTime}, |
||||
update_by = #{updateBy}, |
||||
open_url = #{openUrl}, |
||||
del_flag = #{delFlag} |
||||
WHERE commodity_id = #{commodityId} |
||||
</update> |
||||
<update id="deleteCommodityInfo"> |
||||
UPDATE ybsj_commodity_info |
||||
SET del_flag = '2', |
||||
update_time = #{updateTime}, |
||||
update_by = #{updateBy} |
||||
|
||||
WHERE commodity_id = #{commodityId} |
||||
</update> |
||||
<update id="updateSort"> |
||||
UPDATE ybsj_commodity_info |
||||
SET sort=#{sort}, |
||||
del_flag ='1' |
||||
WHERE commodity_id = #{commodityId} |
||||
</update> |
||||
|
||||
<update id="updateRecommendState"> |
||||
UPDATE ybsj_commodity_info |
||||
SET recommend_state=#{recommendState}, |
||||
del_flag ='1' |
||||
WHERE commodity_id = #{commodityId} |
||||
</update> |
||||
<update id="updateCommodityOpenUrlStatistics"> |
||||
UPDATE ybsj_commodity_open_url_statistics |
||||
SET `number`=`number` + 1 |
||||
WHERE commodity_id = #{commodityId} AND DATE_FORMAT(create_time, '%Y-%m-%d') = CURDATE() |
||||
</update> |
||||
<select id="getCommodityInfoById" resultType="com.cjy.back.ybsjCommodityManage.entity.CommodityInfo"> |
||||
select commodity_name as commodityName, |
||||
commodity_price as commodityPrice, |
||||
commodity_details as commodityDetails, |
||||
cover_picture as cover_picture, |
||||
open_url as openUrl |
||||
from ybsj_commodity_info |
||||
WHERE commodity_id = #{commodityId} |
||||
</select> |
||||
<select id="queryCommodityInfoListByPage" resultType="java.util.Map"> |
||||
select commodity_id as commodityId, |
||||
commodity_name as commodityName, |
||||
commodity_price as commodityPrice, |
||||
recommend_state as recommendState, |
||||
sort |
||||
from ybsj_commodity_info |
||||
where 1 = 1 |
||||
<if test="commodityInfo.commodityName !=null and commodityInfo.commodityName !=''"> |
||||
and commodity_name LIKE CONCAT('%',#{commodityInfo.commodityName},'%') |
||||
</if> |
||||
<if test="commodityInfo.recommendState !=null and commodityInfo.recommendState !=''"> |
||||
and recommend_state=#{commodityInfo.recommendState} |
||||
</if> |
||||
<if test="commodityInfo.sort !=null and commodityInfo.sort !=''"> |
||||
and sort =#{commodityInfo.sort} |
||||
</if> |
||||
and del_flag !='2' |
||||
order by sort,create_time asc |
||||
|
||||
</select> |
||||
<select id="getCommodityOpenUrlStatistics" resultType="java.lang.Integer"> |
||||
select count(*) |
||||
from ybsj_commodity_open_url_statistics |
||||
where commodity_id = #{commodityId} |
||||
AND DATE_FORMAT(create_time, '%Y-%m-%d') = CURDATE() |
||||
</select> |
||||
<select id="queryCommodityOpenUrlStatisticsListByPage" resultType="java.util.Map"> |
||||
SELECT |
||||
t2.title as name, |
||||
t2.jointime as price, |
||||
sum(t1.number) as count |
||||
FROM |
||||
ybsj_commodity_open_url_statistics t1 |
||||
left join ybsj_message_info t2 on t1.commodity_id=t2.guid |
||||
WHERE |
||||
1 =1 |
||||
<if test="commodityOpenUrlStatistics.startDate!=null and commodityOpenUrlStatistics.startDate!='' and commodityOpenUrlStatistics.endDate!=null and commodityOpenUrlStatistics.endDate!='' "> |
||||
and ( DATE_FORMAT( t1.create_time, '%Y-%m-%d' ) between #{commodityOpenUrlStatistics.startDate} and #{commodityOpenUrlStatistics.endDate}) |
||||
</if> |
||||
<if test="commodityOpenUrlStatistics.name!=null and commodityOpenUrlStatistics.name!=''"> |
||||
|
||||
and t2.title LIKE CONCAT('%',#{commodityOpenUrlStatistics.name},'%') |
||||
</if> |
||||
group by t1.commodity_id |
||||
</select> |
||||
</mapper> |
@ -0,0 +1,172 @@ |
||||
package com.cjy.back.ybsjCommodityManage.entity; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @author liangjiawei |
||||
* @createDate 2023/8/29 |
||||
*/ |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class CommodityInfo { |
||||
private Long id; |
||||
//商品id
|
||||
private String commodityId; |
||||
//商品名称
|
||||
private String commodityName; |
||||
//商品价格
|
||||
private BigDecimal commodityPrice; |
||||
//商品详情
|
||||
private String commodityDetails; |
||||
//商品封面图
|
||||
private String coverPicture; |
||||
//推荐状态0:未推荐1:已推荐
|
||||
private String recommendState; |
||||
//排序字段
|
||||
private Integer sort; |
||||
//创建时间
|
||||
private String createTime; |
||||
//创建人
|
||||
private String createBy; |
||||
//修改时间
|
||||
private Date updateTime; |
||||
//修改人
|
||||
private String updateBy; |
||||
// 数据状态 新增:0 修改:1删除:2
|
||||
private String delFlag; |
||||
//打开url
|
||||
private String openUrl; |
||||
|
||||
private String page; |
||||
private String limit; |
||||
|
||||
public String getPage() { |
||||
return page; |
||||
} |
||||
|
||||
public void setPage(String page) { |
||||
this.page = page; |
||||
} |
||||
|
||||
public String getLimit() { |
||||
return limit; |
||||
} |
||||
|
||||
public void setLimit(String limit) { |
||||
this.limit = limit; |
||||
} |
||||
|
||||
public Long getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(Long id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public String getCommodityId() { |
||||
return commodityId; |
||||
} |
||||
|
||||
public void setCommodityId(String commodityId) { |
||||
this.commodityId = commodityId; |
||||
} |
||||
|
||||
public String getCommodityName() { |
||||
return commodityName; |
||||
} |
||||
|
||||
public void setCommodityName(String commodityName) { |
||||
this.commodityName = commodityName; |
||||
} |
||||
|
||||
public BigDecimal getCommodityPrice() { |
||||
return commodityPrice; |
||||
} |
||||
|
||||
public void setCommodityPrice(BigDecimal commodityPrice) { |
||||
this.commodityPrice = commodityPrice; |
||||
} |
||||
|
||||
public String getCommodityDetails() { |
||||
return commodityDetails; |
||||
} |
||||
|
||||
public void setCommodityDetails(String commodityDetails) { |
||||
this.commodityDetails = commodityDetails; |
||||
} |
||||
|
||||
public String getCoverPicture() { |
||||
return coverPicture; |
||||
} |
||||
|
||||
public void setCoverPicture(String coverPicture) { |
||||
this.coverPicture = coverPicture; |
||||
} |
||||
|
||||
public String getRecommendState() { |
||||
return recommendState; |
||||
} |
||||
|
||||
public void setRecommendState(String recommendState) { |
||||
this.recommendState = recommendState; |
||||
} |
||||
|
||||
public Integer getSort() { |
||||
return sort; |
||||
} |
||||
|
||||
public void setSort(Integer sort) { |
||||
this.sort = sort; |
||||
} |
||||
|
||||
public String getCreateTime() { |
||||
return createTime; |
||||
} |
||||
|
||||
public void setCreateTime(String createTime) { |
||||
this.createTime = createTime; |
||||
} |
||||
|
||||
public String getCreateBy() { |
||||
return createBy; |
||||
} |
||||
|
||||
public void setCreateBy(String createBy) { |
||||
this.createBy = createBy; |
||||
} |
||||
|
||||
public Date getUpdateTime() { |
||||
return updateTime; |
||||
} |
||||
|
||||
public void setUpdateTime(Date updateTime) { |
||||
this.updateTime = updateTime; |
||||
} |
||||
|
||||
public String getUpdateBy() { |
||||
return updateBy; |
||||
} |
||||
|
||||
public void setUpdateBy(String updateBy) { |
||||
this.updateBy = updateBy; |
||||
} |
||||
|
||||
public String getDelFlag() { |
||||
return delFlag; |
||||
} |
||||
|
||||
public void setDelFlag(String delFlag) { |
||||
this.delFlag = delFlag; |
||||
} |
||||
|
||||
public String getOpenUrl() { |
||||
return openUrl; |
||||
} |
||||
|
||||
public void setOpenUrl(String openUrl) { |
||||
this.openUrl = openUrl; |
||||
} |
||||
} |
@ -0,0 +1,80 @@ |
||||
package com.cjy.back.ybsjCommodityManage.entity; |
||||
|
||||
/** |
||||
* @author liangjiawei |
||||
* @createDate 2023/8/29 |
||||
*/ |
||||
public class CommodityOpenUrlStatistics { |
||||
private String id; |
||||
private String commodityId; |
||||
private String number; |
||||
private String name; |
||||
private String startDate; |
||||
private String endDate; |
||||
private String page; |
||||
private String limit; |
||||
|
||||
public String getPage() { |
||||
return page; |
||||
} |
||||
|
||||
public void setPage(String page) { |
||||
this.page = page; |
||||
} |
||||
|
||||
public String getLimit() { |
||||
return limit; |
||||
} |
||||
|
||||
public void setLimit(String limit) { |
||||
this.limit = limit; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getStartDate() { |
||||
return startDate; |
||||
} |
||||
|
||||
public void setStartDate(String startDate) { |
||||
this.startDate = startDate; |
||||
} |
||||
|
||||
public String getEndDate() { |
||||
return endDate; |
||||
} |
||||
|
||||
public void setEndDate(String endDate) { |
||||
this.endDate = endDate; |
||||
} |
||||
|
||||
public String getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(String id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public String getCommodityId() { |
||||
return commodityId; |
||||
} |
||||
|
||||
public void setCommodityId(String commodityId) { |
||||
this.commodityId = commodityId; |
||||
} |
||||
|
||||
public String getNumber() { |
||||
return number; |
||||
} |
||||
|
||||
public void setNumber(String number) { |
||||
this.number = number; |
||||
} |
||||
} |
@ -0,0 +1,83 @@ |
||||
package com.cjy.back.ybsjCommodityManage.service; |
||||
|
||||
import com.cjy.back.ybsjCommodityManage.entity.CommodityInfo; |
||||
import com.cjy.back.ybsjCommodityManage.entity.CommodityOpenUrlStatistics; |
||||
import com.cjy.util.ServerResponse; |
||||
|
||||
/** |
||||
* @author liangjiawei |
||||
* @createDate 2023/8/29 |
||||
*/ |
||||
public interface CommodityInfoService { |
||||
/** |
||||
* 添加商品 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
ServerResponse addCommodityInfo(CommodityInfo commodityInfo); |
||||
|
||||
/** |
||||
* 统计数据添加 |
||||
* @param |
||||
* @return |
||||
*/ |
||||
ServerResponse addCommodityOpenUrlStatistics(CommodityOpenUrlStatistics commodityOpenUrlStatistics); |
||||
|
||||
/** |
||||
* 修改商品 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
ServerResponse updateCommodityInfo(CommodityInfo commodityInfo); |
||||
|
||||
/** |
||||
* 删除商品 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
ServerResponse deleteCommodityInfo(CommodityInfo commodityInfo); |
||||
|
||||
/** |
||||
* 通过id获取商品详情 |
||||
* |
||||
* @param commodityId |
||||
* @return |
||||
*/ |
||||
ServerResponse getCommodityInfoById(String commodityId); |
||||
|
||||
/** |
||||
* 获取商品列表 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
ServerResponse getCommodityInfoList(CommodityInfo commodityInfo); |
||||
|
||||
/** |
||||
* 搜索 |
||||
* @param commodityOpenUrlStatistics |
||||
* @return |
||||
*/ |
||||
ServerResponse getCommodityOpenUrlStatisticsList(CommodityOpenUrlStatistics commodityOpenUrlStatistics); |
||||
|
||||
/** |
||||
* 修改排序字段 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
ServerResponse updateSort(CommodityInfo commodityInfo); |
||||
|
||||
/** |
||||
* 修改推荐字段 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
ServerResponse updateRecommendState(CommodityInfo commodityInfo); |
||||
|
||||
|
||||
} |
@ -0,0 +1,185 @@ |
||||
package com.cjy.back.ybsjCommodityManage.service.impl; |
||||
|
||||
import com.cjy.back.ybsjCommodityManage.dao.CommodityInfoMapper; |
||||
import com.cjy.back.ybsjCommodityManage.entity.CommodityInfo; |
||||
import com.cjy.back.ybsjCommodityManage.entity.CommodityOpenUrlStatistics; |
||||
import com.cjy.back.ybsjCommodityManage.service.CommodityInfoService; |
||||
import com.cjy.common.PageWrapper; |
||||
import com.cjy.util.ServerResponse; |
||||
import com.cjy.util.UUIDUtil; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author liangjiawei |
||||
* @createDate 2023/8/29 |
||||
*/ |
||||
@Service |
||||
public class CommodityInfoServiceImpl implements CommodityInfoService { |
||||
@Autowired |
||||
CommodityInfoMapper commodityInfoMapper; |
||||
|
||||
/** |
||||
* 添加商品 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public ServerResponse addCommodityInfo(CommodityInfo commodityInfo) { |
||||
commodityInfo.setCommodityId(UUIDUtil.getuuid()); |
||||
commodityInfoMapper.addCommodityInfo(commodityInfo); |
||||
return ServerResponse.createBySuccess("创建成功"); |
||||
} |
||||
|
||||
/** |
||||
* 修改商品 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public ServerResponse updateCommodityInfo(CommodityInfo commodityInfo) { |
||||
commodityInfo.setDelFlag("1"); |
||||
commodityInfoMapper.updateCommodityInfo(commodityInfo); |
||||
return ServerResponse.createBySuccess("修改成功"); |
||||
} |
||||
|
||||
/** |
||||
* 删除商品 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public ServerResponse deleteCommodityInfo(CommodityInfo commodityInfo) { |
||||
commodityInfoMapper.deleteCommodityInfo(commodityInfo); |
||||
return ServerResponse.createBySuccess("删除成功"); |
||||
} |
||||
|
||||
/** |
||||
* 通过id获取商品详情 |
||||
* |
||||
* @param commodityId |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public ServerResponse getCommodityInfoById(String commodityId) { |
||||
|
||||
return ServerResponse.createBySuccess(commodityInfoMapper.getCommodityInfoById(commodityId)); |
||||
} |
||||
|
||||
/** |
||||
* 获取商品列表 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public ServerResponse getCommodityInfoList(CommodityInfo commodityInfo) { |
||||
// 获取当前页码,在分页组件里 参数固定为currentPage
|
||||
String cpage = commodityInfo.getPage(); |
||||
// 显示行数
|
||||
int limit = Integer.valueOf(commodityInfo.getLimit()); |
||||
int pageNo = 1; |
||||
if (cpage != null && !("").equals(cpage)) { |
||||
pageNo = Integer.parseInt(cpage); |
||||
} |
||||
/* 分页信息开始 */ |
||||
PageWrapper pw = new PageWrapper(); |
||||
pw.getPage().setCurrentPage(pageNo); |
||||
pw.getPage().setPageSize(limit); // 每页条数
|
||||
/* 分页信息结束 */ |
||||
//根据条件进行分页查询数据
|
||||
List<Map<String, Object>> list = commodityInfoMapper.queryCommodityInfoListByPage(pw.getPage(), commodityInfo); |
||||
|
||||
// 查询总行数
|
||||
int userCount = pw.getPage().getTotalCount(); |
||||
//返回数据
|
||||
HashMap<String, Object> resultMap = new HashMap<>(); |
||||
resultMap.put("count", userCount); |
||||
resultMap.put("data", list); |
||||
resultMap.put("msg", "查询成功"); |
||||
resultMap.put("code", 0); |
||||
return ServerResponse.createBySuccess(resultMap); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 搜索 |
||||
* @param commodityOpenUrlStatistics |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public ServerResponse getCommodityOpenUrlStatisticsList(CommodityOpenUrlStatistics commodityOpenUrlStatistics) { |
||||
// 获取当前页码,在分页组件里 参数固定为currentPage
|
||||
String cpage = commodityOpenUrlStatistics.getPage(); |
||||
// 显示行数
|
||||
int limit = Integer.valueOf(commodityOpenUrlStatistics.getLimit()); |
||||
int pageNo = 1; |
||||
if (cpage != null && !("").equals(cpage)) { |
||||
pageNo = Integer.parseInt(cpage); |
||||
} |
||||
/* 分页信息开始 */ |
||||
PageWrapper pw = new PageWrapper(); |
||||
pw.getPage().setCurrentPage(pageNo); |
||||
pw.getPage().setPageSize(limit); // 每页条数
|
||||
/* 分页信息结束 */ |
||||
//根据条件进行分页查询数据
|
||||
List<Map<String, Object>> list = commodityInfoMapper.queryCommodityOpenUrlStatisticsListByPage(pw.getPage(), commodityOpenUrlStatistics); |
||||
|
||||
// 查询总行数
|
||||
int userCount = pw.getPage().getTotalCount(); |
||||
//返回数据
|
||||
HashMap<String, Object> resultMap = new HashMap<>(); |
||||
resultMap.put("count", userCount); |
||||
resultMap.put("data", list); |
||||
resultMap.put("msg", "查询成功"); |
||||
resultMap.put("code", 0); |
||||
return ServerResponse.createBySuccess(resultMap); |
||||
} |
||||
|
||||
/** |
||||
* 修改排序字段 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public ServerResponse updateSort(CommodityInfo commodityInfo) { |
||||
commodityInfoMapper.updateSort(commodityInfo); |
||||
return ServerResponse.createBySuccess("修改成功"); |
||||
} |
||||
|
||||
/** |
||||
* 修改推荐字段 |
||||
* |
||||
* @param commodityInfo |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public ServerResponse updateRecommendState(CommodityInfo commodityInfo) { |
||||
commodityInfoMapper.updateRecommendState(commodityInfo); |
||||
return ServerResponse.createBySuccess("修改成功"); |
||||
} |
||||
|
||||
/** |
||||
* 统计数据添加 |
||||
* @param commodityOpenUrlStatistics |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public ServerResponse addCommodityOpenUrlStatistics(CommodityOpenUrlStatistics commodityOpenUrlStatistics) { |
||||
if (commodityInfoMapper.getCommodityOpenUrlStatistics(commodityOpenUrlStatistics) == 0) { |
||||
commodityInfoMapper.addCommodityOpenUrlStatistics(commodityOpenUrlStatistics); |
||||
} else { |
||||
commodityInfoMapper.updateCommodityOpenUrlStatistics(commodityOpenUrlStatistics); |
||||
} |
||||
|
||||
return ServerResponse.createBySuccess("创建成功"); |
||||
} |
||||
} |
Loading…
Reference in new issue