Commit 3c420c65 by guojuxing

达摩产品情报站

parent f06c88cf
package com.gic.enterprise.dto;
import java.io.Serializable;
import java.util.Date;
/**
* 达摩产品情报站
* @ClassName:
* @Description: 

* @author guojuxing

* @date 2021/5/17 5:02 PM

*/
public class ProductMarketDTO implements Serializable{
private static final long serialVersionUID = -1488266149086925629L;
/**
*
*/
private Integer productMarketId;
/**
* 标题
*/
private String title;
/**
* 类型(1 功能更新、2 产品推广、3 成功案例)
*/
private Integer infoType;
/**
* 超链接
*/
private String hyperLink;
/**
* 发布时间
*/
private Date releaseTime;
/**
* 状态(0:正常;1:删除)
*/
private Integer deleteFlag;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public Integer getProductMarketId() {
return productMarketId;
}
public ProductMarketDTO setProductMarketId(Integer productMarketId) {
this.productMarketId = productMarketId;
return this;
}
public String getTitle() {
return title;
}
public ProductMarketDTO setTitle(String title) {
this.title = title;
return this;
}
public Integer getInfoType() {
return infoType;
}
public ProductMarketDTO setInfoType(Integer infoType) {
this.infoType = infoType;
return this;
}
public String getHyperLink() {
return hyperLink;
}
public ProductMarketDTO setHyperLink(String hyperLink) {
this.hyperLink = hyperLink;
return this;
}
public Date getReleaseTime() {
return releaseTime;
}
public ProductMarketDTO setReleaseTime(Date releaseTime) {
this.releaseTime = releaseTime;
return this;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public ProductMarketDTO setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
return this;
}
public Date getCreateTime() {
return createTime;
}
public ProductMarketDTO setCreateTime(Date createTime) {
this.createTime = createTime;
return this;
}
public Date getUpdateTime() {
return updateTime;
}
public ProductMarketDTO setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
return this;
}
@Override
public String toString() {
return "ProductMarketDTO{" +
"productMarketId=" + productMarketId +
", title='" + title + '\'' +
", infoType=" + infoType +
", hyperLink='" + hyperLink + '\'' +
", releaseTime=" + releaseTime +
", deleteFlag=" + deleteFlag +
", createTime=" + createTime +
", updateTime=" + updateTime +
'}';
}
}
package com.gic.enterprise.qo;
import java.io.Serializable;
/**
* 达摩产品情报站
* @ClassName:
* @Description: 

* @author guojuxing

* @date 2021/5/18 11:03 AM

*/
public class ProductMarketQO implements Serializable{
private static final long serialVersionUID = 5426587736244141621L;
/**
* 标题
*/
private String title;
/**
* 类型(1 功能更新、2 产品推广、3 成功案例)
*/
private Integer infoType;
private Integer pageNum;
private Integer pageSize;
public String getTitle() {
return title;
}
public ProductMarketQO setTitle(String title) {
this.title = title;
return this;
}
public Integer getInfoType() {
return infoType;
}
public ProductMarketQO setInfoType(Integer infoType) {
this.infoType = infoType;
return this;
}
public Integer getPageNum() {
if (pageNum == null) {
return 1;
}
return pageNum;
}
public ProductMarketQO setPageNum(Integer pageNum) {
this.pageNum = pageNum;
return this;
}
public Integer getPageSize() {
if (pageSize == null) {
return 20;
}
return pageSize;
}
public ProductMarketQO setPageSize(Integer pageSize) {
this.pageSize = pageSize;
return this;
}
@Override
public String toString() {
return "ProductMarketQO{" +
"title='" + title + '\'' +
", infoType=" + infoType +
", pageNum=" + pageNum +
", pageSize=" + pageSize +
'}';
}
}
package com.gic.enterprise.service;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.enterprise.dto.ProductMarketDTO;
import com.gic.enterprise.qo.ProductMarketQO;
import javax.validation.constraints.NotNull;
/**
* 达摩产品情报站
* @ClassName:
* @Description: 

* @author guojuxing

* @date 2021/5/17 5:11 PM

*/
public interface ProductMarketApiService {
/**
*
* @param productMarketDTO
* @return
*/
ServiceResponse<Void> saveProductMarket(ProductMarketDTO productMarketDTO);
/**
* 更新情报
* @param productMarketDTO
* @return
*/
ServiceResponse<Void> updateProductMarket(ProductMarketDTO productMarketDTO);
/**
* 删除情报
* @param productMarketId
* @return
*/
ServiceResponse<Void> deleteProductMarket(Integer productMarketId);
/**
* 查询情报
* @param productMarketId
* @return
*/
ServiceResponse<ProductMarketDTO> getProductMarket(@NotNull Integer productMarketId);
/**
* 分页查询
* @param params
* @return
*/
ServiceResponse<Page<ProductMarketDTO>> pageProductMarket(ProductMarketQO params);
/**
* 首页前端是否需要弹窗
* @param enterpriseId
* @param userId
* @return
*/
ServiceResponse<Boolean> isNeedToPopup(Integer enterpriseId, Integer userId);
}
package com.gic.enterprise.dao.mapper;
import com.gic.enterprise.entity.TabProductMarket;
import com.gic.enterprise.qo.ProductMarketQO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 达摩产品情报站
* @ClassName:
* @Description: 

* @author guojuxing

* @date 2021/5/18 9:38 AM

*/
public interface TabProductMarketMapper {
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabProductMarket record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabProductMarket record);
/**
* 根据主键查询
*
* @param productMarketId 主键
* @return 实体对象
*/
TabProductMarket selectByPrimaryKey(Integer productMarketId);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabProductMarket record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabProductMarket record);
/**
* 查询列表
* @param params
* @return
*/
List<TabProductMarket> pageProductMarket(ProductMarketQO params);
/**
* 是否有新消息(当天发布,并且时间小于当前时间,精确到秒)
* @return
*/
Integer countNewInfo(@Param("today") String today);
}
\ No newline at end of file
package com.gic.enterprise.entity;
import java.util.Date;
/**
* 达摩产品情报站
* @ClassName:
* @Description: 

* @author guojuxing

* @date 2021/5/17 5:00 PM

*/
public class TabProductMarket {
/**
*
*/
private Integer productMarketId;
/**
* 标题
*/
private String title;
/**
* 类型(1 功能更新、2 产品推广、3 成功案例)
*/
private Integer infoType;
/**
* 超链接
*/
private String hyperLink;
/**
* 发布时间
*/
private Date releaseTime;
/**
* 状态(0:正常;1:删除)
*/
private Integer deleteFlag;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public Integer getProductMarketId() {
return productMarketId;
}
public TabProductMarket setProductMarketId(Integer productMarketId) {
this.productMarketId = productMarketId;
return this;
}
public String getTitle() {
return title;
}
public TabProductMarket setTitle(String title) {
this.title = title;
return this;
}
public Integer getInfoType() {
return infoType;
}
public TabProductMarket setInfoType(Integer infoType) {
this.infoType = infoType;
return this;
}
public String getHyperLink() {
return hyperLink;
}
public TabProductMarket setHyperLink(String hyperLink) {
this.hyperLink = hyperLink;
return this;
}
public Date getReleaseTime() {
return releaseTime;
}
public TabProductMarket setReleaseTime(Date releaseTime) {
this.releaseTime = releaseTime;
return this;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public TabProductMarket setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
return this;
}
public Date getCreateTime() {
return createTime;
}
public TabProductMarket setCreateTime(Date createTime) {
this.createTime = createTime;
return this;
}
public Date getUpdateTime() {
return updateTime;
}
public TabProductMarket setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
return this;
}
}
\ No newline at end of file
package com.gic.enterprise.service;
import com.gic.enterprise.dto.ProductMarketDTO;
import com.gic.enterprise.entity.TabProductMarket;
import com.gic.enterprise.qo.ProductMarketQO;
import com.github.pagehelper.Page;
/**
* 达摩产品情报站
* @ClassName:
* @Description: 

* @author guojuxing

* @date 2021/5/18 9:28 AM

*/
public interface ProductMarketService {
/**
* 新增情报
* @param productMarketDTO
*/
void saveProductMarket(ProductMarketDTO productMarketDTO);
/**
* 更新情报
* @param productMarketDTO
*/
void updateProductMarket(ProductMarketDTO productMarketDTO);
/**
* 详情
* @param productMarketId
* @return
*/
TabProductMarket getProductMarket(Integer productMarketId);
/**
* 分页查询
* @param params
* @return
*/
Page<TabProductMarket> pageProductMarket(ProductMarketQO params);
/**
* 是否有新消息(当天发布,并且时间小于当前时间,精确到秒)
* @return
*/
Boolean hasNewInfo();
}
package com.gic.enterprise.service.impl;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.constant.DeleteFlagConstants;
import com.gic.enterprise.dao.mapper.TabProductMarketMapper;
import com.gic.enterprise.dto.ProductMarketDTO;
import com.gic.enterprise.entity.TabProductMarket;
import com.gic.enterprise.qo.ProductMarketQO;
import com.gic.enterprise.service.ProductMarketService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* 达摩产品情报站
* @ClassName:
* @Description: 

* @author guojuxing

* @date 2021/5/18 9:37 AM

*/
@Service("productMarketService")
public class ProductMarketServiceImpl implements ProductMarketService{
@Autowired
private TabProductMarketMapper tabProductMarketMapper;
@Override
public void saveProductMarket(ProductMarketDTO productMarketDTO) {
TabProductMarket record = EntityUtil.changeEntityNew(TabProductMarket.class, productMarketDTO);
Date now = new Date();
record.setUpdateTime(now);
record.setCreateTime(now);
record.setDeleteFlag(DeleteFlagConstants.NORMAL_STATUS);
tabProductMarketMapper.insert(record);
}
@Override
public void updateProductMarket(ProductMarketDTO productMarketDTO) {
TabProductMarket record = EntityUtil.changeEntityNew(TabProductMarket.class, productMarketDTO);
record.setUpdateTime(new Date());
tabProductMarketMapper.updateByPrimaryKeySelective(record);
}
@Override
public TabProductMarket getProductMarket(Integer productMarketId) {
return tabProductMarketMapper.selectByPrimaryKey(productMarketId);
}
@Override
public Page<TabProductMarket> pageProductMarket(ProductMarketQO params) {
PageHelper.startPage(params.getPageNum(), params.getPageSize());
List<TabProductMarket> list = tabProductMarketMapper.pageProductMarket(params);
return (Page<TabProductMarket>) list;
}
@Override
public Boolean hasNewInfo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String today = sdf.format(new Date());
Integer count = tabProductMarketMapper.countNewInfo(today);
if (count != null && count > 0) {
return true;
}
return false;
}
}
package com.gic.enterprise.service.outer.impl;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.enterprise.constant.DeleteFlagConstants;
import com.gic.enterprise.dto.ProductMarketDTO;
import com.gic.enterprise.entity.TabProductMarket;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.exception.CommonException;
import com.gic.enterprise.qo.ProductMarketQO;
import com.gic.enterprise.service.ProductMarketApiService;
import com.gic.enterprise.service.ProductMarketService;
import com.gic.redis.data.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.validation.constraints.NotNull;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
/**
* 达摩产品情报站
* @ClassName:
* @Description: 

* @author guojuxing

* @date 2021/5/18 9:26 AM

*/
@Service("productMarketApiService")
public class ProductMarketApiServiceImpl implements ProductMarketApiService{
@Autowired
private ProductMarketService productMarketService;
@Override
public ServiceResponse<Void> saveProductMarket(ProductMarketDTO productMarketDTO) {
validParam(productMarketDTO);
productMarketService.saveProductMarket(productMarketDTO);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> updateProductMarket(ProductMarketDTO productMarketDTO) {
validParam(productMarketDTO);
productMarketService.updateProductMarket(productMarketDTO);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> deleteProductMarket(Integer productMarketId) {
exist(productMarketId);
productMarketService.updateProductMarket(new ProductMarketDTO()
.setProductMarketId(productMarketId)
.setDeleteFlag(DeleteFlagConstants.DELETE_STATUS));
return ServiceResponse.success();
}
@Override
public ServiceResponse<ProductMarketDTO> getProductMarket(@NotNull Integer productMarketId) {
TabProductMarket record = exist(productMarketId);
return ServiceResponse.success(EntityUtil.changeEntityNew(ProductMarketDTO.class, record));
}
@Override
public ServiceResponse<Page<ProductMarketDTO>> pageProductMarket(ProductMarketQO params) {
com.github.pagehelper.Page<TabProductMarket> page = productMarketService.pageProductMarket(params);
Page<ProductMarketDTO> result = PageHelperUtils.changePageHelperToCurrentPage(page, ProductMarketDTO.class);
return ServiceResponse.success(result);
}
@Override
public ServiceResponse<Boolean> isNeedToPopup(Integer enterpriseId, Integer userId) {
Boolean hasNewInfo = productMarketService.hasNewInfo();
if (hasNewInfo) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String today = sdf.format(new Date());
//是否已经弹窗提示过,一天只提示一次
String redisKey = "enterprise:product:market:" + today + ":" + userId;
Object obj = RedisUtil.getCache(redisKey);
if(obj != null){
//已经提示过,不需要再次提示
return ServiceResponse.success(false);
} else {
RedisUtil.setCache(redisKey, redisKey, 24L, TimeUnit.HOURS);
return ServiceResponse.success(true);
}
}
//没有新发布的数据,不需要提示
return ServiceResponse.success(false);
}
private void validParam(ProductMarketDTO productMarketDTO) {
Integer productMarketId = productMarketDTO.getProductMarketId();
boolean isEdit = productMarketId != null;
if (isEdit) {
exist(productMarketId);
}
}
private TabProductMarket exist(Integer productMarketId) {
TabProductMarket record = productMarketService.getProductMarket(productMarketId);
if (record == null) {
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "情报不存在");
}
return record;
}
}
......@@ -133,6 +133,7 @@
<dubbo:service interface="com.gic.enterprise.service.EnterpriseGoodsResourceApiService" ref="enterpriseGoodsResourceApiService" timeout="6000" />
<dubbo:service interface="com.gic.enterprise.service.UnionEnterpriseAuthApiService" ref="unionEnterpriseAuthApiService" timeout="6000" />
<dubbo:service interface="com.gic.enterprise.service.UnionEnterpriseAuthResDetailApiService" ref="unionEnterpriseAuthResDetailApiService" timeout="6000" />
<dubbo:service interface="com.gic.enterprise.service.ProductMarketApiService" ref="productMarketApiService" timeout="6000" />
<dubbo:reference interface="com.gic.mall.share.api.service.ShopApiService" id="shopApiService" timeout="6000" />
......
<?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.gic.enterprise.dao.mapper.TabProductMarketMapper">
<resultMap id="BaseResultMap" type="com.gic.enterprise.entity.TabProductMarket">
<id column="product_market_id" jdbcType="INTEGER" property="productMarketId" />
<result column="title" jdbcType="VARCHAR" property="title" />
<result column="info_type" jdbcType="INTEGER" property="infoType" />
<result column="hyper_link" jdbcType="VARCHAR" property="hyperLink" />
<result column="release_time" jdbcType="TIMESTAMP" property="releaseTime" />
<result column="delete_flag" jdbcType="INTEGER" property="deleteFlag" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
product_market_id, title, info_type, hyper_link, release_time, delete_flag, create_time,
update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_product_market
where product_market_id = #{productMarketId,jdbcType=INTEGER}
</select>
<insert id="insert" parameterType="com.gic.enterprise.entity.TabProductMarket">
insert into tab_product_market (product_market_id, title, info_type,
hyper_link, release_time, delete_flag,
create_time, update_time)
values (#{productMarketId,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{infoType,jdbcType=INTEGER},
#{hyperLink,jdbcType=VARCHAR}, #{releaseTime,jdbcType=TIMESTAMP}, #{deleteFlag,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.enterprise.entity.TabProductMarket">
insert into tab_product_market
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="productMarketId != null">
product_market_id,
</if>
<if test="title != null">
title,
</if>
<if test="infoType != null">
info_type,
</if>
<if test="hyperLink != null">
hyper_link,
</if>
<if test="releaseTime != null">
release_time,
</if>
<if test="deleteFlag != null">
delete_flag,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="productMarketId != null">
#{productMarketId,jdbcType=INTEGER},
</if>
<if test="title != null">
#{title,jdbcType=VARCHAR},
</if>
<if test="infoType != null">
#{infoType,jdbcType=INTEGER},
</if>
<if test="hyperLink != null">
#{hyperLink,jdbcType=VARCHAR},
</if>
<if test="releaseTime != null">
#{releaseTime,jdbcType=TIMESTAMP},
</if>
<if test="deleteFlag != null">
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.enterprise.entity.TabProductMarket">
update tab_product_market
<set>
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="infoType != null">
info_type = #{infoType,jdbcType=INTEGER},
</if>
<if test="hyperLink != null">
hyper_link = #{hyperLink,jdbcType=VARCHAR},
</if>
<if test="releaseTime != null">
release_time = #{releaseTime,jdbcType=TIMESTAMP},
</if>
<if test="deleteFlag != null">
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where product_market_id = #{productMarketId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.enterprise.entity.TabProductMarket">
update tab_product_market
set title = #{title,jdbcType=VARCHAR},
info_type = #{infoType,jdbcType=INTEGER},
hyper_link = #{hyperLink,jdbcType=VARCHAR},
release_time = #{releaseTime,jdbcType=TIMESTAMP},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where product_market_id = #{productMarketId,jdbcType=INTEGER}
</update>
<select id="pageProductMarket" resultMap="BaseResultMap" parameterType="com.gic.enterprise.qo.ProductMarketQO">
select <include refid="Base_Column_List"></include>
from tab_product_market
where delete_flag = 0
<if test="title != null and title != ''">
and title like concat('%', #{title}, '%')
</if>
<if test="infoType != null">
and info_type = #{infoType}
</if>
order by release_time desc
</select>
<select id="countNewInfo" resultType="int">
select count(1) from tab_product_market
where delete_flag = 0
and date(release_time) =:today
and timestamp(release_time) &lt;= now()
</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