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.ManagementPoliceUserSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.ManagementPoliceUnitUserPagerQueryParams;
import com.changhu.module.management.pojo.vo.ManagementPoliceUnitUserPagerVo;
import com.changhu.module.management.service.PoliceService;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
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.*;

/**
 * @author 20252
 * @createTime 2024/9/11 上午9:39
 * @desc PoliceController...
 */
@Tag(name = "后台-公安")
@JsonBody
@RequestMapping("/management/police")
@CheckUserType(userTypes = UserType.MANAGEMENT_POLICE)
public class PoliceController {

    @Autowired
    private PoliceService policeService;

    @Operation(summary = "新增或保存后台用户")
    @PostMapping("/user/saveOrUpdate")
    public void userSaveOrUpdate(@RequestBody @Valid ManagementPoliceUserSaveOrUpdateParams params) {
        policeService.userSaveOrUpdate(params);
    }

    @Operation(summary = "分页查询后台用户")
    @PostMapping("/user/pager")
    public Page<ManagementPoliceUnitUserPagerVo> userPager(@RequestBody PageParams<ManagementPoliceUnitUserPagerQueryParams, ManagementPoliceUnitUserPagerVo> queryParams) {
        return policeService.userPager(queryParams);
    }

    @Operation(summary = "根据id删除后台用户")
    @DeleteMapping("/user/deleteById")
    public void userDeleteById(@RequestParam @Schema(description = "后台公安用户id") Long managementPoliceUnitUserId) {
        policeService.userDeleteById(managementPoliceUnitUserId);
    }

}
