|
@@ -1,29 +1,29 @@
|
|
|
package com.ytpm.service.impl;
|
|
package com.ytpm.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.hutool.core.util.IdUtil;
|
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
-import com.ytpm.advertise.enums.AdPlatformTypeEnum;
|
|
|
|
|
import com.ytpm.advertise.param.AddAppParam;
|
|
import com.ytpm.advertise.param.AddAppParam;
|
|
|
|
|
+import com.ytpm.advertise.param.RelativeChannelParam;
|
|
|
import com.ytpm.advertise.view.AddAppResponse;
|
|
import com.ytpm.advertise.view.AddAppResponse;
|
|
|
import com.ytpm.agent.model.YtApp;
|
|
import com.ytpm.agent.model.YtApp;
|
|
|
-import com.ytpm.agent.model.YtChannel;
|
|
|
|
|
|
|
+import com.ytpm.agent.param.AppListParam;
|
|
|
import com.ytpm.agent.param.AppParam;
|
|
import com.ytpm.agent.param.AppParam;
|
|
|
-import com.ytpm.agent.param.ChannelParam;
|
|
|
|
|
|
|
+import com.ytpm.agent.view.AgentAppView;
|
|
|
import com.ytpm.agent.view.AgentEnableAppView;
|
|
import com.ytpm.agent.view.AgentEnableAppView;
|
|
|
-import com.ytpm.app.view.YtAppListView;
|
|
|
|
|
import com.ytpm.dao.AgentAppMapper;
|
|
import com.ytpm.dao.AgentAppMapper;
|
|
|
import com.ytpm.dao.AppMapper;
|
|
import com.ytpm.dao.AppMapper;
|
|
|
-import com.ytpm.dao.ChannelMapper;
|
|
|
|
|
import com.ytpm.feign.AdvertiseFeign;
|
|
import com.ytpm.feign.AdvertiseFeign;
|
|
|
import com.ytpm.general.RepMessage;
|
|
import com.ytpm.general.RepMessage;
|
|
|
import com.ytpm.general.Result;
|
|
import com.ytpm.general.Result;
|
|
|
import com.ytpm.general.ResultTable;
|
|
import com.ytpm.general.ResultTable;
|
|
|
import com.ytpm.service.AgentAppService;
|
|
import com.ytpm.service.AgentAppService;
|
|
|
-import org.checkerframework.checker.units.qual.A;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
public class AgentAppServiceImpl implements AgentAppService {
|
|
public class AgentAppServiceImpl implements AgentAppService {
|
|
@@ -34,8 +34,6 @@ public class AgentAppServiceImpl implements AgentAppService {
|
|
|
private AdvertiseFeign advertiseFeign;
|
|
private AdvertiseFeign advertiseFeign;
|
|
|
@Resource
|
|
@Resource
|
|
|
private AppMapper appMapper;
|
|
private AppMapper appMapper;
|
|
|
- @Resource
|
|
|
|
|
- private ChannelMapper channelMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询渠道启用的应用列表
|
|
* 查询渠道启用的应用列表
|
|
@@ -50,45 +48,75 @@ public class AgentAppServiceImpl implements AgentAppService {
|
|
|
* 查询应用列表
|
|
* 查询应用列表
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public ResultTable<YtAppListView> searchAppList() {
|
|
|
|
|
- return ResultTable.resultTableOk(new PageInfo<>(agentAppMapper.searchAppList()));
|
|
|
|
|
|
|
+ public ResultTable<AgentAppView> searchAppList(AppListParam appListParam) {
|
|
|
|
|
+ PageHelper.startPage(appListParam.getPage(), appListParam.getLimit());
|
|
|
|
|
+ return ResultTable.resultTableOk(new PageInfo<>(agentAppMapper.searchAppList(appListParam)));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 新增应用
|
|
* 新增应用
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public Result<?> addApp(AppParam param, String userId) {
|
|
|
|
|
|
|
+ public Result<?> saveApp(AppParam param, String userId) {
|
|
|
|
|
+ //构造API对象
|
|
|
|
|
+ AddAppParam addAppParam = new AddAppParam(param);
|
|
|
//调用广告平台API 增加应用
|
|
//调用广告平台API 增加应用
|
|
|
- Result<AddAppResponse> result = advertiseFeign.addApp(param);
|
|
|
|
|
- //数据库存储应用信息
|
|
|
|
|
- AddAppResponse data = result.getData();
|
|
|
|
|
|
|
+ Result<AddAppResponse> result = advertiseFeign.saveApp(addAppParam);
|
|
|
|
|
+ //数据库操作,有appId为修改, 没有时为新增
|
|
|
|
|
+ changeDataAction(param,result,userId);
|
|
|
|
|
+ return Result.resultOk(RepMessage.SAVE_SUCCESS);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理数据库数据变更操作
|
|
|
|
|
+ */
|
|
|
|
|
+ private void changeDataAction(AppParam param, Result<AddAppResponse> result, String userId) {
|
|
|
YtApp app = new YtApp();
|
|
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);
|
|
|
|
|
|
|
+ BeanUtil.copyProperties(param, app);
|
|
|
|
|
+ if(StrUtil.isNotBlank(param.getAppId())){
|
|
|
|
|
+ appMapper.updateOne(app);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ AddAppResponse data = result.getData();
|
|
|
|
|
+ BeanUtil.copyProperties(param, app);
|
|
|
|
|
+ app.setAppId(data.getUuid());
|
|
|
|
|
+ app.setAppKey(data.getApp_key());
|
|
|
|
|
+ app.setUserId(userId);
|
|
|
|
|
+ app.setEnabled(1);
|
|
|
|
|
+ appMapper.insertOne(app);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 新增广告渠道
|
|
|
|
|
|
|
+ * 删除应用
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@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);
|
|
|
|
|
|
|
+ public Result<?> delApp(String appId, String userId) {
|
|
|
|
|
+ YtApp ytApp = appMapper.selectPrimary(appId);
|
|
|
|
|
+ if(Objects.isNull(ytApp)|| !userId.equals(ytApp.getUserId())){
|
|
|
|
|
+ Result.resultErr(RepMessage.NOT_PERMIT);
|
|
|
|
|
+ }
|
|
|
|
|
+ advertiseFeign.delApp(appId);
|
|
|
|
|
+ appMapper.deleteApp(appId);
|
|
|
|
|
+ return Result.resultOk(RepMessage.DELETE_SUCCESS);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 应用关联广告平台 & 广告平台应用
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Result<?> relativeChannel(RelativeChannelParam param) {
|
|
|
|
|
+ //根据应用ID查询应用信息
|
|
|
|
|
+ YtApp ytApp = appMapper.selectPrimary(param.getAppId());
|
|
|
|
|
+ if(Objects.isNull(ytApp)){
|
|
|
|
|
+ Result.resultErr(RepMessage.OBJECT_NOT_EXIST);
|
|
|
|
|
+ }
|
|
|
|
|
+ advertiseFeign.relativePlatform(param);
|
|
|
|
|
+ YtApp app = new YtApp();
|
|
|
|
|
+ app.setAppId(param.getAppId());
|
|
|
|
|
+ app.setChannelId(param.getChannelId());
|
|
|
|
|
+ app.setChannelName(param.getChannelName());
|
|
|
|
|
+ app.setNetworkAppId(param.getNetworkAppId());
|
|
|
|
|
+ appMapper.updateOne(app);
|
|
|
|
|
+ return Result.resultOk(RepMessage.RELATIVE_SUCCESS);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|