|
|
@@ -0,0 +1,375 @@
|
|
|
+package com.poyee.api.controller;
|
|
|
+
|
|
|
+//import com.alibaba.fastjson.JSONObject;
|
|
|
+//import com.github.pagehelper.util.StringUtil;
|
|
|
+//import com.tzy.annotation.ApiLog;
|
|
|
+//import com.tzy.annotation.RequireRoles;
|
|
|
+//import com.tzy.app.domain.*;
|
|
|
+//import com.tzy.app.service.*;
|
|
|
+//import com.tzy.common.constant.Constants;
|
|
|
+//import com.tzy.common.core.domain.entity.SysDictData;
|
|
|
+//import com.tzy.common.dto.InDto;
|
|
|
+//import com.tzy.common.dto.IpAddrDTO;
|
|
|
+//import com.tzy.common.dto.OutDTO;
|
|
|
+//import com.tzy.common.enums.BusinessType;
|
|
|
+//import com.tzy.common.exception.ServiceException;
|
|
|
+//import com.tzy.common.utils.*;
|
|
|
+//import com.tzy.common.utils.bean.DozerUtils;
|
|
|
+//import com.tzy.common.utils.qiniu.QiniuUtil;
|
|
|
+//import com.tzy.coupon.card.domain.AppUserCardRecord;
|
|
|
+//import com.tzy.coupon.card.domain.TzyCardBaseInfo;
|
|
|
+//import com.tzy.coupon.card.service.IAppUserCardRecordService;
|
|
|
+//import com.tzy.coupon.card.service.ITzyCardBaseInfoService;
|
|
|
+//import com.tzy.dashboard.domain.TzyChannelShare;
|
|
|
+//import com.tzy.dashboard.service.ITzyChannelShareService;
|
|
|
+//import com.tzy.framework.util.RedisUtils;
|
|
|
+//import com.tzy.framework.util.SystemConstant;
|
|
|
+//import com.tzy.sportcard.api.bean.marketplace.AppVersionParam;
|
|
|
+//import com.tzy.sportcard.api.domain.AppUserInfoDto;
|
|
|
+//import com.tzy.sportcard.api.domain.ApplicationInfo;
|
|
|
+//import com.tzy.sportcard.api.dto.group.AppCarouselPictureDTO;
|
|
|
+//import com.tzy.sportcard.api.service.BaseApiService;
|
|
|
+//import com.tzy.sportcard.api.service.GroupApiService;
|
|
|
+//import com.tzy.sportcard.api.service.MineApiService;
|
|
|
+//import com.tzy.sportcard.api.service.WeChatApiService;
|
|
|
+//import com.tzy.sportcard.base.service.CommonCacheService;
|
|
|
+//import com.tzy.sportcard.group.service.ICardGroupOrderInfoService;
|
|
|
+//import com.tzy.system.service.ISysDictDataService;
|
|
|
+//import com.tzy.util.HobbyStocksApiUtils;
|
|
|
+//import com.tzy.util.RandomUtil;
|
|
|
+//import com.tzy.util.RedisHandUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 公共基础接口
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api")
|
|
|
+public class BaseApiController {
|
|
|
+// @Autowired
|
|
|
+// private MineApiService mineApiService;
|
|
|
+// @Autowired
|
|
|
+// private IAppAccountService appAccountService;
|
|
|
+// @Autowired
|
|
|
+// private IAppBaseUserService appBaseUserService;
|
|
|
+// @Autowired
|
|
|
+// private IAppRoleService appRoleService;
|
|
|
+// @Autowired
|
|
|
+// private ITzyCardBaseInfoService cardBaseInfoService;
|
|
|
+// @Autowired
|
|
|
+// private WeChatApiService weChatApiService;
|
|
|
+// @Autowired
|
|
|
+// private IAppUserCardRecordService appUserCardRecordService;
|
|
|
+// @Autowired
|
|
|
+// private HobbyStocksApiUtils hobbyStocksApiUtils;
|
|
|
+// @Autowired
|
|
|
+// private IAppMenuService appMenuService;
|
|
|
+// @Autowired
|
|
|
+// private BaseApiService baseApiService;
|
|
|
+// @Autowired
|
|
|
+// private ITzyChannelShareService tzyChannelShareService;
|
|
|
+// @Autowired
|
|
|
+// private ICardGroupOrderInfoService cardGroupOrderInfoService;
|
|
|
+// @Autowired
|
|
|
+// private RedisUtils redisUtils;
|
|
|
+// @Autowired
|
|
|
+// private RedisHandUtil redisHandUtil;
|
|
|
+// @Autowired
|
|
|
+// private ISysDictDataService dictDataService;
|
|
|
+// @Autowired
|
|
|
+// private IAppCarouselPictureService appCarouselPictureService;
|
|
|
+// @Value("${wx.default_avatar}")
|
|
|
+// private String default_avatar ;
|
|
|
+// @Value("${pay.alipay.app.alipayPublicKey}")
|
|
|
+// private String privateAuth;
|
|
|
+// @Autowired
|
|
|
+// @Qualifier("threadPoolTaskExecutor")
|
|
|
+// private ThreadPoolTaskExecutor pools;
|
|
|
+// @Autowired
|
|
|
+// private CommonCacheService commonCacheService;
|
|
|
+// @Autowired
|
|
|
+// private GroupApiService groupApiService;
|
|
|
+
|
|
|
+// //@PostConstruct
|
|
|
+// public void initMsgTemplate(){
|
|
|
+// AppMenu appMenu = new AppMenu();
|
|
|
+// appMenu.setStatus("0");
|
|
|
+// List<AppMenu> appMenus = appMenuService.selectAppMenuList(appMenu);
|
|
|
+// redisUtils.lCommit("login", appMenus);
|
|
|
+// redisHandUtil.lDataDistinct("login","Name");
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 检测app是否需要更新
|
|
|
+// * @param inDto
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// @ApiLog(title = "检测app是否需要更新", businessType = BusinessType.SEARCH)
|
|
|
+// @ResponseBody
|
|
|
+// @RequestMapping(value = "/checkAppVersion", method = RequestMethod.POST)
|
|
|
+// public OutDTO checkAppVersion(@RequestBody InDto inDto){
|
|
|
+// if(null == inDto)return OutDTO.error(10040,"参数不能为空!");
|
|
|
+// //验证来源
|
|
|
+// //String userType = inDto.getUserType();
|
|
|
+// //if(StringUtils.isEmpty(userType) || (!UserType.WX_AUTH.equals(userType)
|
|
|
+// // && !userType.startsWith(UserType.THIRD))
|
|
|
+// //){
|
|
|
+// // return OutDTO.ok().put("data","没有更新");
|
|
|
+// //}
|
|
|
+// String atVersion = inDto.getString("atVersion");
|
|
|
+// SysDictData dictData = new SysDictData();
|
|
|
+// dictData.setDictType("stop_update_version");
|
|
|
+// dictData.setDictLabel(atVersion);
|
|
|
+// dictData.setStatus(Constants.STATUS_OK);
|
|
|
+// List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
|
|
+// if(!list.isEmpty()){
|
|
|
+// return OutDTO.ok().put("data","没有更新");
|
|
|
+// }
|
|
|
+//
|
|
|
+// String appkey = inDto.getString("appkey");
|
|
|
+// String appName = inDto.getString("appName");
|
|
|
+// if(StringUtils.isEmpty(appName) || StringUtils.isEmpty(appkey)
|
|
|
+// || StringUtils.isEmpty(atVersion)) return OutDTO.ok().put("data","没有更新");
|
|
|
+// //查询 最新版本
|
|
|
+// ApplicationInfo applicationInfo = baseApiService.selectNextVersionApp(appkey, appName, atVersion);
|
|
|
+// if(null == applicationInfo) return OutDTO.ok().put("data","没有更新");
|
|
|
+// String releaseType = applicationInfo.getReleaseType();
|
|
|
+// if(StringUtils.isNotEmpty(releaseType) && "private".equals(releaseType)) return OutDTO.ok().put("data","没有更新");
|
|
|
+// return OutDTO.ok().put("appinfo",applicationInfo);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiLog(title = "字典查询信息接口", businessType = BusinessType.SEARCH)
|
|
|
+// @PostMapping("/common/type")
|
|
|
+// @ResponseBody
|
|
|
+// public OutDTO getCommonDictData(@RequestBody InDto inDto) {
|
|
|
+// SysDictData dictData = new SysDictData();
|
|
|
+// dictData.setDictType(inDto.getString("type"));
|
|
|
+// String status = inDto.getString("status");
|
|
|
+// if(StringUtils.isEmpty(status)){
|
|
|
+// dictData.setStatus(Constants.STATUS_OK);
|
|
|
+// }else if (!Constants.All.equals(status)){
|
|
|
+// dictData.setStatus(status);
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
|
|
+// return OutDTO.ok().put("list",list);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiLog(title = "版本审核校验", businessType = BusinessType.SEARCH)
|
|
|
+// @PostMapping("/versionCheck")
|
|
|
+// @ResponseBody
|
|
|
+// public OutDTO versionCheck(@RequestBody InDto inDto) {
|
|
|
+// String version = inDto.getString("version");
|
|
|
+// if (StringUtils.isEmpty(version)) {
|
|
|
+// return OutDTO.error(510,"版本号为空!");
|
|
|
+// }
|
|
|
+// Integer appVersion = Integer.valueOf(version.replaceAll("\\.", StringUtils.NULLSTR));
|
|
|
+// SysDictData dictData = new SysDictData();
|
|
|
+// dictData.setDictType("app_check_type");
|
|
|
+// List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
|
|
+// if (!list.isEmpty() && !StringUtils.isEmpty(list.get(0).getDictValue())&& Constants.STATUS_OK.equals(list.get(0).getStatus())) {
|
|
|
+// Integer dataVersion = Integer.valueOf(list.get(0).getDictValue().replaceAll("\\.", StringUtils.NULLSTR));
|
|
|
+// log.debug("app当前版本:{},数据库版本:{}",appVersion,dataVersion);
|
|
|
+// if (appVersion > dataVersion) {
|
|
|
+// return OutDTO.ok().put("check","1");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return OutDTO.ok().put("check","0");
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiLog(title = "大版本比较", businessType = BusinessType.SEARCH)
|
|
|
+// @PostMapping("/versionOnlineCheck")
|
|
|
+// @ResponseBody
|
|
|
+// public OutDTO versionOnlineCheck(@RequestBody InDto inDto) {
|
|
|
+// String version = inDto.getVersion();
|
|
|
+// if (StringUtils.isEmpty(version)) {
|
|
|
+// return OutDTO.error(510,"版本号为空!");
|
|
|
+// }
|
|
|
+//
|
|
|
+// SysDictData dictData = new SysDictData();
|
|
|
+// dictData.setDictType("app_online_version");
|
|
|
+// List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
|
|
+// if (!list.isEmpty() && !StringUtils.isEmpty(list.get(0).getDictValue())) {
|
|
|
+// Integer appVersion = Integer.valueOf(version.replaceAll("\\.", StringUtils.NULLSTR));
|
|
|
+// Integer dataVersion = Integer.valueOf(list.get(0).getDictValue().replaceAll("\\.", StringUtils.NULLSTR));
|
|
|
+// log.debug("app当前版本:{},数据库版本:{}",appVersion,dataVersion);
|
|
|
+// if (appVersion < dataVersion) {
|
|
|
+// return OutDTO.ok().put("check","1").put("versionCode",dataVersion).put("versionName",list.get(0).getDictValue()).put("versionInfo",list.get(0).getRemark());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return OutDTO.ok().put("check","0");
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiLog(title = "七牛token", businessType = BusinessType.SEARCH)
|
|
|
+// @PostMapping("/qiniu/token")
|
|
|
+// @ResponseBody
|
|
|
+// public OutDTO getQiuNiuToken() {
|
|
|
+// Object tokenCache = redisUtils.get(QiniuUtil.QINIU_TOKEN);
|
|
|
+// String token;
|
|
|
+// if(tokenCache==null||StringUtils.isEmpty(tokenCache.toString())){
|
|
|
+// token = QiniuUtil.getUpToken();
|
|
|
+// if(StringUtils.isEmpty(token)){
|
|
|
+// return OutDTO.error(510,"获取七牛token失败!");
|
|
|
+// }
|
|
|
+// redisUtils.set(QiniuUtil.QINIU_TOKEN,token,1800);
|
|
|
+// }else {
|
|
|
+// token= tokenCache.toString();
|
|
|
+// }
|
|
|
+// log.debug("七牛云token:{}",token);
|
|
|
+// return OutDTO.ok().put("token",token);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// @ApiLog(title = "七牛token", businessType = BusinessType.SEARCH)
|
|
|
+// @PostMapping("/v2/qiniu/token")
|
|
|
+// @ResponseBody
|
|
|
+// public OutDTO getQiuNiuTokenV2(@RequestBody InDto inDto) {
|
|
|
+// String bucketName = inDto.getString("bucketName");
|
|
|
+// if(StringUtils.isEmpty(bucketName)){
|
|
|
+// bucketName="tzy-admin-public";
|
|
|
+// }
|
|
|
+// Object tokenCache = redisUtils.get(QiniuUtil.QINIU_TOKEN+bucketName);
|
|
|
+// String token;
|
|
|
+// if(tokenCache==null||StringUtils.isEmpty(tokenCache.toString())){
|
|
|
+// token = QiniuUtil.getUpToken(bucketName);
|
|
|
+// if(StringUtils.isEmpty(token)){
|
|
|
+// return OutDTO.error(510,"获取七牛token失败!");
|
|
|
+// }
|
|
|
+// redisUtils.set(QiniuUtil.QINIU_TOKEN+bucketName,token,1800);
|
|
|
+// }else {
|
|
|
+// token= tokenCache.toString();
|
|
|
+// }
|
|
|
+// log.debug("七牛云token:{}",token);
|
|
|
+// return OutDTO.ok().put("token",token);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiLog(title = "首页banner", businessType = BusinessType.SEARCH)
|
|
|
+// @PostMapping("/banner")
|
|
|
+// @ResponseBody
|
|
|
+// public OutDTO getBanner() {
|
|
|
+// List<AppCarouselPicture> banners=appCarouselPictureService.getBanner(null);
|
|
|
+// return OutDTO.ok().put("banner",banners);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// @ApiLog(title = "根据type查询banner", businessType = BusinessType.SEARCH)
|
|
|
+// @PostMapping("/banner/type")
|
|
|
+// @ResponseBody
|
|
|
+// public OutDTO getBannerByType(@RequestBody InDto inDto) {
|
|
|
+// String type = inDto.getString("type");
|
|
|
+// List<AppCarouselPicture> banners=appCarouselPictureService.getBanner(type);
|
|
|
+// return OutDTO.ok().put("banner",banners);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiLog(title = "字典查询信息接口", businessType = BusinessType.SEARCH)
|
|
|
+// @PostMapping("/v2/common/type")
|
|
|
+// @ResponseBody
|
|
|
+// public OutDTO getCommonDictDataNew(@RequestBody InDto inDto) {
|
|
|
+// String type = inDto.getString("type");
|
|
|
+// if(StringUtils.isEmpty(type)){
|
|
|
+// return OutDTO.error500("参数为空!");
|
|
|
+// }
|
|
|
+// String status = inDto.getString("status");
|
|
|
+// if(StringUtils.isEmpty(status)){
|
|
|
+// status=Constants.STATUS_OK;
|
|
|
+// }else if (Constants.All.equals(status)){
|
|
|
+// status=null;
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<String> types = Arrays.asList(type.split(","));
|
|
|
+// HashMap<String, List<SysDictData>> datas = new HashMap<>();
|
|
|
+// SysDictData dictData = new SysDictData();
|
|
|
+// for(String t:types){
|
|
|
+// dictData.setDictType(t);
|
|
|
+// dictData.setStatus(status);
|
|
|
+// List<SysDictData> data = commonCacheService.getCommonDictData(t, null, status, "app_cache_" + t, -1);
|
|
|
+// datas.put(t,data);
|
|
|
+// }
|
|
|
+// return OutDTO.ok().put("typeData",datas);
|
|
|
+// }
|
|
|
+//
|
|
|
+//// @ApiLog(title = "根据type查询banner接口(新)", businessType = BusinessType.SEARCH)
|
|
|
+//// @PostMapping("/v2/banner/type")
|
|
|
+//// @ResponseBody
|
|
|
+//// public OutDTO getBannerNew(@RequestBody InDto inDto) throws Exception {
|
|
|
+//// String type = inDto.getString("type");
|
|
|
+//// if(StringUtils.isEmpty(type)){
|
|
|
+//// return OutDTO.error500("参数为空!");
|
|
|
+//// }
|
|
|
+//// //banner
|
|
|
+//// List<AppCarouselPicture> banners=appCarouselPictureService.getBannerByTypes(Arrays.asList(type.split(",")));
|
|
|
+//// Map<String, List<AppCarouselPictureDTO>> bannerList = banners.stream().map(b -> DozerUtils.map(b, AppCarouselPictureDTO.class))
|
|
|
+//// .collect(Collectors.groupingBy(AppCarouselPictureDTO::getType));
|
|
|
+//// //即将售罄底图
|
|
|
+//// String ratePic= groupApiService.findOneRateGroupPic();
|
|
|
+//// return OutDTO.ok().put("banner",bannerList).put("ratePic",ratePic);
|
|
|
+//// }
|
|
|
+//
|
|
|
+//
|
|
|
+// @ApiLog(title = "版本校验(新,2合1)", businessType = BusinessType.SEARCH)
|
|
|
+// @PostMapping("/v2/version/check")
|
|
|
+// @ResponseBody
|
|
|
+// public OutDTO versionCheckNew(@RequestBody InDto inDto) {
|
|
|
+// String version = inDto.getVersion();
|
|
|
+// String phoneType = inDto.getString("type");
|
|
|
+// return OutDTO.ok()
|
|
|
+// .put("storeUpdate", checkStoreVersionUpdate(version, phoneType))
|
|
|
+// .put("hotUpdateShow", checkAppVersionHotUpdate(version,phoneType));
|
|
|
+// }
|
|
|
+//
|
|
|
+// private Map<String, Object> checkStoreVersionUpdate(String version, String phoneType) {
|
|
|
+// //大版本更新
|
|
|
+// Map<String, Object> versionUpdate = new HashMap() {{
|
|
|
+// put("check", 0);
|
|
|
+// }};
|
|
|
+// if (StringUtils.isEmpty(version)|| StringUtils.isEmpty(phoneType)) {
|
|
|
+// return versionUpdate;
|
|
|
+// }
|
|
|
+// String type = Constants.PHONE_TYPE_IOS.equals(phoneType) ? "app_online_version_ios" : "app_online_version_android";
|
|
|
+// List<SysDictData> list = commonCacheService.getCommonDictData("app_online_version", type, null, "app_cache_" + type, -1);
|
|
|
+// SysDictData data = list.get(0);
|
|
|
+// if (!list.isEmpty() && !StringUtils.isEmpty(data.getDictValue())) {
|
|
|
+// Integer appVersion = Integer.valueOf(version.replaceAll("\\.", StringUtils.NULLSTR));
|
|
|
+// Integer dataVersion = Integer.valueOf(data.getDictValue().replaceAll("\\.", StringUtils.NULLSTR));
|
|
|
+// log.debug("app当前版本:{},数据库版本:{}", appVersion, dataVersion);
|
|
|
+// if (appVersion < dataVersion) {
|
|
|
+// versionUpdate.put("check", "1");
|
|
|
+// versionUpdate.put("versionCode", dataVersion);
|
|
|
+// versionUpdate.put("versionName", list.get(0).getDictValue());
|
|
|
+// versionUpdate.put("versionInfo", list.get(0).getRemark());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return versionUpdate;
|
|
|
+// }
|
|
|
+//
|
|
|
+// private Map<String, Object> checkAppVersionHotUpdate(String version,String phoneType) {
|
|
|
+// //热更新
|
|
|
+// Map<String, Object> appVersionData = new HashMap() {{
|
|
|
+// put("code", 0);
|
|
|
+// }};
|
|
|
+// if (StringUtils.isEmpty(version) || StringUtils.isEmpty(phoneType)){
|
|
|
+// return appVersionData;
|
|
|
+// }
|
|
|
+// List<SysDictData> list = commonCacheService.getCommonDictData("stop_update_version", version, "1", "app_cache_stop_update_version", -1);
|
|
|
+// if (!list.isEmpty()) {
|
|
|
+// return appVersionData;
|
|
|
+// }
|
|
|
+// //查询 最新版本
|
|
|
+// ApplicationInfo applicationInfo = baseApiService.selectNextVersionAppNew(new AppVersionParam(version, phoneType));
|
|
|
+// if (null == applicationInfo) {
|
|
|
+// return appVersionData;
|
|
|
+// }
|
|
|
+// appVersionData.put("code", 1);
|
|
|
+// appVersionData.put("appinfo", applicationInfo);
|
|
|
+// return appVersionData;
|
|
|
+// }
|
|
|
+}
|