xuhy
2024-09-05 8c2128317af3e5a2df32150f3684167925ee4508
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TShopController.java
@@ -1,9 +1,11 @@
package com.ruoyi.web.controller.api;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.TShop;
import com.ruoyi.system.dto.TShopDTO;
import com.ruoyi.system.query.TShopQuery;
@@ -15,7 +17,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
@@ -33,11 +34,13 @@
    private final TShopService shopService;
    private final ISysUserService userService;
    private final TokenService tokenService;
    @Autowired
    public TShopController(TShopService shopService, ISysUserService userService) {
    public TShopController(TShopService shopService, ISysUserService userService, TokenService tokenService) {
        this.shopService = shopService;
        this.userService = userService;
        this.tokenService = tokenService;
    }
    /**
@@ -82,6 +85,20 @@
    }
    /**
     * 用户查看店铺信息详情
     */
    @ApiOperation( value = "用户查看店铺信息详情")
    @GetMapping(value = "/getDetailByUserId")
    public AjaxResult<TShop> getDetailByUserId() {
        Integer roleType = tokenService.getLoginUser().getRoleType();
        if(roleType == 1){
            return AjaxResult.error("该用户不是商家账号");
        }
        return AjaxResult.success(shopService.getOne(Wrappers.<TShop>lambdaQuery().eq(TShop::getUserId, tokenService.getLoginUser().getUserId())
                .last("LIMIT 1")));
    }
    /**
     * 删除店铺信息
     */
    @ApiOperation( value = "删除店铺信息")