B2C功能提交
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
package cn.lili.controller.other;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.aop.annotation.DemoSite;
|
||||
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.*;
|
||||
import cn.lili.modules.system.entity.dto.connect.ConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.QQConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.WechatConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.payment.AlipayPaymentSetting;
|
||||
import cn.lili.modules.system.entity.dto.payment.PaymentSupportSetting;
|
||||
import cn.lili.modules.system.entity.dto.payment.UnionPaymentSetting;
|
||||
import cn.lili.modules.system.entity.dto.payment.WechatPaymentSetting;
|
||||
import cn.lili.modules.system.entity.dto.payment.dto.PaymentSupportForm;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
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.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author chc
|
||||
* @since 2022/6/2114:46
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,系统设置")
|
||||
@RequestMapping("/buyer/other/setting")
|
||||
public class SettingBuyerController {
|
||||
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
/**
|
||||
* 缓存
|
||||
*/
|
||||
@Autowired
|
||||
private Cache<String> cache;
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表单
|
||||
* 这里主要包含一个配置对象为空,导致转换异常问题的处理,解决配置项增加减少,带来的系统异常,无法直接配置
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
* @throws InstantiationException
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
private ResultMessage createSetting(String key) {
|
||||
SettingEnum settingEnum = SettingEnum.valueOf(key);
|
||||
cache.remove(key);
|
||||
Setting setting = settingService.get(key);
|
||||
switch (settingEnum) {
|
||||
case BASE_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new BaseSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), BaseSetting.class));
|
||||
case WITHDRAWAL_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new WithdrawalSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), WithdrawalSetting.class));
|
||||
case DISTRIBUTION_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new DistributionSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), DistributionSetting.class));
|
||||
case EMAIL_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new EmailSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), EmailSetting.class));
|
||||
case GOODS_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new GoodsSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), GoodsSetting.class));
|
||||
case LOGISTICS_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new LogisticsSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), LogisticsSetting.class));
|
||||
case ORDER_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new OrderSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), OrderSetting.class));
|
||||
case OSS_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new OssSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), OssSetting.class));
|
||||
case SMS_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new SmsSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), SmsSetting.class));
|
||||
case POINT_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new PointSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), PointSetting.class));
|
||||
case QQ_CONNECT:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new QQConnectSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), QQConnectSetting.class));
|
||||
case CONNECT_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new ConnectSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), ConnectSetting.class));
|
||||
case PAYMENT_SUPPORT:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new PaymentSupportSetting(new PaymentSupportForm())) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), PaymentSupportSetting.class));
|
||||
case ALIPAY_PAYMENT:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new AlipayPaymentSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), AlipayPaymentSetting.class));
|
||||
case UNIONPAY_PAYMENT:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new UnionPaymentSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), UnionPaymentSetting.class));
|
||||
case WECHAT_CONNECT:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new WechatConnectSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), WechatConnectSetting.class));
|
||||
case WECHAT_PAYMENT:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new WechatPaymentSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), WechatPaymentSetting.class));
|
||||
case SECKILL_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new SeckillSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), SeckillSetting.class));
|
||||
case EXPERIENCE_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new ExperienceSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), ExperienceSetting.class));
|
||||
case IM_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new ImSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), ImSetting.class));
|
||||
case HOT_WORDS:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new HotWordsSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), HotWordsSetting.class));
|
||||
case DELIVERY_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new DeliverySetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), DeliverySetting.class));
|
||||
default:
|
||||
throw new ServiceException(ResultCode.SETTING_NOT_TO_SET);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user