package com.changhu.module.superManagement.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.superManagement.pojo.params.ManagementSuperUserSaveOrUpdateParams;
import com.changhu.module.superManagement.pojo.params.UnitCheckPassParams;
import com.changhu.module.superManagement.pojo.queryParams.PoliceUnitPagerQueryParams;
import com.changhu.module.superManagement.pojo.queryParams.SecurityUnitPagerQueryParams;
import com.changhu.module.superManagement.pojo.vo.PoliceUnitPagerVo;
import com.changhu.module.superManagement.pojo.vo.SecurityUnitPagerVo;
import com.changhu.module.superManagement.service.SuperUnitService;
import com.changhu.pojo.params.UnitDisableOrEnableParams;
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;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 20252
 * @createTime 2024/9/11 上午9:38
 * @desc ManagementSuperController...
 */
@Tag(name = "超级后台-单位管理")
@JsonBody
@RequestMapping("/m1/unit")
@CheckUserType(userTypes = UserType.MANAGEMENT_SUPER)
@RestController
public class SuperUnitController {

    @Autowired
    private SuperUnitService superUnitService;

    @Operation(summary = "新增或保存后台用户")
    @PostMapping("/add_upd/user")
    public void saveOrUpdateUser(@RequestBody @Valid ManagementSuperUserSaveOrUpdateParams params) {
        superUnitService.saveOrUpdateUser(params);
    }

    @Operation(summary = "公安单位分页查询")
    @PostMapping("/police/pager")
    public Page<PoliceUnitPagerVo> policeUnitPager(@RequestBody PageParams<PoliceUnitPagerQueryParams, PoliceUnitPagerVo> queryParams) {
        return superUnitService.policeUnitPager(queryParams);
    }

    @Operation(summary = "保安单位分页查询")
    @PostMapping("/security/pager")
    public Page<SecurityUnitPagerVo> securityUnitPager(@RequestBody PageParams<SecurityUnitPagerQueryParams, SecurityUnitPagerVo> queryParams) {
        return superUnitService.securityUnitPager(queryParams);
    }

    @Operation(summary = "审核通过")
    @PostMapping("/check_pass")
    public void checkPass(@RequestBody @Valid UnitCheckPassParams params) {
        superUnitService.checkPass(params);
    }

    @Operation(summary = "启用或禁用状态")
    @PostMapping("/disable_enable")
    public void disableOrEnable(@RequestBody @Valid UnitDisableOrEnableParams params) {
        superUnitService.disableOrEnable(params);
    }

}
