|
|
@@ -1,15 +1,26 @@
|
|
|
package com.ytpm.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.ytpm.advertise.enums.AdPlatformTypeEnum;
|
|
|
import com.ytpm.advertise.param.AddAppParam;
|
|
|
import com.ytpm.advertise.view.AddAppResponse;
|
|
|
+import com.ytpm.agent.model.YtApp;
|
|
|
+import com.ytpm.agent.model.YtChannel;
|
|
|
+import com.ytpm.agent.param.AppParam;
|
|
|
+import com.ytpm.agent.param.ChannelParam;
|
|
|
import com.ytpm.agent.view.AgentEnableAppView;
|
|
|
import com.ytpm.app.view.YtAppListView;
|
|
|
import com.ytpm.dao.AgentAppMapper;
|
|
|
+import com.ytpm.dao.AppMapper;
|
|
|
+import com.ytpm.dao.ChannelMapper;
|
|
|
import com.ytpm.feign.AdvertiseFeign;
|
|
|
+import com.ytpm.general.RepMessage;
|
|
|
import com.ytpm.general.Result;
|
|
|
import com.ytpm.general.ResultTable;
|
|
|
import com.ytpm.service.AgentAppService;
|
|
|
+import org.checkerframework.checker.units.qual.A;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
@@ -21,6 +32,10 @@ public class AgentAppServiceImpl implements AgentAppService {
|
|
|
private AgentAppMapper agentAppMapper;
|
|
|
@Resource
|
|
|
private AdvertiseFeign advertiseFeign;
|
|
|
+ @Resource
|
|
|
+ private AppMapper appMapper;
|
|
|
+ @Resource
|
|
|
+ private ChannelMapper channelMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询渠道启用的应用列表
|
|
|
@@ -43,11 +58,37 @@ public class AgentAppServiceImpl implements AgentAppService {
|
|
|
* 新增应用
|
|
|
*/
|
|
|
@Override
|
|
|
- public Result<?> addApp(AddAppParam param) {
|
|
|
+ public Result<?> addApp(AppParam param, String userId) {
|
|
|
//调用广告平台API 增加应用
|
|
|
Result<AddAppResponse> result = advertiseFeign.addApp(param);
|
|
|
- //TODO 数据库存储应用信息
|
|
|
+ //数据库存储应用信息
|
|
|
+ AddAppResponse data = result.getData();
|
|
|
+ YtApp app = new YtApp();
|
|
|
+ app.setAppId(data.getUuid());
|
|
|
+ app.setAppKey(data.getApp_key());
|
|
|
+ app.setAppName(param.getName());
|
|
|
+ app.setAppType(param.getPlatform());
|
|
|
+ app.setUserId(userId);
|
|
|
+ app.setEnabled(1);
|
|
|
+ app.setApkUrl(param.getApkUrl());
|
|
|
+ app.setQrCode(param.getQrCode());
|
|
|
+ app.setVersionCode(param.getVersionCode());
|
|
|
+ app.setUpdateTips(param.getUpdateTips());
|
|
|
+ //前端上传apk后返回链接,链接生成二维码图片后上传返回二维码链接
|
|
|
+ appMapper.insertOne(app);
|
|
|
+ return Result.resultOk(RepMessage.ADD_SUCCESS);
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
+ /**
|
|
|
+ * 新增广告渠道
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Result<?> addChannel(ChannelParam param, String userId) {
|
|
|
+ YtChannel channel = new YtChannel();
|
|
|
+ BeanUtil.copyProperties(param, channel);
|
|
|
+ channel.setChannelId(IdUtil.fastSimpleUUID());
|
|
|
+ channel.setChannelName(AdPlatformTypeEnum.getDesc(param.getAdPlatformType()));
|
|
|
+ channelMapper.insert(channel);
|
|
|
+ return Result.resultOk(RepMessage.ADD_SUCCESS);
|
|
|
}
|
|
|
}
|