package com.pusong.business.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONArray;
import com.pusong.business.domain.bo.DicDataBo;
import com.pusong.business.domain.vo.PsCustomInfoVo;
import com.pusong.business.service.IPsApproverRecordService;
import com.pusong.business.service.IServiceConfigService;
import com.pusong.common.core.domain.R;
import com.pusong.common.idempotent.annotation.RepeatSubmit;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 服务配置类
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/business/serviceConfig")
@SaIgnore
public class ServiceConfigController {
    private final IServiceConfigService configService;
    /**
     * 获取服务配置
     */
    @GetMapping("/getAllConfig")
    public R<JSONArray> getAllConfig() {
        return R.ok(configService.getAllConfig());
    }

    /**
     * 新增服务配置
     */
    @RepeatSubmit()
    @PostMapping("/add")
    public R<Void> add(@RequestBody DicDataBo bo) {
        configService.add(bo);
        return R.ok();
    }
    /**
     * 修改服务配置
     */
    @RepeatSubmit()
    @PutMapping("/edit")
    public R<Void> edit(@RequestBody DicDataBo bo) {
        configService.edit(bo);
        return R.ok();
    }

    /**
     * 删除服务配置
     */
    @RepeatSubmit()
    @DeleteMapping("/delete")
    public R<Void> delete(Long dictCode) {
        configService.delete(dictCode);
        return R.ok();
    }

    /**
     * 根据合同编码查询资料配置信息
     */
    @GetMapping("/getByContractCode")
    public R<List<String>> getByContractCode(String contractCode) {
        return R.ok(configService.getByContractCode(contractCode));
    }
}
