Browse Source

应用配置编辑

master
nili 6 months ago
parent
commit
c92f270b0b
  1. 1
      game-dao/src/main/java/awesome/group/game/dao/bean/MatrixApp.java
  2. 32
      game-service/src/main/java/awesome/group/game/service/bo/matrix/AppBasicConfig.java
  3. 2
      game-service/src/main/java/awesome/group/game/service/bo/matrix/UmengConfigBo.java
  4. 6
      game-service/src/main/java/awesome/group/game/service/bo/matrix/WxConfig.java
  5. 133
      game-service/src/main/java/awesome/group/game/service/matrix/MatrixAppConfigService.java
  6. 38
      game-service/src/main/java/awesome/group/game/service/matrix/MatrixAppService.java
  7. 85
      game-web/src/main/java/awesome/group/game/web/rest/matrix/MatrixAppConfigController.java
  8. 30
      game-web/src/main/java/awesome/group/game/web/rest/matrix/MatrixAppController.java

1
game-dao/src/main/java/awesome/group/game/dao/bean/MatrixApp.java

@ -16,6 +16,7 @@ public class MatrixApp {
private String channel; private String channel;
private Integer hide; private Integer hide;
private String secret; private String secret;
private Integer version;
private String umeng;//友盟的配置数据 private String umeng;//友盟的配置数据
private String aliPay;//支付宝的配置数据 private String aliPay;//支付宝的配置数据

32
game-service/src/main/java/awesome/group/game/service/bo/matrix/AppBasicConfig.java

@ -0,0 +1,32 @@
package awesome.group.game.service.bo.matrix;
import awesome.group.game.dao.bean.MatrixApp;
public class AppBasicConfig {
public Integer id;
public String code;
public String secret;
public String name;
public String img;
public String url;
public Integer hide;
public String channel;
public Integer version;
//TODO 广告位
public AppBasicConfig() {
}
public AppBasicConfig(MatrixApp app) {
this.id = app.getId();
this.code = app.getCode();
this.secret = app.getSecret();
this.name = app.getName();
this.img = app.getImg();
this.url = app.getUrl();
this.hide = app.getHide();
this.channel = app.getChannel();
this.version = app.getVersion();
}
}

2
game-service/src/main/java/awesome/group/game/service/bo/matrix/UmengConfigBo.java

@ -5,4 +5,6 @@ public class UmengConfigBo {
public String umengAppSecret; public String umengAppSecret;
public String umengAppCode; public String umengAppCode;
public String umengAppKey; public String umengAppKey;
} }

6
game-service/src/main/java/awesome/group/game/service/bo/matrix/WxConfig.java

@ -0,0 +1,6 @@
package awesome.group.game.service.bo.matrix;
public class WxConfig {
public String appId;
public String appSecret;
}

133
game-service/src/main/java/awesome/group/game/service/matrix/MatrixAppConfigService.java

@ -0,0 +1,133 @@
package awesome.group.game.service.matrix;
import awesome.group.game.dao.bean.MatrixApp;
import awesome.group.game.dao.mapper.MatrixAppMapper;
import awesome.group.game.service.bo.matrix.*;
import com.google.gson.Gson;
import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@Service
public class MatrixAppConfigService {
@Autowired
private MatrixAppMapper appMapper;
private Gson gson = new Gson();
public AppNormalConfig getNormalConfig(String appCode) {
MatrixApp app = appMapper.queryByCode(appCode);
return new AppNormalConfig(app);
}
public UmengConfigBo getUMengConfig(String appCode) {
MatrixApp app = appMapper.queryByCode(appCode);
if (StringUtils.hasText(app.getUmeng())) {
return gson.fromJson(app.getUmeng(), UmengConfigBo.class);
}
return null;
}
public AliPayConfigBo getAliPayConfig(String appCode) {
MatrixApp app = appMapper.queryByCode(appCode);
if (!StringUtils.hasText(app.getAliPay())) {
return null;
}
AliPayConfigBo res = gson.fromJson(app.getAliPay(), AliPayConfigBo.class);
res.aliPayPublicCert = res.aliPayPublicCert.substring(0, Math.min(100, res.aliPayPublicCert.length())) + "......";
res.aliPayRootCert = res.aliPayRootCert.substring(0, Math.min(100, res.aliPayRootCert.length())) + "......";
res.aliPayAppCert = res.aliPayAppCert.substring(0, Math.min(100, res.aliPayAppCert.length())) + "......";
res.aliPayPrivateKey = res.aliPayPrivateKey.substring(0, Math.min(10, res.aliPayPrivateKey.length())) + "......";
return res;
}
public void saveNormalConfig(String appCode, AppNormalConfig config) {
MatrixApp app = appMapper.queryByCode(appCode);
if (!CollectionUtils.isEmpty(config.dayRates)) {
app.setDayRates(gson.toJson(config.dayRates));
}
app.setDefaultRate(config.defaultRate);
app.setDayLimit(config.dayLimit);
app.setMaxIncomeEachVideo(config.maxIncomeEachVideo);
app.setNoAuditMoney(config.noAuditMoney);
if (!CollectionUtils.isEmpty(config.moneyLadder)) {
app.setMoneyLadder(gson.toJson(config.moneyLadder));
}
app.setQqUrl(config.qqUrl);
appMapper.updateById(app);
}
public void saveUMengConfig(String appCode, UmengConfigBo configBo) {
Assert.isTrue(StringUtils.hasText(configBo.umengAppKey), "AppKey不能为空(友盟后台获取)");
Assert.isTrue(StringUtils.hasText(configBo.umengAppSecret), "AppSecret不能为空(阿里云后台获取)");
Assert.isTrue(StringUtils.hasText(configBo.umengAppKeyAli), "AppKey不能为空(阿里云后台获取)");
Assert.isTrue(StringUtils.hasText(configBo.umengAppCode), "AppCode不能为空(阿里云后台获取)");
String str = gson.toJson(configBo);
MatrixApp app = appMapper.queryByCode(appCode);
app.setUmeng(str);
appMapper.updateById(app);
}
public void saveAliPayConfig(String appCode, AliPayConfigBo configBo) {
Assert.isTrue(StringUtils.hasText(configBo.aliPayAppId), "AppId不能为空(支付宝开放平台获取)");
Assert.isTrue(StringUtils.hasText(configBo.aliPayPrivateKey), "PrivateKey不能为空(支付宝开放平台获取)");
Assert.isTrue(StringUtils.hasText(configBo.aliPayAppCert), "appCertPublicKey不能为空(密钥工具生成)");
Assert.isTrue(StringUtils.hasText(configBo.aliPayRootCert), "alipayRootCert不能为空(密钥工具生成)");
Assert.isTrue(StringUtils.hasText(configBo.aliPayPublicCert), "alipayCertPublicKey不能为空(密钥工具生成)");
String str = gson.toJson(configBo);
MatrixApp app = appMapper.queryByCode(appCode);
app.setAliPay(str);
appMapper.updateById(app);
}
public AppBasicConfig getAppBasic(String appCode) {
MatrixApp app = appMapper.queryByCode(appCode);
return new AppBasicConfig(app);
}
public void saveAppBasic(AppBasicConfig config) {
if (StringUtils.hasText(config.code)) {
MatrixApp app = appMapper.queryByCode(config.code);
app.setName(config.name);
app.setUrl(config.url);
app.setImg(config.img);
app.setHide(config.hide);
app.setVersion(config.version);
appMapper.updateNameOrUrl(app);
} else {
MatrixApp app = new MatrixApp();
app.setCode(RandomStringUtils.randomAlphabetic(10));
app.setSecret(RandomStringUtils.randomAlphabetic(32));
app.setChannel(config.channel);
app.setName(config.name);
app.setUrl(config.url);
app.setImg(config.img);
app.setHide(config.hide);
app.setVersion(config.version);
appMapper.insert(app);
}
}
public WxConfig getWxConfig(String appCode) {
MatrixApp app = appMapper.queryByCode(appCode);
if (StringUtils.hasText(app.getWx())) {
WxConfig config = gson.fromJson(app.getWx(), WxConfig.class);
config.appSecret = config.appSecret.substring(0, Math.min(10, config.appSecret.length())) + "......";
return config;
}
return null;
}
public void saveWxConfig(String appCode, WxConfig config) {
Assert.isTrue(StringUtils.hasText(config.appId), "AppId不能为空(微信开放平台获取)");
Assert.isTrue(StringUtils.hasText(config.appSecret), "AppSecret不能为空(微信开放平台获取)");
MatrixApp app = appMapper.queryByCode(appCode);
app.setWx(gson.toJson(config));
appMapper.updateById(app);
}
}

38
game-service/src/main/java/awesome/group/game/service/matrix/MatrixAppService.java

@ -1,38 +0,0 @@
package awesome.group.game.service.matrix;
import awesome.group.game.dao.bean.MatrixApp;
import awesome.group.game.dao.mapper.MatrixAppMapper;
import awesome.group.game.service.bo.matrix.AppNormalConfig;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@Service
public class MatrixAppService {
@Autowired
private MatrixAppMapper appMapper;
private Gson gson = new Gson();
public AppNormalConfig getNormalConfig(String appCode) {
MatrixApp app = appMapper.queryByCode(appCode);
return new AppNormalConfig(app);
}
public void saveNormalConfig(String appCode, AppNormalConfig config) {
MatrixApp app = appMapper.queryByCode(appCode);
if (!CollectionUtils.isEmpty(config.dayRates)) {
app.setDayRates(gson.toJson(config.dayRates));
}
app.setDefaultRate(config.defaultRate);
app.setDayLimit(config.dayLimit);
app.setMaxIncomeEachVideo(config.maxIncomeEachVideo);
app.setNoAuditMoney(config.noAuditMoney);
if (!CollectionUtils.isEmpty(config.moneyLadder)) {
app.setMoneyLadder(gson.toJson(config.moneyLadder));
}
app.setQqUrl(config.qqUrl);
appMapper.updateById(app);
}
}

85
game-web/src/main/java/awesome/group/game/web/rest/matrix/MatrixAppConfigController.java

@ -0,0 +1,85 @@
package awesome.group.game.web.rest.matrix;
import awesome.group.game.service.bo.matrix.*;
import awesome.group.game.service.common.response.R;
import awesome.group.game.service.matrix.MatrixAppConfigService;
import awesome.group.game.web.aop.RestApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/matrix/app")
public class MatrixAppConfigController {
@Autowired
private MatrixAppConfigService appService;
@GetMapping("/normalConfig")
@RestApi
public R<AppNormalConfig> getAppNormalConfig(@RequestParam String appCode) {
AppNormalConfig data = appService.getNormalConfig(appCode);
return new R<>(data);
}
@PostMapping("/normalConfig")
@RestApi
public R<Void> saveNormalConfig(@RequestParam String appCode, @RequestBody AppNormalConfig config) {
appService.saveNormalConfig(appCode, config);
return new R<>(null);
}
@GetMapping("/uMengConfig")
@RestApi
public R<UmengConfigBo> getUMengConfig(@RequestParam String appCode) {
UmengConfigBo data = appService.getUMengConfig(appCode);
return new R<>(data);
}
@PostMapping("/uMengConfig")
@RestApi
public R<Void> saveUMengConfig(@RequestParam String appCode, @RequestBody UmengConfigBo config) {
appService.saveUMengConfig(appCode, config);
return new R<>(null);
}
@GetMapping("/aliPayConfig")
@RestApi
public R<AliPayConfigBo> getAliPayConfig(@RequestParam String appCode) {
AliPayConfigBo data = appService.getAliPayConfig(appCode);
return new R<>(data);
}
@PostMapping("/aliPayConfig")
@RestApi
public R<Void> saveAliPayConfig(@RequestParam String appCode, @RequestBody AliPayConfigBo config) {
appService.saveAliPayConfig(appCode, config);
return new R<>(null);
}
@GetMapping("/basicConfig")
@RestApi
public R<AppBasicConfig> getBasicConfig(@RequestParam String appCode) {
AppBasicConfig data = appService.getAppBasic(appCode);
return new R<>(data);
}
@PostMapping("/basicConfig")
@RestApi
public R<Void> saveBasicConfig(@RequestBody AppBasicConfig config) {
appService.saveAppBasic(config);
return new R<>(null);
}
@GetMapping("/wxConfig")
@RestApi
public R<WxConfig> getWxConfig(@RequestParam String appCode) {
return new R<>(appService.getWxConfig(appCode));
}
@PostMapping("/wxConfig")
@RestApi
public R<Void> saveWxConfig(@RequestParam String appCode, @RequestBody WxConfig config) {
appService.saveWxConfig(appCode, config);
return new R<>(null);
}
}

30
game-web/src/main/java/awesome/group/game/web/rest/matrix/MatrixAppController.java

@ -1,30 +0,0 @@
package awesome.group.game.web.rest.matrix;
import awesome.group.game.service.bo.matrix.AppNormalConfig;
import awesome.group.game.service.common.response.R;
import awesome.group.game.service.matrix.MatrixAppService;
import awesome.group.game.web.aop.RestApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/matrix/app")
public class MatrixAppController {
@Autowired
private MatrixAppService appService;
@GetMapping("/normalConfig")
@RestApi
public R<AppNormalConfig> getAppNormalConfig(@RequestParam String appCode) {
AppNormalConfig data = appService.getNormalConfig(appCode);
return new R<>(data);
}
@PostMapping("/normalConfig")
@RestApi
public R<Void> saveNormalConfig(@RequestParam String appCode, @RequestBody AppNormalConfig config) {
appService.saveNormalConfig(appCode, config);
return new R<>(null);
}
}
Loading…
Cancel
Save