package com.gic.haoban.manage.web.controller.content;

import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.content.api.dto.setting.ContentSettingDTO;
import com.gic.content.api.service.ContentSettingApiService;
import com.gic.haoban.manage.web.utils.ApolloUtils;
import com.gic.haoban.manage.web.vo.content.ContentSettingVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 好办-内容配置
 * @Author MUSI
 * @Date 2023/11/29 10:43 AM
 * @Description
 * @Version
 **/
@RestController
@RequestMapping(path = "/content/setting")
public class ContentSettingController {

    @Autowired
    private ContentSettingApiService contentSettingApiService;

    /**
     * 查询企业内容配置
     *
     * @param enterpriseId
     * @return
     */
    @RequestMapping(path = "/info")
    public RestResponse<ContentSettingVO> queryContentSetting(String enterpriseId) {

        ServiceResponse<ContentSettingDTO> serviceResponse =
                contentSettingApiService.queryContentSettingInfo(enterpriseId);
        if (!serviceResponse.isSuccess() || serviceResponse.getResult() == null) {
           return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
        }
        ContentSettingVO contentSettingVO = EntityUtil.changeEntityByJSON(ContentSettingVO.class, serviceResponse.getResult());
        contentSettingVO.setCombinedType(ApolloUtils.combinedType(enterpriseId));
        return RestResponse.successResult(contentSettingVO);
    }
}
