Merge branch 'test' into dev
This commit is contained in:
commit
bc89e9e87a
|
|
@ -44,8 +44,9 @@ public class AppUserPrizeExchangeController {
|
||||||
@PostMapping("/exchange")
|
@PostMapping("/exchange")
|
||||||
@ApiOperation("兑换")
|
@ApiOperation("兑换")
|
||||||
public Result exchange(@RequestAttribute("userId") Long userId, @RequestBody UserPrizeExchange entity) {
|
public Result exchange(@RequestAttribute("userId") Long userId, @RequestBody UserPrizeExchange entity) {
|
||||||
userPrizeExchangeService.exchange(userId, entity);
|
//userPrizeExchangeService.exchange(userId, entity);
|
||||||
return Result.success();
|
//return Result.success();
|
||||||
|
return Result.error("奖品正在路上,请耐心等待");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Login
|
@Login
|
||||||
|
|
|
||||||
|
|
@ -78,4 +78,11 @@ public class AppCommonController {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@PutMapping("putAppUseKvToOss")
|
||||||
|
//@ResponseBody
|
||||||
|
public Result putAppUseKvToOss() {
|
||||||
|
String data = commonService.putOss();
|
||||||
|
return Result.success().put("data", data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,4 +45,6 @@ public interface CommonInfoService {
|
||||||
Map<Integer,String> findAppKv();
|
Map<Integer,String> findAppKv();
|
||||||
|
|
||||||
void cleanAppKv();
|
void cleanAppKv();
|
||||||
|
|
||||||
|
String putOss();
|
||||||
}
|
}
|
||||||
|
|
@ -1,13 +1,20 @@
|
||||||
package com.sqx.modules.common.service.impl;
|
package com.sqx.modules.common.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.sqx.common.utils.RedisUtils;
|
||||||
import com.sqx.common.utils.Result;
|
import com.sqx.common.utils.Result;
|
||||||
import com.sqx.modules.common.dao.CommonInfoDao;
|
import com.sqx.modules.common.dao.CommonInfoDao;
|
||||||
import com.sqx.modules.common.entity.CommonInfo;
|
import com.sqx.modules.common.entity.CommonInfo;
|
||||||
import com.sqx.modules.common.service.CommonInfoService;
|
import com.sqx.modules.common.service.CommonInfoService;
|
||||||
import com.sqx.modules.course.service.CourseService;
|
import com.sqx.modules.course.service.CourseService;
|
||||||
|
import com.sqx.modules.oss.cloud.OSSFactory;
|
||||||
|
import com.sqx.modules.oss.entity.SysOssEntity;
|
||||||
|
import com.sqx.modules.oss.service.SysOssService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.CacheManager;
|
import org.springframework.cache.CacheManager;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
|
@ -15,6 +22,7 @@ import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -37,6 +45,10 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CacheManager cacheManager;
|
private CacheManager cacheManager;
|
||||||
|
@Autowired
|
||||||
|
private SysOssService sysOssService;
|
||||||
|
@Autowired
|
||||||
|
private RedisUtils redisUtils;
|
||||||
|
|
||||||
|
|
||||||
@CacheEvict(key = "#commonInfo.id")
|
@CacheEvict(key = "#commonInfo.id")
|
||||||
|
|
@ -91,17 +103,57 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
||||||
@Override
|
@Override
|
||||||
@Cacheable("commonInfoAppKv")
|
@Cacheable("commonInfoAppKv")
|
||||||
public Map<Integer, String> findAppKv() {
|
public Map<Integer, String> findAppKv() {
|
||||||
List<CommonInfo> list = commonInfoDao.selectList(Wrappers.<CommonInfo>lambdaQuery().eq(CommonInfo::getIsAppUse, 1).orderByAsc(CommonInfo::getType).orderByAsc(CommonInfo::getId));
|
List<CommonInfo> list = commonInfoDao.selectList(Wrappers.<CommonInfo>lambdaQuery()
|
||||||
|
.eq(CommonInfo::getIsAppUse, 1)
|
||||||
|
.orderByAsc(CommonInfo::getType)
|
||||||
|
.orderByAsc(CommonInfo::getId));
|
||||||
if (CollUtil.isEmpty(list)) {
|
if (CollUtil.isEmpty(list)) {
|
||||||
return new HashMap<>(0);
|
return new HashMap<>(0);
|
||||||
}
|
}
|
||||||
Map<Integer, String> data = list.stream().collect(Collectors.toMap(CommonInfo::getType, CommonInfo::getValue));
|
Map<Integer, String> data = list.stream().collect(Collectors.toMap(CommonInfo::getType, CommonInfo::getValue));
|
||||||
|
String url = putOss();
|
||||||
|
// 移除 条款、服务协议、隐私政策 这些长text字段,为减缓宽带消耗,放到oss中加载
|
||||||
|
data.put(154, url);
|
||||||
|
data.put(155, url);
|
||||||
|
data.put(246, url);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanAppKv() {
|
public void cleanAppKv() {
|
||||||
cacheManager.getCache("commonInfoAppKv").clear();
|
cacheManager.getCache("commonInfoAppKv").clear();
|
||||||
|
redisUtils.delete(SYS_OSS_CONFIG_JSON_URL_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String SYS_OSS_CONFIG_JSON_URL_KEY = "SYS_OSS_CONFIG_JSON_URL";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String putOss() {
|
||||||
|
String url = redisUtils.get(SYS_OSS_CONFIG_JSON_URL_KEY);
|
||||||
|
if (StrUtil.isNotBlank(url)) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
List<CommonInfo> list = commonInfoDao.selectList(Wrappers.<CommonInfo>lambdaQuery()
|
||||||
|
.eq(CommonInfo::getIsAppUse, 1)
|
||||||
|
.in(CommonInfo::getType, 154, 155, 246));
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
Map<Integer, String> data = list.stream().collect(Collectors.toMap(CommonInfo::getType, CommonInfo::getValue));
|
||||||
|
String jsonStr = JSONUtil.toJsonStr(data);
|
||||||
|
File file = FileUtil.createTempFile("hutool", ".json", null, true);
|
||||||
|
FileUtil.writeUtf8String(jsonStr, file);
|
||||||
|
//上传文件
|
||||||
|
String suffix = FileUtil.extName(file);
|
||||||
|
url = OSSFactory.build().uploadSuffix(FileUtil.readBytes(file), "." + suffix);
|
||||||
|
file.delete();
|
||||||
|
//保存文件信息
|
||||||
|
SysOssEntity ossEntity = new SysOssEntity();
|
||||||
|
ossEntity.setUrl(url);
|
||||||
|
ossEntity.setCreateDate(new Date());
|
||||||
|
sysOssService.save(ossEntity);
|
||||||
|
redisUtils.set(SYS_OSS_CONFIG_JSON_URL_KEY, url);
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,9 @@ package com.sqx.modules.discSpinning.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.sqx.common.utils.PageUtils;
|
||||||
import com.sqx.common.utils.RedisKeys;
|
import com.sqx.common.utils.RedisKeys;
|
||||||
import com.sqx.common.utils.RedisUtils;
|
import com.sqx.common.utils.RedisUtils;
|
||||||
import com.sqx.common.utils.Result;
|
import com.sqx.common.utils.Result;
|
||||||
|
|
@ -13,6 +16,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@Api(value = "现金红包 抽奖配置", tags = {"现金红包 抽奖金额配置"})
|
@Api(value = "现金红包 抽奖配置", tags = {"现金红包 抽奖金额配置"})
|
||||||
|
|
@ -59,7 +64,10 @@ public class DiscSpinningAmountController {
|
||||||
@GetMapping("/selectDiscSpinningAmount")
|
@GetMapping("/selectDiscSpinningAmount")
|
||||||
@ApiOperation("查询现金红包 抽奖配置")
|
@ApiOperation("查询现金红包 抽奖配置")
|
||||||
public Result selectDiscSpinningAmount(Integer page, Integer limit) {
|
public Result selectDiscSpinningAmount(Integer page, Integer limit) {
|
||||||
return Result.success().put("data", discSpinningAmountService.page(new Page<>(page, limit), new QueryWrapper<DiscSpinningAmount>().orderByDesc("status").orderByAsc("num","random","max_amount")));
|
PageHelper.startPage(page, limit);
|
||||||
|
List<DiscSpinningAmount> list = discSpinningAmountService.list(new QueryWrapper<DiscSpinningAmount>().orderByDesc("status").orderByAsc("num", "random", "max_amount"));
|
||||||
|
PageInfo<DiscSpinningAmount> pageInfo = new PageInfo<>(list);
|
||||||
|
return Result.success().put("data", PageUtils.page(pageInfo, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ public class DiscSpinningController {
|
||||||
@RequestMapping("/app/discSpinning/receive")
|
@RequestMapping("/app/discSpinning/receive")
|
||||||
@Login
|
@Login
|
||||||
public Result receive(@RequestAttribute("userId") Long userId) {
|
public Result receive(@RequestAttribute("userId") Long userId) {
|
||||||
userService.addBlackUser(userId, "转盘奖项领取");
|
// userService.addBlackUser(userId, "转盘奖项领取");
|
||||||
return Result.success().put("data", 1);
|
return Result.success().put("data", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue