微信平台接口

This commit is contained in:
张博 2024-11-14 15:06:47 +08:00
parent 1033950cd6
commit 66548134db
21 changed files with 195 additions and 132 deletions

View File

@ -92,6 +92,8 @@ public class GlobalValue {
private String wxAppid;
@Value("${global.wx.secret}")
private String wxSecret;
@Value("${global.wx.url}")
private String wxUrl;
@Value("${global.app.key}")
private String appKey;

View File

@ -3,7 +3,6 @@ package net.shapelight.modules.app.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.minio.MinioClient;
@ -20,7 +19,6 @@ import net.shapelight.modules.app.entity.AppUserScopeEntity;
import net.shapelight.modules.app.service.AppUserScopeService;
import net.shapelight.modules.app.service.AppUserService;
//import net.shapelight.modules.dev.mqtt.CmdProcess;
import net.shapelight.modules.job.entity.KeysEntity;
import net.shapelight.modules.nettyapi.service.ServerApiService;
import net.shapelight.modules.sys.entity.*;
import net.shapelight.modules.sys.service.*;
@ -28,8 +26,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.shapelight.modules.ten.entity.*;
import net.shapelight.modules.ten.service.*;
import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient;
import net.shapelight.modules.vo.TenCelldeptSelectVo;
import net.shapelight.modules.fegin.OpFeignClient;
import net.shapelight.modules.vo.TenCelldeptWeVo;
import net.shapelight.modules.vo.TenDeviceVo;
import org.apache.commons.codec.digest.DigestUtils;
@ -96,7 +93,6 @@ public class AppApiController {
private TenParentService tenParentService;
@Autowired
private TenRelationService relationService;
@Qualifier("net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient")
@Autowired
private OpFeignClient opFeignClient;

View File

@ -21,7 +21,7 @@ import net.shapelight.modules.sys.service.SysDeviceAppService;
import net.shapelight.modules.sys.service.SysUserService;
import net.shapelight.modules.ten.entity.*;
import net.shapelight.modules.ten.service.*;
import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient;
import net.shapelight.modules.fegin.OpFeignClient;
import net.shapelight.modules.vo.SchoolNameVo;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FilenameUtils;
@ -83,7 +83,6 @@ public class AppParentApiController {
private TenParentService tenParentService;
@Autowired
private TenRelationService relationService;
@Qualifier("net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient")
@Autowired
private OpFeignClient opFeignClient;
@Autowired

View File

@ -1,4 +1,4 @@
package net.shapelight.modules.tripartitePlatform.operatorPlatform;
package net.shapelight.modules.fegin;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;

View File

@ -0,0 +1,80 @@
package net.shapelight.modules.fegin;
import com.alibaba.fastjson.JSONObject;
import net.shapelight.modules.fegin.config.OpFeignConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.PostConstruct;
import java.util.Map;
/*
* name 指定调用rest接口对应服务名
* path 指定调用接口所在Controller的@RequestMapping对应路径没有则不填
* 青桔话务平台
*/
@FeignClient(name = "operator-service", url = "${global.wx.url}",configuration = OpFeignConfig.class)
@Component
public interface OpFeignClient {
/**
* 获取密钥 1800s
* @return
*/
@PostConstruct
@PostMapping("/empower")
JSONObject empower(@RequestBody Map<String,Object> params);
@PostMapping("/submitData")
JSONObject submitData(@RequestBody Map<String,Object> params);
/*
获取token
*/
@GetMapping("cgi-bin/token")
JSONObject getToken(@RequestParam Map<String, Object> params);
/*
创建设备组
*/
@PostMapping("wxa/business/group/createid")
JSONObject createIotGroupId(@RequestBody Map<String,Object> params);
/*
删除设备组设备
*/
@PostMapping("wxa/business/group/removedevice")
JSONObject removeIotGroupDevice(@RequestBody Map<String,Object> params);
/*
新增设备组设备
*/
@PostMapping("wxa/business/group/adddevice")
JSONObject addIotGroupDevice(@RequestBody Map<String,Object> params);
/*
获取设备组信息
*/
@PostMapping("wxa/business/group/getinfo")
JSONObject getIotGroupInfo(@RequestBody Map<String,Object> params);
/*
激活licence
*/
@PostMapping("wxa/business/license/activedevice")
JSONObject activeLicenseDevice(@RequestBody Map<String,Object> params);
/*
查询license资源包列表
*/
@PostMapping("wxa/business/license/getdeviceinfo")
JSONObject getLicenseDeviceInfo(@RequestBody Map<String,Object> params);
}

View File

@ -0,0 +1,21 @@
package net.shapelight.modules.fegin;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import net.shapelight.common.utils.RedisUtils;
import net.shapelight.modules.job.entity.KeysEntity;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
public class OpFeignInterceptor implements RequestInterceptor {
@Autowired
RedisUtils redisUtils;
@Override
public void apply(RequestTemplate requestTemplate) {
requestTemplate.header("access_token", redisUtils.get("wxToken").toString());
//requestTemplate.header("empowerText", KeysEntity.empowerText);
log.info("feign拦截器");
}
}

View File

@ -0,0 +1,67 @@
package net.shapelight.modules.fegin;
import com.alibaba.fastjson.JSONObject;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class OpHystrix implements FallbackFactory<OpFeignClient> {
@Override
public OpFeignClient create(Throwable throwable) {
return new OpFeignClient() {
@Override
public JSONObject empower(Map<String, Object> params) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("errormsg","获取密钥失败");
return jsonObject;
}
@Override
public JSONObject submitData(Map<String, Object> params) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("errormsg",params.get("operation")+"失败");
return jsonObject;
}
@Override
public JSONObject getToken(Map<String, Object> params) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("errorMessage","token获取失败");
return jsonObject;
}
@Override
public JSONObject createIotGroupId(Map<String, Object> params) {
return null;
}
@Override
public JSONObject removeIotGroupDevice(Map<String, Object> params) {
return null;
}
@Override
public JSONObject addIotGroupDevice(Map<String, Object> params) {
return null;
}
@Override
public JSONObject getIotGroupInfo(Map<String, Object> params) {
return null;
}
@Override
public JSONObject activeLicenseDevice(Map<String, Object> params) {
return null;
}
@Override
public JSONObject getLicenseDeviceInfo(Map<String, Object> params) {
return null;
}
};
}
}

View File

@ -1,8 +1,8 @@
package net.shapelight.modules.tripartitePlatform.operatorPlatform.config;
package net.shapelight.modules.fegin.config;
import feign.Logger;
import feign.Request;
import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignInterceptor;
import net.shapelight.modules.fegin.OpFeignInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

View File

@ -0,0 +1,10 @@
package net.shapelight.modules.job.entity;
import lombok.Data;
@Data
public class KeysEntity {
public static String passKey;
public static String empowerText;
}

View File

@ -3,7 +3,7 @@ package net.shapelight.modules.job.task;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import net.shapelight.modules.job.entity.KeysEntity;
import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient;
import net.shapelight.modules.fegin.OpFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

View File

@ -2,8 +2,6 @@ package net.shapelight.modules.ten.controller;
import java.util.*;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@ -11,16 +9,14 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import net.shapelight.common.utils.Constant;
import net.shapelight.common.utils.SnowflakeIdWorker;
import net.shapelight.modules.job.entity.KeysEntity;
import net.shapelight.modules.sys.controller.AbstractController;
import net.shapelight.modules.sys.entity.SysUserEntity;
import net.shapelight.modules.sys.service.SysUserRoleService;
import net.shapelight.modules.ten.entity.TenCellEntity;
import net.shapelight.modules.ten.entity.TenUserScopeEntity;
import net.shapelight.modules.ten.service.TenCellService;
import net.shapelight.modules.ten.service.TenPersonService;
import net.shapelight.modules.ten.service.TenUserScopeService;
import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient;
import net.shapelight.modules.fegin.OpFeignClient;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@ -55,7 +51,6 @@ public class TenBuildController extends AbstractController {
private TenPersonService tenPersonService;
@Value("${global.qingju.accountNumber}")
private String accountNumber;
@Qualifier("net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient")
@Autowired
private OpFeignClient opFeignClient;

View File

@ -1,7 +1,6 @@
package net.shapelight.modules.ten.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@ -11,16 +10,14 @@ import net.shapelight.common.config.GlobalValue;
import net.shapelight.common.utils.PageUtils;
import net.shapelight.common.utils.R;
import net.shapelight.modules.app.entity.AppUserEntity;
import net.shapelight.modules.app.entity.AppUserScopeEntity;
import net.shapelight.modules.app.service.impl.AppUserScopeServiceImpl;
import net.shapelight.modules.app.service.impl.AppUserServiceImpl;
import net.shapelight.modules.job.entity.KeysEntity;
import net.shapelight.modules.sys.controller.AbstractController;
import net.shapelight.modules.ten.entity.TenParent;
import net.shapelight.modules.ten.entity.TenRelation;
import net.shapelight.modules.ten.service.TenParentService;
import net.shapelight.modules.ten.service.TenRelationService;
import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient;
import net.shapelight.modules.fegin.OpFeignClient;
import net.shapelight.modules.vo.ParentVo;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -28,11 +25,8 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("ten/parent")
@ -49,7 +43,6 @@ public class TenParentController extends AbstractController {
private TenRelationService relationService;
@Autowired
private GlobalValue globalValue;
@Qualifier("net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient")
@Autowired
private OpFeignClient opFeignClient;

View File

@ -6,9 +6,6 @@ import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipOutputStream;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.minio.MinioClient;
@ -22,7 +19,6 @@ import net.shapelight.common.config.GlobalValue;
import net.shapelight.common.config.MinioConfig;
import net.shapelight.common.utils.*;
import net.shapelight.commons.engine.sdk.PalmSDK;
import net.shapelight.commons.engine.sdk.PicSDK;
import net.shapelight.commons.engine.sdk.SdkImageUtils;
import net.shapelight.commons.engine.sdk.palm.FaceFeatureBase;
import net.shapelight.commons.engine.sdk.palm.OutArg;
@ -31,20 +27,17 @@ import net.shapelight.modules.app.entity.AppUserScopeEntity;
import net.shapelight.modules.app.service.AppUserService;
import net.shapelight.modules.app.service.impl.AppUserScopeServiceImpl;
import net.shapelight.modules.excel.model.PersonModel;
import net.shapelight.modules.job.entity.KeysEntity;
import net.shapelight.modules.nettyapi.service.ServerApiService;
import net.shapelight.modules.sys.controller.AbstractController;
import net.shapelight.modules.sys.entity.SysDictEntity;
import net.shapelight.modules.sys.entity.SysUserEntity;
import net.shapelight.modules.sys.service.SysUserRoleService;
import net.shapelight.modules.sys.service.SysUserService;
import net.shapelight.modules.sys.service.impl.SysDictServiceImpl;
import net.shapelight.modules.ten.entity.*;
import net.shapelight.modules.ten.service.*;
import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient;
import net.shapelight.modules.fegin.OpFeignClient;
import net.shapelight.modules.vo.TenDeviceVo;
import net.shapelight.modules.vo.TenPersonOperationVo;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
@ -106,7 +99,6 @@ public class TenPersonController extends AbstractController {
private String imagBaseUrl;
@Value("${global.minio.bucketName}")
private String bucketName;
@Qualifier("net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient")
@Autowired
private OpFeignClient opFeignClient;
@Autowired

View File

@ -1,13 +1,10 @@
package net.shapelight.modules.ten.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import net.shapelight.common.config.GlobalValue;
import net.shapelight.common.utils.Constant;
import net.shapelight.common.utils.R;
import net.shapelight.modules.app.entity.AppUserEntity;
import net.shapelight.modules.app.service.impl.AppUserServiceImpl;
import net.shapelight.modules.job.entity.KeysEntity;
import net.shapelight.modules.sys.controller.AbstractController;
import net.shapelight.modules.sys.entity.SysUserEntity;
import net.shapelight.modules.sys.service.SysUserRoleService;
@ -16,7 +13,7 @@ import net.shapelight.modules.ten.entity.TenUserScopeEntity;
import net.shapelight.modules.ten.service.TenParentService;
import net.shapelight.modules.ten.service.TenRelationService;
import net.shapelight.modules.ten.service.TenUserScopeService;
import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient;
import net.shapelight.modules.fegin.OpFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
@ -39,7 +36,6 @@ public class TenRelationController extends AbstractController {
private TenParentService parentService;
@Autowired
private AppUserServiceImpl appUserService;
@Qualifier("net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient")
@Autowired
private OpFeignClient opFeignClient;

View File

@ -3,7 +3,6 @@ package net.shapelight.modules.ten.controller;
import java.util.*;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@ -11,14 +10,13 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import net.shapelight.common.config.GlobalValue;
import net.shapelight.common.utils.*;
import net.shapelight.modules.job.entity.KeysEntity;
import net.shapelight.modules.nettyapi.service.ServerApiService;
import net.shapelight.modules.sys.controller.AbstractController;
import net.shapelight.modules.sys.entity.SysUserEntity;
import net.shapelight.modules.sys.service.SysUserRoleService;
import net.shapelight.modules.ten.entity.*;
import net.shapelight.modules.ten.service.*;
import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient;
import net.shapelight.modules.fegin.OpFeignClient;
import net.shapelight.modules.vo.TenPersonOperationVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
@ -53,7 +51,6 @@ public class TenRoomController extends AbstractController {
private TenPersonSyncService tenPersonSyncService;
@Autowired
private ServerApiService serverApiService;
@Qualifier("net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient")
@Autowired
private OpFeignClient opFeignClient;
@Autowired

View File

@ -32,7 +32,7 @@ import net.shapelight.modules.sys.service.impl.SysDictServiceImpl;
import net.shapelight.modules.ten.dao.TenRelationMapper;
import net.shapelight.modules.ten.entity.*;
import net.shapelight.modules.ten.service.*;
import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient;
import net.shapelight.modules.fegin.OpFeignClient;
import net.shapelight.modules.vo.*;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -95,7 +95,6 @@ public class TenPersonServiceImpl implements TenPersonService {
private TenCellDeptService tenCellDeptService;
@Autowired
private TenRelationService relationService;
@Qualifier("net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient")
@Autowired
private OpFeignClient opFeignClient;
@Autowired

View File

@ -5,22 +5,18 @@ import net.shapelight.modules.ten.entity.TenAddressEntity;
import net.shapelight.modules.ten.entity.TenBuildEntity;
import net.shapelight.modules.ten.entity.TenCellEntity;
import net.shapelight.modules.ten.service.*;
import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient;
import net.shapelight.modules.fegin.OpFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.shapelight.common.utils.PageUtils;
import net.shapelight.common.utils.Query;
import net.shapelight.modules.ten.dao.TenRoomDao;
import net.shapelight.modules.ten.entity.TenRoomEntity;

View File

@ -1,34 +0,0 @@
package net.shapelight.modules.tripartitePlatform.operatorPlatform;
import com.alibaba.fastjson.JSONObject;
import net.shapelight.modules.tripartitePlatform.operatorPlatform.config.OpFeignConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.PostConstruct;
import java.util.Map;
/*
* name 指定调用rest接口对应服务名
* path 指定调用接口所在Controller的@RequestMapping对应路径没有则不填
* 青桔话务平台
*/
@FeignClient(name = "operator-service", url = "${global.qingju.url}",configuration = OpFeignConfig.class)
@Component
public interface OpFeignClient {
/**
* 获取密钥 1800s
* @return
*/
@PostConstruct
@PostMapping("/empower")
JSONObject empower(@RequestBody Map<String,Object> params);
@PostMapping("/submitData")
JSONObject submitData(@RequestBody Map<String,Object> params);
}

View File

@ -1,17 +0,0 @@
package net.shapelight.modules.tripartitePlatform.operatorPlatform;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import net.shapelight.modules.job.entity.KeysEntity;
@Slf4j
public class OpFeignInterceptor implements RequestInterceptor {
@Override
public void apply(RequestTemplate requestTemplate) {
requestTemplate.header("passKey", KeysEntity.passKey);
requestTemplate.header("empowerText", KeysEntity.empowerText);
log.info("feign拦截器");
}
}

View File

@ -1,30 +0,0 @@
package net.shapelight.modules.tripartitePlatform.operatorPlatform;
import com.alibaba.fastjson.JSONObject;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class OpHystrix implements FallbackFactory<OpFeignClient> {
@Override
public OpFeignClient create(Throwable throwable) {
return new OpFeignClient() {
@Override
public JSONObject empower(Map<String, Object> params) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("errormsg","获取密钥失败");
return jsonObject;
}
@Override
public JSONObject submitData(Map<String, Object> params) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("errormsg",params.get("operation")+"失败");
return jsonObject;
}
};
}
}

View File

@ -107,7 +107,8 @@ global:
# bucketName: cell
wx:
appid: wx313273bb23519704
secret: 30b523b2bdd7b0739b7f06e9dc1519f8
secret: a9162ffebee8e9892418bb78d86d7a80
url: https://api.weixin.qq.com/
tcp_server:
port: 8086
app: