package com.ningdatech.pmapi.expert.controller;


import com.ningdatech.basic.model.PageVo;
import com.ningdatech.log.annotation.WebLog;
import com.ningdatech.pmapi.expert.manage.ExpertAdminManage;
import com.ningdatech.pmapi.expert.manage.ExpertManage;
import com.ningdatech.pmapi.expert.model.ExpertAdminExpertManageQuery;
import com.ningdatech.pmapi.expert.model.req.AdminExpertBasicInfoModifyRequest;
import com.ningdatech.pmapi.expert.model.req.ExpertRegistrationRequest;
import com.ningdatech.pmapi.expert.model.req.ExpertUserBasicInfoSubmitRequest;
import com.ningdatech.pmapi.expert.model.req.GetZzdInfoRequest;
import com.ningdatech.pmapi.expert.model.vo.ExpertAdminExpertManageListVO;
import com.ningdatech.pmapi.expert.model.vo.ExpertBasicInfoModifyResultVO;
import com.ningdatech.pmapi.expert.model.vo.ExpertFullInfoVO;
import com.ningdatech.pmapi.expert.model.vo.ZzdInfoByMobileVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Liuxinxin
 * @since 2023-02-22
 */
@RestController
@Api(tags = "专家管理相关接口")
@RequestMapping("/api/v1/expert")
@RequiredArgsConstructor
public class ExpertController {

    private final ExpertManage expertManage;
    private final ExpertAdminManage expertAdminManage;

    @PostMapping("/registration")
    @ApiOperation("社会专家报名")
    @WebLog("社会专家报名")
    public void expertRegistration(@Valid @RequestBody ExpertRegistrationRequest request) {
        expertManage.expertRegistration(request);
    }

    @PostMapping("/basic-info-submit")
    @ApiOperation("专家管理员新增专家)")
    @WebLog("专家管理员新增专家")
    public void expertBasicInfoSubmit(@Valid @RequestBody ExpertUserBasicInfoSubmitRequest request) {
        expertManage.expertBasicInfoSubmit(request);
    }

    @GetMapping("/detail")
    @ApiOperation("专家获取专家详细信息")
    public ExpertFullInfoVO getExpertFullInfoDetail() {
        return expertManage.getExpertFullInfoDetail(null);
    }


    @GetMapping("/admin/detail")
    @ApiOperation("专家管理员获取专家详细信息")
    public ExpertFullInfoVO getExpertFullInfoDetail(@RequestParam(value = "expertUserId") @NotNull Long expertUserId) {
        return expertManage.getExpertFullInfoDetail(expertUserId);
    }

    @PostMapping("/expert-library/list")
    @ApiOperation("专家库列表查询接口")
    public PageVo<ExpertAdminExpertManageListVO> getExpertLibraryList(@RequestBody @Valid ExpertAdminExpertManageQuery query) {
        return expertAdminManage.getExpertLibraryList(query);
    }

    @PostMapping("/basic-info-modify")
    @ApiOperation("专家信息编辑")
    @WebLog("专家信息编辑")
    public ExpertBasicInfoModifyResultVO expertBasicInfoModify(@Valid @RequestBody AdminExpertBasicInfoModifyRequest request) {
        return expertAdminManage.adminModifyExpertBasicInfo(request);
    }

    @PostMapping("/get-zzd-info")
    @ApiOperation("获取浙政钉用户信息")
    @WebLog("获取浙政钉用户信息")
    public ZzdInfoByMobileVO getZzdInfo(@Valid @RequestBody GetZzdInfoRequest request) {
        return expertAdminManage.getZzdInfo(request);
    }

}
