package com.zcloud.fire.check.web;


import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.jjb.saas.framework.auth.model.SSOUser;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.zcloud.fire.check.api.FireCheckStandardServiceI;
import com.zcloud.fire.check.dto.FireCheckStandardAddCmd;
import com.zcloud.fire.check.dto.FireCheckStandardImportCmd;
import com.zcloud.fire.check.dto.FireCheckStandardPageQry;
import com.zcloud.fire.check.dto.FireCheckStandardUpdateCmd;
import com.zcloud.fire.check.dto.clientobject.FireCheckStandardCO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotBlank;
import java.util.ArrayList;

/**
 * web-adapter
 *
 * @Author zhaokai
 * @Date 2025-11-26 10:12:14
 */
@Api(tags = "消防检查标准表")
@RequestMapping("/${application.gateway}/fireCheckStandard")
@RestController
@AllArgsConstructor
public class FireCheckStandardController {
    private final FireCheckStandardServiceI fireCheckStandardService;

    @ApiOperation("消防检查标准新增")
    @PostMapping("/save")
    public SingleResponse<FireCheckStandardCO> add(@Validated @RequestBody FireCheckStandardAddCmd cmd) {
        return fireCheckStandardService.add(cmd);
    }

    @ApiOperation("消防检查标准分页")
    @PostMapping("/list")
    @PreAuthorize("@pms.hasAnyPermission('xfqcjcbz')")
    public PageResponse<FireCheckStandardCO> page(@RequestBody FireCheckStandardPageQry qry) {
        return fireCheckStandardService.listPage(qry);
    }


    @ApiOperation("消防检查标准-根据条件查询所有数据")
    @PostMapping("/listAll")
    public MultiResponse<FireCheckStandardCO> listAll(@RequestBody FireCheckStandardPageQry qry) {
        return MultiResponse.of(fireCheckStandardService.listAll(qry));
    }

    @ApiOperation("消防检查标准详情")
    @GetMapping("/getInfoById/{id}")
    public SingleResponse<FireCheckStandardCO> getInfoById(@PathVariable("id") Long id) {
        return SingleResponse.of(fireCheckStandardService.getInfoById(id));
    }

    @ApiOperation("消防检查标准-删除")
    @GetMapping("/remove/{id}")
    public Response remove(@PathVariable("id") Long id) {
        fireCheckStandardService.remove(id);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("消防检查标准-删除多个")
    @GetMapping("/remove/ids")
    public Response removeBatch(@RequestParam Long[] ids) {
        fireCheckStandardService.removeBatch(ids);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("消防检查标准-修改")
    @PostMapping("/edit")
    public SingleResponse edit(@Validated @RequestBody FireCheckStandardUpdateCmd fireCheckStandardUpdateCmd) {
        fireCheckStandardService.edit(fireCheckStandardUpdateCmd);
        return SingleResponse.buildSuccess();
    }
    @ApiOperation("消防检查标准-导入")
    @PostMapping("/importFireCheckStandardList")
    public Response importFireCheckStandardList(@Validated FireCheckStandardImportCmd fireCheckStandardImportCmd) {
        fireCheckStandardService.importFireCheckStandardList(fireCheckStandardImportCmd);
        return SingleResponse.buildSuccess();
    }
}

