Ver código fonte

add promot

master
lin 1 ano atrás
pai
commit
3e0121ba5b
13 arquivos alterados com 488 adições e 2 exclusões
  1. +54
    -0
      gptCApi/src/main/java/com/iformall/controller/WxPromoteController.java
  2. +31
    -0
      gptService/src/main/java/com/iformall/domain/po/WxPromotTitle.java
  3. +29
    -0
      gptService/src/main/java/com/iformall/domain/po/WxPromotType.java
  4. +33
    -0
      gptService/src/main/java/com/iformall/enums/EnumDeleteStatus.java
  5. +15
    -0
      gptService/src/main/java/com/iformall/mapper/WxPromotTitleMapper.java
  6. +15
    -0
      gptService/src/main/java/com/iformall/mapper/WxPromotTypeMapper.java
  7. +21
    -0
      gptService/src/main/java/com/iformall/service/WxPromotService.java
  8. +0
    -2
      gptService/src/main/java/com/iformall/service/cache/WxProductCache.java
  9. +75
    -0
      gptService/src/main/java/com/iformall/service/cache/WxPromotCache.java
  10. +75
    -0
      gptService/src/main/java/com/iformall/service/impl/WxPromotServiceImpl.java
  11. +3
    -0
      gptService/src/main/java/com/iformall/utils/Constant.java
  12. +71
    -0
      gptService/src/main/resources/mapper/WxPromotTitleMapper.xml
  13. +66
    -0
      gptService/src/main/resources/mapper/WxPromotTypeMapper.xml

+ 54
- 0
gptCApi/src/main/java/com/iformall/controller/WxPromoteController.java Ver arquivo

@@ -0,0 +1,54 @@
package com.iformall.controller;

import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxPromotTitle;
import com.iformall.domain.po.WxPromotType;
import com.iformall.service.SysConfigService;
import com.iformall.service.WxPromotService;
import com.iformall.service.wx.WxPayService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/promote")
public class WxPromoteController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
SysConfigService sysConfigService;
@Autowired
WxPromotService wxPromotService;
@Autowired
WxPayService wxPayService;
@GetMapping("/list")
public ResultData list() {
WxCUser user = getCUser();
WxPromotType pt = new WxPromotType();
pt.updateTenantInfo(user);
List<WxPromotType> plist = wxPromotService.promotTypeList(pt);
return new ResultData(plist);
}
@GetMapping("/titleList")
@ApiImplicitParams({
@ApiImplicitParam(name = "typeId", value = "页数", dataType = "Long", paramType = "query", required = true)
})
public ResultData titleList(Long typeId) {
WxCUser user = getCUser();
WxPromotTitle pt = new WxPromotTitle();
pt.setPromotTypeId(typeId);
pt.updateTenantInfo(user);
List<WxPromotTitle> plist = wxPromotService.getPromotTitleList(pt);
return new ResultData(plist);
}

}

+ 31
- 0
gptService/src/main/java/com/iformall/domain/po/WxPromotTitle.java Ver arquivo

@@ -0,0 +1,31 @@
package com.iformall.domain.po;

import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.TenantEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.*;

@TableName(value = "wx_promot_title")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString
public class WxPromotTitle extends TenantEntity {

private static final long serialVersionUID = -5094915301794376964L;

protected Long id;
@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime")
private Date createTime;
@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime")
private Date updateTime;
@io.swagger.annotations.ApiModelProperty(value="名称",name="title")
private String title;
@io.swagger.annotations.ApiModelProperty(value="对话加的前缀",name="prePromot")
private String prePromot;
@io.swagger.annotations.ApiModelProperty(value="typeId",name="promotTypeId")
private Long promotTypeId;
@io.swagger.annotations.ApiModelProperty(value="状态EnumDeleteStatus",name="status")
private Integer status;
}

+ 29
- 0
gptService/src/main/java/com/iformall/domain/po/WxPromotType.java Ver arquivo

@@ -0,0 +1,29 @@
package com.iformall.domain.po;

import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.TenantEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.*;

@TableName(value = "wx_promot_type")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString
public class WxPromotType extends TenantEntity {

private static final long serialVersionUID = -5094915301794376964L;

protected Long id;
@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime")
private Date createTime;
@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime")
private Date updateTime;
@io.swagger.annotations.ApiModelProperty(value="产品名称",name="name")
private String name;
@io.swagger.annotations.ApiModelProperty(value="产品图片",name="img")
private String img;
@io.swagger.annotations.ApiModelProperty(value="状态EnumDeleteStatus",name="status")
private Integer status;
}

+ 33
- 0
gptService/src/main/java/com/iformall/enums/EnumDeleteStatus.java Ver arquivo

@@ -0,0 +1,33 @@
package com.iformall.enums;

public enum EnumDeleteStatus {

NORMAL(0, "正常"),
DELETED(1, "已删除"),
;

public static EnumDeleteStatus getEnum(Integer code) {
for (EnumDeleteStatus value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumDeleteStatus(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

+ 15
- 0
gptService/src/main/java/com/iformall/mapper/WxPromotTitleMapper.java Ver arquivo

@@ -0,0 +1,15 @@
package com.iformall.mapper;

import java.util.*;

import org.apache.ibatis.annotations.Param;

import com.iformall.common.CommonMapper;
import com.iformall.domain.po.WxPromotTitle;

public interface WxPromotTitleMapper extends CommonMapper<WxPromotTitle, Long> {

WxPromotTitle selectById(@Param("id")Long id,@Param("tenantId")String tenantId);
List<WxPromotTitle> findList(WxPromotTitle wxProduct);
}

+ 15
- 0
gptService/src/main/java/com/iformall/mapper/WxPromotTypeMapper.java Ver arquivo

@@ -0,0 +1,15 @@
package com.iformall.mapper;

import java.util.*;

import org.apache.ibatis.annotations.Param;

import com.iformall.common.CommonMapper;
import com.iformall.domain.po.WxPromotType;

public interface WxPromotTypeMapper extends CommonMapper<WxPromotType, Long> {

WxPromotType selectById(@Param("id")Long id,@Param("tenantId")String tenantId);
List<WxPromotType> findList(WxPromotType wxProduct);
}

+ 21
- 0
gptService/src/main/java/com/iformall/service/WxPromotService.java Ver arquivo

@@ -0,0 +1,21 @@
package com.iformall.service;

import com.iformall.domain.po.WxPromotTitle;
import com.iformall.domain.po.WxPromotType;
import java.util.List;

public interface WxPromotService {


/**
* 根据Id获得实体
*
* @param id
* @return
*/
WxPromotType getPromotTypeById(Long id,String tenantId);
List<WxPromotType> promotTypeList(WxPromotType product);
List<WxPromotTitle> getPromotTitleList(WxPromotTitle product);
}

+ 0
- 2
gptService/src/main/java/com/iformall/service/cache/WxProductCache.java Ver arquivo

@@ -30,8 +30,6 @@ public class WxProductCache {
RedisCacheUtils.removeCache(redisTemplate, key);
}
private static String getFirstKey(String tenantId) {
String key = Constant.productFirstPre + tenantId;
return key;


+ 75
- 0
gptService/src/main/java/com/iformall/service/cache/WxPromotCache.java Ver arquivo

@@ -0,0 +1,75 @@
package com.iformall.service.cache;

import java.util.List;

import org.springframework.data.redis.core.RedisTemplate;

import com.iformall.domain.po.WxProduct;
import com.iformall.domain.po.WxPromotTitle;
import com.iformall.domain.po.WxPromotType;
import com.iformall.utils.Constant;
import com.iformall.utils.RedisCacheUtils;

public class WxPromotCache {

private static String getKey(Long productId) {
String key = Constant.promotPre + productId;
return key;
}
public static WxPromotType getCache(RedisTemplate<String, Object> redisTemplate,Long promotTypeId) {
String key = getKey(promotTypeId);
return RedisCacheUtils.getCacheObject(redisTemplate, key, WxPromotType.class);
}
public static void cache(RedisTemplate<String, Object> redisTemplate,WxPromotType wxPromotType) {
String key = getKey(wxPromotType.getId());
RedisCacheUtils.cache(redisTemplate, key, wxPromotType, 3600*24*7);
}
public static void removeCache(RedisTemplate<String, Object> redisTemplate,Long promotTypeId) {
String key = getKey(promotTypeId);
RedisCacheUtils.removeCache(redisTemplate, key);
}
private static String getListKey(String tenantId) {
String key = Constant.promotListPre + tenantId;
return key;
}
public static List<WxPromotType> getCacheList(RedisTemplate<String, Object> redisTemplate,String tenantId) {
String key = getListKey(tenantId);
return RedisCacheUtils.getCacheListObject(redisTemplate, key, WxPromotType.class);
}
public static void cacheList(RedisTemplate<String, Object> redisTemplate,List<WxPromotType> wxPromotTypeList,String tenantId) {
String key = getListKey(tenantId);
RedisCacheUtils.cache(redisTemplate, key, wxPromotTypeList, 3600*24*7);
}
public static void removeCacheList(RedisTemplate<String, Object> redisTemplate,String tenantId) {
String key = getListKey(tenantId);
RedisCacheUtils.removeCache(redisTemplate, key);
}
private static String getTitleListKey(Long promoteTypeId) {
String key = Constant.promotTitleListPre + promoteTypeId;
return key;
}
public static List<WxPromotTitle> getCacheTitleList(RedisTemplate<String, Object> redisTemplate,Long promoteTypeId) {
String key = getTitleListKey(promoteTypeId);
return RedisCacheUtils.getCacheListObject(redisTemplate, key, WxPromotTitle.class);
}
public static void cacheTitleList(RedisTemplate<String, Object> redisTemplate,List<WxPromotTitle> wxPromotTitleList,Long promoteTypeId) {
String key = getTitleListKey(promoteTypeId);
RedisCacheUtils.cache(redisTemplate, key, wxPromotTitleList, 3600*24*7);
}
public static void removeCacheTitleList(RedisTemplate<String, Object> redisTemplate,Long promoteTypeId) {
String key = getTitleListKey(promoteTypeId);
RedisCacheUtils.removeCache(redisTemplate, key);
}
}

+ 75
- 0
gptService/src/main/java/com/iformall/service/impl/WxPromotServiceImpl.java Ver arquivo

@@ -0,0 +1,75 @@
package com.iformall.service.impl;

import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumDeleteStatus;
import com.iformall.enums.EnumYesOrNo;
import com.iformall.mapper.WxProductMapper;
import com.iformall.mapper.WxPromotTitleMapper;
import com.iformall.mapper.WxPromotTypeMapper;
import com.iformall.service.*;
import com.iformall.service.cache.WxProductCache;
import com.iformall.service.cache.WxPromotCache;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class WxPromotServiceImpl implements WxPromotService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
WxPromotTypeMapper wxPromotTypeMapper;
@Autowired
WxPromotTitleMapper wxPromotTitleMapper;
@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> objectCommonRedisTemplate;

@Override
public WxPromotType getPromotTypeById(Long id, String tenantId) {
return wxPromotTypeMapper.selectById(id, tenantId);
}

@Override
public List<WxPromotType> promotTypeList(WxPromotType product) {
List<WxPromotType> productList = WxPromotCache.getCacheList(objectCommonRedisTemplate,product.getTenantId());
if (null == productList || productList.size() <= 0 ) {
WxPromotType p = new WxPromotType();
p.updateTenantInfo(product);
p.setStatus(EnumDeleteStatus.NORMAL.getCode());
List<WxPromotType> plist = wxPromotTypeMapper.findList(p);
if (null != plist && plist.size() > 0 ) {
WxPromotCache.cacheList(objectCommonRedisTemplate, plist,product.getTenantId());
return plist;
}
}
return productList;
}

@Override
public List<WxPromotTitle> getPromotTitleList(WxPromotTitle product) {
List<WxPromotTitle> productList = WxPromotCache.getCacheTitleList(objectCommonRedisTemplate,product.getPromotTypeId());
if (null == productList || productList.size() <= 0 ) {
WxPromotTitle p = new WxPromotTitle();
p.updateTenantInfo(product);
p.setStatus(EnumDeleteStatus.NORMAL.getCode());
List<WxPromotTitle> plist = wxPromotTitleMapper.findList(p);
if (null != plist && plist.size() > 0 ) {
WxPromotCache.cacheTitleList(objectCommonRedisTemplate, plist,product.getPromotTypeId());
return plist;
}
}
return productList;
}


}

+ 3
- 0
gptService/src/main/java/com/iformall/utils/Constant.java Ver arquivo

@@ -13,6 +13,9 @@ public class Constant {
public static final String noticeListPrev = "gpt:noticeList:";
public static final String linkPrev = "gpt:link:";
public static final String linkListPrev = "gpt:linkList:";
public static final String promotPre = "gpt:promot:";
public static final String promotListPre= "gpt:promotList:";
public static final String promotTitleListPre= "gpt:promotTitleList:";
public static final String currentUser = "currentUser";
public static final String TENANT_ID = "tenantId";
public static final String PARENT_TENANT_ID = "parentTenantId";


+ 71
- 0
gptService/src/main/resources/mapper/WxPromotTitleMapper.xml Ver arquivo

@@ -0,0 +1,71 @@
<?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.iformall.mapper.WxPromotTitleMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxPromotTitle">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="title" jdbcType="VARCHAR" property="title"/>
<result column="pre_promot" jdbcType="VARCHAR" property="prePromot"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="promot_type_id" jdbcType="BIGINT" property="promotTypeId"/>
</resultMap>

<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`title`,`pre_promot`,`status`,`promot_type_id`
</sql>

<sql id="dynamicWhereConditions">
where `tenant_id` = #{tenantId}

<if test=" null != id ">
and `id` = #{id}
</if>

<if test=" null != parentTenantId and '' != parentTenantId">
and `parent_tenant_id` = #{parentTenantId}
</if>

<if test=" null != createTime ">
and `create_time` = #{createTime}
</if>

<if test=" null != updateTime ">
and `update_time` = #{updateTime}
</if>

<if test=" null != name ">
and `name` like concat('%', #{name},'%')
</if>
<if test=" null != status ">
and `status` = #{status}
</if>
<if test=" null != promotTypeId ">
and `promot_type_id` = #{promotTypeId}
</if>

<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>
<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>

<select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
select <include refid="allColumns"/> from wx_promot_title where id = #{id} and tenant_id = #{tenantId}
</select>

<select id="findList" parameterType="com.iformall.domain.po.WxPromotTitle" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_promot_title
<include refid="dynamicWhereConditions"/>
</select>
</mapper>

+ 66
- 0
gptService/src/main/resources/mapper/WxPromotTypeMapper.xml Ver arquivo

@@ -0,0 +1,66 @@
<?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.iformall.mapper.WxPromotTypeMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxPromotType">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="img" jdbcType="VARCHAR" property="img"/>
<result column="status" jdbcType="INTEGER" property="status"/>
</resultMap>

<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`name`,`img`,`status`
</sql>

<sql id="dynamicWhereConditions">
where `tenant_id` = #{tenantId}

<if test=" null != id ">
and `id` = #{id}
</if>

<if test=" null != parentTenantId and '' != parentTenantId">
and `parent_tenant_id` = #{parentTenantId}
</if>

<if test=" null != createTime ">
and `create_time` = #{createTime}
</if>

<if test=" null != updateTime ">
and `update_time` = #{updateTime}
</if>

<if test=" null != name ">
and `name` like concat('%', #{name},'%')
</if>
<if test=" null != status ">
and `status` = #{status}
</if>

<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>
<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>

<select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
select <include refid="allColumns"/> from wx_promot_type where id = #{id} and tenant_id = #{tenantId}
</select>

<select id="findList" parameterType="com.iformall.domain.po.WxPromotType" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_promot_type
<include refid="dynamicWhereConditions"/>
</select>
</mapper>

Carregando…
Cancelar
Salvar