丁云鹏 10 bulan lalu
induk
melakukan
e860316ea5

+ 0 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/MBG.java

@@ -6,8 +6,6 @@ import org.mybatis.generator.config.xml.ConfigurationParser;
 import org.mybatis.generator.internal.DefaultShellCallback;
 
 import java.io.File;
-import java.io.IOException;
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 

+ 36 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/mapper/crawler/ArticleGzhDeveloperMapper.java

@@ -0,0 +1,36 @@
+package com.tzld.longarticle.recommend.server.repository.mapper.crawler;
+
+import com.tzld.longarticle.recommend.server.repository.model.ArticleGzhDeveloper;
+import com.tzld.longarticle.recommend.server.repository.model.ArticleGzhDeveloperExample;
+import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface ArticleGzhDeveloperMapper {
+    long countByExample(ArticleGzhDeveloperExample example);
+
+    int deleteByExample(ArticleGzhDeveloperExample example);
+
+    int deleteByPrimaryKey(String gzhId);
+
+    int insert(ArticleGzhDeveloper row);
+
+    int insertSelective(ArticleGzhDeveloper row);
+
+    List<ArticleGzhDeveloper> selectByExample(ArticleGzhDeveloperExample example);
+
+    ArticleGzhDeveloper selectByPrimaryKey(String gzhId);
+
+    int updateByExampleSelective(@Param("row") ArticleGzhDeveloper row, @Param("example") ArticleGzhDeveloperExample example);
+
+    int updateByExample(@Param("row") ArticleGzhDeveloper row, @Param("example") ArticleGzhDeveloperExample example);
+
+    int updateByPrimaryKeySelective(ArticleGzhDeveloper row);
+
+    int updateByPrimaryKey(ArticleGzhDeveloper row);
+
+    String selectGzhIdByAppId(String appId);
+
+}

+ 23 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/model/ArticleGzhDeveloper.java

@@ -0,0 +1,23 @@
+package com.tzld.longarticle.recommend.server.repository.model;
+
+public class ArticleGzhDeveloper {
+    private String gzhId;
+
+    private String appId;
+
+    public String getGzhId() {
+        return gzhId;
+    }
+
+    public void setGzhId(String gzhId) {
+        this.gzhId = gzhId == null ? null : gzhId.trim();
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId == null ? null : appId.trim();
+    }
+}

+ 339 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/model/ArticleGzhDeveloperExample.java

@@ -0,0 +1,339 @@
+package com.tzld.longarticle.recommend.server.repository.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ArticleGzhDeveloperExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    public ArticleGzhDeveloperExample() {
+        oredCriteria = new ArrayList<>();
+    }
+
+    public void setOrderByClause(String orderByClause) {
+        this.orderByClause = orderByClause;
+    }
+
+    public String getOrderByClause() {
+        return orderByClause;
+    }
+
+    public void setDistinct(boolean distinct) {
+        this.distinct = distinct;
+    }
+
+    public boolean isDistinct() {
+        return distinct;
+    }
+
+    public List<Criteria> getOredCriteria() {
+        return oredCriteria;
+    }
+
+    public void or(Criteria criteria) {
+        oredCriteria.add(criteria);
+    }
+
+    public Criteria or() {
+        Criteria criteria = createCriteriaInternal();
+        oredCriteria.add(criteria);
+        return criteria;
+    }
+
+    public Criteria createCriteria() {
+        Criteria criteria = createCriteriaInternal();
+        if (oredCriteria.size() == 0) {
+            oredCriteria.add(criteria);
+        }
+        return criteria;
+    }
+
+    protected Criteria createCriteriaInternal() {
+        Criteria criteria = new Criteria();
+        return criteria;
+    }
+
+    public void clear() {
+        oredCriteria.clear();
+        orderByClause = null;
+        distinct = false;
+    }
+
+    protected abstract static class GeneratedCriteria {
+        protected List<Criterion> criteria;
+
+        protected GeneratedCriteria() {
+            super();
+            criteria = new ArrayList<>();
+        }
+
+        public boolean isValid() {
+            return criteria.size() > 0;
+        }
+
+        public List<Criterion> getAllCriteria() {
+            return criteria;
+        }
+
+        public List<Criterion> getCriteria() {
+            return criteria;
+        }
+
+        protected void addCriterion(String condition) {
+            if (condition == null) {
+                throw new RuntimeException("Value for condition cannot be null");
+            }
+            criteria.add(new Criterion(condition));
+        }
+
+        protected void addCriterion(String condition, Object value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value));
+        }
+
+        protected void addCriterion(String condition, Object value1, Object value2, String property) {
+            if (value1 == null || value2 == null) {
+                throw new RuntimeException("Between values for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value1, value2));
+        }
+
+        public Criteria andGzhIdIsNull() {
+            addCriterion("gzh_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andGzhIdIsNotNull() {
+            addCriterion("gzh_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andGzhIdEqualTo(String value) {
+            addCriterion("gzh_id =", value, "gzhId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGzhIdNotEqualTo(String value) {
+            addCriterion("gzh_id <>", value, "gzhId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGzhIdGreaterThan(String value) {
+            addCriterion("gzh_id >", value, "gzhId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGzhIdGreaterThanOrEqualTo(String value) {
+            addCriterion("gzh_id >=", value, "gzhId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGzhIdLessThan(String value) {
+            addCriterion("gzh_id <", value, "gzhId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGzhIdLessThanOrEqualTo(String value) {
+            addCriterion("gzh_id <=", value, "gzhId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGzhIdLike(String value) {
+            addCriterion("gzh_id like", value, "gzhId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGzhIdNotLike(String value) {
+            addCriterion("gzh_id not like", value, "gzhId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGzhIdIn(List<String> values) {
+            addCriterion("gzh_id in", values, "gzhId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGzhIdNotIn(List<String> values) {
+            addCriterion("gzh_id not in", values, "gzhId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGzhIdBetween(String value1, String value2) {
+            addCriterion("gzh_id between", value1, value2, "gzhId");
+            return (Criteria) this;
+        }
+
+        public Criteria andGzhIdNotBetween(String value1, String value2) {
+            addCriterion("gzh_id not between", value1, value2, "gzhId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdIsNull() {
+            addCriterion("app_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdIsNotNull() {
+            addCriterion("app_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdEqualTo(String value) {
+            addCriterion("app_id =", value, "appId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdNotEqualTo(String value) {
+            addCriterion("app_id <>", value, "appId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdGreaterThan(String value) {
+            addCriterion("app_id >", value, "appId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdGreaterThanOrEqualTo(String value) {
+            addCriterion("app_id >=", value, "appId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdLessThan(String value) {
+            addCriterion("app_id <", value, "appId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdLessThanOrEqualTo(String value) {
+            addCriterion("app_id <=", value, "appId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdLike(String value) {
+            addCriterion("app_id like", value, "appId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdNotLike(String value) {
+            addCriterion("app_id not like", value, "appId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdIn(List<String> values) {
+            addCriterion("app_id in", values, "appId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdNotIn(List<String> values) {
+            addCriterion("app_id not in", values, "appId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdBetween(String value1, String value2) {
+            addCriterion("app_id between", value1, value2, "appId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppIdNotBetween(String value1, String value2) {
+            addCriterion("app_id not between", value1, value2, "appId");
+            return (Criteria) this;
+        }
+    }
+
+    public static class Criteria extends GeneratedCriteria {
+        protected Criteria() {
+            super();
+        }
+    }
+
+    public static class Criterion {
+        private String condition;
+
+        private Object value;
+
+        private Object secondValue;
+
+        private boolean noValue;
+
+        private boolean singleValue;
+
+        private boolean betweenValue;
+
+        private boolean listValue;
+
+        private String typeHandler;
+
+        public String getCondition() {
+            return condition;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object getSecondValue() {
+            return secondValue;
+        }
+
+        public boolean isNoValue() {
+            return noValue;
+        }
+
+        public boolean isSingleValue() {
+            return singleValue;
+        }
+
+        public boolean isBetweenValue() {
+            return betweenValue;
+        }
+
+        public boolean isListValue() {
+            return listValue;
+        }
+
+        public String getTypeHandler() {
+            return typeHandler;
+        }
+
+        protected Criterion(String condition) {
+            super();
+            this.condition = condition;
+            this.typeHandler = null;
+            this.noValue = true;
+        }
+
+        protected Criterion(String condition, Object value, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.typeHandler = typeHandler;
+            if (value instanceof List<?>) {
+                this.listValue = true;
+            } else {
+                this.singleValue = true;
+            }
+        }
+
+        protected Criterion(String condition, Object value) {
+            this(condition, value, null);
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.secondValue = secondValue;
+            this.typeHandler = typeHandler;
+            this.betweenValue = true;
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue) {
+            this(condition, value, secondValue, null);
+        }
+    }
+}

+ 14 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/UserManagementService.java

@@ -2,7 +2,9 @@ package com.tzld.longarticle.recommend.server.service;
 
 import com.tzld.longarticle.recommend.server.model.WxUserGetResponse;
 import com.tzld.longarticle.recommend.server.remote.WxUserManagementRemoteService;
+import com.tzld.longarticle.recommend.server.repository.mapper.crawler.ArticleGzhDeveloperMapper;
 import com.tzld.longarticle.recommend.server.repository.mapper.crawler.ArticleUserGroupMapper;
+import com.tzld.longarticle.recommend.server.repository.model.ArticleGzhDeveloper;
 import com.tzld.longarticle.recommend.server.repository.model.ArticleUserGroup;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -29,7 +31,10 @@ public class UserManagementService {
     @Autowired
     private ArticleUserGroupMapper articleUserGroupMapper;
 
-    public void addGZH(String gzhId, int groupNum) {
+    @Autowired
+    private ArticleGzhDeveloperMapper articleGzhDeveloperMapper;
+
+    public void addGZH(String gzhId, String appId, int groupNum) {
 
         // syncAllUserOnce(gzhId, groupNum);
 
@@ -89,6 +94,11 @@ public class UserManagementService {
         }
 
         log.info("end sync user gzhId={}", gzhId);
+
+        ArticleGzhDeveloper obj = new ArticleGzhDeveloper();
+        obj.setAppId(appId);
+        obj.setGzhId(gzhId);
+        articleGzhDeveloperMapper.insert(obj);
 //        log.info("start group gzhId={}", gzhId);
 
 
@@ -142,7 +152,9 @@ public class UserManagementService {
                 param.put(e.getName(), e.getTextTrim());
             }
 
-            String gzhId = param.get("ToUserName");
+            String appId = param.get("ToUserName");
+            String gzhId = articleGzhDeveloperMapper.selectGzhIdByAppId(appId);
+
             String openId = param.get("FromUserName");
             if (StringUtils.equals("event", param.get("MsgType"))) {
                 String event = param.get("Event");

+ 2 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/UserManagementController.java

@@ -24,8 +24,9 @@ public class UserManagementController {
 
     @RequestMapping("/addGZH")
     public String addGZH(@RequestParam(name = "gzhId") String gzhId,
+                         @RequestParam(name = "appId") String appId,
                          @RequestParam(name = "groupNum") int groupNum) {
-        userManagementService.addGZH(gzhId, groupNum);
+        userManagementService.addGZH(gzhId,appId, groupNum);
         return "success";
     }
 

+ 2 - 2
long-article-recommend-service/src/main/resources/generatorConfig.xml

@@ -6,7 +6,7 @@
 <generatorConfiguration>
     <context id="simple" targetRuntime="MyBatis3">
         <commentGenerator>
-            <property name="suppressAllComments" value="false"/>
+            <property name="suppressAllComments" value="true"/>
         </commentGenerator>
         <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                         connectionURL="jdbc:mysql://rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com:3306/piaoquan-crawler?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false"
@@ -33,7 +33,7 @@
             <property name="enableSubPackages" value="true" />
         </javaClientGenerator>
 
-        <table schema="mybatis" tableName="article_user_group" >
+        <table schema="mybatis" tableName="article_gzh_developer" >
             <generatedKey column="id" sqlStatement="mysql" identity="true" />
         </table>
 

+ 171 - 0
long-article-recommend-service/src/main/resources/mapper/crawler/ArticleGzhDeveloperMapper.xml

@@ -0,0 +1,171 @@
+<?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.tzld.longarticle.recommend.server.repository.mapper.crawler.ArticleGzhDeveloperMapper">
+  <resultMap id="BaseResultMap" type="com.tzld.longarticle.recommend.server.repository.model.ArticleGzhDeveloper">
+    <id column="gzh_id" jdbcType="VARCHAR" property="gzhId" />
+    <result column="app_id" jdbcType="VARCHAR" property="appId" />
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause">
+    <where>
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    gzh_id, app_id
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.longarticle.recommend.server.repository.model.ArticleGzhDeveloperExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from article_gzh_developer
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from article_gzh_developer
+    where gzh_id = #{gzhId,jdbcType=VARCHAR}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+    delete from article_gzh_developer
+    where gzh_id = #{gzhId,jdbcType=VARCHAR}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.longarticle.recommend.server.repository.model.ArticleGzhDeveloperExample">
+    delete from article_gzh_developer
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.longarticle.recommend.server.repository.model.ArticleGzhDeveloper">
+    insert into article_gzh_developer (gzh_id, app_id)
+    values (#{gzhId,jdbcType=VARCHAR}, #{appId,jdbcType=VARCHAR})
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.longarticle.recommend.server.repository.model.ArticleGzhDeveloper">
+    insert into article_gzh_developer
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="gzhId != null">
+        gzh_id,
+      </if>
+      <if test="appId != null">
+        app_id,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="gzhId != null">
+        #{gzhId,jdbcType=VARCHAR},
+      </if>
+      <if test="appId != null">
+        #{appId,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.tzld.longarticle.recommend.server.repository.model.ArticleGzhDeveloperExample" resultType="java.lang.Long">
+    select count(*) from article_gzh_developer
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update article_gzh_developer
+    <set>
+      <if test="row.gzhId != null">
+        gzh_id = #{row.gzhId,jdbcType=VARCHAR},
+      </if>
+      <if test="row.appId != null">
+        app_id = #{row.appId,jdbcType=VARCHAR},
+      </if>
+    </set>
+    <if test="example != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    update article_gzh_developer
+    set gzh_id = #{row.gzhId,jdbcType=VARCHAR},
+      app_id = #{row.appId,jdbcType=VARCHAR}
+    <if test="example != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.longarticle.recommend.server.repository.model.ArticleGzhDeveloper">
+    update article_gzh_developer
+    <set>
+      <if test="appId != null">
+        app_id = #{appId,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where gzh_id = #{gzhId,jdbcType=VARCHAR}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.tzld.longarticle.recommend.server.repository.model.ArticleGzhDeveloper">
+    update article_gzh_developer
+    set app_id = #{appId,jdbcType=VARCHAR}
+    where gzh_id = #{gzhId,jdbcType=VARCHAR}
+  </update>
+
+  <select id="selectGzhIdByAppId" resultType="string">
+    select
+      distinct gzhId
+    from article_gzh_developer
+    where app_id = #{appId}
+  </select>
+</mapper>