Ver Fonte

微信公众号-图文素材

chao há 3 anos atrás
pai
commit
2118d04d82

+ 39 - 0
db.sql

@@ -69,6 +69,7 @@ CREATE TABLE `sys_role_menu` (
 -- ============================================== 系统表 end ===============================
 
 -- ============================================== 微信表 start =============================
+
 -- 微信公众号菜单表(原表:caimei_weixin.menu_tree)
 DROP TABLE IF EXISTS `wechat_menu`;
 CREATE TABLE `wechat_menu` (
@@ -90,6 +91,7 @@ CREATE TABLE `wechat_menu` (
   `updateDate` datetime DEFAULT NULL COMMENT '最后更新时间',
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='微信菜单tree';
+
 -- 微信公众号自动回复表(原表:caimei_weixin.cm_wxparam)
 DROP TABLE IF EXISTS `wechat_reply`;
 CREATE TABLE `wechat_reply` (
@@ -106,6 +108,7 @@ CREATE TABLE `wechat_reply` (
   `update_date` datetime DEFAULT NULL COMMENT '最后更新时间',
   PRIMARY KEY (`cm_wxparamID`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='回复配置表';
+
 -- 微信公众号-文本素材(原表:caimei_weixin.cm_wxtext)
 DROP TABLE IF EXISTS `wechat_text`;
 CREATE TABLE `wechat_text` (
@@ -120,5 +123,41 @@ CREATE TABLE `wechat_text` (
   `update_date` datetime DEFAULT NULL COMMENT '最后更新时间',
   PRIMARY KEY (`cm_wxtextID`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='微信文本素材表';
+INSERT INTO security.wechat_text
+SELECT * FROM caimei_weixin.cm_wxtext;
+
+-- 微信公众号-文本素材(原表:caimei_weixin.cm_wxarticle)
+DROP TABLE IF EXISTS `wechat_article`;
+CREATE TABLE `wechat_article` (
+  `cm_wxarticleID` bigint(11) NOT NULL AUTO_INCREMENT,
+  `title` varchar(128) DEFAULT NULL COMMENT '标题',
+  `addTime` varchar(19) DEFAULT NULL,
+  `wx_type` varchar(20) DEFAULT NULL COMMENT '微信公众号类型',
+  `create_by` bigint(11) DEFAULT NULL COMMENT '创建人',
+  `create_date` datetime DEFAULT NULL COMMENT '创建时间',
+  `update_by` bigint(11) DEFAULT NULL COMMENT '最后更新人',
+  `update_date` datetime DEFAULT NULL COMMENT '最后更新时间',
+  PRIMARY KEY (`cm_wxarticleID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='微信图文素材表';
+
+INSERT INTO security.wechat_article (cm_wxarticleID,title,wx_type,create_by,create_date,update_by,update_date)
+SELECT cm_wxarticleID,title,wx_type,create_by,create_date,update_by,update_date FROM caimei_weixin.cm_wxarticle;
+
+-- 微信公众号-文本素材(原表:caimei_weixin.cm_wxarticledtl)
+DROP TABLE IF EXISTS `wechat_article_detail`;
+CREATE TABLE `wechat_article_detail` (
+  `cm_wxarticledtlID` int(11) NOT NULL AUTO_INCREMENT,
+  `cm_wxarticleID` int(11) DEFAULT NULL COMMENT '图文素材id',
+  `title` varchar(128) DEFAULT NULL COMMENT '标题',
+  `linkurl` varchar(255) DEFAULT NULL COMMENT '跳转链接',
+  `picurl` varchar(255) DEFAULT NULL COMMENT '图片链接',
+  `create_by` bigint(11) DEFAULT NULL COMMENT '创建人',
+  `create_date` datetime DEFAULT NULL COMMENT '创建时间',
+  `update_by` bigint(11) DEFAULT NULL COMMENT '最后更新人',
+  `update_date` datetime DEFAULT NULL COMMENT '最后更新时间',
+  PRIMARY KEY (`cm_wxarticledtlID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='微信图文素材详细表';
+INSERT INTO security.wechat_article_detail
+SELECT * FROM caimei_weixin.cm_wxarticledtl;
 
 -- ============================================== 微信表 end ===============================

+ 88 - 0
src/main/java/com/caimei365/manager/controller/wechat/WechatArticleApi.java

@@ -0,0 +1,88 @@
+package com.caimei365.manager.controller.wechat;
+
+import com.caimei365.manager.config.security.ConstantKey;
+import com.caimei365.manager.config.security.JwtService;
+import com.caimei365.manager.entity.PaginationVo;
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.wechat.WechatArticle;
+import com.caimei365.manager.service.wechat.WechatArticleService;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 微信公众号-图文素材
+ *
+ * @author : Charles
+ * @date : 2022/1/6
+ */
+@RestController
+@RequestMapping("/wechat/article")
+public class WechatArticleApi {
+
+    @Resource
+    private WechatArticleService wechatArticleService;
+    @Resource
+    private JwtService jwtService;
+
+    /**
+     * 获取图文素材列表
+     *
+     * @param type 类型: 1采美,2呵呵商城
+     * @param title 标题
+     * @param pageNum  页码
+     * @param pageSize 每页大小
+     */
+    @GetMapping("/list")
+    public ResponseJson<PaginationVo<WechatArticle>> articleList(Integer type, String title,
+                                                               @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                               @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+        return wechatArticleService.getArticleList(type, title, pageNum, pageSize);
+    }
+
+    /**
+     * 根据ID获取图文素材
+     */
+    @GetMapping("/{id}")
+    public ResponseJson<WechatArticle> getArticle(@PathVariable("id") Integer id) {
+        if (null == id || id <= 0) {
+            return ResponseJson.error("图文素材Id不能为空!", null);
+        }
+        return wechatArticleService.getArticle(id);
+    }
+
+    /**
+     * 根据ID更新图文素材
+     */
+    @PostMapping("/update/{id}")
+    public ResponseJson<Void> updateArticle(HttpServletRequest request, @PathVariable("id") Integer id, @RequestBody WechatArticle article) {
+        if (null == id || id <= 0) {
+            return ResponseJson.error("图文素材Id不能为空!", null);
+        }
+        String token = request.getHeader(ConstantKey.TOKEN_NAME);
+        String username = jwtService.getUsername(token);
+        return wechatArticleService.updateArticle(id, article, username);
+    }
+
+    /**
+     * 添加图文素材
+     */
+    @PostMapping("/create")
+    public ResponseJson<Void> addArticle(HttpServletRequest request, @RequestBody WechatArticle article) {
+        String token = request.getHeader(ConstantKey.TOKEN_NAME);
+        String username = jwtService.getUsername(token);
+        return wechatArticleService.addArticle(article, username);
+    }
+
+    /**
+     * 根据ID删除图文素材
+     */
+    @PostMapping("/delete/{id}")
+    public ResponseJson<Void> deleteArticle(@PathVariable("id") Integer id) {
+        if (null == id || id <= 0) {
+            return ResponseJson.error("图文素材Id不能为空!", null);
+        }
+        return wechatArticleService.deleteArticle(id);
+    }
+}

+ 45 - 5
src/main/java/com/caimei365/manager/dao/WeChatDao.java

@@ -1,8 +1,6 @@
 package com.caimei365.manager.dao;
 
-import com.caimei365.manager.entity.wechat.WechatMenu;
-import com.caimei365.manager.entity.wechat.WechatReply;
-import com.caimei365.manager.entity.wechat.WechatText;
+import com.caimei365.manager.entity.wechat.*;
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
@@ -58,7 +56,7 @@ public interface WeChatDao {
     /**
      * 根据ID更新回复配置
      */
-    void updateWechatReply(WechatReply dbReply);
+    void updateWechatReply(WechatReply reply);
     /**
      * 添加回复配置
      */
@@ -80,7 +78,7 @@ public interface WeChatDao {
     /**
      * 根据ID更新文本素材
      */
-    void updateWechatText(WechatText dbText);
+    void updateWechatText(WechatText text);
     /**
      * 添加文本素材
      */
@@ -89,4 +87,46 @@ public interface WeChatDao {
      * 根据ID删除文本素材
      */
     void deleteWechatText(Integer id);
+
+    /**
+     * 获取图文素材列表
+     * @param wxType 公众号Id
+     */
+    List<WechatArticle> getArticleList(String wxType, String title);
+    /**
+     * 根据ID获取图文素材
+     */
+    WechatArticle getWechatArticle(Integer id);
+    /**
+     * 根据图文ID获取详情列表
+     */
+    List<WechatArticleDetail> getArticleDetailList(Integer articleId);
+    /**
+     * 根据ID获取图文素材文章
+     */
+    WechatArticleDetail getWechatArticleDetail(Integer id);
+    /**
+     * 根据ID更新图文素材
+     */
+    void updateWechatArticle(WechatArticle article);
+    /**
+     * 更新图文素材文章
+     */
+    void updateWechatArticleDetail(WechatArticleDetail detail);
+    /**
+     * 添加图文素材
+     */
+    void insertWechatArticle(WechatArticle article);
+    /**
+     * 添加图文素材文章
+     */
+    void insertWechatArticleDetail(WechatArticleDetail detail);
+    /**
+     * 根据ID删除图文素材
+     */
+    void deleteWechatArticle(Integer id);
+    /**
+     * 根据ID删除图文素材文章列表
+     */
+    void deleteWechatArticleDetail(Integer articleId);
 }

+ 58 - 0
src/main/java/com/caimei365/manager/entity/wechat/WechatArticle.java

@@ -0,0 +1,58 @@
+package com.caimei365.manager.entity.wechat;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2022/1/6
+ */
+@Data
+public class WechatArticle {
+    private static final long serialVersionUID = 1L;
+    /**
+     * Id
+     */
+    private Integer id;
+    /**
+     * 标题
+     */
+    private String title;
+    /**
+     * 微信公众号类型
+     */
+    private String wxType;
+    /**
+     * 操作人用户Id
+     */
+    private Integer userId;
+    /**
+     * 类型: 1采美,2呵呵商城
+     */
+    private Integer type;
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
+    private Date updateTime;
+    /**
+     * 文章列表
+     */
+    private List<WechatArticleDetail> detailList;
+    /**
+     * 文章列表JSON数据:[
+     *            { "id":         "文章ID"
+     *              "title":      "文章标题",
+     *              "linkUrl":    "跳转链接",
+     *              "pictureUrl": "图片链接",
+     *            },
+     *            {多条数据结构同上}
+     *         ]
+     */
+    private String detailJson;
+}

+ 39 - 0
src/main/java/com/caimei365/manager/entity/wechat/WechatArticleDetail.java

@@ -0,0 +1,39 @@
+package com.caimei365.manager.entity.wechat;
+
+import lombok.Data;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2022/1/7
+ */
+@Data
+public class WechatArticleDetail {
+    private static final long serialVersionUID = 1L;
+    /**
+     * Id
+     */
+    private Integer id;
+    /**
+     * 图文Id
+     */
+    private Integer articleId;
+    /**
+     * 文章标题
+     */
+    private String title;
+    /**
+     * 跳转链接
+     */
+    private String linkUrl;
+    /**
+     * 图片链接
+     */
+    private String pictureUrl;
+    /**
+     * 操作人用户Id
+     */
+    private Integer userId;
+}
+

+ 39 - 0
src/main/java/com/caimei365/manager/service/wechat/WechatArticleService.java

@@ -0,0 +1,39 @@
+package com.caimei365.manager.service.wechat;
+
+import com.caimei365.manager.entity.PaginationVo;
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.wechat.WechatArticle;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2022/1/6
+ */
+public interface WechatArticleService {
+    /**
+     * 获取图文素材列表
+     *
+     * @param type 类型: 1采美,2呵呵商城
+     * @param title 标题
+     * @param pageNum  页码
+     * @param pageSize 每页大小
+     */
+    ResponseJson<PaginationVo<WechatArticle>> getArticleList(Integer type, String title, int pageNum, int pageSize);
+    /**
+     * 根据ID获取图文素材
+     */
+    ResponseJson<WechatArticle> getArticle(Integer id);
+    /**
+     * 根据ID更新图文素材
+     */
+    ResponseJson<Void> updateArticle(Integer id, WechatArticle article, String username);
+    /**
+     * 添加图文素材
+     */
+    ResponseJson<Void> addArticle(WechatArticle article, String username);
+    /**
+     * 根据ID删除图文素材
+     */
+    ResponseJson<Void> deleteArticle(Integer id);
+}

+ 192 - 0
src/main/java/com/caimei365/manager/service/wechat/impl/WechatArticleServiceImpl.java

@@ -0,0 +1,192 @@
+package com.caimei365.manager.service.wechat.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.caimei365.manager.dao.SysDao;
+import com.caimei365.manager.dao.WeChatDao;
+import com.caimei365.manager.entity.PaginationVo;
+import com.caimei365.manager.entity.ResponseJson;
+import com.caimei365.manager.entity.wechat.WechatArticle;
+import com.caimei365.manager.entity.wechat.WechatArticleDetail;
+import com.caimei365.manager.service.wechat.WechatArticleService;
+import com.github.pagehelper.PageHelper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.alibaba.fastjson.JSON.parseArray;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2022/1/6
+ */
+@Slf4j
+@Service
+public class WechatArticleServiceImpl implements WechatArticleService {
+
+    @Value("${wechat.caimei.id}")
+    private String caimeiId;
+    @Value("${wechat.hehe.id}")
+    private String heheId;
+
+    @Resource
+    private WeChatDao weChatDao;
+    @Resource
+    private SysDao sysDao;
+
+    /**
+     * 获取图文素材列表
+     *
+     * @param type     类型: 1采美,2呵呵商城
+     * @param title    标题
+     * @param pageNum  页码
+     * @param pageSize 每页大小
+     */
+    @Override
+    public ResponseJson<PaginationVo<WechatArticle>> getArticleList(Integer type, String title, int pageNum, int pageSize) {
+        String wxType = "";
+        if (null != type && 1 == type) {
+            wxType = caimeiId;
+        } else if (null != type && 2 == type) {
+            wxType = heheId;
+        }
+        PageHelper.startPage(pageNum, pageSize);
+        List<WechatArticle> articleList = weChatDao.getArticleList(wxType, title);
+        PaginationVo<WechatArticle> pageData = new PaginationVo<>(articleList);
+        return ResponseJson.success(pageData);
+    }
+
+    /**
+     * 根据ID获取图文素材
+     */
+    @Override
+    public ResponseJson<WechatArticle> getArticle(Integer id) {
+        WechatArticle article = weChatDao.getWechatArticle(id);
+        List<WechatArticleDetail> articleList = weChatDao.getArticleDetailList(article.getId());
+        article.setDetailList(articleList);
+        return ResponseJson.success(article);
+    }
+
+    /**
+     * 根据ID更新图文素材
+     */
+    @Override
+    public ResponseJson<Void> updateArticle(Integer id, WechatArticle article, String username) {
+        WechatArticle dbArticle = weChatDao.getWechatArticle(id);
+        if (null == dbArticle) {
+            return ResponseJson.error("当前回复配置异常!", null);
+        }
+        if (StringUtils.hasLength(article.getTitle())){
+            dbArticle.setTitle(article.getTitle());
+        }
+        if (null != article.getType() && 1 == article.getType()) {
+            dbArticle.setWxType(caimeiId);
+        } else if (null != article.getType() && 2 == article.getType()) {
+            dbArticle.setWxType(heheId);
+        }
+        Integer userId = sysDao.getUserIdByUsername(username);
+        dbArticle.setUserId(userId);
+        // 更新
+        weChatDao.updateWechatArticle(dbArticle);
+        // 文章列表JSON数据解析
+        ResponseJson<Void> error = parseArticleJson(dbArticle, article.getDetailJson());
+        if (error != null) {
+            return error;
+        }
+        return ResponseJson.success();
+    }
+
+    /**
+     * 文章列表JSON数据解析
+     * @param article 图文素材
+     * @param jsonStr 文章列表JSON串
+     */
+    private ResponseJson<Void> parseArticleJson(WechatArticle article, String jsonStr) {
+        // 文章列表JSON数据解析
+        JSONArray articleJson = null;
+        List<WechatArticleDetail> detailList = new ArrayList<>();
+        try {
+            articleJson = parseArray(jsonStr);
+            if (null == articleJson || articleJson.isEmpty()) {
+                return ResponseJson.error("文章列表JSON数据异常!", null);
+            }
+            for (Object articleObject : articleJson) {
+                JSONObject detail = (JSONObject) articleObject;
+                Integer articleId = (Integer) detail.get("id");
+                String articleTitle = (String) detail.get("title");
+                String linkUrl = (String) detail.get("linkUrl");
+                String pictureUrl = (String) detail.get("pictureUrl");
+                WechatArticleDetail dbDetail = null;
+                if (null != articleId && articleId > 0) {
+                    dbDetail = weChatDao.getWechatArticleDetail(articleId);
+                } else {
+                    dbDetail = new WechatArticleDetail();
+                }
+                if (StringUtils.hasLength(articleTitle)){
+                    dbDetail.setTitle(articleTitle);
+                }
+                if (StringUtils.hasLength(linkUrl)){
+                    dbDetail.setLinkUrl(linkUrl);
+                }
+                if (StringUtils.hasLength(pictureUrl)){
+                    dbDetail.setPictureUrl(pictureUrl);
+                }
+                dbDetail.setArticleId(article.getId());
+                dbDetail.setUserId(article.getUserId());
+                detailList.add(dbDetail);
+            }
+        } catch (Exception e) {
+            log.error("文章列表JSON数据解析异常try-catch:", e);
+            return ResponseJson.error("文章列表JSON数据解析异常!", null);
+        }
+        for (WechatArticleDetail detail : detailList) {
+            if (null != detail.getId() && detail.getId() > 0) {
+                weChatDao.updateWechatArticleDetail(detail);
+            } else {
+                weChatDao.insertWechatArticleDetail(detail);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 添加图文素材
+     */
+    @Override
+    public ResponseJson<Void> addArticle(WechatArticle article, String username) {
+        if (null != article.getType() && 1 == article.getType()) {
+            article.setWxType(caimeiId);
+        } else if (null != article.getType() && 2 == article.getType()) {
+            article.setWxType(heheId);
+        } else {
+            return ResponseJson.error("配置类型type不正确!", null);
+        }
+        Integer userId = sysDao.getUserIdByUsername(username);
+        article.setUserId(userId);
+        // 新增
+        weChatDao.insertWechatArticle(article);
+        // 文章列表JSON数据解析
+        ResponseJson<Void> error = parseArticleJson(article, article.getDetailJson());
+        if (error != null) {
+            return error;
+        }
+        return ResponseJson.success();
+    }
+
+    /**
+     * 根据ID删除图文素材
+     */
+    @Override
+    public ResponseJson<Void> deleteArticle(Integer id) {
+        weChatDao.deleteWechatArticle(id);
+        weChatDao.deleteWechatArticleDetail(id);
+        return ResponseJson.success();
+    }
+}

+ 4 - 0
src/main/java/com/caimei365/manager/service/wechat/impl/WechatMenuServiceImpl.java

@@ -70,6 +70,9 @@ public class WechatMenuServiceImpl implements WechatMenuService {
         } else {
             return ResponseJson.error("菜单类型不能为空", null);
         }
+        // 获取根菜单
+        WechatMenu rootMenu = weChatDao.getWechatMenu(type);
+        // 获取一级菜单列表
         List<WechatMenu> list = weChatDao.getWechatMenuList(type, wxType);
         // 获取子菜单
         for (WechatMenu menu : list) {
@@ -77,6 +80,7 @@ public class WechatMenuServiceImpl implements WechatMenuService {
             for (WechatMenu sub : subList) {
                 sub.setParentName(menu.getName());
             }
+            menu.setParentName(rootMenu.getName());
             menu.setChildren(subList);
         }
         return ResponseJson.success(list);

+ 55 - 6
src/main/resources/mapper/WeChatDao.xml

@@ -31,7 +31,7 @@
     </delete>
     <select id="getReplyList" resultType="com.caimei365.manager.entity.wechat.WechatReply">
         SELECT a.cm_wxparamID AS id, a.keyword, a.title, a.responsetype AS responseType,
-               a.msgtype AS msgType, a.relateID AS relateId, a.wx_type AS wxType, IFNULL(a.updatee_date,a.create_date) AS updateTime
+               a.msgtype AS msgType, a.relateID AS relateId, a.wx_type AS wxType, IFNULL(a.update_date,a.create_date) AS updateTime
         FROM wechat_reply a
         <where>
             <if test=" wxType != null and  wxType != ''">
@@ -51,12 +51,12 @@
     </select>
     <select id="getWechatReply" resultType="com.caimei365.manager.entity.wechat.WechatReply">
         SELECT a.cm_wxparamID AS id, a.keyword, a.title, a.responsetype AS responseType,
-               a.msgtype AS msgType, a.relateID AS relateId, a.wx_type AS wxType, IFNULL(a.updatee_date,a.create_date) AS updateTime
+               a.msgtype AS msgType, a.relateID AS relateId, a.wx_type AS wxType, IFNULL(a.update_date,a.create_date) AS updateTime
         FROM wechat_reply a WHERE a.cm_wxparamID = #{id}
     </select>
     <update id="updateWechatReply">
         UPDATE wechat_reply SET keyword = #{keyword}, title = #{title}, responsetype = #{responseType},
-                                msgtype = #{msgType}, relateID = #{relateId}, update_by = #{userId}, updatee_date = NOW()
+                                msgtype = #{msgType}, relateID = #{relateId}, update_by = #{userId}, update_date = NOW()
         WHERE cm_wxparamID = #{id}
     </update>
     <insert id="insertWechatReply" keyProperty="id" useGeneratedKeys="true">
@@ -68,7 +68,7 @@
     </delete>
     <select id="getTextList" resultType="com.caimei365.manager.entity.wechat.WechatText">
         SELECT a.cm_wxtextID AS id, a.title, a.content, a.wx_type AS wxType,
-               IFNULL(a.updatee_date,a.create_date) AS updateTime
+               IFNULL(a.update_date,a.create_date) AS updateTime
         FROM wechat_text a
         <where>
             <if test=" wxType != null and  wxType != ''">
@@ -82,11 +82,11 @@
     </select>
     <select id="getWechatText" resultType="com.caimei365.manager.entity.wechat.WechatText">
         SELECT a.cm_wxtextID AS id, a.title, a.content, a.wx_type AS wxType,
-               IFNULL(a.updatee_date,a.create_date) AS updateTime
+               IFNULL(a.update_date,a.create_date) AS updateTime
         FROM wechat_text a WHERE a.cm_wxtextID = #{id}
     </select>
     <update id="updateWechatText">
-        UPDATE wechat_text SET title = #{title}, content = #{content}, wx_type = #{wxType}, update_by = #{userId}, updatee_date = NOW()
+        UPDATE wechat_text SET title = #{title}, content = #{content}, wx_type = #{wxType}, update_by = #{userId}, update_date = NOW()
         WHERE cm_wxtextID = #{id}
     </update>
     <insert id="insertWechatText" keyProperty="id" useGeneratedKeys="true">
@@ -96,4 +96,53 @@
     <delete id="deleteWechatText">
         DELETE FROM wechat_text WHERE cm_wxtextID = #{id}
     </delete>
+    <select id="getArticleList" resultType="com.caimei365.manager.entity.wechat.WechatArticle">
+        SELECT a.cm_wxarticleID AS id, a.title, a.wx_type AS wxType,
+        IFNULL(a.update_date,a.create_date) AS updateTime
+        FROM wechat_article a
+        <where>
+            <if test=" wxType != null and  wxType != ''">
+                AND a.wx_type =#{wxType}
+            </if>
+            <if test="title != null and title != ''">
+                AND a.title LIKE concat('%',#{title},'%')
+            </if>
+        </where>
+        ORDER BY updateTime DESC
+    </select>
+    <select id="getWechatArticle" resultType="com.caimei365.manager.entity.wechat.WechatArticle">
+        SELECT a.cm_wxarticleID AS id, a.title, a.wx_type AS wxType,
+               IFNULL(a.update_date,a.create_date) AS updateTime
+        FROM wechat_article a WHERE a.cm_wxarticleID = #{id}
+    </select>
+    <select id="getArticleDetailList" resultType="com.caimei365.manager.entity.wechat.WechatArticleDetail">
+        SELECT a.cm_wxarticledtlID AS id,a.cm_wxarticleID AS articleId, a.title, a.linkurl AS linkUrl, a.picurl AS pictureUrl
+        FROM wechat_article_detail a WHERE a.cm_wxarticleID = #{articleId}
+    </select>
+    <select id="getWechatArticleDetail" resultType="com.caimei365.manager.entity.wechat.WechatArticleDetail">
+        SELECT a.cm_wxarticledtlID AS id,a.cm_wxarticleID AS articleId, a.title, a.linkurl AS linkUrl, a.picurl AS pictureUrl
+        FROM wechat_article_detail a WHERE a.cm_wxarticledtlID = #{id}
+    </select>
+    <update id="updateWechatArticle">
+        UPDATE wechat_article SET title = #{title}, wx_type = #{wxType}, update_by = #{userId}, update_date = NOW()
+        WHERE cm_wxarticleID = #{id}
+    </update>
+    <update id="updateWechatArticleDetail">
+        UPDATE wechat_article_detail SET title = #{title}, linkurl = #{linkUrl}, picurl = #{pictureUrl}, update_by = #{userId}, update_date = NOW()
+        WHERE cm_wxarticledtlID = #{id}
+    </update>
+    <insert id="insertWechatArticle">
+        INSERT INTO wechat_article(title, wx_type, create_by, create_date)
+        VALUES (#{title}, #{wxType}, #{userId}, NOW())
+    </insert>
+    <insert id="insertWechatArticleDetail">
+        INSERT INTO wechat_article_detail(cm_wxarticleID, title, linkurl, picurl, create_by, create_date)
+        VALUES (#{articleId}, #{title}, #{linkUrl},#{pictureUrl}, #{userId}, NOW())
+    </insert>
+    <delete id="deleteWechatArticle">
+        DELETE FROM wechat_article WHERE cm_wxarticleID = #{id}
+    </delete>
+    <delete id="deleteWechatArticleDetail">
+        DELETE FROM wechat_article_detail WHERE cm_wxarticleID = #{articleId}
+    </delete>
 </mapper>