xuhy
2024-09-13 3d1cf55e874a5b79c74725af946bfe235c3b06fd
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TShopController.java
@@ -6,17 +6,21 @@
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.TBoard;
import com.ruoyi.system.domain.TShop;
import com.ruoyi.system.dto.TShopDTO;
import com.ruoyi.system.query.TShopQuery;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.TBoardService;
import com.ruoyi.system.service.TShopService;
import com.ruoyi.system.vo.TShopVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
@@ -34,12 +38,14 @@
    private final TShopService shopService;
    private final ISysUserService userService;
    private final TBoardService boardService;
    private final TokenService tokenService;
    @Autowired
    public TShopController(TShopService shopService, ISysUserService userService, TokenService tokenService) {
    public TShopController(TShopService shopService, ISysUserService userService, TBoardService boardService, TokenService tokenService) {
        this.shopService = shopService;
        this.userService = userService;
        this.boardService = boardService;
        this.tokenService = tokenService;
    }
@@ -60,7 +66,9 @@
    public AjaxResult<String> add(@RequestBody TShopDTO dto) {
        shopService.save(dto);
        // 添加账号
        userService.addAccount(dto);
        Long userId = userService.addAccount(dto);
        dto.setUserId(userId);
        shopService.updateById(dto);
        return AjaxResult.success();
    }
@@ -80,8 +88,14 @@
     */
    @ApiOperation( value = "查看店铺信息详情")
    @GetMapping(value = "/getDetailById")
    public AjaxResult<TShop> getDetailById(@RequestParam("id") Long id) {
        return AjaxResult.success(shopService.getById(id));
    public AjaxResult<TShopVO> getDetailById(@RequestParam("id") Long id) {
        TShop shop = shopService.getById(id);
        TShopVO shopVO = new TShopVO();
        BeanUtils.copyProperties(shop,shopVO);
        List<TBoard> list = boardService.list(Wrappers.lambdaQuery(TBoard.class)
                .eq(TBoard::getShopId, id));
        shopVO.setBoards(list);
        return AjaxResult.success(shopVO);
    }
    /**