This commit is contained in:
Chopper 2021-09-17 14:47:25 +08:00
parent 3459169885
commit 9cee1093f4
4 changed files with 73 additions and 20 deletions

View File

@ -0,0 +1,49 @@
package cn.lili.controller.common;
import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.system.entity.dos.Setting;
import cn.lili.modules.system.entity.dto.ImSetting;
import cn.lili.modules.system.entity.enums.SettingEnum;
import cn.lili.modules.system.service.SettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;
/**
* IM控制器
*
* @author Chopper
* @version v1.0
* 2021-09-16 15:32
*/
@RestController
@RequestMapping("/common/IM")
@Api(tags = "IM 中心")
public class IMController {
@Autowired
private SettingService settingService;
@ApiOperation(value = "获取店铺列表分页")
@GetMapping
public ResultMessage<String> getUrl() {
String imUrl;
try {
Setting imSettingVal = settingService.get(SettingEnum.IM_SETTING.name());
ImSetting imSetting = JSONUtil.toBean(imSettingVal.getSettingValue(), ImSetting.class);
imUrl = imSetting.getHttpUrl() + "?tenant_id=" + imSetting.getTenantId()+"&merchant_euid=";
} catch (Exception e) {
throw new ServiceException(ResultCode.PLATFORM_NOT_SUPPORTED_IM);
}
return ResultUtil.data(imUrl);
}
}

View File

@ -37,6 +37,8 @@ public enum ResultCode {
LIMIT_ERROR(1003, "访问过于频繁,请稍后再试"),
ILLEGAL_REQUEST_ERROR(1004, "非法请求,请重新刷新页面操作"),
IMAGE_FILE_EXT_ERROR(1005, "不支持图片格式"),
PLATFORM_NOT_SUPPORTED_IM(1006, "平台未开启IM"),
STORE_NOT_SUPPORTED_IM(1007, "店铺未开启IM"),
/**
* 分类
*/

View File

@ -31,6 +31,8 @@ public enum SettingEnum {
EXPERIENCE_SETTING,
//秒杀活动设置
SECKILL_SETTING,
//IM 配置
IM_SETTING,
//微信 联合登陆设置
WECHAT_CONNECT,
@ -42,7 +44,5 @@ public enum SettingEnum {
//支付宝支付设置
ALIPAY_PAYMENT,
//微信支付设置
WECHAT_PAYMENT,
//IM 配置
IM;
WECHAT_PAYMENT;
}

View File

@ -63,6 +63,23 @@ public class SettingManagerController {
return ResultUtil.success();
}
@DemoSite
@ApiOperation(value = "查看配置")
@GetMapping(value = "/get/{key}")
@ApiImplicitParam(name = "key", value = "配置key", paramType = "path"
, allowableValues = "BASE_SETTING,EMAIL_SETTING,GOODS_SETTING,KUAIDI_SETTING,ORDER_SETTING,OSS_SETTING,POINT_SETTING," +
"WECHAT_PC_CONNECT,WECHAT_WAP_CONNECT,WECHAT_APP_CONNECT,WECHAT_MP_CONNECT," +
"QQ_WEB_CONNECT,QQ_APP_CONNECT," +
"QQ_WEB_CONNECT,QQ_APP_CONNECT,WEIBO_CONNECT,ALIPAY_CONNECT," +
"PAYMENT_SUPPORT,ALIPAY_PAYMENT,WECHAT_PAYMENT,SECKILL_SETTING,EXPERIENCE_SETTING,IM"
)
public ResultMessage settingGet(@PathVariable String key) {
return createSetting(key);
}
/**
* 对配置进行过滤
*
@ -83,21 +100,6 @@ public class SettingManagerController {
return configValue;
}
@DemoSite
@ApiOperation(value = "查看配置")
@GetMapping(value = "/get/{key}")
@ApiImplicitParam(name = "key", value = "配置key", paramType = "path"
, allowableValues = "BASE_SETTING,EMAIL_SETTING,GOODS_SETTING,KUAIDI_SETTING,ORDER_SETTING,OSS_SETTING,POINT_SETTING," +
"WECHAT_PC_CONNECT,WECHAT_WAP_CONNECT,WECHAT_APP_CONNECT,WECHAT_MP_CONNECT," +
"QQ_WEB_CONNECT,QQ_APP_CONNECT," +
"QQ_WEB_CONNECT,QQ_APP_CONNECT,WEIBO_CONNECT,ALIPAY_CONNECT," +
"PAYMENT_SUPPORT,ALIPAY_PAYMENT,WECHAT_PAYMENT,SECKILL_SETTING,EXPERIENCE_SETTING,IM"
)
public ResultMessage settingGet(@PathVariable String key) {
return createSetting(key);
}
/**
* 获取表单
* 这里主要包含一个配置对象为空导致转换异常问题的处理解决配置项增加减少带来的系统异常无法直接配置
@ -179,9 +181,9 @@ public class SettingManagerController {
return setting == null ?
ResultUtil.data(new ExperienceSetting()) :
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), ExperienceSetting.class));
case IM:
case IM_SETTING:
return setting == null ?
ResultUtil.data(new ExperienceSetting()) :
ResultUtil.data(new ImSetting()) :
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), ImSetting.class));
default:
throw new ServiceException(ResultCode.SETTING_NOT_TO_SET);