package com.jeequan.jeepay.mgr.ctrl.anon;

import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.core.model.DBOEMConfig;
import com.jeequan.jeepay.core.service.ISysConfigService;
import com.jeequan.jeepay.core.utils.JsonKit;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.service.impl.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* 网站信息ctrl
*
* @author terrfly
*
* @date 2022/2/14 20:56
*/
@RestController
@RequestMapping("/api/anon/siteInfos")
public class SiteInfoController extends CommonCtrl {

	@Autowired private ISysConfigService sysConfigService;

	@GetMapping(value = "")
	public ApiRes getSiteInfos() throws BizException {

		// 是否查询配置信息（兼容历史接口）
		Byte queryConfig = getValByteDefault("queryConfig", CS.NO);

		DBOEMConfig dboemConfig = sysConfigService.getOemConfig();
		if(queryConfig == CS.YES){

			JSONObject result = new JSONObject();
			result.put("siteInfo", dboemConfig);
			result.put("sysConfig", JsonKit.newJson("httpMsgIsEncrypt", SysConfigService.HTTP_MSG_IS_ENCRYPT));

			return ApiRes.ok(result);
		}

		return ApiRes.ok(dboemConfig);
	}

}
