wzy
2021-01-10 16da0ad1fda1dffa3019425a6887d38ed4217f44
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
package com.matrix.system.shopXcx.api.action;
 
import com.matrix.core.pojo.AjaxResult;
import com.matrix.biz.bean.BizUser;
 
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.system.shopXcx.dao.ShopSearchRecordDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import java.util.*;
 
/**
 * @description 搜索记录
 * @author pengliang
 * @date 2019-06-14 15:00
 */
 
 
 
@Controller
@RequestMapping(value="/wxapi/shopUserSearchRecord")
@CrossOrigin(origins = "*", maxAge = 3600)
public class WxUserSearchRecord {
 
    @Autowired
    private ShopSearchRecordDao shopSearchRecordDao;
 
    @Autowired
    private RedisUserLoginUtils redisUserLoginUtils;
 
    /**
     * 查询搜索记录
     * @return
     */
    @RequestMapping(value = "/getSearchRecordList")
    @ResponseBody
    public AjaxResult getSearchRecordList(){
        BizUser bigUser = redisUserLoginUtils.getLoginUser(BizUser.class);
        if(bigUser == null){
            return new AjaxResult(AjaxResult.STATUS_FAIL,"用户未授权");
        }
        List<String> list = shopSearchRecordDao.selectByUserId(bigUser.getOpenId());
        return new AjaxResult(AjaxResult.STATUS_SUCCESS,list);
    }
 
    /**
     * 删除搜索记录
     * @return
     */
    @RequestMapping(value = "/deleteSearchRecord")
    @ResponseBody
    public AjaxResult deleteSearchRecord(){
        BizUser bigUser = redisUserLoginUtils.getLoginUser(BizUser.class);
        shopSearchRecordDao.deleteByUserId(bigUser.getOpenId());
        return new AjaxResult(AjaxResult.STATUS_SUCCESS,"删除成功");
    }
 
}