Просмотр исходного кода

Merge branch 'master' into dev-lqc

lqc 4 лет назад
Родитель
Сommit
a1cf29b521

+ 18 - 18
src/main/java/com/mokamrp/privates/controller/pangu/PromoteCodeController.java

@@ -17,6 +17,7 @@ import com.mokamrp.privates.mapper.pangu.pojo.PromoteQrcodePool;
 import com.mokamrp.privates.mapper.pojo.User;
 import com.mokamrp.privates.service.pangu.PromoteQrcodePoolService;
 import com.mokamrp.privates.utils.StringUtils;
+import com.mokamrp.privates.utils.sign.Aes;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.validation.BindingResult;
@@ -56,12 +57,12 @@ public class PromoteCodeController extends BaseController<PromoteCode> {
      * 如果需要定制化,需要将BaseController中对应的方法复制到当前控制器,然后进行修改
      */
     @PostMapping("/list")
-    public Object list(@RequestBody PromoteCodeListHandle promoteCodeListHandle,@AuthUser User authUser) {
+    public Object list(@RequestBody PromoteCodeListHandle promoteCodeListHandle, @AuthUser User authUser) {
         Object res;
-        if (authUser.getIsSuperAdmin().equals(1)){
-            res = promoteCodeService.getlist(promoteCodeListHandle,null);
-        }else{
-            res = promoteCodeService.getlist(promoteCodeListHandle,authUser.getDepartment());
+        if (authUser.getIsSuperAdmin().equals(1)) {
+            res = promoteCodeService.getlist(promoteCodeListHandle, null);
+        } else {
+            res = promoteCodeService.getlist(promoteCodeListHandle, authUser.getDepartment());
         }
         return AjaxResult.success(res);
     }
@@ -84,10 +85,10 @@ public class PromoteCodeController extends BaseController<PromoteCode> {
         this.onInsert(addHandle.getRaw());
         addHandle.getRaw().setDeptId(authUser.getDepartment());
         Boolean res = promoteCodeService.save(addHandle.getRaw());
-        if (res){
+        if (res) {
             this.sync();
             return AjaxResult.success(Constants.SUCCESS, res);
-        }else{
+        } else {
             return AjaxResult.error("新增失败");
         }
     }
@@ -101,7 +102,7 @@ public class PromoteCodeController extends BaseController<PromoteCode> {
         String[] ids = delHandle.getIds().split(",");
         QueryWrapper.in("id", ids);
         boolean res = service.remove(QueryWrapper);
-        promoteQrcodePoolService.remove(new QueryWrapper<PromoteQrcodePool>().in("promote_id",ids));
+        promoteQrcodePoolService.remove(new QueryWrapper<PromoteQrcodePool>().in("promote_id", ids));
         if (!res) {
             return AjaxResult.error("删除失败");
         }
@@ -114,15 +115,15 @@ public class PromoteCodeController extends BaseController<PromoteCode> {
         if (bindingResult.hasErrors()) {
             return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
         }
-        if (editHandle.getRaw().getHourUvMax() != null){
+        if (editHandle.getRaw().getHourUvMax() != null) {
             PromoteQrcodePool save = new PromoteQrcodePool();
             save.setHourUvMax(editHandle.getRaw().getHourUvMax());
-            promoteQrcodePoolService.update(save,new QueryWrapper<PromoteQrcodePool>().eq("promote_id",editHandle.getIds()));
+            promoteQrcodePoolService.update(save, new QueryWrapper<PromoteQrcodePool>().eq("promote_id", editHandle.getIds()));
         }
-        if (editHandle.getRaw().getDayUvMax() != null){
+        if (editHandle.getRaw().getDayUvMax() != null) {
             PromoteQrcodePool save = new PromoteQrcodePool();
             save.setDayUvMax(editHandle.getRaw().getDayUvMax());
-            promoteQrcodePoolService.update(save,new QueryWrapper<PromoteQrcodePool>().eq("promote_id",editHandle.getIds()));
+            promoteQrcodePoolService.update(save, new QueryWrapper<PromoteQrcodePool>().eq("promote_id", editHandle.getIds()));
         }
         this.onUpdate(editHandle);
         service.update(editHandle.getRaw(), new QueryWrapper<PromoteCode>().in("id", editHandle.getIds()));
@@ -143,12 +144,11 @@ public class PromoteCodeController extends BaseController<PromoteCode> {
     }
 
 
-
-    public Boolean delRedis(String[] ids){
-        for (String id : ids){
-            stringRedisTemplate.opsForHash().delete(RedisKey.PanPromoteCodeInfo,id);
-            stringRedisTemplate.delete(RedisKey.PanCustServiceIdView+id);
-            stringRedisTemplate.delete(RedisKey.PanCustServiceIdDayView+id);
+    public Boolean delRedis(String[] ids) {
+        for (String id : ids) {
+            stringRedisTemplate.opsForHash().delete(RedisKey.PanPromoteCodeInfo, id);
+            stringRedisTemplate.delete(RedisKey.PanCustServiceIdView + id);
+            stringRedisTemplate.delete(RedisKey.PanCustServiceIdDayView + id);
         }
         return true;
     }

+ 4 - 4
src/main/java/com/mokamrp/privates/controller/pangu/PromoteCodeDataController.java

@@ -118,10 +118,10 @@ public class PromoteCodeDataController{
     @GetMapping("/getTotal")
     public Object getTotal(@RequestParam(name = "promoteId") Integer promoteId){
         PromoteQrcodePoolRecord total = promoteQrcodePoolRecordService.getOne(new QueryWrapper<PromoteQrcodePoolRecord>()
-                .select("sum(long_touch_pv) as long_touch_pv," +
-                        "sum(take_qrcode_pv) as take_qrcode_pv," +
-                        "sum(long_touch_uv) as long_touch_uv," +
-                        "sum(take_qrcode_uv) as take_qrcode_uv")
+                .select("ifnull(sum(long_touch_pv),0) as long_touch_pv," +
+                        "ifnull(sum(take_qrcode_pv),0) as take_qrcode_pv," +
+                        "ifnull(sum(long_touch_uv),0) as long_touch_uv," +
+                        "ifnull(sum(take_qrcode_uv),0) as take_qrcode_uv")
                 .eq("promote_id",promoteId));
         Map<String,Object> res = new HashMap<>();
         res.put("longTouchPv",total.getLongTouchPv());

+ 2 - 0
src/main/java/com/mokamrp/privates/mapper/crawer/LoginBanMapper.java

@@ -1,5 +1,6 @@
 package com.mokamrp.privates.mapper.crawer;
 
+import com.baomidou.dynamic.datasource.annotation.DS;
 import com.mokamrp.privates.mapper.crawer.pojo.LoginBan;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -16,6 +17,7 @@ import java.util.List;
  * @since 2021-10-11
  */
 @Component
+@DS("crawerdb")
 public interface LoginBanMapper extends BaseMapper<LoginBan> {
     public List<LoginBan> getList(Page<LoginBan> pageObj);
 }

+ 2 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxMobileWxfriend.java

@@ -1,5 +1,6 @@
 package com.mokamrp.privates.mapper.pangu.pojo;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -42,6 +43,7 @@ public class FosterwxMobileWxfriend extends Model<FosterwxMobileWxfriend> {
     /**
      * 好友ID
      */
+    @TableField(exist = false)
     private Integer friendId;
     /**
      * 创建时间

+ 2 - 0
src/main/java/com/mokamrp/privates/service/crawer/impl/LoginBanServiceImpl.java

@@ -1,5 +1,6 @@
 package com.mokamrp.privates.service.crawer.impl;
 
+import com.baomidou.dynamic.datasource.annotation.DS;
 import com.mokamrp.privates.mapper.crawer.pojo.LoginBan;
 import com.mokamrp.privates.mapper.crawer.LoginBanMapper;
 import com.mokamrp.privates.service.crawer.LoginBanService;
@@ -21,6 +22,7 @@ import java.util.*;
  * @since 2021-10-11
  */
 @Service
+@DS("crawerdb")
 public class LoginBanServiceImpl extends ServiceImpl<LoginBanMapper, LoginBan> implements LoginBanService {
 
     @Autowired

+ 1 - 1
src/main/java/com/mokamrp/privates/service/pangu/impl/PromoteCodeServiceImpl.java

@@ -52,7 +52,7 @@ public class PromoteCodeServiceImpl extends ServiceImpl<PromoteCodeMapper, Promo
             Integer promoteId = promoteCodeVo.getId();
             String promoteIdAes;
             try{
-                promoteIdAes = Aes.encryptAES(promoteId.toString());
+                promoteIdAes = Aes.encryptAES(promoteId.toString(),null,null);
                 promoteIdAes = Aes.enAna(promoteIdAes);
             }catch (Exception e){
                 promoteIdAes = promoteId.toString();

+ 22 - 4
src/main/java/com/mokamrp/privates/utils/sign/Aes.java

@@ -8,15 +8,27 @@ public class Aes {
     /*
      * 加密用的Key 可以用26个字母和数字组成 使用AES-128-CBC加密模式,key需要为16位。
      */
-    private static final String key="hj7x89H$ZuBI0456";
-    private static final String iv ="NIfb&95GAY86Gfgh";
+    private static final String defualtKey="hj7x89H$ZuBI0456";
+    private static final String defualtIv ="NIfb&95GAY86Gfgh";
     /**
      * @author miracle.qu
      * @Description AES算法加密明文
      * @param data 明文
      * @return 密文
      */
-    public static String encryptAES(String data) throws Exception {
+    /**
+     * @author miracle.qu
+     * @Description AES算法加密明文
+     * @param data 明文
+     * @return 密文
+     */
+    public static String encryptAES(String data,String key,String iv) throws Exception {
+        if (key == null){
+            key = defualtKey;
+        }
+        if (iv == null){
+            iv = defualtIv;
+        }
         try {
             Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
             int blockSize = cipher.getBlockSize();
@@ -50,7 +62,13 @@ public class Aes {
      * @param data 密文
      * @return 明文
      */
-    public static String decryptAES(String data) throws Exception {
+    public static String decryptAES(String data,String key,String iv) throws Exception {
+        if (key == null){
+            key = defualtKey;
+        }
+        if (iv == null){
+            iv = defualtIv;
+        }
         try
         {
             byte[] encrypted1 = Aes.decode(data);//先用base64解密