jiangqs
2023-06-08 6cca89c41aea52ae6b23909bb9fbd2834f0094d5
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
106
107
108
109
110
111
112
package com.ruoyi.shop.controller.console;
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.shop.domain.pojo.shop.ShopRelUser;
import com.ruoyi.shop.domain.pojo.shop.ShopStaff;
import com.ruoyi.shop.service.shop.ShopRelUserService;
import com.ruoyi.shop.service.shop.ShopService;
import com.ruoyi.shop.service.shop.ShopStaffService;
import com.ruoyi.shop.service.shop.ShopSuggestService;
import com.ruoyi.system.api.domain.poji.shop.Shop;
import com.ruoyi.system.api.domain.poji.sys.SysUser;
import com.ruoyi.system.api.domain.vo.ShopRelUserVo;
import com.ruoyi.system.api.model.QwH5LoginVo;
import com.ruoyi.system.api.model.QwUserDetailDto;
import com.ruoyi.system.api.service.RemoteUserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.util.Optional;
 
/**
 * @author jqs34
 * @ClassName ShopController
 * @description: TODO
 * @date 2023年05月03日
 * @version: 1.0
 */
@RestController
@RequestMapping("/shop")
public class ShopController {
 
    @Resource
    private ShopService shopService;
 
    @Resource
    private ShopRelUserService shopRelUserService;
 
    @Resource
    private ShopStaffService shopStaffService;
 
    @Resource
    private RemoteUserService remoteUserService;
 
    @Resource
    private ShopSuggestService shopSuggestService;
 
 
    /**
     * 企业微信H5登录
     * @param qwUserDetail
     * @return
     */
    @PostMapping("/qwH5Login")
    public R<QwH5LoginVo> qwH5Login(@RequestBody QwUserDetailDto qwUserDetail)
    {
        String mobile = qwUserDetail.getMobile();
        ShopStaff shopStaff = shopStaffService.getByMobile(mobile);
        Long userId = shopStaff.getUserId();
        SysUser sysUser = remoteUserService.getSysUser(userId).getData();
        Optional.ofNullable(sysUser).orElseThrow(() -> new ServiceException("登录失败,未查询到用户"));
        // 构造登录返回信息
        QwH5LoginVo qwH5LoginVo = new QwH5LoginVo();
        qwH5LoginVo.setUserid(qwUserDetail.getUserid());
        qwH5LoginVo.setMobile(qwUserDetail.getMobile());
        qwH5LoginVo.setSysUser(sysUser);
        return R.ok(qwH5LoginVo);
    }
 
    @PostMapping("/getShop")
    public R<Shop> getShop(@RequestBody Long shopId)
    {
        Shop shop = shopService.getByShopId(shopId);
        return R.ok(shop);
    }
 
 
    @PostMapping("/getShopByUserId")
    public R<ShopRelUserVo> getShopByUserId(@RequestBody Long userId)
    {
        ShopRelUser shopRelUser = shopRelUserService.getByUserId(userId);
        Optional.ofNullable(shopRelUser).orElseThrow(() -> new ServiceException("未查询到商户信息"));
        ShopRelUserVo shopRelUserVo = new ShopRelUserVo();
        shopRelUserVo.setShopId(shopRelUser.getShopId());
        shopRelUserVo.setUserName(shopRelUser.getUserName());
        return R.ok(shopRelUserVo);
    }
 
    /**
     * @description  删除商户标签
     * @author  jqs
     * @date    2023/6/8 15:52
     * @param tag
     * @return  R
     */
    @PostMapping("/deleteShopTag")
    public R deleteShopTag(@RequestBody String tag)
    {
        shopService.deleteShopTag(tag);
        return R.ok();
    }
 
    @PostMapping("/deleteShopSuggestTag")
    public R deleteShopSuggestTag(@RequestBody String tag)
    {
        shopSuggestService.deleteShopSuggestTag(tag);
        return R.ok();
    }
}