package com.rongwei.bsserver.sys.controller;

import com.rongwei.bscommon.sys.service.SubConfigService;
import com.rongwei.bscommon.sys.utils.ExceptionUtils;
import com.rongwei.bsentity.dto.IdGeneralDTO;
import com.rongwei.rwcommon.base.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author shangmi
 * @title SubConfigController
 * @date 2024/1/5 13:59
 * @description 子系统配置
 */
@Slf4j
@RestController
@RequestMapping("/subsystem-config")
public class SubConfigController {

    @Autowired
    public SubConfigService subConfigService;

    /**
     * 查询菜单字段详细
     *
     * @param id 菜单ID
     * @return {@link List < KdSubsystemDetailVo>}
     * @date 2024/1/8 11:48
     * @author shangmi
     *
     */

    @PostMapping("/getModulesById")
    public R getModulesById(@RequestParam String id){
        try {
            log.info("进入接口：/subsystem-config/getModulesById,入参为：{}",id);
            return subConfigService.getModulesById(id);
        }catch (Exception e){
            ExceptionUtils.printExceptionDetail(e,"异常为：");
            log.error(e.getMessage());
            return R.error(e.getMessage());
        }
    }


    /**
     * 查询菜单字段详细
     *
     * @param id 菜单ID
     * @return {@link List < KdSubsystemDetailVo>}
     * @date 2024/1/8 11:48
     * @author shangmi
     *
     */

    @PostMapping("/getTableIdByModuleId")
    public R getTableSqlByModuleId(@RequestBody IdGeneralDTO id){
        try {
            log.info("进入接口：/subsystem-config/getTableIdByModuleId,入参为：{}",id);
            return subConfigService.getTableSqlByModuleId(id.getId());
        }catch (Exception e){
            ExceptionUtils.printExceptionDetail(e,"异常为：");
            log.error(e.getMessage());
            return R.error(e.getMessage());
        }
    }
}
