package com.ruoyi.web.controller.zdsz;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.convert.ExcelBigNumberConvert;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zdsz.domain.bo.ZEnginNotInstalledBo;
import com.ruoyi.zdsz.domain.vo.GExportsVo;
import com.ruoyi.zdsz.domain.vo.GImportVo;
import com.ruoyi.zdsz.domain.vo.ZEnginNotInstalledVo;
import com.ruoyi.zdsz.service.IZEnginNotInstalledService;
import com.ruoyi.zdsz.service.IZEnginNotInstalledService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.util.*;

/**
 * 未安装
 *
 * @author ruoyi
 * @date 2023-12-27
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/zdsz/enginNotInstalled")
public class ZEnginNotInstalledController extends BaseController {

    private final IZEnginNotInstalledService iZEnginNotInstalledService;

    /**
     * 查询小区管理列表
     */
    @GetMapping("/list")
    public TableDataInfo<ZEnginNotInstalledVo> list(ZEnginNotInstalledBo bo, PageQuery pageQuery) {
        return iZEnginNotInstalledService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出小区管理列表
     */
    @Log(title = "小区管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,ZEnginNotInstalledBo bo) {
        List<ZEnginNotInstalledVo> gExportsVos = iZEnginNotInstalledService.queryList(bo);
        ExcelUtil.exportExcel(gExportsVos, "小区管理", ZEnginNotInstalledVo.class, response);
    }

    /**
     * 获取小区管理详细信息
     *
     * @param id 主键
     */
    @GetMapping("/{id}")
    public R<ZEnginNotInstalledVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable String id) {
        return R.ok(iZEnginNotInstalledService.queryById(id));
    }

    /**
     * 新增小区管理
     */
    @Log(title = "小区管理", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody ZEnginNotInstalledBo bo) {
        return toAjax(iZEnginNotInstalledService.insertByBo(bo));
    }

    /**
     * 修改小区管理
     */
    @Log(title = "小区管理", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ZEnginNotInstalledBo bo) {
        return toAjax(iZEnginNotInstalledService.updateByBo(bo));
    }

    /**
     * 删除小区管理
     *
     * @param ids 主键串
     */
    @Log(title = "小区管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R remove(@NotEmpty(message = "主键不能为空") @PathVariable String[] ids) {
        return toAjax(iZEnginNotInstalledService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
}
