package com.zhongshu.card.server.core.controller.feign;

import com.zhongshu.card.client.model.org.*;
import com.github.microservice.net.ResultContent;
import com.zhongshu.card.client.service.org.OrganizationService;
import com.zhongshu.card.client.service.org.UserAccountService;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author TRX
 * @date 2024/7/23
 */
@RestController
@RequestMapping("organizationFeign")
@Tag(name = "机构信息")
@Hidden
public class OrganizationFeignController {

    @Autowired
    OrganizationService organizationService;

    @Autowired
    UserAccountService userAccountService;

    @Operation(summary = "机构简单信息", description = "机构简单信息")
    @RequestMapping(value = "manager/getDetail", method = {RequestMethod.GET})
    public ResultContent<OrganizationSimpleModel> getDetail(
            @Parameter(name = "oid", description = "oid", required = false)
            @RequestParam(name = "oid") String oid) {
        return organizationService.getDetail(oid);
    }

    @Operation(summary = "得到项目信息", description = "得到项目信息")
    @RequestMapping(value = "manager/getProjectInfo", method = {RequestMethod.GET})
    public ResultContent<ProjectOrgModel> getProjectInfo(
            @Parameter(name = "projectOid", description = "oid", required = false)
            @RequestParam(name = "projectOid")
            String projectOid) {
        return organizationService.getProjectDetail(projectOid);
    }

    @Operation(summary = "得到学校详情", description = "得到学校详情")
    @RequestMapping(value = "manager/getSchoolDetail", method = {RequestMethod.GET})
    public ResultContent<OrganizationModel> getSchoolDetail(
            @Parameter(name = "schoolOid", description = "oid", required = false)
            @RequestParam(name = "schoolOid")
            String schoolOid) {
        return organizationService.getSchoolDetail(schoolOid);
    }

    @Operation(summary = "得到商户详情", description = "得到商户详情")
    @RequestMapping(value = "manager/getBusinessMainDetail", method = {RequestMethod.GET})
    public ResultContent<OrganizationModel> getBusinessMainDetail(
            @Parameter(name = "businessMainOid", description = "oid", required = false)
            @RequestParam(name = "businessMainOid")
            String businessMainOid) {
        return organizationService.getBusinessMainDetail(businessMainOid);
    }

    @Operation(summary = "得到学校所在的项目详情", description = "得到学校所在的项目详情")
    @RequestMapping(value = "manager/getSchoolProjectDetail", method = {RequestMethod.GET})
    public ResultContent<ProjectOrgModel> getSchoolProjectDetail(
            @Parameter(name = "schoolOid", description = "oid", required = false)
            @RequestParam(name = "schoolOid")
            String schoolOid) {
        return organizationService.getSchoolProjectDetail(schoolOid);
    }

    @Operation(summary = "得到用户在结构的信息", description = "得到用户在结构的信息")
    @RequestMapping(value = "manager/getOrgUserDetail", method = {RequestMethod.POST})
    public ResultContent<OrganizationUserModel> getOrgUserDetail(@RequestBody OrgUserDetailParam param) {
        return userAccountService.getOrgUserDetail(param);
    }

    @Operation(summary = "oid类型判断和关联的 项目oid、学校oid、商户oid", description = "oid类型判断和关联的 项目oid、学校oid、商户oid")
    @RequestMapping(value = "manager/getOidAboutOrgInfo", method = {RequestMethod.GET})
    public ResultContent<OidAboutInfo> getOidAboutOrgInfo(
            @Parameter(name = "oid", description = "oid", required = false)
            @RequestParam(name = "oid") String oid) {
        OidAboutInfo oidAboutInfo = organizationService.getOidAboutOrgInfo(oid);
        return ResultContent.buildSuccess(oidAboutInfo);
    }

}
