浏览代码

代码优化

JiangChongBo 2 年之前
父节点
当前提交
ec22b8d8e4

+ 0 - 7
src/main/java/com/caimei/controller/wechat/LoginApi.java

@@ -90,11 +90,4 @@ public class LoginApi {
         }
         return loginService.passwordLogin(mobile, password, authUserId);
     }
-    @ApiOperation("根据token获取用户信息")
-    @GetMapping("/token/check")
-    public ResponseJson<WxClubUserVo> getUserInfoByToken(HttpServletRequest httpRequest) {
-
-        return loginService.getUserInfoByToken(httpRequest);
-    }
-
 }

+ 11 - 0
src/main/java/com/caimei/controller/wechat/WxDataApi.java

@@ -11,6 +11,7 @@ import com.caimei.service.data.DatabaseService;
 import com.caimei.service.data.FileService;
 import com.caimei.service.data.ImageService;
 import com.caimei.service.data.VideoService;
+import com.caimei.service.wechat.LoginService;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -20,6 +21,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
@@ -38,6 +40,7 @@ public class WxDataApi {
     private final FileService fileService;
     private final AuthClubService authClubService;
     private final DatabaseService databaseService;
+    private final LoginService loginService;
 
     @ApiOperation("资料库文章列表")
     @ApiImplicitParams({
@@ -138,4 +141,12 @@ public class WxDataApi {
         return authClubService.submitFeedback(clubUserId, content);
     }
 
+    @ApiOperation("根据token获取用户信息")
+    @GetMapping("/token/check")
+
+    public ResponseJson<WxClubUserVo> getUserInfoByToken(HttpServletRequest httpRequest) {
+
+        return loginService.getUserInfoByToken(httpRequest);
+    }
+
 }

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

@@ -93,7 +93,7 @@ public interface AuthProductMapper {
 
     void checkAuthProduct(Integer productId);
 
-    void insertProductRelation(ProductRelationVo relationVo);
+    Integer insertProductRelation(@Param("authId") Integer authId, @Param("productId") Integer productId, @Param("authType") Integer authType);
 
     ProductRelationVo getProductRelation(@Param("relationId") Integer relationId, @Param("productId") Integer productId, @Param("authId") Integer authId);
 

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

@@ -310,13 +310,8 @@ public class AuthProductServiceImpl implements AuthProductService {
                 // 关联设备,更新设备
                 authProductMapper.updateProductByProductId(product);
             }
-            ProductRelationVo relationVo = new ProductRelationVo();
-            relationVo.setAuthId(authId);
-            relationVo.setProductId(product.getProductId());
-            relationVo.setAuthType(authType);
             // 插入机构设备关联关系
-            authProductMapper.insertProductRelation(relationVo);
-            relationId = relationVo.getRelationId();
+            relationId = authProductMapper.insertProductRelation(authId, product.getProductId(), authType);
         } else {
             if (1 == dbRelation.getAuthType()) {
                 // 更新设备
@@ -470,7 +465,7 @@ public class AuthProductServiceImpl implements AuthProductService {
                 map.put("addWord2_style", Font.BOLD);
                 map.put("addWord2_size", (int) Math.round(90 * rate));
                 map.put("addWord2_x", (int) Math.round(2168 * rate));
-                map.put("addWord2_y", (int) Math.round(3157 * rate));
+                map.put("addWord2_y", (int) Math.round(3160 * rate));
             }
             // 添加认证日期信息
             if (null != product.getCreateTime()) {
@@ -481,7 +476,7 @@ public class AuthProductServiceImpl implements AuthProductService {
                 map.put("addWord3_style", Font.PLAIN);
                 map.put("addWord3_size", (int) Math.round(90 * rate));
                 map.put("addWord3_x", (int) Math.round(2085 * rate));
-                map.put("addWord3_y", (int) Math.round(3289 * rate));
+                map.put("addWord3_y", (int) Math.round(3292 * rate));
             }
             // 添加二维码信息
             if (StringUtils.isNotEmpty(template.getQrPosition())) {

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

@@ -239,6 +239,7 @@ public class LoginServiceImpl implements LoginService {
         }
         String[] club = token.split(",");
         WxClubUserVo userInfoByToken = clubMapper.getUserInfoByToken(Integer.valueOf(club[2]));
+        userInfoByToken.setAccessToken(tokenStr);
         //从token中获取clubuserid
         return ResponseJson.success(userInfoByToken);
     }

+ 35 - 35
src/main/resources/mapper/AuthProductMapper.xml

@@ -26,15 +26,15 @@
         insert into cm_brand_product_type_param (productTypeId, name, content)
         values (#{productTypeId}, #{paramName}, #{paramContent})
     </insert>
+    <insert id="insertProductRelation" useGeneratedKeys="true" keyColumn="id">
+        insert into cm_brand_product_relation (authId, productId, authType)
+        values (#{authId}, #{productId}, #{authType})
+    </insert>
     <insert id="addScanCount">
         update cm_brand_auth_product
         set scanCount = scanCount + 1
         where id = #{productId}
     </insert>
-    <insert id="insertProductRelation" useGeneratedKeys="true" parameterType="com.caimei.model.vo.ProductRelationVo" keyProperty="relationId" keyColumn="id">
-        insert into cm_brand_product_relation (authId, productId, authType)
-        values (#{authId}, #{productId}, #{authType})
-    </insert>
 
     <update id="updateProductStatusByProductId">
         update cm_brand_auth_product
@@ -44,32 +44,32 @@
     <update id="updateProductByProductId">
         update cm_brand_auth_product
         set
-            `infoId`           = #{infoId},
-            `productTypeId`    = #{productTypeId},
-            `snCode`           = #{snCode},
-            `certificateImageType` = #{certificateImageType},
-            `certificateImage` = #{certificateImage},
-            <if test="pcCertificateImage != null and pcCertificateImage != ''">
-                `pcCertificateImage`      = #{pcCertificateImage},
-            </if>
-            <if test="appletsCertificateImage != null and appletsCertificateImage != ''">
-                `appletsCertificateImage`      = #{appletsCertificateImage},
-            </if>
-            <if test="name != null and name != ''">
-                name = #{name},
-                image = #{image},
-            </if>
-            <if test="productTypeId != null">
-                productTypeId = #{productTypeId},
-                name = null,
-                image = null,
-            </if>
-            purchaseWay        = #{purchaseWay},
-            invoiceImage       = #{invoiceImage},
-            `status`           = #{status},
-            `auditStatus`      = #{auditStatus},
-            `shopAuditStatus`  = #{shopAuditStatus},
-            checkFlag          = #{checkFlag}
+        `infoId`           = #{infoId},
+        `productTypeId`    = #{productTypeId},
+        `snCode`           = #{snCode},
+        `certificateImageType` = #{certificateImageType},
+        `certificateImage` = #{certificateImage},
+        <if test="pcCertificateImage != null and pcCertificateImage != ''">
+            `pcCertificateImage`      = #{pcCertificateImage},
+        </if>
+        <if test="appletsCertificateImage != null and appletsCertificateImage != ''">
+            `appletsCertificateImage`      = #{appletsCertificateImage},
+        </if>
+        <if test="name != null and name != ''">
+            name = #{name},
+            image = #{image},
+        </if>
+        <if test="productTypeId != null">
+            productTypeId = #{productTypeId},
+            name = null,
+            image = null,
+        </if>
+        purchaseWay        = #{purchaseWay},
+        invoiceImage       = #{invoiceImage},
+        `status`           = #{status},
+        `auditStatus`      = #{auditStatus},
+        `shopAuditStatus`  = #{shopAuditStatus},
+        checkFlag          = #{checkFlag}
         where id = #{productId};
     </update>
     <update id="updateImageByProductId">
@@ -364,7 +364,7 @@
           and p.auditStatus = 1
           and t.status = 1
           and t.auditStatus = 1
-        limit 1
+            limit 1
     </select>
     <select id="getAuthProductParams" resultType="com.caimei.model.po.ProductParamPo">
         select p.name as paramName, p.content as paramContent
@@ -411,7 +411,7 @@
     <select id="getWxProductTypeList" resultType="com.caimei.model.vo.WxProductTypeListVo">
         select t.id as productTypeId,t.name,t.image
         from cm_brand_product_type t
-            left join cm_brand_auth_user u on t.authUserId = u.authUserId
+        left join cm_brand_auth_user u on t.authUserId = u.authUserId
         where u.authUserId = #{authUserId} and t.delFlag = 0 and t.status = 1 and auditStatus = 1
         <if test="name != null and name != ''">
             and t.name like concat('%',#{name},'%')
@@ -449,7 +449,7 @@
                  left join cm_brand_product_relation r on p.id = r.productId
                  left join cm_brand_auth a on r.authId = a.id
         where p.id = #{productId} and a.delFlag = 0
-        limit 1
+            limit 1
     </select>
     <select id="getProductTypeParamList" resultType="com.caimei.model.po.ProductParamPo">
         select name as paramName, content as paramContent
@@ -490,8 +490,8 @@
     <select id="getSnCodeList" resultType="java.lang.String">
         select DISTINCT snCode
         from cm_brand_auth_product p
-                 left join cm_brand_product_relation r on p.id = r.productId
-                 left join cm_brand_auth a on a.id = r.authId
+        left join cm_brand_product_relation r on p.id = r.productId
+        left join cm_brand_auth a on a.id = r.authId
         where a.authUserId = #{authUserId} and a.delFlag = 0 and (r.authType = 2 or (r.authType = 1 and a.id != #{authId}) ) and p.auditStatus = 1
         <if test="snCodeList != null and snCodeList.size>0">
             and p.snCode not in