|
@@ -1,11 +1,26 @@
|
|
package com.om.service.impl;
|
|
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.App;
|
|
|
|
+import com.om.entity.po.AppVersionDescribe;
|
|
|
|
+import com.om.entity.po.User;
|
|
|
|
+import com.om.entity.vo.AppVO;
|
|
|
|
+import com.om.entity.vo.DignosisPageVO;
|
|
import com.om.mapper.AppMapper;
|
|
import com.om.mapper.AppMapper;
|
|
import com.om.service.IAppService;
|
|
import com.om.service.IAppService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
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;
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 服务实现类
|
|
* 服务实现类
|
|
@@ -17,4 +32,83 @@ import org.springframework.stereotype.Service;
|
|
@Service
|
|
@Service
|
|
public class AppServiceImpl extends ServiceImpl<AppMapper, App> implements IAppService {
|
|
public class AppServiceImpl extends ServiceImpl<AppMapper, App> implements IAppService {
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ IUserService userService;
|
|
|
|
+ @Resource
|
|
|
|
+ IAppVersionDescribeService describeService;
|
|
|
|
+ @Override
|
|
|
|
+ public Result add(AppVO app) {
|
|
|
|
+ if (StringUtils.isEmpty(app.getClientNums())){
|
|
|
|
+ return Result.error();
|
|
|
|
+ }
|
|
|
|
+ //保存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
|
|
|
|
+ LambdaQueryWrapper<App> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(App::getAdmin,user.getNickName());
|
|
|
|
+ queryWrapper.eq(App::getClientNums,app.getClientNums());
|
|
|
|
+ App newApp = getOne(queryWrapper);
|
|
|
|
+ Integer id = newApp.getId();
|
|
|
|
+
|
|
|
|
+ //保存到另一个表
|
|
|
|
+ AppVersionDescribe describe = new AppVersionDescribe();
|
|
|
|
+ describe.setAppId(id);
|
|
|
|
+ describe.setDescription(app.getDescription());
|
|
|
|
+ describeService.save(describe);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return Result.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result delete(AppVO app) {
|
|
|
|
+ //删除当前表
|
|
|
|
+ int appId = app.getId();
|
|
|
|
+ this.removeById(appId);
|
|
|
|
+ //删除描述表
|
|
|
|
+ LambdaQueryWrapper<AppVersionDescribe> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(AppVersionDescribe::getAppId,appId);
|
|
|
|
+ describeService.remove(queryWrapper);
|
|
|
|
+ return Result.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result downloadFile(AppVO app) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result getPageList(DignosisPageVO dignosisPageVO) {
|
|
|
|
+
|
|
|
|
+ Page<App> page = this.lambdaQuery()
|
|
|
|
+ .like(StringUtils.isNotBlank(dignosisPageVO.getQuery()),App::getAdmin,dignosisPageVO.getQuery())
|
|
|
|
+ .page(new Page<>(dignosisPageVO.getPageIndex(),dignosisPageVO.getPageSize()));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return Result.ok(page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result edit(AppVO app) {
|
|
|
|
+
|
|
|
|
+ int appId = app.getId();
|
|
|
|
+ App newApp = this.getById(appId);
|
|
|
|
+ newApp.setClientNums(app.getClientNums());
|
|
|
|
+ this.update(newApp,null);
|
|
|
|
+
|
|
|
|
+ //此处运用单表删除
|
|
|
|
+
|
|
|
|
+ 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();
|
|
|
|
+ }
|
|
}
|
|
}
|