package org.dromara.system.controller.shyj;

import java.util.List;

import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.system.domain.vo.ZhxyShyjVo;
import org.dromara.system.domain.bo.ZhxyShyjBo;
import org.dromara.system.service.IZhxyShyjService;
import org.dromara.common.mybatis.core.page.TableDataInfo;

/**
 * 智慧校园_审核意见
 *
 * @author boman
 * @date 2023-08-21
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/audit/shyj")
public class ZhxyShyjController extends BaseController {

    private final IZhxyShyjService zhxyShyjService;

    /**
     * 查询智慧校园_审核意见列表
     */
    @SaCheckPermission("audit:shyj:list")
    @GetMapping("/list")
    public TableDataInfo<ZhxyShyjVo> list(ZhxyShyjBo bo, PageQuery pageQuery) {
        return zhxyShyjService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出智慧校园_审核意见列表
     */
    @SaCheckPermission("audit:shyj:export")
    @Log(title = "智慧校园_审核意见", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(ZhxyShyjBo bo, HttpServletResponse response) {
        List<ZhxyShyjVo> list = zhxyShyjService.queryList(bo);
        ExcelUtil.exportExcel(list, "智慧校园_审核意见", ZhxyShyjVo.class, response);
    }

    /**
     * 获取智慧校园_审核意见详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("audit:shyj:query")
    @GetMapping("/{id}")
    public R<ZhxyShyjVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(zhxyShyjService.queryById(id));
    }

    /**
     * 新增智慧校园_审核意见
     */
    @SaCheckPermission("audit:shyj:add")
    @Log(title = "智慧校园_审核意见", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody ZhxyShyjBo bo) {
        return toAjax(zhxyShyjService.insertByBo(bo));
    }

    /**
     * 修改智慧校园_审核意见
     */
    @SaCheckPermission("audit:shyj:edit")
    @Log(title = "智慧校园_审核意见", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PostMapping("/put")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ZhxyShyjBo bo) {
        return toAjax(zhxyShyjService.updateByBo(bo));
    }

    /**
     * 删除智慧校园_审核意见
     *
     * @param ids 主键串
     */
    @SaCheckPermission("audit:shyj:remove")
    @Log(title = "智慧校园_审核意见", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(zhxyShyjService.deleteWithValidByIds(List.of(ids), true));
    }
}
