935090232@qq.com
2021-03-19 81a3369395a7cccceb7cd36f5238cc6fe2aa88e5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.matrix.system.shopXcx.api.action;
 
import com.matrix.core.pojo.AjaxResult;
import com.matrix.system.shopXcx.bean.*;
import com.matrix.system.shopXcx.dao.ShopArticleDao;
import com.matrix.system.shopXcx.dao.ShopArticleTypeDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
 
import java.util.*;
 
/**
 * @description 文章
 * @author jiangyouyao
 * @date 2019-06-11 10:15
 */
@CrossOrigin(origins = "*", maxAge = 3600)
@Controller
@RequestMapping(value = "wxapi/Article")
public class WxArticleAction {
    @Autowired
    private ShopArticleTypeDao articleTypeDao;
    @Autowired
    private ShopArticleDao articleDao;
 
    /**
     * 查询常见问题文章类型接口
     * @param
     * @return
     */
    @PostMapping("/findArticleType")
    @ResponseBody
    public AjaxResult getArticleByTypeCode() {
        List<ShopArticleType> shopArticleTypes = articleTypeDao.selectByTypeCode();
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, shopArticleTypes, shopArticleTypes.size());
        return result;
    }
 
    /**
     * 根据类型code查询类型文章
     * @param
     * @return
     */
    @PostMapping("/findArticleByArtypeCode/{artypeCode}")
    @ResponseBody
    public AjaxResult getArticleByArtypeCode(@PathVariable("artypeCode") String artypeCode) {
        List<ShopArticle> shopArticles = articleDao.selectArticleByArtypeCode(artypeCode);
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, shopArticles);
        return result;
    }
 
    /**
     * 根据标题和类型查询文章接口
     * @param
     * @return
     */
    @PostMapping("/findArticleByTitleAndType")
    @ResponseBody
    public AjaxResult findArticleByTitleAndType(@RequestBody ShopArticle shopArticle) {
        List<ShopArticle> shopArticles = articleDao.findArticleByTitleAndType(shopArticle);
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, shopArticles);
        return result;
    }
 
    /**
     * 根据ID查询文章
     * @param
     * @return
     */
    @PostMapping("/findArticById/{artId}")
    @ResponseBody
    public AjaxResult getArticleByArtypeId(@PathVariable("artId") Integer artId) {
        ShopArticle shopArticles = articleDao.selectById(artId);
        if(null != shopArticles){
            Integer artVisitstimes = shopArticles.getArtVisitstimes();
            Map<String, Object> modifyMap = new HashMap<>();
            if(null == artVisitstimes){
                modifyMap.put("artVisitstimes", 1);
            }else{
                modifyMap.put("artVisitstimes", artVisitstimes+1);
            }
            modifyMap.put("artId", artId);
            articleDao.updateByMap(modifyMap);
        }
 
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, Collections.singletonList(shopArticles));
 
        return result;
    }
 
    /**
     * 查询常见问题类型文章
     * @param
     * @return
     */
    @PostMapping("/findArticle")
    @ResponseBody
    public AjaxResult getArticle() {
        List<ShopArticle> shopArticles = articleDao.selectArticle();
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, shopArticles, shopArticles.size());
        return result;
    }
 
}