package com.sqx.modules.consortia.controller.app;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.consortia.entity.Consortia;
import com.sqx.modules.consortia.service.ConsortiaService;
import com.sqx.modules.sys.controller.AbstractController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "商家", tags = {"商家"})
@RequestMapping(value = "/app/consortia")
public class AppConsortiaController extends AbstractController {

    @Autowired
    private ConsortiaService consortiaService;

    @Login
    @GetMapping("/selectConsortiaByUserId")
    @ApiOperation("查询商家详情")
    public Result selectConsortiaByUserId(Long consortiaId){
        return consortiaService.selectConsortiaByUserId(consortiaId);
    }

    @Login
    @GetMapping("/selectUserListByConsortiaId")
    @ApiOperation("查询师傅列表")
    public Result selectUserListByConsortiaId(Integer page,Integer limit,String userName,String phone,Long consortiaId,Long shopId,Integer flag,String time){
        return consortiaService.selectUserListByConsortiaId(page, limit, userName, phone, consortiaId,shopId,flag,time);
    }

    @Login
    @GetMapping("/selectConsortiaMoney")
    @ApiOperation("查询师傅带来的总收益")
    public Result selectConsortiaMoney(Long shopId,Integer flag,String time){
        return consortiaService.selectConsortiaMoney(shopId, flag, time);
    }

    @Login
    @GetMapping("/selectConsortiaList")
    @ApiOperation("查询店铺信息")
    public Result selectConsortiaList(Integer page,Integer limit,String consortiaName,String userName,String phone){
        return consortiaService.selectConsortiaList(page, limit, consortiaName,userName,phone);
    }


    @PostMapping("/updateConsortia")
    @ApiOperation("修改商家")
    public Result updateConsortia(@RequestBody Consortia consortia){
        return consortiaService.updateConsortia(consortia);
    }


    @Login
    @GetMapping("/selectConsortiaUserId")
    @ApiOperation("查询商家详情")
    public Result selectConsortiaUserId(@RequestAttribute Long userId){
        return consortiaService.selectConsortiaUserId(userId);
    }
}