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.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.DmBackgroundDto;
import com.xueyi.system.resource.domain.query.DmBackgroundQuery;
import com.xueyi.system.resource.service.IDmBackgroundService;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 背景图素材管理 业务处理
 *
 * @author xueyi
 */
@RestController
@RequestMapping("/background")
public class DmBackgroundController extends BaseController<DmBackgroundQuery, DmBackgroundDto, IDmBackgroundService> {

    /** 定义节点名称 */
    @Override
    protected String getNodeName() {
        return "背景图素材" ;
    }

    /**
     * 查询背景图素材列表
     */
    @Override
    @GetMapping("/list")
    @RequiresPermissions(Auth.DM_BACKGROUND_LIST)
    public AjaxResult list(DmBackgroundQuery background) {
        return super.list(background);
    }

    /**
     * 背景图素材新增
     */
    @Override
    @PostMapping
    @RequiresPermissions(Auth.DM_BACKGROUND_ADD)
    @Log(title = "背景图素材管理", businessType = BusinessType.INSERT)
    public AjaxResult add(@Validated({V_A.class}) @RequestBody DmBackgroundDto background) {
        return super.add(background);
    }

    /**
     * 背景图素材批量删除
     */
    @Override
    @DeleteMapping("/batch/{idList}")
    @RequiresPermissions(Auth.DM_BACKGROUND_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_BACKGROUND_LIST = "resource:background:list";
        /** 系统 - 背景图素材管理 - 新增 */
        String DM_BACKGROUND_ADD = "resource:background:add";
        /** 系统 - 背景图素材管理 - 删除 */
        String DM_BACKGROUND_DEL = "resource:background:delete";
    }
}
