|
|
@@ -1,9 +1,11 @@
|
|
|
package com.mokamrp.privates.controller.pangu;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.mokamrp.privates.constant.Constants;
|
|
|
import com.mokamrp.privates.constant.HttpStatus;
|
|
|
+import com.mokamrp.privates.constant.RedisKey;
|
|
|
import com.mokamrp.privates.controller.BaseController;
|
|
|
import com.mokamrp.privates.entity.AddHandle;
|
|
|
import com.mokamrp.privates.entity.EditHandle;
|
|
|
@@ -16,11 +18,14 @@ import com.mokamrp.privates.mapper.pojo.User;
|
|
|
import com.mokamrp.privates.service.CoralApiService;
|
|
|
import com.mokamrp.privates.service.WechatApiService;
|
|
|
import com.mokamrp.privates.service.pangu.FosterwxStationService;
|
|
|
+import org.checkerframework.checker.units.qual.A;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@@ -45,6 +50,9 @@ public class FosterwxStationController extends BaseController<FosterwxStation> {
|
|
|
@Autowired
|
|
|
public WechatApiService wechatApiService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ public StringRedisTemplate stringRedisTemplate;
|
|
|
+
|
|
|
/*
|
|
|
* @fast
|
|
|
* 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
|
|
|
@@ -83,6 +91,7 @@ public class FosterwxStationController extends BaseController<FosterwxStation> {
|
|
|
|
|
|
this.onUpdate(editHandle);
|
|
|
service.update(editHandle.getRaw(), new QueryWrapper<FosterwxStation>().in("id", editHandle.getIds()));
|
|
|
+ this.sync();
|
|
|
return AjaxResult.success(Constants.SUCCESS, true);
|
|
|
}
|
|
|
|
|
|
@@ -103,7 +112,6 @@ public class FosterwxStationController extends BaseController<FosterwxStation> {
|
|
|
if (fosterwxStationService.count(fosterwxStationLambdaQueryWrapper) > 0) {
|
|
|
return AjaxResult.error("用户名重复");
|
|
|
}
|
|
|
-
|
|
|
addHandle.getRaw().setUploadUid(user.getId());
|
|
|
this.onInsert(addHandle.getRaw());
|
|
|
Boolean res = fosterwxStationService.save(addHandle.getRaw());
|
|
|
@@ -114,6 +122,7 @@ public class FosterwxStationController extends BaseController<FosterwxStation> {
|
|
|
fosterwxStation.setBoxShareUrl(qrcodeUrl);
|
|
|
fosterwxStation.setId(addHandle.getRaw().getId());
|
|
|
fosterwxStationService.updateById(fosterwxStation);
|
|
|
+ this.sync();
|
|
|
return AjaxResult.success(Constants.SUCCESS, res);
|
|
|
} else {
|
|
|
return AjaxResult.error("新增失败", res);
|
|
|
@@ -141,5 +150,13 @@ public class FosterwxStationController extends BaseController<FosterwxStation> {
|
|
|
return AjaxResult.success(qrcodeUrl);
|
|
|
}
|
|
|
|
|
|
+ public Boolean sync(){
|
|
|
+ List<FosterwxStation> fosterwxStationList = fosterwxStationService.list();
|
|
|
+ for(FosterwxStation fosterwxStation : fosterwxStationList){
|
|
|
+ stringRedisTemplate.opsForHash().put(RedisKey.PanWxFosterStationInfo,fosterwxStation.getId().toString(), JSONArray.toJSONString(fosterwxStation));
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|