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.ManagementSuperUserSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.PoliceUnitPagerQueryParams;
import com.changhu.module.management.pojo.queryParams.SecurityUnitPagerQueryParams;
import com.changhu.module.management.pojo.vo.PoliceUnitPagerVo;
import com.changhu.module.management.pojo.vo.SecurityUnitPagerVo;
import com.changhu.module.management.service.SuperService;
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/11 上午9:38
 * @desc ManagementSuperController...
 */
@Tag(name = "超级后台")
@JsonBody
@RequestMapping("/management/super")
@CheckUserType(userTypes = UserType.MANAGEMENT_SUPER)
public class SuperController {

    @Autowired
    private SuperService superService;

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

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

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

}
