package com.xueyi.system.pass.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.api.pass.domain.dto.DmRecognizedRecordsDto;
import com.xueyi.system.pass.domain.query.DmRecognizedRecordsQuery;
import com.xueyi.system.pass.service.IDmRecognizedRecordsService;
import com.xueyi.system.pass.service.impl.DmRecognizedRecordsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 人员识别管理 业务处理
 *
 * @author xueyi
 */
@RestController
@RequestMapping("/pass")
public class DmRecognizedRecordsController extends BaseController<DmRecognizedRecordsQuery, DmRecognizedRecordsDto, IDmRecognizedRecordsService> {

    /** 定义节点名称 */
    @Override
    protected String getNodeName() {
        return "人员识别" ;
    }


    @Autowired
    private DmRecognizedRecordsServiceImpl recognizedRecordsService;

    /**
     * 查询人员识别列表
     */
    @Override
    @GetMapping("/list")
    @RequiresPermissions(Auth.DM_RECOGNIZED_RECORDS_LIST)
    public AjaxResult list(DmRecognizedRecordsQuery dmRecognizedRecords) {
        //TODO 测试Es，随后会删除
        recognizedRecordsService.createEsIndex(new DmRecognizedRecordsDto());
        return super.list(dmRecognizedRecords);
    }

    /**
     * 查询人员识别详细
     */
    @Override
    @GetMapping(value = "/{id}")
    @RequiresPermissions(Auth.DM_RECOGNIZED_RECORDS_SINGLE)
    public AjaxResult getInfo(@PathVariable Serializable id) {
        return super.getInfo(id);
    }

    /**
     * 人员识别新增
     */
    @Override
    @PostMapping
    @RequiresPermissions(Auth.DM_RECOGNIZED_RECORDS_ADD)
    @Log(title = "人员识别管理", businessType = BusinessType.INSERT)
    public AjaxResult add(@Validated({V_A.class}) @RequestBody DmRecognizedRecordsDto dmRecognizedRecords) {
        return super.add(dmRecognizedRecords);
    }

    /**
     * 人员识别修改
     */
    @Override
    @PutMapping
    @RequiresPermissions(Auth.DM_RECOGNIZED_RECORDS_EDIT)
    @Log(title = "人员识别管理", businessType = BusinessType.UPDATE)
    public AjaxResult edit(@Validated({V_E.class}) @RequestBody DmRecognizedRecordsDto dmRecognizedRecords) {
        return super.edit(dmRecognizedRecords);
    }

    /**
     * 人员识别批量删除
     */
    @Override
    @DeleteMapping("/batch/{idList}")
    @RequiresPermissions(Auth.DM_RECOGNIZED_RECORDS_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_RECOGNIZED_RECORDS_LIST = "pass:pass:list";
        /** 系统 - 人员识别管理 - 详情 */
        String DM_RECOGNIZED_RECORDS_SINGLE = "pass:pass:single";
        /** 系统 - 人员识别管理 - 新增 */
        String DM_RECOGNIZED_RECORDS_ADD = "pass:pass:add";
        /** 系统 - 人员识别管理 - 修改 */
        String DM_RECOGNIZED_RECORDS_EDIT = "pass:pass:edit";
        /** 系统 - 人员识别管理 - 删除 */
        String DM_RECOGNIZED_RECORDS_DEL = "pass:pass:delete";
    }
}
