package com.project.zcustom.controller.backManager.engineering;


import com.project.zcustom.controller.core.AjaxResult;
import com.project.zcustom.controller.core.BaseController;
import com.project.zcustom.domain.basics.PlatAppOrg;
import com.project.zcustom.service.service.basics.IPlatAppOrgService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * 地区编码Controller
 *
 * @author change
 * @date 2024-12-30
 */
@RestController
@RequestMapping("/zcustom/platAppOrg")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class LargePlatAppOrgController extends BaseController {

    private final IPlatAppOrgService largeUnitService;

    @GetMapping("/list")
    public AjaxResult list(PlatAppOrg entity) {
        return AjaxResult.success("查询成功", largeUnitService.pagingPlatAppOrgList(entity));
    }

    @GetMapping("/listAll")
    public AjaxResult listAll(PlatAppOrg entity) {
        return AjaxResult.success("查询成功", largeUnitService.selectPlatAppOrgList(entity));
    }

    @GetMapping("/listTree")
    public AjaxResult listTree(PlatAppOrg entity) {
        return AjaxResult.success("查询成功", largeUnitService.selectPlatAppOrgListTree(entity));
    }



    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success("查询成功", largeUnitService.getById(id));
    }


    @PostMapping("add")
    public AjaxResult add(@RequestBody PlatAppOrg entity) {
        return toAjax(largeUnitService.save(entity));
    }


    @PostMapping("edit")
    public AjaxResult edit(@RequestBody PlatAppOrg entity) {
        return toAjax(largeUnitService.updateById(entity));
    }


	@GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(largeUnitService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }

    /**
     * 接入单位数量
     */
    @GetMapping("/getConnectUnitNum")
    public AjaxResult getConnectUnitNum() {
        return AjaxResult.success("查询成功", largeUnitService.getConnectUnitNum());
    }

    /**
     * 各单位已接入摄像头数量（在线和离线）
     */
    @GetMapping("/getAllCameraCondition")
    public AjaxResult getAllCameraCondition(){
        return AjaxResult.success("查询成功", largeUnitService.getAllCameraCondition());
    }

    /**
     * 某单位已接入摄像头数量（在线和离线）
     */
    @GetMapping("/getCameraConditionByAppOrg/{appOrg}")
    public AjaxResult getCameraConditionByAppOrg(@PathVariable String appOrg){
        return AjaxResult.success("查询成功", largeUnitService.getCameraConditionByAppOrg(appOrg));
    }
}
