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.DmScreenOffDto;
import com.xueyi.system.resource.domain.query.DmScreenOffQuery;
import com.xueyi.system.resource.service.IDmScreenOffService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

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

/**
 * 展示页管理 业务处理
 *
 * @author xueyi
 */
@RestController
@RequestMapping("/screen_off")
public class DmScreenOffController extends BaseController<DmScreenOffQuery, DmScreenOffDto, IDmScreenOffService> {

    /** 定义节点名称 */
    @Override
    protected String getNodeName() {
        return "展示页" ;
    }



    /**
     * 查询静态资源列表
     */
    @Override
    @GetMapping("/list")
    @RequiresPermissions(Auth.DM_RESOURCES_LIST)
    public AjaxResult list(DmScreenOffQuery dmResources) {
        return super.list(dmResources);
    }

    /**
     * 查询静态资源详细
     */
    @Override
    @GetMapping(value = "/{id}")
    @RequiresPermissions(Auth.DM_RESOURCES_SINGLE)
    public AjaxResult getInfo(@PathVariable Serializable id) {
        return super.getInfo(id);
    }


    @Override
    @PostMapping
    @RequiresPermissions(Auth.DM_RESOURCES_ADD)
    @Log(title = "展示页管理", businessType = BusinessType.INSERT)
    public AjaxResult add(@Validated({V_A.class}) @RequestBody DmScreenOffDto dto) {
        return super.add(dto);
    }

    /**
     * 静态资源修改
     */
    @Override
    @PutMapping
    @RequiresPermissions(Auth.DM_RESOURCES_EDIT)
    @Log(title = "静态资源管理", businessType = BusinessType.UPDATE)
    public AjaxResult edit(@Validated({V_E.class}) @RequestBody DmScreenOffDto dmResources) {
        return super.edit(dmResources);
    }

    /**
     * 静态资源批量删除
     */
    @Override
    @DeleteMapping("/batch/{idList}")
    @RequiresPermissions(Auth.DM_RESOURCES_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_RESOURCES_LIST = "resource:resources:list";
        /** 系统 - 静态资源管理 - 详情 */
        String DM_RESOURCES_SINGLE = "resource:resources:single";
        /** 系统 - 静态资源管理 - 新增 */
        String DM_RESOURCES_ADD = "resource:resources:add";
        /** 系统 - 静态资源管理 - 修改 */
        String DM_RESOURCES_EDIT = "resource:resources:edit";
        /** 系统 - 静态资源管理 - 删除 */
        String DM_RESOURCES_DEL = "resource:resources:delete";
    }

}
