package com.xueyi.system.resource.controller;

import com.xueyi.common.core.web.result.AjaxResult;
import com.xueyi.common.core.web.validate.V_A;
import com.xueyi.common.core.web.validate.V_E;
import com.xueyi.common.log.annotation.Log;
import com.xueyi.common.log.enums.BusinessType;
import com.xueyi.common.security.annotation.RequiresPermissions;
import com.xueyi.common.web.entity.controller.BaseController;
import com.xueyi.system.resource.domain.dto.DmFaceAuthMappingDto;
import com.xueyi.system.resource.domain.query.DmFaceAuthMappingQuery;
import com.xueyi.system.resource.service.IDmFaceAuthMappingService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;

/**
 * 人脸权限管理 业务处理
 *
 * @author xueyi
 */
@RestController
@RequestMapping("/resource")
public class DmFaceAuthMappingController extends BaseController<DmFaceAuthMappingQuery, DmFaceAuthMappingDto, IDmFaceAuthMappingService> {

    /** 定义节点名称 */
    @Override
    protected String getNodeName() {
        return "人脸权限" ;
    }

    /**
     * 查询人脸权限列表
     */
    @Override
    @GetMapping("/list")
    @RequiresPermissions(Auth.DM_FACE_AUTH_MAPPING_LIST)
    public AjaxResult list(DmFaceAuthMappingQuery dmFaceAuthMapping) {
        return super.list(dmFaceAuthMapping);
    }

    /**
     * 查询人脸权限详细
     */
    @Override
    @GetMapping(value = "/{id}")
    @RequiresPermissions(Auth.DM_FACE_AUTH_MAPPING_SINGLE)
    public AjaxResult getInfo(@PathVariable Serializable id) {
        return super.getInfo(id);
    }

    /**
     * 人脸权限新增
     */
    @Override
    @PostMapping
    @RequiresPermissions(Auth.DM_FACE_AUTH_MAPPING_ADD)
    @Log(title = "人脸权限管理", businessType = BusinessType.INSERT)
    public AjaxResult add(@Validated({V_A.class}) @RequestBody DmFaceAuthMappingDto dmFaceAuthMapping) {
        return super.add(dmFaceAuthMapping);
    }

    /**
     * 人脸权限修改
     */
    @Override
    @PutMapping
    @RequiresPermissions(Auth.DM_FACE_AUTH_MAPPING_EDIT)
    @Log(title = "人脸权限管理", businessType = BusinessType.UPDATE)
    public AjaxResult edit(@Validated({V_E.class}) @RequestBody DmFaceAuthMappingDto dmFaceAuthMapping) {
        return super.edit(dmFaceAuthMapping);
    }

    /**
     * 人脸权限批量删除
     */
    @Override
    @DeleteMapping("/batch/{idList}")
    @RequiresPermissions(Auth.DM_FACE_AUTH_MAPPING_DEL)
    @Log(title = "人脸权限管理", businessType = BusinessType.DELETE)
    public AjaxResult batchRemove(@PathVariable List<Long> idList) {
        return super.batchRemove(idList);
    }

    /**
     * 获取人脸权限选择框列表
     */
    @Override
    @GetMapping("/option")
    public AjaxResult option() {
        return super.option();
    }

    interface Auth {
        /** 系统 - 人脸权限管理 - 列表 */
        String DM_FACE_AUTH_MAPPING_LIST = "resource:resource:list";
        /** 系统 - 人脸权限管理 - 详情 */
        String DM_FACE_AUTH_MAPPING_SINGLE = "resource:resource:single";
        /** 系统 - 人脸权限管理 - 新增 */
        String DM_FACE_AUTH_MAPPING_ADD = "resource:resource:add";
        /** 系统 - 人脸权限管理 - 修改 */
        String DM_FACE_AUTH_MAPPING_EDIT = "resource:resource:edit";
        /** 系统 - 人脸权限管理 - 删除 */
        String DM_FACE_AUTH_MAPPING_DEL = "resource:resource:delete";
    }
}
