Commit 4aed6792 by 梅存智

管理端活动服务需求优化

parent 4d956ae6
package com.yizhi.training.application.vo.domain; package com.yizhi.training.application.vo.domain;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.yizhi.training.application.vo.api.TrainingProjectDetailsImageVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/** /**
* <p> * <p>
* 培训项目主体表(报名、签到 是在报名签到表中记录项目id,论坛是单独的关系表) * 培训项目主体表(报名、签到 是在报名签到表中记录项目id,论坛是单独的关系表)
...@@ -130,6 +132,51 @@ public class TrainingProjectSaveVo extends Model<TrainingProjectSaveVo> { ...@@ -130,6 +132,51 @@ public class TrainingProjectSaveVo extends Model<TrainingProjectSaveVo> {
@ApiModelProperty(value = "权重") @ApiModelProperty(value = "权重")
private Integer weight; private Integer weight;
@ApiModelProperty(value = "活动类型的ID,从site_dic获取(当业务类型是1时是这些枚举值)")
private Integer activityType;
@ApiModelProperty(value = "业务类型:1活动服务;2培训测试")
private Integer bizType;
@ApiModelProperty(value = "活动CODE")
private String activityCode;
@ApiModelProperty(value = "副标题")
private String subtitle;
@ApiModelProperty(value = "图片来源")
private String pictureSource;
@ApiModelProperty(value = "活动地址")
private String activityAddress;
@ApiModelProperty(value = "组织方")
private String organizer;
@ApiModelProperty(value = "协办方")
private String coOrganizer;
@ApiModelProperty(value = "温馨提示")
private String tips;
@ApiModelProperty(value = "其它提示")
private String other;
@ApiModelProperty(value = "是否置顶:false否;true是")
private Boolean topUp;
@ApiModelProperty(value = "关联投票ID")
private Long researchId;
@ApiModelProperty(value = "上传视频地址")
private String videoUrl;
@ApiModelProperty(value = "活动奖励")
private String activityReward;
@ApiModelProperty(value = "上传图片")
private List<TrainingProjectDetailsImageVO> detailsImage;
@Override @Override
protected Serializable pkVal() { protected Serializable pkVal() {
......
package com.yizhi.training.application.vo.domain; package com.yizhi.training.application.vo.domain;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotations.TableField;
import com.fasterxml.jackson.annotation.JsonFormat; import com.yizhi.training.application.vo.api.TrainingProjectDetailsImageVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/** /**
* <p> * <p>
* 培训项目主体表(报名、签到 是在报名签到表中记录项目id,论坛是单独的关系表) * 培训项目主体表(报名、签到 是在报名签到表中记录项目id,论坛是单独的关系表)
...@@ -156,12 +157,51 @@ public class TrainingProjectVo extends Model<TrainingProjectVo> { ...@@ -156,12 +157,51 @@ public class TrainingProjectVo extends Model<TrainingProjectVo> {
@ApiModelProperty(value = "签到结束时间") @ApiModelProperty(value = "签到结束时间")
private Date signEndTime; private Date signEndTime;
@ApiModelProperty(value = "活动类型CODE") @ApiModelProperty(value = "活动类型的ID,从site_dic获取(当业务类型是1时是这些枚举值)")
private Integer activityType; private Integer activityType;
@ApiModelProperty(value = "业务类型:1活动服务;2培训测试") @ApiModelProperty(value = "业务类型:1活动服务;2培训测试")
private Integer bizType; private Integer bizType;
@ApiModelProperty(value = "活动CODE")
private String activityCode;
@ApiModelProperty(value = "副标题")
private String subtitle;
@ApiModelProperty(value = "图片来源")
private String pictureSource;
@ApiModelProperty(value = "活动地址")
private String activityAddress;
@ApiModelProperty(value = "组织方")
private String organizer;
@ApiModelProperty(value = "协办方")
private String coOrganizer;
@ApiModelProperty(value = "温馨提示")
private String tips;
@ApiModelProperty(value = "其它提示")
private String other;
@ApiModelProperty(value = "是否置顶:false否;true是")
private Boolean topUp;
@ApiModelProperty(value = "关联投票ID")
private Long researchId;
@ApiModelProperty(value = "上传视频地址")
private String videoUrl;
@ApiModelProperty(value = "活动奖励")
private String activityReward;
@ApiModelProperty(value = "上传图片")
private List<TrainingProjectDetailsImageVO> detailsImage;
@Override @Override
protected Serializable pkVal() { protected Serializable pkVal() {
return this.id; return this.id;
......
...@@ -23,6 +23,7 @@ import com.yizhi.training.application.job.Process2PlatTrainingProject; ...@@ -23,6 +23,7 @@ import com.yizhi.training.application.job.Process2PlatTrainingProject;
import com.yizhi.training.application.job.ProcessFinishedRecordCacheJob; import com.yizhi.training.application.job.ProcessFinishedRecordCacheJob;
import com.yizhi.training.application.mapper.TpPlanMapper; import com.yizhi.training.application.mapper.TpPlanMapper;
import com.yizhi.training.application.mapper.TpViewRecordMapper; import com.yizhi.training.application.mapper.TpViewRecordMapper;
import com.yizhi.training.application.mapper.TrainingProjectDetailsImageMapper;
import com.yizhi.training.application.model.BaseModel; import com.yizhi.training.application.model.BaseModel;
import com.yizhi.training.application.param.PaidTrainingProjectQO; import com.yizhi.training.application.param.PaidTrainingProjectQO;
import com.yizhi.training.application.param.TrainingProjectParam; import com.yizhi.training.application.param.TrainingProjectParam;
...@@ -94,6 +95,9 @@ public class TrainingProjectController { ...@@ -94,6 +95,9 @@ public class TrainingProjectController {
public static String VISIBLE_RANGE_KEY = "tp:visible:rangee"; public static String VISIBLE_RANGE_KEY = "tp:visible:rangee";
@Autowired @Autowired
private RedisDistributedLock redisDistributedLock; private RedisDistributedLock redisDistributedLock;
@Autowired
private TrainingProjectDetailsImageMapper trainingProjectDetailsImageMapper;
@GetMapping(value = "/list") @GetMapping(value = "/list")
public Page<TrainingProject> list(@RequestBody SearchProjectVo searchProjectVo) { public Page<TrainingProject> list(@RequestBody SearchProjectVo searchProjectVo) {
...@@ -505,7 +509,12 @@ public class TrainingProjectController { ...@@ -505,7 +509,12 @@ public class TrainingProjectController {
*/ */
@GetMapping("/one/get") @GetMapping("/one/get")
public TrainingProject getOne(@RequestParam("id") Long id) { public TrainingProject getOne(@RequestParam("id") Long id) {
return trainingProjectService.selectById(id); TrainingProject trainingProject = trainingProjectService.selectById(id);
if(trainingProject != null){
List<TrainingProjectDetailsImageVO> detailsImage = trainingProjectDetailsImageMapper.selectTrainingProjectDetailsImage(id);
trainingProject.setDetailsImage(detailsImage);
}
return trainingProject;
} }
/** /**
......
package com.yizhi.training.application.domain; package com.yizhi.training.application.domain;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill; import com.baomidou.mybatisplus.enums.FieldFill;
import com.yizhi.training.application.vo.api.TrainingProjectDetailsImageVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/** /**
* <p> * <p>
* 培训项目主体表(报名、签到 是在报名签到表中记录项目id,论坛是单独的关系表) * 培训项目主体表(报名、签到 是在报名签到表中记录项目id,论坛是单独的关系表)
...@@ -168,7 +170,7 @@ public class TrainingProject extends Model<TrainingProject> { ...@@ -168,7 +170,7 @@ public class TrainingProject extends Model<TrainingProject> {
@ApiModelProperty(value = "副标题") @ApiModelProperty(value = "副标题")
private String subtitle; private String subtitle;
@ApiModelProperty(value = "活动类型:1支部主题党日;2特色活动;3献计献策;4其他(当业务类型是1时是这些枚举值)") @ApiModelProperty(value = "活动类型的ID,从site_dic获取(当业务类型是1时是这些枚举值)")
private String activityType; private String activityType;
@ApiModelProperty(value = "图片来源") @ApiModelProperty(value = "图片来源")
...@@ -198,6 +200,13 @@ public class TrainingProject extends Model<TrainingProject> { ...@@ -198,6 +200,13 @@ public class TrainingProject extends Model<TrainingProject> {
@ApiModelProperty(value = "视频地址") @ApiModelProperty(value = "视频地址")
private String videoUrl; private String videoUrl;
@ApiModelProperty(value = "活动奖励")
private String activityReward;
@ApiModelProperty(value = "上传图片")
@TableField(exist = false)
private List<TrainingProjectDetailsImageVO> detailsImage;
@Override @Override
protected Serializable pkVal() { protected Serializable pkVal() {
return this.id; return this.id;
......
package com.yizhi.training.application.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.training.application.domain.TrainingProjectDetailsImage;
import com.yizhi.training.application.vo.api.TrainingProjectDetailsImageVO;
/**
* <p>
* 培训项目 - 详情图片 Mapper 接口
* </p>
*
* @author shengchenglong
* @since 2018-03-27
*/
public interface TrainingProjectDetailsImageMapper extends BaseMapper<TrainingProjectDetailsImage> {
/**
* 获取最大Sort
* @param trainingId
* @return
*/
Integer selectMaxSort(@Param("projectId") Long projectId);
/**
* 获取项目关联图片
* @param projectId
* @return
*/
List<TrainingProjectDetailsImageVO> selectTrainingProjectDetailsImage(@Param("projectId") Long projectId);
/**
* 删除项目关联图片
* @param id
* @param updateById
* @param updateByName
* @return
*/
Integer deleImg(@Param("id") Long id, @Param("updateById") Long updateById, @Param("updateByName") String updateByName);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yizhi.training.application.mapper.TrainingProjectDetailsImageMapper">
<select id="selectMaxSort" resultType="java.lang.Integer">
SELECT MAX(sort) AS sort
FROM training_project_details_image
WHERE training_id=#{projectId} AND deleted=0
</select>
<select id="selectTrainingProjectDetailsImage" resultType="com.yizhi.training.application.vo.api.TrainingProjectDetailsImageVO">
SELECT id,training_id,img,sort
FROM training_project_details_image
WHERE training_id=#{projectId} AND deleted=0
</select>
<update id="deleImg">
UPDATE training_project_details_image
SET deleted=1, update_by_id=#{updateById},update_by_name=#{updateByName},update_time=NOW()
WHERE id=#{id}
</update>
</mapper>
...@@ -50,6 +50,7 @@ import com.yizhi.training.application.domain.TpStudentEnrollPassed; ...@@ -50,6 +50,7 @@ import com.yizhi.training.application.domain.TpStudentEnrollPassed;
import com.yizhi.training.application.domain.TpStudentProjectRecord; import com.yizhi.training.application.domain.TpStudentProjectRecord;
import com.yizhi.training.application.domain.TpViewRecord; import com.yizhi.training.application.domain.TpViewRecord;
import com.yizhi.training.application.domain.TrainingProject; import com.yizhi.training.application.domain.TrainingProject;
import com.yizhi.training.application.domain.TrainingProjectDetailsImage;
import com.yizhi.training.application.enums.TrEnrollStatusEnum; import com.yizhi.training.application.enums.TrEnrollStatusEnum;
import com.yizhi.training.application.mapper.TpAuthorizationRangeMapper; import com.yizhi.training.application.mapper.TpAuthorizationRangeMapper;
import com.yizhi.training.application.mapper.TpPlanActivityConditionPostMapper; import com.yizhi.training.application.mapper.TpPlanActivityConditionPostMapper;
...@@ -64,6 +65,7 @@ import com.yizhi.training.application.mapper.TpStudentActivityRecordMapper; ...@@ -64,6 +65,7 @@ import com.yizhi.training.application.mapper.TpStudentActivityRecordMapper;
import com.yizhi.training.application.mapper.TpStudentEnrollPassedMapper; import com.yizhi.training.application.mapper.TpStudentEnrollPassedMapper;
import com.yizhi.training.application.mapper.TpStudentProjectRecordMapper; import com.yizhi.training.application.mapper.TpStudentProjectRecordMapper;
import com.yizhi.training.application.mapper.TpViewRecordMapper; import com.yizhi.training.application.mapper.TpViewRecordMapper;
import com.yizhi.training.application.mapper.TrainingProjectDetailsImageMapper;
import com.yizhi.training.application.mapper.TrainingProjectMapper; import com.yizhi.training.application.mapper.TrainingProjectMapper;
import com.yizhi.training.application.model.BaseModel; import com.yizhi.training.application.model.BaseModel;
import com.yizhi.training.application.param.PaidTrainingProjectQO; import com.yizhi.training.application.param.PaidTrainingProjectQO;
...@@ -171,6 +173,9 @@ public class TrainingProjectServiceImpl extends ServiceImpl<TrainingProjectMappe ...@@ -171,6 +173,9 @@ public class TrainingProjectServiceImpl extends ServiceImpl<TrainingProjectMappe
@Autowired @Autowired
ResearchClient researchClient; ResearchClient researchClient;
@Autowired
private TrainingProjectDetailsImageMapper trainingProjectDetailsImageMapper;
private static final String ACTIVITY_KEY = "activity"; private static final String ACTIVITY_KEY = "activity";
private static final String REDIS_PRO_ACTIVITY_TYPE_KEY = "REDIS_PRO_ACTIVITY_TYPE"; private static final String REDIS_PRO_ACTIVITY_TYPE_KEY = "REDIS_PRO_ACTIVITY_TYPE";
...@@ -220,6 +225,27 @@ public class TrainingProjectServiceImpl extends ServiceImpl<TrainingProjectMappe ...@@ -220,6 +225,27 @@ public class TrainingProjectServiceImpl extends ServiceImpl<TrainingProjectMappe
public TrainingProject save(TrainingProject trainingProject) { public TrainingProject save(TrainingProject trainingProject) {
trainingProject.setId(idGenerator.generate()); trainingProject.setId(idGenerator.generate());
trainingProjectMapper.insert(trainingProject); trainingProjectMapper.insert(trainingProject);
//保存项目图片
if (!CollectionUtils.isEmpty(trainingProject.getDetailsImage())) {
TrainingProjectDetailsImage saveImg = new TrainingProjectDetailsImage();
int sort = 0;
for(TrainingProjectDetailsImageVO item : trainingProject.getDetailsImage()){
item.setId(idGenerator.generate());
item.setTrainingId(trainingProject.getId());
item.setCreateById(trainingProject.getCreateById());
item.setCreateByName(trainingProject.getCreateByName());
item.setCreateTime(trainingProject.getCreateTime());
item.setUpdateById(trainingProject.getCreateById());
item.setUpdateByName(trainingProject.getCreateByName());
item.setUpdateTime(trainingProject.getCreateTime());
item.setSort(++sort);
BeanUtils.copyProperties(item, saveImg);
trainingProjectDetailsImageMapper.insert(saveImg);
}
}
return trainingProject; return trainingProject;
} }
...@@ -243,7 +269,63 @@ public class TrainingProjectServiceImpl extends ServiceImpl<TrainingProjectMappe ...@@ -243,7 +269,63 @@ public class TrainingProjectServiceImpl extends ServiceImpl<TrainingProjectMappe
LOGGER.info("删除项目报名结果;1成功;-1失败: projectId = {} , result = {}",trainingProject,result); LOGGER.info("删除项目报名结果;1成功;-1失败: projectId = {} , result = {}",trainingProject,result);
} }
} }
return trainingProjectMapper.selectById(trainingProject.getId());
//保存项目图片
if (!CollectionUtils.isEmpty(trainingProject.getDetailsImage())) {
TrainingProjectDetailsImage saveImg = new TrainingProjectDetailsImage();
Integer sort = trainingProjectDetailsImageMapper.selectMaxSort(trainingProject.getId());
for(TrainingProjectDetailsImageVO item : trainingProject.getDetailsImage()){
if(item.getId() == null){
item.setId(idGenerator.generate());
item.setTrainingId(trainingProject.getId());
item.setCreateById(trainingProject.getUpdateById());
item.setCreateByName(trainingProject.getUpdateByName());
item.setCreateTime(trainingProject.getUpdateTime());
}
item.setUpdateById(trainingProject.getUpdateById());
item.setUpdateByName(trainingProject.getUpdateByName());
item.setUpdateTime(trainingProject.getUpdateTime());
item.setSort(++sort);
BeanUtils.copyProperties(item, saveImg);
trainingProjectDetailsImageMapper.insert(saveImg);
}
//删除不存在的项目图片
RequestContext context = ContextHolder.get();
List<TrainingProjectDetailsImageVO> oldImgs = trainingProjectDetailsImageMapper.selectTrainingProjectDetailsImage(trainingProject.getId());
if (!CollectionUtils.isEmpty(oldImgs)) {
boolean isDel = true;
for(TrainingProjectDetailsImageVO oldItem : oldImgs){
isDel = true;
for(TrainingProjectDetailsImageVO item : trainingProject.getDetailsImage()){
if(oldItem.getId().equals(item.getId())){
isDel = false;
break;
}
}
if(isDel){
trainingProjectDetailsImageMapper.deleImg(oldItem.getId(), context.getAccountId(), context.getAccountName());
}
}
}
} else {
//删除不存在的项目图片
RequestContext context = ContextHolder.get();
List<TrainingProjectDetailsImageVO> oldImgs = trainingProjectDetailsImageMapper.selectTrainingProjectDetailsImage(trainingProject.getId());
if (!CollectionUtils.isEmpty(oldImgs)) {
for(TrainingProjectDetailsImageVO oldItem : oldImgs){
trainingProjectDetailsImageMapper.deleImg(oldItem.getId(), context.getAccountId(), context.getAccountName());
}
}
}
TrainingProject project = trainingProjectMapper.selectById(trainingProject.getId());
project.setDetailsImage(trainingProject.getDetailsImage());
return project;
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment