|
|
@@ -0,0 +1,96 @@
|
|
|
+package com.gree.mall.manager.logic.message;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.gree.mall.manager.bean.admin.AdminUserCom;
|
|
|
+import com.gree.mall.manager.bean.message.TrainingVO;
|
|
|
+import com.gree.mall.manager.commonmapper.CommonMapper;
|
|
|
+import com.gree.mall.manager.logic.common.CommonLogic;
|
|
|
+import com.gree.mall.manager.plus.entity.CommonFile;
|
|
|
+import com.gree.mall.manager.plus.entity.Training;
|
|
|
+import com.gree.mall.manager.plus.service.CommonFileService;
|
|
|
+import com.gree.mall.manager.plus.service.TrainingService;
|
|
|
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
|
|
|
+import com.gree.mall.manager.zfire.util.FieldUtils;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class TrainingLogic {
|
|
|
+
|
|
|
+ private final CommonMapper commonMapper;
|
|
|
+ private final CommonLogic commonLogic;
|
|
|
+ private final TrainingService trainingService;
|
|
|
+ private final CommonFileService commonFileService;
|
|
|
+
|
|
|
+ public IPage<TrainingVO> list(ZfireParamBean zfireParamBean) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+ FieldUtils.supplyParam(zfireParamBean, TrainingVO.class, adminUser);
|
|
|
+
|
|
|
+ IPage<TrainingVO> page = commonMapper.trainingPage(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ public TrainingBean detail(String id) {
|
|
|
+ TrainingBean trainingBean = new TrainingBean();
|
|
|
+ final Training training = trainingService.getById(id);
|
|
|
+ BeanUtils.copyProperties(training, trainingBean);
|
|
|
+ final CommonFile commonFile = commonFileService.getById(training.getObjId());
|
|
|
+ trainingBean.setCommonFile(commonFile);
|
|
|
+
|
|
|
+ return trainingBean;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void save(TrainingBean trainingBean) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+ if (adminUser.getType() == 2) {
|
|
|
+ trainingBean.setCompanyWechatId("0");
|
|
|
+ } else {
|
|
|
+ trainingBean.setCompanyWechatId(adminUser.getCompanyWechatId());
|
|
|
+ trainingBean.setCompanyName(adminUser.getCompanyName());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(trainingBean.getId())) {
|
|
|
+ trainingBean.setId(IdWorker.getIdStr());
|
|
|
+ }
|
|
|
+
|
|
|
+ Training training = new Training();
|
|
|
+ BeanUtils.copyProperties(trainingBean, training);
|
|
|
+
|
|
|
+ CommonFile commonFile = trainingBean.getCommonFile();
|
|
|
+ if (StringUtils.isBlank(commonFile.getId())) {
|
|
|
+ commonFile.setId(IdWorker.getIdStr());
|
|
|
+ commonFileService.lambdaUpdate()
|
|
|
+ .eq(CommonFile::getObjId, training.getId())
|
|
|
+ .eq(CommonFile::getObjType, "TRAINING")
|
|
|
+ .remove();
|
|
|
+ }
|
|
|
+
|
|
|
+ commonFile.setObjType("TRAINING");
|
|
|
+ commonFile.setObjId(training.getId());
|
|
|
+
|
|
|
+ // 文件库id注入
|
|
|
+ training.setObjId(commonFile.getId());
|
|
|
+
|
|
|
+
|
|
|
+ training.insertOrUpdate();
|
|
|
+ commonFile.insertOrUpdate();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void del(String id) {
|
|
|
+ trainingService.removeById(id);
|
|
|
+ commonFileService.lambdaUpdate()
|
|
|
+ .eq(CommonFile::getObjId, id)
|
|
|
+ .eq(CommonFile::getObjType, "TRAINING")
|
|
|
+ .remove();
|
|
|
+ }
|
|
|
+}
|