package com.hotwj.platform.securityManagement.serviceQualityComplaint.controller;

import com.hotwj.platform.securityManagement.serviceQualityComplaint.domain.bo.HotServiceQualityComplaintBo;
import com.hotwj.platform.securityManagement.serviceQualityComplaint.domain.vo.HotServiceQualityComplaintVo;
import com.hotwj.platform.securityManagement.serviceQualityComplaint.service.IHotServiceQualityComplaintService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
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.excel.utils.ExcelUtil;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 服务质量投诉
 *
 * @author shihongwei
 * @date 2026-01-07
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/securityManagement/serviceQualityComplaint")
@Tag(name = "服务质量投诉", description = "服务质量投诉管理")
public class HotServiceQualityComplaintController extends BaseController {

    private final IHotServiceQualityComplaintService hotServiceQualityComplaintService;

    /**
     * 查询服务质量投诉列表
     */
    //@SaCheckPermission("securityManagement:serviceQualityComplaint:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询服务质量投诉列表")
    public TableDataInfo<HotServiceQualityComplaintVo> list(HotServiceQualityComplaintBo bo, PageQuery pageQuery) {
        return hotServiceQualityComplaintService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出服务质量投诉列表
     */
    //@SaCheckPermission("securityManagement:serviceQualityComplaint:export")
    @Log(title = "服务质量投诉", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出服务质量投诉列表")
    public void export(HotServiceQualityComplaintBo bo, HttpServletResponse response) {
        List<HotServiceQualityComplaintVo> list = hotServiceQualityComplaintService.queryList(bo);
        ExcelUtil.exportExcel(list, "服务质量投诉", HotServiceQualityComplaintVo.class, response);
    }

    /**
     * 获取服务质量投诉详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("securityManagement:serviceQualityComplaint:query")
    @GetMapping("/{id}")
    @Operation(summary = "获取服务质量投诉详细信息")
    public R<HotServiceQualityComplaintVo> getInfo(@NotNull(message = "主键不能为空")
                                                   @Parameter(name = "id", description = "主键", required = true, example = "1")
                                                   @PathVariable Long id) {
        return R.ok(hotServiceQualityComplaintService.queryById(id));
    }

    /**
     * 新增服务质量投诉
     */
    //@SaCheckPermission("securityManagement:serviceQualityComplaint:add")
    @Log(title = "服务质量投诉", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增服务质量投诉")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotServiceQualityComplaintBo bo) {
        return toAjax(hotServiceQualityComplaintService.insertByBo(bo));
    }

    /**
     * 修改服务质量投诉
     */
    //@SaCheckPermission("securityManagement:serviceQualityComplaint:edit")
    @Log(title = "服务质量投诉", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改服务质量投诉")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotServiceQualityComplaintBo bo) {
        return toAjax(hotServiceQualityComplaintService.updateByBo(bo));
    }

    /**
     * 删除服务质量投诉
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("securityManagement:serviceQualityComplaint:remove")
    @Log(title = "服务质量投诉", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除服务质量投诉")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @Parameter(name = "ids", description = "主键串", required = true, example = "1,2,3")
                          @PathVariable Long[] ids) {
        return toAjax(hotServiceQualityComplaintService.deleteWithValidByIds(List.of(ids), true));
    }
}
