jiangqs
2023-05-11 27ce5dbd577f5c5dbf7098b0f980d355a275266c
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
package com.ruoyi.shop.controller.console;
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.security.annotation.InnerAuth;
import com.ruoyi.shop.domain.pojo.shop.ShopRelUser;
import com.ruoyi.shop.service.shop.ShopRelUserService;
import com.ruoyi.shop.service.shop.ShopService;
import com.ruoyi.system.api.domain.poji.activity.ActivityGoods;
import com.ruoyi.system.api.domain.poji.shop.Shop;
import com.ruoyi.system.api.domain.vo.ShopRelUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
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;
 
 
    @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);
    }
 
 
}