| @@ -49,6 +49,9 @@ public class WxChatController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| WxAppinfoService wxAppinfoServie; | WxAppinfoService wxAppinfoServie; | ||||
| @Autowired | |||||
| WxLinkService wxLinkService; | |||||
| @GetMapping("/limit") | @GetMapping("/limit") | ||||
| public ResultData chatLimit() { | public ResultData chatLimit() { | ||||
| Map retMap = new HashMap(); | Map retMap = new HashMap(); | ||||
| @@ -86,9 +89,21 @@ public class WxChatController extends BaseController { | |||||
| @GetMapping("/link") | @GetMapping("/link") | ||||
| public ResultData link() { | public ResultData link() { | ||||
| Map retMap = new HashMap(); | Map retMap = new HashMap(); | ||||
| TenantEntity tenantEntity = getCUser(); | |||||
| SysConfig config = sysConfigService.getByKey(SysConfigConstant.linkQrCode, tenantEntity); | |||||
| retMap.put("linkQrCode", config.getConfigItemValue()); | |||||
| WxCUser user = getCUser(); | |||||
| SysConfig linkFirstSlogan = sysConfigService.getByKey(SysConfigConstant.linkFirstSlogan, user); | |||||
| retMap.put("linkFirstSlogan", linkFirstSlogan.getConfigItemValue()); | |||||
| SysConfig linkSecondSlogan = sysConfigService.getByKey(SysConfigConstant.linkSecondSlogan, user); | |||||
| retMap.put("linkSecondSlogan", linkSecondSlogan.getConfigItemValue()); | |||||
| SysConfig linkCompany = sysConfigService.getByKey(SysConfigConstant.linkCompany, user); | |||||
| retMap.put("linkCompany", linkCompany.getConfigItemValue()); | |||||
| SysConfig linkCompanyAddress = sysConfigService.getByKey(SysConfigConstant.linkCompanyAddress, user); | |||||
| retMap.put("linkCompanyAddress", linkCompanyAddress.getConfigItemValue()); | |||||
| List<WxLink> linkList = wxLinkService.getCLinkList(user); | |||||
| retMap.put("linkList", linkList); | |||||
| return new ResultData(retMap); | return new ResultData(retMap); | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,30 @@ | |||||
| 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_link") | |||||
| @Data | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| @ToString | |||||
| public class WxLink 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="qrCode") | |||||
| private String qrCode; | |||||
| @io.swagger.annotations.ApiModelProperty(value="电话",name="phone") | |||||
| private String phone; | |||||
| @io.swagger.annotations.ApiModelProperty(value="邮箱",name="email") | |||||
| private String email; | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.mapper; | |||||
| import java.util.*; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxLink; | |||||
| public interface WxLinkMapper extends CommonMapper<WxLink, Long> { | |||||
| WxLink selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||||
| List<WxLink> findList(WxLink wxLink); | |||||
| } | |||||
| @@ -0,0 +1,25 @@ | |||||
| package com.iformall.service; | |||||
| import com.iformall.domain.po.WxLink; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import java.util.List; | |||||
| public interface WxLinkService { | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxLink getById(Long id,String tenantId); | |||||
| List<WxLink> list(WxLink product); | |||||
| List<WxLink> getCLinkList(TenantEntity tenantEntity); | |||||
| WxLink getCLink(TenantEntity tenantEntity,Long id); | |||||
| } | |||||
| @@ -0,0 +1,53 @@ | |||||
| package com.iformall.service.cache; | |||||
| import java.util.List; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import com.iformall.domain.po.WxLink; | |||||
| import com.iformall.utils.Constant; | |||||
| import com.iformall.utils.RedisCacheUtils; | |||||
| public class WxLinkCache { | |||||
| private static String getKey(Long linkId) { | |||||
| String key = Constant.linkPrev + linkId; | |||||
| return key; | |||||
| } | |||||
| public static WxLink getCache(RedisTemplate<String, Object> redisTemplate,Long linkId) { | |||||
| String key = getKey(linkId); | |||||
| return RedisCacheUtils.getCacheObject(redisTemplate, key, WxLink.class); | |||||
| } | |||||
| public static void cache(RedisTemplate<String, Object> redisTemplate,WxLink link) { | |||||
| String key = getKey(link.getId()); | |||||
| RedisCacheUtils.cache(redisTemplate, key, link, 3600*24*7); | |||||
| } | |||||
| public static void removeCache(RedisTemplate<String, Object> redisTemplate,Long linkId) { | |||||
| String key = getKey(linkId); | |||||
| RedisCacheUtils.removeCache(redisTemplate, key); | |||||
| } | |||||
| private static String getListKey(String tenantId) { | |||||
| String key = Constant.linkListPrev + tenantId; | |||||
| return key; | |||||
| } | |||||
| public static List<WxLink> getCacheList(RedisTemplate<String, Object> redisTemplate,String tenantId) { | |||||
| String key = getListKey(tenantId); | |||||
| return RedisCacheUtils.getCacheListObject(redisTemplate, key, WxLink.class); | |||||
| } | |||||
| public static void cacheList(RedisTemplate<String, Object> redisTemplate,List<WxLink> wxLinkList,String tenantId) { | |||||
| String key = getListKey(tenantId); | |||||
| RedisCacheUtils.cache(redisTemplate, key, wxLinkList, 3600*24*7); | |||||
| } | |||||
| public static void removeCacheList(RedisTemplate<String, Object> redisTemplate,String tenantId) { | |||||
| String key = getListKey(tenantId); | |||||
| RedisCacheUtils.removeCache(redisTemplate, key); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,67 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.iformall.domain.po.WxLink; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.mapper.WxLinkMapper; | |||||
| import com.iformall.service.WxLinkService; | |||||
| import com.iformall.service.cache.WxLinkCache; | |||||
| 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 WxLinkServiceImpl implements WxLinkService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxLinkMapper wxLinkMapper; | |||||
| @Autowired | |||||
| @Qualifier("objectCommonRedisTemplate") | |||||
| RedisTemplate<String, Object> objectCommonRedisTemplate; | |||||
| @Override | |||||
| public WxLink getById(Long id, String tenantId) { | |||||
| return wxLinkMapper.selectById(id, tenantId); | |||||
| } | |||||
| @Override | |||||
| public List<WxLink> list(WxLink product) { | |||||
| return wxLinkMapper.findList(product); | |||||
| } | |||||
| @Override | |||||
| public List<WxLink> getCLinkList(TenantEntity tenantEntity) { | |||||
| List<WxLink> productList = WxLinkCache.getCacheList(objectCommonRedisTemplate,tenantEntity.getTenantId()); | |||||
| if (null == productList || productList.size() <= 0 ) { | |||||
| WxLink p = new WxLink(); | |||||
| p.updateTenantInfo(tenantEntity); | |||||
| List<WxLink> plist = list(p); | |||||
| if (null != plist && plist.size() > 0 ) { | |||||
| WxLinkCache.cacheList(objectCommonRedisTemplate, plist,tenantEntity.getTenantId()); | |||||
| return plist; | |||||
| } | |||||
| } | |||||
| return productList; | |||||
| } | |||||
| @Override | |||||
| public WxLink getCLink(TenantEntity tenantEntity,Long id) { | |||||
| WxLink _product = WxLinkCache.getCache(objectCommonRedisTemplate,id); | |||||
| if (null == _product) { | |||||
| _product = getById(id, tenantEntity.getTenantId()); | |||||
| if (null != _product) { | |||||
| WxLinkCache.cache(objectCommonRedisTemplate, _product); | |||||
| } | |||||
| } | |||||
| return _product; | |||||
| } | |||||
| } | |||||
| @@ -11,6 +11,8 @@ public class Constant { | |||||
| public static final String payaccountPrev = "gpt:payAccount:"; | public static final String payaccountPrev = "gpt:payAccount:"; | ||||
| public static final String noticePrev = "gpt:notice:"; | public static final String noticePrev = "gpt:notice:"; | ||||
| public static final String noticeListPrev = "gpt:noticeList:"; | 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 currentUser = "currentUser"; | public static final String currentUser = "currentUser"; | ||||
| public static final String TENANT_ID = "tenantId"; | public static final String TENANT_ID = "tenantId"; | ||||
| public static final String PARENT_TENANT_ID = "parentTenantId"; | public static final String PARENT_TENANT_ID = "parentTenantId"; | ||||
| @@ -6,6 +6,9 @@ public class SysConfigConstant { | |||||
| public static final String freeDays="freeDays"; | public static final String freeDays="freeDays"; | ||||
| public static final String promotContentCount="promotContentCount"; | public static final String promotContentCount="promotContentCount"; | ||||
| public static final String completionContentCount="completionContentCount"; | public static final String completionContentCount="completionContentCount"; | ||||
| public static final String linkQrCode="linkQrCode"; | |||||
| public static final String linkFirstSlogan="linkFirstSlogan"; | |||||
| public static final String linkSecondSlogan="linkSecondSlogan"; | |||||
| public static final String linkCompany="linkCompany"; | |||||
| public static final String linkCompanyAddress="linkCompanyAddress"; | |||||
| } | } | ||||
| @@ -0,0 +1,58 @@ | |||||
| <?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.WxLinkMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxLink"> | |||||
| <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="qr_code" jdbcType="VARCHAR" property="qrCode"/> | |||||
| <result column="phone" jdbcType="VARCHAR" property="phone"/> | |||||
| <result column="email" jdbcType="VARCHAR" property="email"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`qr_code`,`phone`,`email` | |||||
| </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 != 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_link where id = #{id} and tenant_id = #{tenantId} | |||||
| </select> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxLink" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_link | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| </mapper> | |||||