package com.kxs.user.biz.controller.admin;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kxs.common.core.util.R;
import com.kxs.common.log.annotation.SysLog;
import com.kxs.user.api.model.KxsUserEquity;
import com.kxs.user.biz.service.KxsUserEquityService;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户模块(AdminUserEquity)控制层
 *
 * @author 系统
 * @since 2024-02-27 13:46:03
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("sysUserEquity")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class AdminUserEquityController {

    /**
     * 服务对象
     */
    private final KxsUserEquityService kxsUserEquityService;


    /**
     * 我的职级-权益列表
     *
     * @param page 分页
     * @param param 查询实体
     * @return 我的职级-权益列表
     */
    @GetMapping("/page")
    public R page(@ParameterObject Page<KxsUserEquity> page, @ParameterObject KxsUserEquity param) {
        return R.ok(kxsUserEquityService.page(page, new QueryWrapper<>(param)));
    }

    /**
     * 我的职级-权益新增/修改
     *
     * @param param 实体对象
     * @return 我的职级-权益新增/修改
     */
    @SysLog("权益新增/修改")
    @PostMapping("/save")
//    @PreAuthorize("@pms.hasPermission('sys_equity_save')")
    public R save(@RequestBody @Valid KxsUserEquity param) {

        return R.ok(kxsUserEquityService.saveOrUpdate(param));
    }

    /**
     * 我的职级-权益删除
     *
     * @param idsList id集合结合
     * @return 我的职级-权益删除
     */
    @PostMapping("remove")
    @SysLog("权益删除")
//    @PreAuthorize("@pms.hasPermission('sys_equity_del')")
    public R remove(@RequestBody List<Integer> idsList) {

        return R.ok(kxsUserEquityService.removeBatchByIds(idsList));
    }





}

