feat: 产品中心
This commit is contained in:
parent
73d46a1eac
commit
5a82097a6d
|
|
@ -26,7 +26,7 @@ import com.nflg.mobilebroken.starter.service.EmailService;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -79,7 +79,7 @@ public class AdminUserController extends ControllerBase {
|
|||
private IDictionaryItemTranslateService dictionaryItemTranslateService;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
/**
|
||||
* 获取部门列表
|
||||
|
|
@ -304,11 +304,11 @@ public class AdminUserController extends ControllerBase {
|
|||
@ApiMark(moduleName = "账号管理", apiName = "修改密码")
|
||||
public ApiResult<Void> updatePassword(@Valid @RequestBody UpdatePasswordRequest request) {
|
||||
String redisKey = StrUtil.format(Constant.REDIS_KEY_USER_UPDATE_KAPTCHA_ADMIN, AdminUserUtil.getEmail());
|
||||
String captcha = redisTemplate.opsForValue().get(redisKey);
|
||||
String captcha = stringRedisTemplate.opsForValue().get(redisKey);
|
||||
VUtils.trueThrowBusinessError(StrUtil.isBlank(captcha)).throwMessage("验证码已失效,请重新获取");
|
||||
VUtils.trueThrowBusinessError(!StrUtil.equals(captcha, request.getCaptcha())).throwMessage("验证码不正确");
|
||||
adminUserService.updatePassword(AdminUserUtil.getUserId(), request.getNewPassword());
|
||||
redisTemplate.delete(redisKey);
|
||||
stringRedisTemplate.delete(redisKey);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
|
|
@ -322,7 +322,7 @@ public class AdminUserController extends ControllerBase {
|
|||
String email = AdminUserUtil.getEmail();
|
||||
String kaptcha = RandomUtil.randomString(6);
|
||||
// 将生成的验证码存入redis
|
||||
redisTemplate.opsForValue().set(StrUtil.format(Constant.REDIS_KEY_USER_UPDATE_KAPTCHA_ADMIN, email), kaptcha, Duration.ofHours(72));
|
||||
stringRedisTemplate.opsForValue().set(StrUtil.format(Constant.REDIS_KEY_USER_UPDATE_KAPTCHA_ADMIN, email), kaptcha, Duration.ofHours(72));
|
||||
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_CHANGE_PASSWORD, Constant.DEFAULT_LANGUAGE_CODE);
|
||||
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_ACCOUNT_CHANGE_PASSWORD, Constant.DEFAULT_LANGUAGE_CODE)
|
||||
.replace("${loginName}",email)
|
||||
|
|
@ -380,8 +380,8 @@ public class AdminUserController extends ControllerBase {
|
|||
.exists())
|
||||
.throwMessage("已存在相同的登录名");
|
||||
String code= RandomUtil.randomString(6);
|
||||
redisTemplate.opsForValue().set(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + user.getLoginName(), code, Duration.ofHours(72));
|
||||
redisTemplate.opsForValue().set(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + code, request.getEmail(), Duration.ofHours(72));
|
||||
stringRedisTemplate.opsForValue().set(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + user.getLoginName(), code, Duration.ofHours(72));
|
||||
stringRedisTemplate.opsForValue().set(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + code, request.getEmail(), Duration.ofHours(72));
|
||||
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_CHANGE_EMAIL, Constant.DEFAULT_LANGUAGE_CODE);
|
||||
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_CHANGE_EMAIL, Constant.DEFAULT_LANGUAGE_CODE)
|
||||
.replace("${email}", user.getLoginName())
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import com.nflg.mobilebroken.starter.service.EmailService;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ public class AppUserController extends ControllerBase {
|
|||
private IDictionaryItemTranslateService dictionaryItemTranslateService;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
private ITBasePositionService positionService;
|
||||
|
|
@ -448,8 +448,8 @@ public class AppUserController extends ControllerBase {
|
|||
.exists())
|
||||
.throwMessage("已存在相同的登录名");
|
||||
String code= RandomUtil.randomString(6);
|
||||
redisTemplate.opsForValue().set(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + user.getLoginName(), code, Duration.ofHours(72));
|
||||
redisTemplate.opsForValue().set(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + code, request.getEmail(), Duration.ofHours(72));
|
||||
stringRedisTemplate.opsForValue().set(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + user.getLoginName(), code, Duration.ofHours(72));
|
||||
stringRedisTemplate.opsForValue().set(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + code, request.getEmail(), Duration.ofHours(72));
|
||||
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_CHANGE_EMAIL, Constant.DEFAULT_LANGUAGE_CODE);
|
||||
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_CHANGE_EMAIL, Constant.DEFAULT_LANGUAGE_CODE)
|
||||
.replace("${email}", user.getLoginName())
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ package com.nflg.mobilebroken.admin.controller;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.mobilebroken.admin.service.ITranslate;
|
||||
import com.nflg.mobilebroken.common.constant.Constant;
|
||||
import com.nflg.mobilebroken.common.constant.PublishState;
|
||||
import com.nflg.mobilebroken.common.constant.STATE;
|
||||
import com.nflg.mobilebroken.common.exception.NflgException;
|
||||
|
|
@ -23,7 +27,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
|
@ -61,6 +64,12 @@ public class ProductModelController extends ControllerBase{
|
|||
@Resource
|
||||
private IProductModelHotimageService productModelHotimageService;
|
||||
|
||||
@Resource
|
||||
private ILanguageService languageService;
|
||||
|
||||
@Resource
|
||||
private ITranslate translate;
|
||||
|
||||
/**
|
||||
* 添加机型
|
||||
* @param request 请求参数
|
||||
|
|
@ -299,19 +308,33 @@ public class ProductModelController extends ControllerBase{
|
|||
* @param request 请求参数
|
||||
*/
|
||||
@PostMapping("/addParamsItem")
|
||||
public ApiResult<ParamsItemVO> addParamsItem(@Valid @RequestBody ProductModelParamsItemAddRequest1 request){
|
||||
public ApiResult<Integer> addParamsItem(@Valid @RequestBody ProductModelParamsItemAddRequest1 request){
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(request.getModelParamsId())).throwMessage("机型参数id不能为空");
|
||||
ProductModelParams info = productModelParamsService.getById(request.getModelParamsId());
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(info)).throwMessage("无效的数据");
|
||||
if (Objects.equals(info.getState(), PublishState.Published.getState())) {
|
||||
Integer oldId=request.getModelParamsId();
|
||||
Integer oldId = request.getModelParamsId();
|
||||
request.setModelParamsId(productModelParamsService.add(request.getModelId()));
|
||||
productModelParamsService.copyItems(oldId,request.getModelParamsId());
|
||||
productModelParamsService.copyItems(oldId, request.getModelParamsId());
|
||||
}
|
||||
ParamsItemVO vo=new ParamsItemVO();
|
||||
vo.setModelParamsId(request.getModelParamsId());
|
||||
vo.setModelParamsItemId(productModelParamsItemService.addItem(request));
|
||||
return ApiResult.success(vo);
|
||||
String batchNumber = IdUtil.getSnowflakeNextIdStr();
|
||||
List<Language> languages = languageService.getLanguages();
|
||||
request.setLanguageCode(Constant.DEFAULT_LANGUAGE_CODE);
|
||||
request.setBatchNumber(batchNumber);
|
||||
List<ProductModelParamsItemAddRequest1> datas = new ArrayList<>();
|
||||
datas.add(request);
|
||||
languages.forEach(language -> {
|
||||
if (!StrUtil.equals(language.getCode(), Constant.DEFAULT_LANGUAGE_CODE)) {
|
||||
ProductModelParamsItemAddRequest1 copy = ObjectUtil.cloneByStream(request);
|
||||
copy.setLanguageCode(language.getCode());
|
||||
copy.setIndexName(translate.translateWord(request.getIndexName(), language.getTranslateCode()));
|
||||
copy.setName(translate.translateWord(request.getName(), language.getTranslateCode()));
|
||||
copy.setValue(translate.translateWord(request.getValue(), language.getTranslateCode()));
|
||||
datas.add(copy);
|
||||
}
|
||||
});
|
||||
productModelParamsItemService.addItem(datas);
|
||||
return ApiResult.success(request.getModelParamsId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -359,8 +382,10 @@ public class ProductModelController extends ControllerBase{
|
|||
Integer oldId = request.getModelParamsId();
|
||||
request.setModelParamsId(productModelParamsService.add(request.getModelId()));
|
||||
productModelParamsService.copyItems(oldId, request.getModelParamsId());
|
||||
ProductModelParamsItem oldItem=productModelParamsItemService.getById(request.getModelParamsItemId());
|
||||
ProductModelParamsItem oldItem = productModelParamsItemService.getById(request.getModelParamsItemId());
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(oldItem)).throwMessage("无效的数据");
|
||||
VUtils.trueThrowBusinessError(!StrUtil.equals(oldItem.getLanguageCode(), Constant.DEFAULT_LANGUAGE_CODE))
|
||||
.throwMessage("只能删除中文环境参数");
|
||||
ProductModelParamsItem item = productModelParamsItemService.lambdaQuery()
|
||||
.eq(ProductModelParamsItem::getModelParamsId, request.getModelParamsId())
|
||||
.eq(ProductModelParamsItem::getLanguageCode, oldItem.getLanguageCode())
|
||||
|
|
@ -370,7 +395,7 @@ public class ProductModelController extends ControllerBase{
|
|||
VUtils.trueThrowBusinessError(Objects.isNull(item)).throwMessage("删除失败");
|
||||
request.setModelParamsItemId(item.getId());
|
||||
}
|
||||
productModelParamsItemService.delete(request);
|
||||
productModelParamsItemService.deleteParam(request);
|
||||
return ApiResult.success(request.getModelParamsId());
|
||||
}
|
||||
|
||||
|
|
@ -617,7 +642,7 @@ public class ProductModelController extends ControllerBase{
|
|||
* @param request 请求参数
|
||||
*/
|
||||
@PostMapping("/addFile")
|
||||
public ApiResult<Void> addFile(@Valid @RequestBody @NotEmpty ProductModelFileAddRequest request){
|
||||
public ApiResult<Void> addFile(@Valid @RequestBody ProductModelFileAddRequest request){
|
||||
productModelFileService.add(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import org.apache.poi.ss.util.RegionUtil;
|
|||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -104,7 +104,7 @@ public class TicketController extends ControllerBase {
|
|||
private TicketEventPublisher ticketEventPublisher;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
private ITicketFavoritesService ticketFavoritesService;
|
||||
|
|
@ -694,7 +694,7 @@ public class TicketController extends ControllerBase {
|
|||
List<ChatMessageVO> messageVOS = ticketChatService.getMessages(ticketId, userId);
|
||||
vo.setMessages(messageVOS);
|
||||
String key = "chatMessage:readed:" + ticketId + ":admin:" + userId;
|
||||
Set<String> readeds = redisTemplate.opsForSet().members(key);
|
||||
Set<String> readeds = stringRedisTemplate.opsForSet().members(key);
|
||||
Set<String> notReadeds = new LinkedHashSet<>();
|
||||
if (CollectionUtil.isEmpty(readeds)) {
|
||||
notReadeds = messageVOS.stream()
|
||||
|
|
@ -711,7 +711,7 @@ public class TicketController extends ControllerBase {
|
|||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(notReadeds)) {
|
||||
redisTemplate.opsForSet().add(key, notReadeds.stream().toArray(String[]::new));
|
||||
stringRedisTemplate.opsForSet().add(key, notReadeds.stream().toArray(String[]::new));
|
||||
vo.setNotReadCount(notReadeds.size());
|
||||
vo.setFirstMessageId(notReadeds.iterator().next());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,4 +3,8 @@ package com.nflg.mobilebroken.admin.service;
|
|||
public interface ITranslate {
|
||||
|
||||
String translateWord(String text,String sourceLanguage,String targetLanguage,String formatType);
|
||||
|
||||
String translateWord(String text,String targetLanguage,String formatType);
|
||||
|
||||
String translateWord(String text,String targetLanguage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.nflg.mobilebroken.common.pojo.request.WXQrcodeRequest;
|
|||
import com.nflg.mobilebroken.common.pojo.request.WXQrcodeScene;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.WXQrcodeVO;
|
||||
import com.nflg.mobilebroken.common.util.QRCodeUtil;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
|
@ -20,14 +20,14 @@ import java.util.Objects;
|
|||
public class WXQRCodeService {
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
public byte[] generateQRCode(Integer userId) throws Exception {
|
||||
return QRCodeUtil.generateQRCode(getFollowUrl(userId), 200, 200);
|
||||
}
|
||||
|
||||
public String getFollowUrl(Integer userId) {
|
||||
Object obj = redisTemplate.opsForHash().get("wx:url:follow:admin", userId);
|
||||
Object obj = stringRedisTemplate.opsForHash().get("wx:url:follow:admin", userId);
|
||||
if (Objects.isNull(obj)) {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> response1 = restTemplate.getForEntity(Constant.WX_TOKEN_URL, String.class);
|
||||
|
|
@ -39,7 +39,7 @@ public class WXQRCodeService {
|
|||
WXQrcodeRequest req = new WXQrcodeRequest().setAction_info(new WXQrcodeActionInfo().setScene(new WXQrcodeScene().setScene_str(scene_str)));
|
||||
WXQrcodeVO qvo = restTemplate.postForObject(url, req, WXQrcodeVO.class);
|
||||
obj = qvo.getUrl();
|
||||
redisTemplate.opsForHash().put("wx:url:follow:admin", userId, obj);
|
||||
stringRedisTemplate.opsForHash().put("wx:url:follow:admin", userId, obj);
|
||||
}
|
||||
return obj.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.nflg.mobilebroken.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.aliyun.alimt20181012.models.TranslateGeneralResponse;
|
||||
import com.aliyun.credentials.Client;
|
||||
|
|
@ -12,9 +14,12 @@ import com.nflg.mobilebroken.common.util.VUtils;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "translate.platform", havingValue = "aliyun")
|
||||
|
|
@ -32,6 +37,9 @@ public class AliYunTranslate implements ITranslate {
|
|||
|
||||
private com.aliyun.alimt20181012.Client client;
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@PostConstruct
|
||||
public void init() throws Exception {
|
||||
Config credentialConfig = new Config();
|
||||
|
|
@ -54,15 +62,25 @@ public class AliYunTranslate implements ITranslate {
|
|||
.setFormatType(formatType)
|
||||
.setSourceText(text);
|
||||
log.info("翻译,请求参数:{}", JSONUtil.toJsonStr(request));
|
||||
System.out.println("Key serializer: " + stringRedisTemplate.getKeySerializer());
|
||||
System.out.println("Value serializer: " + stringRedisTemplate.getValueSerializer());
|
||||
String key = "translate:" + SecureUtil.md5(text) + ":" + targetLanguage;
|
||||
String result = stringRedisTemplate.opsForValue().get(key);
|
||||
if (StrUtil.isNotBlank(result)) {
|
||||
log.info("翻译,响应,从缓存读取,翻译结果:{}", result);
|
||||
return result;
|
||||
}
|
||||
try {
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
TranslateGeneralResponse response = client.translateGeneralWithOptions(request, new com.aliyun.teautil.models.RuntimeOptions());
|
||||
VUtils.trueThrowBusinessError(response.statusCode != 200).throwMessage("翻译失败:"+response.getBody().getMessage());
|
||||
VUtils.trueThrowBusinessError(response.statusCode != 200).throwMessage("翻译失败:" + response.getBody().getMessage());
|
||||
log.info("翻译,响应,识别到的原始语言:{},字数:{},翻译结果:{}"
|
||||
, response.getBody().getData().getDetectedLanguage()
|
||||
,response.getBody().getData().getWordCount()
|
||||
,JSONUtil.toJsonStr(response.getBody().getData().getTranslated()));
|
||||
return response.body.getData().getTranslated();
|
||||
, response.getBody().getData().getWordCount()
|
||||
, JSONUtil.toJsonStr(response.getBody().getData().getTranslated()));
|
||||
result = response.body.getData().getTranslated();
|
||||
stringRedisTemplate.opsForValue().set(key, result, 30, TimeUnit.DAYS);
|
||||
return result;
|
||||
} catch (Exception ex) {
|
||||
TeaException error = new TeaException(ex.getMessage(), ex);
|
||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
|
|
@ -73,4 +91,14 @@ public class AliYunTranslate implements ITranslate {
|
|||
throw new NflgException(STATE.BusinessError, "翻译失败:" + error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translateWord(String text, String targetLanguage, String formatType) {
|
||||
return translateWord(text, "auto", targetLanguage, formatType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translateWord(String text, String targetLanguage) {
|
||||
return translateWord(text, targetLanguage, "text");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ import com.nflg.mobilebroken.common.constant.Constant;
|
|||
import com.nflg.mobilebroken.common.pojo.dto.UserDTO;
|
||||
import com.nflg.mobilebroken.starter.service.INotifyPushService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -21,11 +19,11 @@ public class WXINotifyPushService implements INotifyPushService {
|
|||
@Value("${wx.mp.templateMessage.config.templateId}")
|
||||
private String templateId;
|
||||
|
||||
@Resource
|
||||
private WxMpService wxMpService;
|
||||
|
||||
@Resource
|
||||
private WxMpConfigStorage wxMpConfigStorage;
|
||||
// @Resource
|
||||
// private WxMpService wxMpService;
|
||||
//
|
||||
// @Resource
|
||||
// private WxMpConfigStorage wxMpConfigStorage;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.nflg.mobilebroken.admin.task;
|
||||
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModel;
|
||||
import com.nflg.mobilebroken.repository.service.IProductModelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ProductScheduledTasks {
|
||||
|
||||
@Resource
|
||||
private IProductModelService productModelService;
|
||||
|
||||
/**
|
||||
* 机型是否新版本设置
|
||||
* 每天午夜12点执行一次
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void resetRecommend() {
|
||||
log.info("【产品中心-机型-新品】开始执行");
|
||||
productModelService.lambdaUpdate()
|
||||
.set(ProductModel::getRecommend, false)
|
||||
.eq(ProductModel::getRecommend, true)
|
||||
.gt(ProductModel::getRecommendTime, LocalDateTime.now().minusYears(2))
|
||||
.update();
|
||||
log.info("【产品中心-机型-新品】执行完毕");
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import com.nflg.mobilebroken.repository.service.IAnonymousTicketService;
|
|||
import com.wf.captcha.SpecCaptcha;
|
||||
import com.wf.captcha.base.Captcha;
|
||||
import org.springframework.data.redis.core.BoundValueOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -29,7 +29,7 @@ public class AnonymousTicketController extends ControllerBase{
|
|||
private IAnonymousTicketService anonymousTicketService;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
/**
|
||||
* 获取验证码
|
||||
|
|
@ -47,7 +47,7 @@ public class AnonymousTicketController extends ControllerBase{
|
|||
// specCaptcha.setFont(new Font("Verdana", Font.PLAIN, 32)); // 有默认字体,可以不用设置
|
||||
// 设置类型,纯数字、纯字母、字母数字混合
|
||||
specCaptcha.setCharType(Captcha.TYPE_ONLY_NUMBER);
|
||||
BoundValueOperations<String,String> bo=redisTemplate.boundValueOps("anonymous:ticket:captcha:"+email);
|
||||
BoundValueOperations<String,String> bo=stringRedisTemplate.boundValueOps("anonymous:ticket:captcha:"+email);
|
||||
bo.set(specCaptcha.text(), Duration.ofMinutes(10));
|
||||
// 输出图片流
|
||||
specCaptcha.out(response.getOutputStream());
|
||||
|
|
@ -59,10 +59,10 @@ public class AnonymousTicketController extends ControllerBase{
|
|||
@PostMapping("/addAnonymousTicket")
|
||||
public ApiResult<Void> addAnonymousTicket(@Valid @RequestBody AnonymousTicketAddRequest request){
|
||||
String captcha=request.getCode();
|
||||
BoundValueOperations<String,String> bo=redisTemplate.boundValueOps("anonymous:ticket:captcha:"+request.getEmail());
|
||||
BoundValueOperations<String,String> bo=stringRedisTemplate.boundValueOps("anonymous:ticket:captcha:"+request.getEmail());
|
||||
VUtils.trueThrowBusinessError(!StrUtil.equals(captcha,bo.get())).throwMessage("验证码不正确或已失效");
|
||||
anonymousTicketService.add(request);
|
||||
redisTemplate.delete("anonymous:ticket:captcha:"+request.getEmail());
|
||||
stringRedisTemplate.delete("anonymous:ticket:captcha:"+request.getEmail());
|
||||
return ApiResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import com.nflg.mobilebroken.repository.entity.*;
|
|||
import com.nflg.mobilebroken.repository.service.*;
|
||||
import com.nflg.mobilebroken.starter.service.UniPushService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -82,7 +82,7 @@ public class TicketController extends ControllerBase {
|
|||
private TicketEventPublisher ticketEventPublisher;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
private ITBasePartService partService;
|
||||
|
|
@ -303,7 +303,7 @@ public class TicketController extends ControllerBase {
|
|||
List<ChatMessageVO> messageVOS = ticketChatService.getMessages(ticketId, userId);
|
||||
vo.setMessages(messageVOS);
|
||||
String key = "chatMessage:readed:" + ticketId + ":app:" + userId;
|
||||
Set<String> readeds = redisTemplate.opsForSet().members(key);
|
||||
Set<String> readeds = stringRedisTemplate.opsForSet().members(key);
|
||||
Set<String> notReadeds = new LinkedHashSet<>();
|
||||
if (CollectionUtil.isEmpty(readeds)) {
|
||||
notReadeds = messageVOS.stream()
|
||||
|
|
@ -320,7 +320,7 @@ public class TicketController extends ControllerBase {
|
|||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(notReadeds)) {
|
||||
redisTemplate.opsForSet().add(key, notReadeds.toArray(String[]::new));
|
||||
stringRedisTemplate.opsForSet().add(key, notReadeds.toArray(String[]::new));
|
||||
vo.setNotReadCount(notReadeds.size());
|
||||
vo.setFirstMessageId(notReadeds.iterator().next());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import com.nflg.mobilebroken.repository.service.*;
|
|||
import com.nflg.mobilebroken.starter.service.EmailService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -70,7 +70,7 @@ public class UserController extends ControllerBase {
|
|||
private IAppUserApplyforService appUserApplyforService;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
private ITBaseCustomerService customerService;
|
||||
|
|
@ -132,7 +132,7 @@ public class UserController extends ControllerBase {
|
|||
String email = AppUserUtil.getEmail();
|
||||
String kaptcha = RandomUtil.randomString(6);
|
||||
// 将生成的验证码存入redis
|
||||
redisTemplate.opsForValue().set(StrUtil.format(Constant.REDIS_KEY_USER_UPDATE_KAPTCHA_APP, email), kaptcha, Duration.ofHours(72));
|
||||
stringRedisTemplate.opsForValue().set(StrUtil.format(Constant.REDIS_KEY_USER_UPDATE_KAPTCHA_APP, email), kaptcha, Duration.ofHours(72));
|
||||
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_CHANGE_PASSWORD, Constant.DEFAULT_LANGUAGE_CODE);
|
||||
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_ACCOUNT_CHANGE_PASSWORD, Constant.DEFAULT_LANGUAGE_CODE)
|
||||
.replace("${loginName}",email)
|
||||
|
|
@ -152,11 +152,11 @@ public class UserController extends ControllerBase {
|
|||
@PostMapping("updatePassword")
|
||||
public ApiResult<Void> updatePassword(@Valid @RequestBody UpdatePasswordRequest request){
|
||||
String redisKey = StrUtil.format(Constant.REDIS_KEY_USER_UPDATE_KAPTCHA_APP, AppUserUtil.getEmail());
|
||||
String captcha = redisTemplate.opsForValue().get(redisKey);
|
||||
String captcha = stringRedisTemplate.opsForValue().get(redisKey);
|
||||
VUtils.trueThrowBusinessError(StrUtil.isBlank(captcha)).throwMessage("验证码已失效,请重新获取");
|
||||
VUtils.trueThrowBusinessError(!StrUtil.equals(captcha, request.getCaptcha())).throwMessage("验证码不正确");
|
||||
appUserService.updatePassword(AppUserUtil.getUserId(), request.getNewPassword());
|
||||
redisTemplate.delete(redisKey);
|
||||
stringRedisTemplate.delete(redisKey);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.nflg.mobilebroken.common.pojo.request.WXQrcodeRequest;
|
|||
import com.nflg.mobilebroken.common.pojo.request.WXQrcodeScene;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.WXQrcodeVO;
|
||||
import com.nflg.mobilebroken.common.util.QRCodeUtil;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
|
@ -20,14 +20,14 @@ import java.util.Objects;
|
|||
public class WXQRCodeService {
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
public byte[] generateQRCode(Integer userId) throws Exception {
|
||||
return QRCodeUtil.generateQRCode(getFollowUrl(userId), 200, 200);
|
||||
}
|
||||
|
||||
public String getFollowUrl(Integer userId) {
|
||||
Object obj = redisTemplate.opsForHash().get("wx:url:follow:app", userId);
|
||||
Object obj = stringRedisTemplate.opsForHash().get("wx:url:follow:app", userId);
|
||||
if (Objects.isNull(obj)) {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> response1 = restTemplate.getForEntity(Constant.WX_TOKEN_URL, String.class);
|
||||
|
|
@ -39,7 +39,7 @@ public class WXQRCodeService {
|
|||
WXQrcodeRequest req = new WXQrcodeRequest().setAction_info(new WXQrcodeActionInfo().setScene(new WXQrcodeScene().setScene_str(scene_str)));
|
||||
WXQrcodeVO qvo = restTemplate.postForObject(url, req, WXQrcodeVO.class);
|
||||
obj = qvo.getUrl();
|
||||
redisTemplate.opsForHash().put("wx:url:follow:app", userId, obj);
|
||||
stringRedisTemplate.opsForHash().put("wx:url:follow:app", userId, obj);
|
||||
}
|
||||
return obj.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ public class ParamsIndexNameDeleteRequest {
|
|||
private String languageCode;
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
* 批次号
|
||||
*/
|
||||
@NotBlank
|
||||
private String indexName;
|
||||
}
|
||||
private String batchNumber;
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import lombok.Data;
|
|||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -40,6 +41,7 @@ public class ProductModelFileAddRequest {
|
|||
/**
|
||||
* 多语言数据
|
||||
*/
|
||||
@NotEmpty
|
||||
private List<ProductModelFileItemAddRequest> items;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package com.nflg.mobilebroken.common.pojo.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ProductModelParamsItemAddRequest {
|
||||
public class ProductModelParamsItemAddRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 语言编码
|
||||
|
|
@ -19,6 +21,12 @@ public class ProductModelParamsItemAddRequest {
|
|||
@NotBlank
|
||||
private String indexName;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
@JsonIgnore
|
||||
private String batchNumber;
|
||||
|
||||
/**
|
||||
* 参数名称
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ package com.nflg.mobilebroken.common.pojo.request;
|
|||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ProductModelParamsItemAddRequest1 extends ProductModelParamsItemAddRequest {
|
||||
public class ProductModelParamsItemAddRequest1 extends ProductModelParamsItemAddRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 机型id
|
||||
|
|
|
|||
|
|
@ -14,5 +14,10 @@ public class ProductModelMainParamsItemChildrenVO {
|
|||
*/
|
||||
private String indexName;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String batchNumber;
|
||||
|
||||
private List<ProductParamsItemVO> items;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.nflg.mobilebroken.common.pojo.vo;
|
|||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
|
|
@ -14,5 +15,5 @@ public class ProductModelParamsItemVO {
|
|||
*/
|
||||
private String languageCode;
|
||||
|
||||
private List<ProductModelMainParamsItemChildrenVO> items;
|
||||
private List<ProductModelMainParamsItemChildrenVO> items=new ArrayList<>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@ public class ProductParamsItemVO {
|
|||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String batchNumber;
|
||||
|
||||
/**
|
||||
* 参数名称
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ public class ProductModel implements Serializable {
|
|||
*/
|
||||
private Boolean recommend;
|
||||
|
||||
/**
|
||||
* 设置为新品的时间
|
||||
*/
|
||||
private LocalDateTime recommendTime;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -44,6 +44,11 @@ public class ProductModelParamsItem implements Serializable {
|
|||
*/
|
||||
private String indexName;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String batchNumber;
|
||||
|
||||
/**
|
||||
* 参数名称
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ import java.util.List;
|
|||
*/
|
||||
public interface IProductModelParamsItemService extends IService<ProductModelParamsItem> {
|
||||
|
||||
void add(Integer paramsId, @NotEmpty List<ProductModelParamsItemAddRequest> items);
|
||||
// void add(Integer paramsId, @NotEmpty List<ProductModelParamsItemAddRequest> items);
|
||||
|
||||
void update(Integer paramsId, @NotEmpty List<ProductModelParamsItemAddRequest> items);
|
||||
// void update(Integer paramsId, @NotEmpty List<ProductModelParamsItemAddRequest> items);
|
||||
|
||||
void deleteByParamsIds(@NotEmpty List<Integer> ids);
|
||||
|
||||
|
|
@ -34,11 +34,11 @@ public interface IProductModelParamsItemService extends IService<ProductModelPar
|
|||
|
||||
void addIndexName(@Valid ProductModelParamsNameAddRequest request);
|
||||
|
||||
Integer addItem(@Valid ProductModelParamsItemAddRequest1 request);
|
||||
void addItem(@Valid List<ProductModelParamsItemAddRequest1> request);
|
||||
|
||||
void updateIndexName(@Valid ProductModelParamsNameUpdateRequest request);
|
||||
|
||||
void delete(@Valid ProductModelParamsItemDeleteRequest request);
|
||||
void deleteParam(@Valid ProductModelParamsItemDeleteRequest request);
|
||||
|
||||
void importModelParamsItem(@Valid @NotNull Integer modelParamsId, List<ProductModelParamsExcelDTO> datas);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nflg.mobilebroken.common.pojo.request.BatchDeleteRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.ProductModelIntroSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.ProductModelParamsAddRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.ProductPublishRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductModelMainParamsItemChildrenVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductModelParamVO;
|
||||
|
|
@ -25,11 +24,11 @@ import java.util.List;
|
|||
*/
|
||||
public interface IProductModelParamsService extends IService<ProductModelParams> {
|
||||
|
||||
void add(@Valid ProductModelParamsAddRequest request);
|
||||
// void add(@Valid ProductModelParamsAddRequest request);
|
||||
|
||||
Integer add(Integer modelId);
|
||||
|
||||
void update(@Valid ProductModelParamsAddRequest request);
|
||||
// void update(@Valid ProductModelParamsAddRequest request);
|
||||
|
||||
void delete(@Valid BatchDeleteRequest request);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import com.nflg.mobilebroken.common.util.VUtils;
|
|||
import com.nflg.mobilebroken.repository.entity.*;
|
||||
import com.nflg.mobilebroken.repository.mapper.AdminUserMapper;
|
||||
import com.nflg.mobilebroken.repository.service.*;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -59,7 +59,7 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
|||
private IAdminUserRoleMapService adminUserRoleMapService;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
private ITBaseDeviceTypeService deviceTypeService;
|
||||
|
|
@ -239,10 +239,10 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
|||
updateById(adminUser);
|
||||
}else if (StrUtil.equals("1", type)){
|
||||
//修改邮箱
|
||||
code=redisTemplate.opsForValue().get(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + email);
|
||||
code=stringRedisTemplate.opsForValue().get(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + email);
|
||||
VUtils.trueThrowBusinessError(!StrUtil.equals(code, request.getRandomCode()))
|
||||
.throwMessage("无效的激活码");
|
||||
String email1=redisTemplate.opsForValue().get(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + code);
|
||||
String email1=stringRedisTemplate.opsForValue().get(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + code);
|
||||
VUtils.trueThrowBusinessError(StrUtil.isBlank(email1))
|
||||
.throwMessage("无效的激活码");
|
||||
AdminUser user = lambdaQuery().eq(AdminUser::getIsDel, 0).eq(AdminUser::getLoginName, email).one();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import com.nflg.mobilebroken.common.util.VUtils;
|
|||
import com.nflg.mobilebroken.repository.entity.*;
|
||||
import com.nflg.mobilebroken.repository.mapper.AppUserMapper;
|
||||
import com.nflg.mobilebroken.repository.service.*;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -67,7 +67,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
private IAdminRoleService roleService;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Override
|
||||
public AppUser getUser(String userName, String password) {
|
||||
|
|
@ -691,10 +691,10 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
updateById(appUser);
|
||||
}else if (StrUtil.equals("1", type)){
|
||||
//修改邮箱
|
||||
code=redisTemplate.opsForValue().get(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + email);
|
||||
code=stringRedisTemplate.opsForValue().get(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + email);
|
||||
VUtils.trueThrowBusinessError(!StrUtil.equals(code, request.getRandomCode()))
|
||||
.throwMessage("无效的激活码");
|
||||
String email1=redisTemplate.opsForValue().get(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + code);
|
||||
String email1=stringRedisTemplate.opsForValue().get(Constant.REDIS_KEY_CHANGE_EMAIL_CODE + code);
|
||||
VUtils.trueThrowBusinessError(StrUtil.isBlank(email1))
|
||||
.throwMessage("无效的激活码");
|
||||
AppUser user = lambdaQuery().eq(AppUser::getIsDel, 0).eq(AppUser::getLoginName, email).one();
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@ import com.nflg.mobilebroken.common.pojo.vo.ProductModelParamsItemVO;
|
|||
import com.nflg.mobilebroken.common.pojo.vo.ProductParamsItemVO;
|
||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.repository.entity.DictionaryItemTranslate;
|
||||
import com.nflg.mobilebroken.repository.entity.Language;
|
||||
import com.nflg.mobilebroken.repository.entity.ProductModelParamsItem;
|
||||
import com.nflg.mobilebroken.repository.mapper.ProductModelParamsItemMapper;
|
||||
import com.nflg.mobilebroken.repository.service.IDictionaryItemTranslateService;
|
||||
import com.nflg.mobilebroken.repository.service.ILanguageService;
|
||||
import com.nflg.mobilebroken.repository.service.IProductModelParamsItemService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -43,51 +45,54 @@ public class ProductModelParamsItemServiceImpl extends ServiceImpl<ProductModelP
|
|||
@Resource
|
||||
private IDictionaryItemTranslateService dictionaryItemTranslateService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void add(Integer paramsId, List<ProductModelParamsItemAddRequest> items) {
|
||||
if (CollectionUtil.isNotEmpty(items)){
|
||||
saveBatch(
|
||||
items.stream()
|
||||
.map(it -> new ProductModelParamsItem()
|
||||
.setModelParamsId(paramsId)
|
||||
.setLanguageCode(it.getLanguageCode())
|
||||
.setName(it.getName())
|
||||
.setIndexName(it.getIndexName())
|
||||
.setValue(it.getValue())
|
||||
.setMain(it.getMain())
|
||||
.setCompare(it.getCompare())
|
||||
.setCreateBy(AdminUserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
}
|
||||
@Resource
|
||||
private ILanguageService languageService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void update(Integer paramsId, List<ProductModelParamsItemAddRequest> items) {
|
||||
remove(new LambdaQueryWrapper<ProductModelParamsItem>()
|
||||
.eq(ProductModelParamsItem::getModelParamsId, paramsId));
|
||||
if (CollectionUtil.isNotEmpty(items)){
|
||||
saveBatch(
|
||||
items.stream()
|
||||
.map(it -> new ProductModelParamsItem()
|
||||
.setModelParamsId(paramsId)
|
||||
.setLanguageCode(it.getLanguageCode())
|
||||
.setName(it.getName())
|
||||
.setIndexName(it.getIndexName())
|
||||
.setValue(it.getValue())
|
||||
.setMain(it.getMain())
|
||||
.setCompare(it.getCompare())
|
||||
.setUpdateBy(AdminUserUtil.getUserName())
|
||||
.setUpdateTime(LocalDateTime.now())
|
||||
)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
}
|
||||
// @Transactional
|
||||
// @Override
|
||||
// public void add(Integer paramsId, List<ProductModelParamsItemAddRequest> items) {
|
||||
// if (CollectionUtil.isNotEmpty(items)){
|
||||
// saveBatch(
|
||||
// items.stream()
|
||||
// .map(it -> new ProductModelParamsItem()
|
||||
// .setModelParamsId(paramsId)
|
||||
// .setLanguageCode(it.getLanguageCode())
|
||||
// .setName(it.getName())
|
||||
// .setIndexName(it.getIndexName())
|
||||
// .setValue(it.getValue())
|
||||
// .setMain(it.getMain())
|
||||
// .setCompare(it.getCompare())
|
||||
// .setCreateBy(AdminUserUtil.getUserName())
|
||||
// .setCreateTime(LocalDateTime.now())
|
||||
// )
|
||||
// .collect(Collectors.toList())
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// @Transactional
|
||||
// @Override
|
||||
// public void update(Integer paramsId, List<ProductModelParamsItemAddRequest> items) {
|
||||
// remove(new LambdaQueryWrapper<ProductModelParamsItem>()
|
||||
// .eq(ProductModelParamsItem::getModelParamsId, paramsId));
|
||||
// if (CollectionUtil.isNotEmpty(items)){
|
||||
// saveBatch(
|
||||
// items.stream()
|
||||
// .map(it -> new ProductModelParamsItem()
|
||||
// .setModelParamsId(paramsId)
|
||||
// .setLanguageCode(it.getLanguageCode())
|
||||
// .setName(it.getName())
|
||||
// .setIndexName(it.getIndexName())
|
||||
// .setValue(it.getValue())
|
||||
// .setMain(it.getMain())
|
||||
// .setCompare(it.getCompare())
|
||||
// .setUpdateBy(AdminUserUtil.getUserName())
|
||||
// .setUpdateTime(LocalDateTime.now())
|
||||
// )
|
||||
// .collect(Collectors.toList())
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void deleteByParamsIds(List<Integer> ids) {
|
||||
|
|
@ -141,16 +146,17 @@ public class ProductModelParamsItemServiceImpl extends ServiceImpl<ProductModelP
|
|||
maps.forEach((languageCode, data) -> {
|
||||
ProductModelParamsItemVO vo = new ProductModelParamsItemVO()
|
||||
.setLanguageCode(languageCode);
|
||||
vos.add(vo);
|
||||
Map<String, List<ProductModelParamsItem>> itemMap = data.stream().collect(Collectors.groupingBy(ProductModelParamsItem::getIndexName));
|
||||
itemMap.forEach((indexName, itemData) -> {
|
||||
vo.setItems(data.stream().map(it -> new ProductModelMainParamsItemChildrenVO()
|
||||
.setIndexName(indexName)
|
||||
.setItems(itemData.stream()
|
||||
.filter(pi->StrUtil.isNotBlank(pi.getName()))
|
||||
.map(pi -> Convert.convert(ProductParamsItemVO.class, pi))
|
||||
.collect(Collectors.toList())))
|
||||
ProductModelMainParamsItemChildrenVO ivo=new ProductModelMainParamsItemChildrenVO()
|
||||
.setIndexName(indexName)
|
||||
.setBatchNumber(CollectionUtil.isNotEmpty(itemData) ? itemData.get(0).getBatchNumber() : "")
|
||||
.setItems(itemData.stream()
|
||||
.filter(pi -> StrUtil.isNotBlank(pi.getName()))
|
||||
.map(pi -> Convert.convert(ProductParamsItemVO.class, pi))
|
||||
.collect(Collectors.toList()));
|
||||
vos.add(vo);
|
||||
vo.getItems().add(ivo);
|
||||
});
|
||||
});
|
||||
return vos;
|
||||
|
|
@ -172,18 +178,20 @@ public class ProductModelParamsItemServiceImpl extends ServiceImpl<ProductModelP
|
|||
// .setCreateTime(LocalDateTime.now()));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Integer addItem(ProductModelParamsItemAddRequest1 request) {
|
||||
ProductModelParamsItem info=new ProductModelParamsItem()
|
||||
.setModelParamsId(request.getModelParamsId())
|
||||
.setLanguageCode(request.getLanguageCode())
|
||||
.setIndexName(request.getIndexName())
|
||||
.setName(request.getName())
|
||||
.setValue(request.getValue())
|
||||
.setCreateBy(AdminUserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
save(info);
|
||||
return info.getId();
|
||||
public void addItem(List<ProductModelParamsItemAddRequest1> request) {
|
||||
saveBatch(request.stream().map(it -> new ProductModelParamsItem()
|
||||
.setModelParamsId(it.getModelParamsId())
|
||||
.setLanguageCode(it.getLanguageCode())
|
||||
.setBatchNumber(it.getBatchNumber())
|
||||
.setIndexName(it.getIndexName())
|
||||
.setName(it.getName())
|
||||
.setValue(it.getValue())
|
||||
.setCreateBy(AdminUserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now()))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -198,9 +206,14 @@ public class ProductModelParamsItemServiceImpl extends ServiceImpl<ProductModelP
|
|||
.update();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void delete(ProductModelParamsItemDeleteRequest request) {
|
||||
removeById(request.getModelParamsItemId());
|
||||
public void deleteParam(ProductModelParamsItemDeleteRequest request) {
|
||||
ProductModelParamsItem info=getById(request.getModelParamsItemId());
|
||||
remove(new LambdaQueryWrapper<ProductModelParamsItem>()
|
||||
.eq(ProductModelParamsItem::getBatchNumber,info.getBatchNumber())
|
||||
.eq(ProductModelParamsItem::getModelParamsId,request.getModelParamsId())
|
||||
);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
@ -255,11 +268,23 @@ public class ProductModelParamsItemServiceImpl extends ServiceImpl<ProductModelP
|
|||
.update();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void deleteIndexName(ParamsIndexNameDeleteRequest request) {
|
||||
remove(new LambdaQueryWrapper<ProductModelParamsItem>()
|
||||
.eq(ProductModelParamsItem::getModelParamsId, request.getModelParamsId())
|
||||
.eq(ProductModelParamsItem::getLanguageCode, request.getLanguageCode())
|
||||
.eq(ProductModelParamsItem::getIndexName, request.getIndexName()));
|
||||
List<Language> languages = languageService.getAllLanguages();
|
||||
languages.forEach(lang -> {
|
||||
ProductModelParamsItem item = lambdaQuery()
|
||||
.eq(ProductModelParamsItem::getBatchNumber, request.getBatchNumber())
|
||||
.eq(ProductModelParamsItem::getModelParamsId, request.getModelParamsId())
|
||||
.eq(ProductModelParamsItem::getLanguageCode, lang.getCode())
|
||||
.one();
|
||||
if (Objects.nonNull(item)) {
|
||||
remove(new LambdaQueryWrapper<ProductModelParamsItem>()
|
||||
.eq(ProductModelParamsItem::getModelParamsId, request.getModelParamsId())
|
||||
.eq(ProductModelParamsItem::getLanguageCode, lang.getCode())
|
||||
.eq(ProductModelParamsItem::getIndexName, item.getIndexName())
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,6 @@ import com.nflg.mobilebroken.common.constant.Constant;
|
|||
import com.nflg.mobilebroken.common.constant.PublishState;
|
||||
import com.nflg.mobilebroken.common.pojo.request.BatchDeleteRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.ProductModelIntroSearchRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.ProductModelParamsAddRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.request.ProductPublishRequest;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductModelMainParamsItemChildrenVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductModelParamVO;
|
||||
|
|
@ -43,14 +42,14 @@ public class ProductModelParamsServiceImpl extends ServiceImpl<ProductModelParam
|
|||
@Resource
|
||||
private IProductModelParamsItemService productModelParamsItemService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void add(ProductModelParamsAddRequest request) {
|
||||
ProductModelParams info=new ProductModelParams()
|
||||
.setModelId(request.getModelId());
|
||||
save(info);
|
||||
productModelParamsItemService.add(info.getId(),request.getItems());
|
||||
}
|
||||
// @Transactional
|
||||
// @Override
|
||||
// public void add(ProductModelParamsAddRequest request) {
|
||||
// ProductModelParams info=new ProductModelParams()
|
||||
// .setModelId(request.getModelId());
|
||||
// save(info);
|
||||
// productModelParamsItemService.add(info.getId(),request.getItems());
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Integer add(Integer modelId) {
|
||||
|
|
@ -62,19 +61,19 @@ public class ProductModelParamsServiceImpl extends ServiceImpl<ProductModelParam
|
|||
return info.getId();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void update(ProductModelParamsAddRequest request) {
|
||||
ProductModelParams info=getById(request.getId());
|
||||
if (Objects.equals(info.getState(), PublishState.Published.getState())){
|
||||
add(request);
|
||||
}else {
|
||||
info.setUpdateBy(AdminUserUtil.getUserName());
|
||||
info.setUpdateTime(LocalDateTime.now());
|
||||
updateById(info);
|
||||
productModelParamsItemService.update(request.getId(),request.getItems());
|
||||
}
|
||||
}
|
||||
// @Transactional
|
||||
// @Override
|
||||
// public void update(ProductModelParamsAddRequest request) {
|
||||
// ProductModelParams info=getById(request.getId());
|
||||
// if (Objects.equals(info.getState(), PublishState.Published.getState())){
|
||||
// add(request);
|
||||
// }else {
|
||||
// info.setUpdateBy(AdminUserUtil.getUserName());
|
||||
// info.setUpdateTime(LocalDateTime.now());
|
||||
// updateById(info);
|
||||
// productModelParamsItemService.update(request.getId(),request.getItems());
|
||||
// }
|
||||
// }
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@ public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, Pro
|
|||
.setImage(request.getImage())
|
||||
.setCreateBy(AdminUserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
if (request.getRecommend()){
|
||||
productModel.setRecommendTime(LocalDateTime.now());
|
||||
}
|
||||
save(productModel);
|
||||
return productModel.getId();
|
||||
}
|
||||
|
|
@ -74,13 +77,21 @@ public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, Pro
|
|||
public Integer update(ProductModelUpdateRequest request) {
|
||||
ProductModel info = getById(request.getId());
|
||||
if (Objects.equals(info.getState(), PublishState.Published.getState())) {
|
||||
Integer id=add(request);
|
||||
copyToNew(info.getId(),id);
|
||||
Integer id = add(request);
|
||||
copyToNew(info.getId(), id);
|
||||
return id;
|
||||
} else {
|
||||
info.setNo(request.getNo());
|
||||
info.setSort(request.getSort());
|
||||
info.setRecommend(request.getRecommend());
|
||||
if (request.getRecommend()) {
|
||||
if (!info.getRecommend()) {
|
||||
info.setRecommend(true);
|
||||
info.setRecommendTime(LocalDateTime.now());
|
||||
}
|
||||
} else {
|
||||
info.setRecommend(false);
|
||||
info.setRecommendTime(null);
|
||||
}
|
||||
info.setImage(request.getImage());
|
||||
info.setUpdateBy(AdminUserUtil.getUserName());
|
||||
info.setUpdateTime(LocalDateTime.now());
|
||||
|
|
|
|||
|
|
@ -55,15 +55,15 @@
|
|||
<!-- <artifactId>activation</artifactId>-->
|
||||
<!-- <version>1.1.1</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java-mp-spring-boot-starter</artifactId>
|
||||
<version>4.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.binarywang</groupId>-->
|
||||
<!-- <artifactId>wx-java-mp-spring-boot-starter</artifactId>-->
|
||||
<!-- <version>4.6.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
@Configuration
|
||||
|
|
@ -42,11 +42,11 @@ public class RedisConfig {
|
|||
// 设置 Key 的序列化器
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
// 设置 Value 的序列化器
|
||||
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||
template.setValueSerializer(new StringRedisSerializer());
|
||||
// 设置 Hash Key 的序列化器
|
||||
template.setHashKeySerializer(new StringRedisSerializer());
|
||||
// 设置 Hash Value 的序列化器
|
||||
template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||
template.setHashValueSerializer(new StringRedisSerializer());
|
||||
return template;
|
||||
}
|
||||
|
||||
|
|
@ -57,11 +57,17 @@ public class RedisConfig {
|
|||
// 设置 Key 的序列化器
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
// 设置 Value 的序列化器
|
||||
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||
template.setValueSerializer(new StringRedisSerializer());
|
||||
// 设置 Hash Key 的序列化器
|
||||
template.setHashKeySerializer(new StringRedisSerializer());
|
||||
// 设置 Hash Value 的序列化器
|
||||
template.setHashValueSerializer(new StringRedisSerializer());
|
||||
template.afterPropertiesSet();
|
||||
return template;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory factory) {
|
||||
return new StringRedisTemplate(factory);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue