|
@@ -3,16 +3,13 @@ package com.om.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.om.entity.po.App;
|
|
|
-import com.om.entity.po.AppVersionDescribe;
|
|
|
-import com.om.entity.po.User;
|
|
|
+import com.om.entity.po.*;
|
|
|
import com.om.entity.vo.AppVO;
|
|
|
import com.om.entity.vo.DignosisPageVO;
|
|
|
+import com.om.entity.vo.PcbInfoVO;
|
|
|
import com.om.mapper.AppMapper;
|
|
|
-import com.om.service.IAppService;
|
|
|
+import com.om.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.om.service.IAppVersionDescribeService;
|
|
|
-import com.om.service.IUserService;
|
|
|
import com.om.utils.CommonUtil;
|
|
|
import com.om.utils.Result;
|
|
|
import com.om.utils.UserContext;
|
|
@@ -20,6 +17,8 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -36,41 +35,49 @@ public class AppServiceImpl extends ServiceImpl<AppMapper, App> implements IAppS
|
|
|
private IUserService userService;
|
|
|
@Resource
|
|
|
private IAppVersionDescribeService describeService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IAppsClientsService clientsService;
|
|
|
+
|
|
|
@Override
|
|
|
- public Result add(AppVO app) {
|
|
|
- if (StringUtils.isEmpty(app.getClientNums())){
|
|
|
- return Result.error();
|
|
|
+ public Result add(AppVO appVO) {
|
|
|
+ App app = new App();
|
|
|
+ BeanUtil.copyProperties(appVO,app);
|
|
|
+ this.save(app);
|
|
|
+ Integer appId = app.getId();
|
|
|
+
|
|
|
+ //appClient
|
|
|
+ for (int i = 0; i < appVO.getClientNums().length; i++) {
|
|
|
+
|
|
|
+ AppsClients appsClients = new AppsClients();
|
|
|
+ appsClients.setAppId(appId);
|
|
|
+ appsClients.setClientNum(appVO.getClientNums()[i]);
|
|
|
+ clientsService.save(appsClients);
|
|
|
}
|
|
|
- //保存app表
|
|
|
- App appSave = new App();
|
|
|
- appSave.setClientNums(app.getClientNums());
|
|
|
- appSave.setVersionNum(CommonUtil.appVersion(null));
|
|
|
- User user = userService.getById(UserContext.getUserId());
|
|
|
- appSave.setAdmin(user.getNickName());
|
|
|
- this.save(appSave);
|
|
|
- //获取保存表的id
|
|
|
-
|
|
|
- Integer id = appSave.getId();
|
|
|
|
|
|
- //保存到另一个表
|
|
|
- AppVersionDescribe describe = new AppVersionDescribe();
|
|
|
- describe.setAppId(id);
|
|
|
- describe.setDescription(app.getDescription());
|
|
|
- describeService.save(describe);
|
|
|
|
|
|
+ for (int i = 0; i < appVO.getLanguage().length; i++) {
|
|
|
|
|
|
- return Result.ok();
|
|
|
+ AppVersionDescribe describe = new AppVersionDescribe();
|
|
|
+ describe.setAppId(appId);
|
|
|
+ describe.setLanguage(appVO.getLanguage()[i]);
|
|
|
+ describe.setDescription(appVO.getDescription()[i]);
|
|
|
+ describeService.save(describe);
|
|
|
+ }
|
|
|
+ return Result.ok();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result delete(AppVO app) {
|
|
|
- //删除当前表
|
|
|
- int appId = app.getId();
|
|
|
- this.removeById(appId);
|
|
|
- //删除描述表
|
|
|
+ public Result delete(Integer id) {
|
|
|
+
|
|
|
+ removeById(id);
|
|
|
LambdaQueryWrapper<AppVersionDescribe> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(AppVersionDescribe::getAppId,appId);
|
|
|
- describeService.remove(queryWrapper);
|
|
|
+ queryWrapper.eq(AppVersionDescribe::getAppId,id);
|
|
|
+ boolean info = describeService.remove(queryWrapper);
|
|
|
+ //还有关联表删除
|
|
|
+ LambdaQueryWrapper<AppsClients> clientsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ clientsLambdaQueryWrapper.eq(AppsClients::getAppId,id);
|
|
|
+ clientsService.remove(clientsLambdaQueryWrapper);
|
|
|
return Result.ok();
|
|
|
}
|
|
|
|
|
@@ -80,30 +87,77 @@ public class AppServiceImpl extends ServiceImpl<AppMapper, App> implements IAppS
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result getPageList(DignosisPageVO dignosisPageVO) {
|
|
|
-
|
|
|
+ public Result getPageList(Integer pageIndex, Integer pageSize, String username) {
|
|
|
Page<App> page = this.lambdaQuery()
|
|
|
- .like(StringUtils.isNotBlank(dignosisPageVO.getQuery()),App::getAdmin,dignosisPageVO.getQuery())
|
|
|
- .page(new Page<>(dignosisPageVO.getPageIndex(),dignosisPageVO.getPageSize()));
|
|
|
+ .like(StringUtils.isNotBlank(username), App::getAdmin, username)
|
|
|
+ .page(new Page<>(pageIndex, pageSize));
|
|
|
+ List<App> infoList = page.getRecords();
|
|
|
+
|
|
|
+ //返回的List集合
|
|
|
+ List<AppVO> appInfoVOS = new ArrayList<>();
|
|
|
+ for (int i = 0; i < infoList.size(); i++) {
|
|
|
+ //传输的类型
|
|
|
+ AppVO appVO = new AppVO();
|
|
|
+
|
|
|
+ App appInfo = infoList.get(i);
|
|
|
+ //先copy基本数据
|
|
|
+ BeanUtil.copyProperties(appInfo,appVO);
|
|
|
+
|
|
|
+ Integer id = appInfo.getId();
|
|
|
+ //先取语言和描述信息
|
|
|
+ LambdaQueryWrapper<AppVersionDescribe> describeQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ describeQueryWrapper.eq(AppVersionDescribe::getAppId,id);
|
|
|
+ List<AppVersionDescribe> describeList = describeService.list(describeQueryWrapper);
|
|
|
+ //把取出来的数据存入俩个字符串中
|
|
|
+ String [] l = new String[describeList.size()];
|
|
|
+ String [] d = new String[describeList.size()];
|
|
|
+
|
|
|
+ for (int i1 = 0; i1 < describeList.size(); i1++) {
|
|
|
+ l[i1] = describeList.get(i1).getLanguage();
|
|
|
+ d[i1] = describeList.get(i1).getDescription();
|
|
|
+ }
|
|
|
+ appVO.setDescription(d);
|
|
|
+ appVO.setLanguage(l);
|
|
|
+
|
|
|
+ //在取出来客户端编号
|
|
|
+ LambdaQueryWrapper<AppsClients> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(AppsClients::getAppId,id);
|
|
|
+ List<AppsClients> list = clientsService.list(queryWrapper);
|
|
|
+ String [] n = new String[list.size()];
|
|
|
+ for (int j = 0; j < n.length; j++) {
|
|
|
+ n[j] = list.get(j).getClientNum();
|
|
|
+ }
|
|
|
+ appVO.setClientNums(n);
|
|
|
+ appInfoVOS.add(appVO);
|
|
|
+ }
|
|
|
|
|
|
+ Page<AppVO> appVOPage = new Page<>();
|
|
|
+ BeanUtil.copyProperties(page,appVOPage);
|
|
|
+ appVOPage.setRecords(appInfoVOS);
|
|
|
|
|
|
- return Result.ok(page);
|
|
|
+ return Result.ok(appVOPage);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result edit(AppVO app) {
|
|
|
-
|
|
|
- int appId = app.getId();
|
|
|
- App newApp = this.getById(appId);
|
|
|
- newApp.setClientNums(app.getClientNums());
|
|
|
- this.update(newApp,null);
|
|
|
+ public Result edit(AppVO appVO) {
|
|
|
+ App app = getById(appVO.getId());
|
|
|
+ LambdaQueryWrapper<App> infoQueryWapper = new LambdaQueryWrapper<>();
|
|
|
+ infoQueryWapper.eq(App::getId,app.getId());
|
|
|
+ BeanUtil.copyProperties(appVO,app);
|
|
|
+ this.update(app,infoQueryWapper);
|
|
|
+
|
|
|
+ //修改客户端id
|
|
|
+ String[] clientNum = appVO.getClientNums();
|
|
|
+ LambdaQueryWrapper<AppsClients> clientQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ clientQueryWrapper.eq(AppsClients::getAppId,appVO.getId());
|
|
|
+ clientsService.remove(clientQueryWrapper);
|
|
|
+ for (int i = 0; i < clientNum.length; i++) {
|
|
|
+ AppsClients clients = new AppsClients();
|
|
|
+ clients.setAppId(appVO.getId());
|
|
|
+ clients.setClientNum(clientNum[i]);
|
|
|
+ }
|
|
|
|
|
|
- //此处运用单表删
|
|
|
- LambdaQueryWrapper<AppVersionDescribe> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(AppVersionDescribe::getAppId,appId);
|
|
|
- AppVersionDescribe one = describeService.getOne(queryWrapper);
|
|
|
- one.setDescription(app.getDescription());
|
|
|
- describeService.update(one,null);
|
|
|
+ //没有进行描述和语言进行修改
|
|
|
|
|
|
return Result.ok();
|
|
|
}
|