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

import com.github.microservice.auth.security.annotations.ResourceAuth;
import com.github.microservice.auth.security.type.AuthType;
import com.zhongshu.card.client.model.org.OrganizationRelationSearch;
import com.zhongshu.card.client.model.school.ShopToSchoolModel;
import com.github.microservice.net.ResultContent;
import com.zhongshu.card.client.service.school.BookInfoService;
import com.zhongshu.card.client.service.school.NoticeInfoService;
import com.zhongshu.card.client.service.school.SchoolBingShopService;
import com.zhongshu.card.server.core.service.user.RoleServiceImpl;
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.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;

/**
 * 学校 通讯录管理
 *
 * @author TRX
 * @date 2024/6/5
 */
@RestController
@RequestMapping("/school/bindShop")
@Tag(name = "学校-商户管理")
public class OrganizationRelationController {

    @Autowired
    RoleServiceImpl roleService;

    @Autowired
    NoticeInfoService noticeInfoService;

    @Autowired
    BookInfoService bookInfoService;

    @Autowired
    SchoolBingShopService schoolBingShopService;

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "学校添加商户", description = "学校添加商户")
    @RequestMapping(value = "schoolBingShop", method = {RequestMethod.GET})
    public ResultContent schoolBingShop(@Parameter(name = "shopOid", description = "商品Oid", example = "") @RequestParam("shopOid") String shopOid) {
        return this.schoolBingShopService.schoolBingShop(shopOid);
    }

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "学校删除商户", description = "学校删除商户")
    @RequestMapping(value = "deleteSchoolBingShop", method = {RequestMethod.GET})
    public ResultContent deleteSchoolBingShop(@Parameter(name = "shopOid", description = "商户Oid", example = "") @RequestParam("shopOid") String shopOid) {
        return this.schoolBingShopService.deleteSchoolBingShop(shopOid);
    }

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "查询学校商户详情", description = "查询学校商户详情")
    @RequestMapping(value = "getSchoolBingShop", method = {RequestMethod.GET})
    public ResultContent<ShopToSchoolModel> getSchoolBingShop(@Parameter(name = "shopOid", description = "商户Oid", example = "") @RequestParam("shopOid") String shopOid) {
        return this.schoolBingShopService.getSchoolBingShop(shopOid);
    }

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "商户列表-分页查询", description = "商户列表-分页查询")
    @RequestMapping(value = {"pageTeacher"}, method = {RequestMethod.POST})
    public ResultContent<Page<ShopToSchoolModel>> pageTeacher(
            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
            @Parameter(required = false) OrganizationRelationSearch param) {
        return schoolBingShopService.page(param, pageable);
    }

}
