package com.czg.controller.admin;

import com.czg.account.dto.RoleTemplateDTO;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.market.entity.SysRoleTemplate;
import com.czg.market.service.SysRoleTemplateService;
import com.czg.resp.CzgResult;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 角色模板
 */
@RestController
@RequestMapping("/admin/roleTemplate")
public class RoleTemplateController {
    @Resource
    private SysRoleTemplateService roleTemplateService;

    /**
     * 添加
     */
    @PostMapping
    public CzgResult<Boolean> save(@RequestBody @Validated RoleTemplateDTO dto) {
        return CzgResult.success(roleTemplateService.saveInfo(dto));
    }

    /**
     * 删除
     */
    @DeleteMapping
    public CzgResult<Boolean> delete(@RequestParam Long id) {
        return CzgResult.success(roleTemplateService.removeById(id));
    }

    /**
     * 编辑
     */
    @PutMapping
    public CzgResult<Boolean> edit(@RequestBody @Validated RoleTemplateDTO dto) {
        return CzgResult.success(roleTemplateService.editInfo(dto));
    }

    /**
     * 列表
     */
    @GetMapping("/list")
    public CzgResult<List<SysRoleTemplate>> list(@RequestParam(required = false) Long pid, @RequestParam(required = false) Integer isEnable) {
        return CzgResult.success(roleTemplateService.listInfo(pid, isEnable));
    }
}

