package com.education.api.controller.admin.education;

import com.education.auth.annotation.Logical;
import com.education.auth.annotation.RequiresPermissions;
import com.education.business.service.education.CustomizeModelService;
import com.education.common.base.BaseController;
import com.education.common.utils.Result;
import com.education.model.dto.CustomizeModelDto;
import com.education.model.entity.CustomizeModel;
import com.education.model.request.PageParam;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 自定义模版管理
 */
@RequestMapping("/system/customizeModel")
@RestController
public class CustomizeModelController extends BaseController {

    @Resource
    private CustomizeModelService customizeModelService;

    /**
     * 模版分页列表
     * @param pageParam
     * @param customizeModel
     * @return
     */
    @GetMapping
    //@RequiresPermissions("system:customizeModel:list")
    public Result selectPage(PageParam pageParam, CustomizeModel customizeModel) {
        return Result.success(customizeModelService.selectPageList(pageParam, customizeModel));
    }

    /**
     * 添加或修改
     * @param customizeModelDto
     * @return
     */
    @PostMapping
    //@RequiresPermissions(value = {"system:customizeModel:save","system:customizeModel:update"}, logical = Logical.OR)
    public Result saveOrUpdate(@RequestBody CustomizeModelDto customizeModelDto) {
        customizeModelService.saveOrUpdate(customizeModelDto);
        return Result.success();
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("{id}")
    //@RequiresPermissions("system:customizeModel:deleteById")
    public Result deleteById(@PathVariable Integer id) {
        customizeModelService.removeById(id);
        return Result.success();
    }

}