nili
6 months ago
6 changed files with 108 additions and 4 deletions
@ -0,0 +1,34 @@ |
|||||
|
package awesome.group.game.service.bo.matrix; |
||||
|
|
||||
|
import awesome.group.game.dao.bean.MatrixApp; |
||||
|
import awesome.group.game.service.bo.citrus.AppCashConfig; |
||||
|
import com.google.gson.Gson; |
||||
|
import com.google.gson.reflect.TypeToken; |
||||
|
import org.springframework.util.StringUtils; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public class AppNormalConfig extends AppCashConfig { |
||||
|
public Integer maxIncomeEachVideo;//每个视频最大收益,单位分
|
||||
|
public List<DayRate> dayRates; |
||||
|
public Integer defaultRate;//默认收益率
|
||||
|
|
||||
|
public AppNormalConfig() { |
||||
|
} |
||||
|
|
||||
|
public AppNormalConfig(MatrixApp app) { |
||||
|
super(app); |
||||
|
this.maxIncomeEachVideo = app.getMaxIncomeEachVideo(); |
||||
|
if (StringUtils.hasText(app.getDayRates())) { |
||||
|
Gson gson = new Gson(); |
||||
|
this.dayRates = gson.fromJson(app.getDayRates(), new TypeToken<List<DayRate>>() { |
||||
|
}.getType()); |
||||
|
} |
||||
|
this.defaultRate = app.getDefaultRate(); |
||||
|
} |
||||
|
|
||||
|
public static class DayRate { |
||||
|
public Integer day; |
||||
|
public Integer rate; |
||||
|
} |
||||
|
} |
@ -0,0 +1,38 @@ |
|||||
|
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); |
||||
|
} |
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
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…
Reference in new issue