package com.zcloud.basic.info.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.basic.info.api.DepartmentSuperviseServiceI;
import com.zcloud.basic.info.dto.DepartmentSuperviseAddCmd;
import com.zcloud.basic.info.dto.DepartmentSupervisePageQry;
import com.zcloud.basic.info.dto.DepartmentSuperviseUpdateCmd;
import com.zcloud.basic.info.dto.clientobject.DepartmentSuperviseCO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * web-adapter
 *
 * @Author zhaokai
 * @Date 2025-11-10 14:13:45
 */
@Api(tags = "部门监管权限表")
@RequestMapping("/${application.gateway}/departmentSupervise")
@RestController
@AllArgsConstructor
public class DepartmentSuperviseController {
    private final DepartmentSuperviseServiceI departmentSuperviseService;

    @ApiOperation("新增")
    @PostMapping("/save")
    public SingleResponse<DepartmentSuperviseCO> add(@Validated @RequestBody DepartmentSuperviseAddCmd cmd) {
        SSOUser ssoUser = AuthContext.getCurrentUser();
        return departmentSuperviseService.add(cmd);
    }

    @ApiOperation("分页")
    @PostMapping("/list")
    public PageResponse<DepartmentSuperviseCO> page(@RequestBody DepartmentSupervisePageQry qry) {
        return departmentSuperviseService.listPage(qry);
    }

    @ApiOperation("详情")
    @GetMapping("/{id}")
    public SingleResponse<DepartmentSuperviseCO> getInfoById(@PathVariable("id") Long id) {
        return SingleResponse.of(new DepartmentSuperviseCO());
    }

    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public Response remove(@PathVariable("id") Long id) {
        departmentSuperviseService.remove(id);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("删除多个")
    @DeleteMapping("/ids")
    public Response removeBatch(@RequestParam Long[] ids) {
        departmentSuperviseService.removeBatch(ids);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("修改")
    @PutMapping("/edit")
    public SingleResponse edit(@Validated @RequestBody DepartmentSuperviseUpdateCmd departmentSuperviseUpdateCmd) {
        departmentSuperviseService.edit(departmentSuperviseUpdateCmd);
        return SingleResponse.buildSuccess();
    }
}

