Browse Source

前端设备搜索

Aslee 2 years ago
parent
commit
af151baa44

+ 69 - 0
src/main/java/com/caimei/config/RedisCacheConfig.java

@@ -0,0 +1,69 @@
+package com.caimei.config;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.cache.RedisCacheWriter;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.RedisSerializationContext;
+
+import java.io.Serializable;
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/4/28
+ */
+@Configuration
+@EnableCaching
+public class RedisCacheConfig implements Serializable {
+/**
+     * 最新版,设置redis缓存过期时间
+     */
+
+    @Bean
+    public RedisCacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
+        return new RedisCacheManager(
+           RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory),
+           // 默认策略,未配置的 key 会使用这个,3小时失效
+           this.getRedisCacheConfigurationWithTtl( 3 * 60 * 60),
+           // 指定 key 策略
+           this.getRedisCacheConfigurationMap()
+        );
+    }
+
+    private Map<String, RedisCacheConfiguration> getRedisCacheConfigurationMap() {
+        Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>();
+        //自定义设置缓存时间,6小时
+//        redisCacheConfigurationMap.put("getCommodityClassify", this.getRedisCacheConfigurationWithTtl(6 * 60 * 60));
+        return redisCacheConfigurationMap;
+    }
+
+
+    private RedisCacheConfiguration getRedisCacheConfigurationWithTtl(Integer seconds) {
+        Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
+        ObjectMapper om = new ObjectMapper();
+        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
+        jackson2JsonRedisSerializer.setObjectMapper(om);
+        RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig();
+        redisCacheConfiguration = redisCacheConfiguration.serializeValuesWith(
+                RedisSerializationContext
+                        .SerializationPair
+                        .fromSerializer(jackson2JsonRedisSerializer)
+        ).entryTtl(Duration.ofSeconds(seconds));
+
+        return redisCacheConfiguration;
+    }
+
+}

+ 4 - 2
src/main/java/com/caimei/controller/wechat/WxAuthApi.java

@@ -105,16 +105,18 @@ public class WxAuthApi {
     @ApiImplicitParams({
     @ApiImplicitParams({
             @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1供应商设备分类上线设备列表 2设备认证列表"),
             @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1供应商设备分类上线设备列表 2设备认证列表"),
             @ApiImplicitParam(name = "authId", required = false, value = "机构id"),
             @ApiImplicitParam(name = "authId", required = false, value = "机构id"),
+            @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"),
             @ApiImplicitParam(name = "productTypeId", required = false, value = "设备分类id"),
             @ApiImplicitParam(name = "productTypeId", required = false, value = "设备分类id"),
             @ApiImplicitParam(name = "snCode", required = false, value = "sn码后四位"),
             @ApiImplicitParam(name = "snCode", required = false, value = "sn码后四位"),
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     })
     @GetMapping("/product/list")
     @GetMapping("/product/list")
-    public ResponseJson<PageInfo<WxProductListVo>> getWxProductList(Integer listType, Integer authId, Integer productTypeId, String snCode,
+    public ResponseJson<PageInfo<WxProductListVo>> getWxProductList(Integer listType, Integer authId, Integer productTypeId,
+                                                                    String authParty, String snCode,
                                                                     @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                                     @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                                     @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
                                                                     @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
-        return authProductService.getWxProductList(listType, authId, productTypeId, snCode, pageNum, pageSize);
+        return authProductService.getWxProductList(listType, authId, authParty, productTypeId, snCode, pageNum, pageSize);
     }
     }
 
 
     /**
     /**

+ 1 - 1
src/main/java/com/caimei/mapper/cmMapper/AuthProductMapper.java

@@ -52,7 +52,7 @@ public interface AuthProductMapper {
 
 
     void updateProductAuditStatus(@Param("productId") Integer productId, @Param("productTypeId") Integer productTypeId, @Param("status") Integer status, @Param("auditStatus") Integer auditStatus, @Param("invalidReason") String invalidReason, @Param("auditBy") Integer auditBy, @Param("auditTime") Date auditTime);
     void updateProductAuditStatus(@Param("productId") Integer productId, @Param("productTypeId") Integer productTypeId, @Param("status") Integer status, @Param("auditStatus") Integer auditStatus, @Param("invalidReason") String invalidReason, @Param("auditBy") Integer auditBy, @Param("auditTime") Date auditTime);
 
 
-    List<WxProductListVo> getWxProductList(@Param("listType") Integer listType, @Param("authId") Integer authId, @Param("productTypeId") Integer productTypeId, @Param("snCode") String snCode);
+    List<WxProductListVo> getWxProductList(@Param("listType") Integer listType, @Param("authId") Integer authId, @Param("authParty") String authParty, @Param("productTypeId") Integer productTypeId, @Param("snCode") String snCode);
 
 
     Integer getBrandIdByBrandName(String brand);
     Integer getBrandIdByBrandName(String brand);
 
 

+ 2 - 1
src/main/java/com/caimei/service/auth/AuthProductService.java

@@ -106,13 +106,14 @@ public interface AuthProductService {
      * 微信公众号机构列表
      * 微信公众号机构列表
      *
      *
      * @param listType
      * @param listType
+     * @param authParty
      * @param productTypeId         设备分类id
      * @param productTypeId         设备分类id
      * @param snCode   sn码后四位
      * @param snCode   sn码后四位
      * @param pageNum       第几页
      * @param pageNum       第几页
      * @param pageSize      一页多少条
      * @param pageSize      一页多少条
      * @return
      * @return
      */
      */
-    ResponseJson<PageInfo<WxProductListVo>> getWxProductList(Integer listType, Integer authId, Integer productTypeId, String snCode, Integer pageNum, Integer pageSize);
+    ResponseJson<PageInfo<WxProductListVo>> getWxProductList(Integer listType, Integer authId, String authParty, Integer productTypeId, String snCode, Integer pageNum, Integer pageSize);
 
 
     /**
     /**
      * 认证商品详情
      * 认证商品详情

+ 2 - 0
src/main/java/com/caimei/service/auth/impl/AddressServiceImpl.java

@@ -16,6 +16,7 @@ import com.caimei.utils.RequestUtil;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
@@ -71,6 +72,7 @@ public class AddressServiceImpl implements AddressService {
     }
     }
 
 
     @Override
     @Override
+    @Cacheable(value = "getAllAddress")
     public ResponseJson<List<AddressSelectVo>> getAllSelectAddress() {
     public ResponseJson<List<AddressSelectVo>> getAllSelectAddress() {
         // 获取所有省份列表
         // 获取所有省份列表
         List<AddressSelectVo> provinceList = addressMapper.getAllProvinceList();
         List<AddressSelectVo> provinceList = addressMapper.getAllProvinceList();

+ 2 - 2
src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java

@@ -490,13 +490,13 @@ public class AuthProductServiceImpl implements AuthProductService {
     }
     }
 
 
     @Override
     @Override
-    public ResponseJson<PageInfo<WxProductListVo>> getWxProductList(Integer listType, Integer authId, Integer productTypeId, String snCode, Integer pageNum, Integer pageSize) {
+    public ResponseJson<PageInfo<WxProductListVo>> getWxProductList(Integer listType, Integer authId, String authParty, Integer productTypeId, String snCode, Integer pageNum, Integer pageSize) {
         listType = null == listType ? 1 : listType;
         listType = null == listType ? 1 : listType;
         if (1 == listType && null == productTypeId) {
         if (1 == listType && null == productTypeId) {
             return ResponseJson.error("参数异常,请输入设备分类id", null);
             return ResponseJson.error("参数异常,请输入设备分类id", null);
         }
         }
         PageHelper.startPage(pageNum, pageSize);
         PageHelper.startPage(pageNum, pageSize);
-        List<WxProductListVo> productList = authProductMapper.getWxProductList(listType, authId, productTypeId, snCode);
+        List<WxProductListVo> productList = authProductMapper.getWxProductList(listType, authId, authParty, productTypeId, snCode);
         PageInfo<WxProductListVo> pageData = new PageInfo<>(productList);
         PageInfo<WxProductListVo> pageData = new PageInfo<>(productList);
         return ResponseJson.success(pageData);
         return ResponseJson.success(pageData);
     }
     }

+ 1 - 4
src/main/java/com/caimei/service/wechat/impl/LoginServiceImpl.java

@@ -100,11 +100,8 @@ public class LoginServiceImpl implements LoginService {
             return ResponseJson.error("供应商不存在");
             return ResponseJson.error("供应商不存在");
         } else {
         } else {
             shopName = shop.getShopName();
             shopName = shop.getShopName();
-            if (shopName.contains("上海品辉")) {
-                shopName = "上海品辉";
-            }
         }
         }
-        String verifyCode = "prod".equals(active) ? CodeUtil.generateCodeInt(6) : "666666";;
+        String verifyCode = "prod".equals(active) ? CodeUtil.generateCodeInt(6) : "666666";
         String content = "欢迎登录" + shopName + "会员,您的短信验证码为:" + verifyCode + ",该验证码 5 分钟内有效,请勿泄漏于他人。";
         String content = "欢迎登录" + shopName + "会员,您的短信验证码为:" + verifyCode + ",该验证码 5 分钟内有效,请勿泄漏于他人。";
         Boolean sendSms = SmsUtils.sendSms(11, mobile, content);
         Boolean sendSms = SmsUtils.sendSms(11, mobile, content);
         if (!sendSms) {
         if (!sendSms) {

+ 4 - 1
src/main/resources/mapper/AuthProductMapper.xml

@@ -273,11 +273,14 @@
                 and t.auditStatus = 1
                 and t.auditStatus = 1
             </if>
             </if>
             <if test="snCode != null and snCode != ''">
             <if test="snCode != null and snCode != ''">
-                and p.snCode like concat('%',#{snCode})
+                and p.snCode like concat('%',#{snCode},'%')
             </if>
             </if>
             <if test="authId != null">
             <if test="authId != null">
                 and p.authId = #{authId}
                 and p.authId = #{authId}
             </if>
             </if>
+            <if test="authParty != null and authParty != ''">
+                and a.authParty like concat('%',#{authParty},'%')
+            </if>
         </where>
         </where>
         order by p.createTime desc
         order by p.createTime desc
     </select>
     </select>