package com.cool.store.controller.webc;

import com.cool.store.dto.GetUserDTO;
import com.cool.store.dto.UserDTO;
import com.cool.store.request.LinesRequest;
import com.cool.store.request.UpdatePartnerNameRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.LinePayService;
import com.cool.store.service.LineService;
import com.cool.store.service.UserAuthMappingService;
import com.cool.store.vo.IntendProcessTotalVO;
import com.cool.store.vo.LineInfoVO;
import com.cool.store.vo.LineVO;
import com.cool.store.vo.interview.AppointmentTimeVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;

/**
 * @Author suzhuhong
 * @Date 2024/3/25 13:43
 * @Version 1.0
 */
@RestController
@RequestMapping("/mini/line")
@Api(tags = "线索信息")
@Slf4j
public class LineController {

    @Resource
    LineService lineService;

    @Resource
    LinePayService linePayService;

    @Resource
    private UserAuthMappingService userAuthMappingService;
    @ApiOperation("查询线索详情")
    @GetMapping("/getLineDetail")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lineId", value = "线索id", required = true)
    })
    public ResponseResult<LineInfoVO> getLineInfo(@RequestParam("lineId")Long lineId) {
        return ResponseResult.success(lineService.getLineInfo(lineId, null));
    }

    @ApiOperation("根据线索id查询大区的支付二维码图片")
    @GetMapping("/getRegionPayPic")
    public ResponseResult<String> getRegionPayPic(@RequestParam("lineId")Long lineId) {
        return ResponseResult.success(lineService.getPayPicByLineId(lineId));
    }


    @ApiOperation("线索流程进度")
    @GetMapping("/getIntendProcess")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lineId", value = "线索id", required = true)
    })
    public ResponseResult<IntendProcessTotalVO> getIntendProcessTotal(@RequestParam("lineId")Long lineId) {
        return ResponseResult.success(lineService.getIntendProcessTotal(lineId));
    }
    @ApiOperation("修改加盟商名称")
    @PostMapping("/updatePartnerName")
    public ResponseResult<Integer> updatePartnerName(@RequestBody @Validated UpdatePartnerNameRequest request) {
        return ResponseResult.success(lineService.updatePartnerName(request.getUsername(),request.getLineId()));
    }

    @ApiOperation("查询所有人支持模糊查询")
    @PostMapping("/getAllUser")
    public ResponseResult<PageInfo<UserDTO>> getAllUser(@RequestBody GetUserDTO dto) {
        return ResponseResult.success(userAuthMappingService.getAllUser(dto.getKeyword(),dto.getPageNum(),dto.getPageSize()));
    }
    @ApiOperation("获取ai模块是否展示，true展示false不展示")
    @GetMapping("/getAiModule")
    public ResponseResult<Boolean> getAiModule() {
        return ResponseResult.success(lineService.getAiModule());
    }

    @ApiOperation("设置ai模块是否展示，true展示false不展示")
    @GetMapping("/setAiModule")
    public ResponseResult<Boolean> setAiModule(@RequestParam("flag") Boolean flag) {
        return ResponseResult.success(lineService.setAiModule(flag));
    }



}
