package com.changhu.module.management.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changhu.common.annotation.CheckUserType;
import com.changhu.common.annotation.JsonBody;
import com.changhu.common.db.enums.UserType;
import com.changhu.module.management.pojo.params.IndexCheckPassParams;
import com.changhu.module.management.pojo.params.IndexCheckStatusParams;
import com.changhu.module.management.pojo.params.IndexDisableOrEnableParams;
import com.changhu.module.management.pojo.queryParams.UnitMiniProgramUserPagerQueryParams;
import com.changhu.module.management.pojo.vo.UnitCheckStatusVo;
import com.changhu.module.management.pojo.vo.UnitMiniProgramUserPagerVo;
import com.changhu.module.management.service.ManagementService;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author 20252
 * @createTime 2024/9/2 上午9:48
 * @desc IndexController...
 */
@Tag(name = "后台-通用接口")
@JsonBody
@RequestMapping("/management")
public class ManagementController {

    @Autowired
    private ManagementService managementService;

    @Operation(summary = "审核通过")
    @PostMapping("/checkPass")
    @CheckUserType(userTypes = UserType.MANAGEMENT_SUPER)
    public void checkPass(@RequestBody @Valid IndexCheckPassParams params) {
        managementService.checkPass(params);
    }

    @Operation(summary = "获取审核状态")
    @PostMapping("/getCheckStatus")
    public UnitCheckStatusVo getCheckStatus(@RequestBody @Valid IndexCheckStatusParams params) {
        return managementService.getCheckStatus(params);
    }

    @Operation(summary = "启用或禁用状态")
    @PostMapping("/disableOrEnable")
    @CheckUserType(userTypes = UserType.MANAGEMENT_SUPER)
    public void disableOrEnable(@RequestBody @Valid IndexDisableOrEnableParams params) {
        managementService.disableOrEnable(params);
    }

    @Operation(summary = "查询单位下的小程序用户")
    @PostMapping("/miniProgramUserPager")
    @CheckUserType(userTypes = {UserType.MANAGEMENT_POLICE, UserType.MANAGEMENT_SECURITY})
    public Page<UnitMiniProgramUserPagerVo> miniProgramUserPager(@RequestBody PageParams<UnitMiniProgramUserPagerQueryParams, UnitMiniProgramUserPagerVo> queryParams) {
        return managementService.miniProgramUserPager(queryParams);
    }

    @Operation(summary = "审核通过小程序用户")
    @PostMapping("/passMiniProgramUser")
    @CheckUserType(userTypes = {UserType.MANAGEMENT_POLICE, UserType.MANAGEMENT_SECURITY})
    public void passMiniProgramUser(@RequestBody @Valid IndexDisableOrEnableParams params) {
        managementService.passMiniProgramUser(params);
    }

    @Operation(summary = "禁用或启用小程序用户")
    @PostMapping("/disableOrEnableMiniProgramUser")
    @CheckUserType(userTypes = {UserType.MANAGEMENT_POLICE, UserType.MANAGEMENT_SECURITY})
    public void disableOrEnableMiniProgramUser(@RequestBody @Valid IndexDisableOrEnableParams params) {
        managementService.disableOrEnableMiniProgramUser(params);
    }
}
