Authored by wangshusheng

Merge branch 'test6.8.5' into gray

Conflicts:
	pom.xml
... ... @@ -32,7 +32,7 @@ public final class ActivityTemplatedFloorDetailHelper {
private static Logger logger = LoggerFactory.getLogger(ActivityTemplatedFloorDetailHelper.class);
public static Set<Integer> paramTypeIntSet = Sets.newHashSet(TempCompParamType.number.getIntVal(),
TempCompParamType.string.getIntVal(),TempCompParamType.image.getIntVal(),TempCompParamType.date.getIntVal());
TempCompParamType.string.getIntVal(),TempCompParamType.image.getIntVal(),TempCompParamType.date.getIntVal(),TempCompParamType.text.getIntVal());
private static final Convert convert = new BeanConvert();
... ...
... ... @@ -6,6 +6,7 @@ import com.yohobuy.platform.model.common.api.BizObjName;
import com.yohobuy.platform.model.common.api.Message;
import com.yohobuy.platform.model.common.api.OperationName;
import com.yohobuy.platform.model.operations.ActivtyTemplatedBo;
import com.yohobuy.platform.model.operations.request.ActivityTemplateLinkBo;
import com.yohobuy.platform.model.operations.request.ActivityTemplatedPageBo;
import com.yohobuy.platform.operations.model.ActivtyTemplatedVo;
import com.yohobuy.platform.operations.service.impl.ActivtyTemplatedService;
... ... @@ -72,6 +73,50 @@ public class ActivtyTemplatedController extends BasicController{
}
}
/**
* 添加活动与模板的关联关系
* @param req
* @return
*/
@RequestMapping(value = "/addActivityTemplateLink")
@ResponseBody
public ApiResponse addActivityTemplateLink(@RequestBody ActivityTemplateLinkBo req){
logger.info("ActivtyTemplatedController.addActivityTemplateLink req {}",req);
if (req == null){
return handleParamIsNull();
}
try {
if (req.getTemplateId() != null){
activtyTemplatedService.upateActivityTemplateLink(req);
}else{
Integer templateId = activtyTemplatedService.addActivityTemplateLink(req);
req.setTemplateId(templateId);
}
return new ApiResponse.ApiResponseBuilder()
.code(SUCCESS)
.data(req)
.message(Message.buildApiMessage(BizObjName.ACTIVITY_TEMPLATED,
OperationName.SAVE, Message.SUCCESS))
.build();
}catch (Exception e){
logger.error("addActivityTemplateLink occur error",e);
return handleException(e);
}
}
@RequestMapping(value = "/deleteActivityTemplateLink")
@ResponseBody
public ApiResponse deleteActivityTemplateLink(@RequestBody Integer templateId){
logger.info("ActivtyTemplatedController :: deleteActivityTemplateLink templateId {}",templateId);
try {
activtyTemplatedService.deleteActivityTemplate(templateId);
}catch (Exception e){
logger.info("ActivtyTemplatedController :: deleteActivityTemplateLink error!", e);
return new ApiResponse.ApiResponseBuilder().code(500).build();
}
return new ApiResponse.ApiResponseBuilder().code(200).build();
}
@RequestMapping(value = "/getActivtyTemplated")
@ResponseBody
public ApiResponse getActivtyTemplated(@RequestParam("id") Integer id){
... ... @@ -86,6 +131,22 @@ public class ActivtyTemplatedController extends BasicController{
.build();
}
@RequestMapping(value = "/getTemplateInfoByTemplateId")
@ResponseBody
public ApiResponse getTemplateInfoByTemplateId(@RequestBody Integer templateId){
logger.info("ActivtyTemplatedController.getTemplateInfoByTemplateId templateId {}",templateId);
if (templateId == null){
return handleParamIsNull();
}
ActivtyTemplatedBo bo = activtyTemplatedService.getTemplateInfoByTemplateId(templateId);
return new ApiResponse.ApiResponseBuilder()
.code(SUCCESS)
.data(bo)
.message(Message.buildApiMessage(BizObjName.ACTIVITY_TEMPLATED,
OperationName.QUERY, Message.SUCCESS))
.build();
}
@RequestMapping(value = "/getActivtyTemplatedBaseInfo")
@ResponseBody
public ApiResponse getActivtyTemplatedBaseInfo(@RequestParam("id") Integer id){
... ... @@ -109,6 +170,7 @@ public class ActivtyTemplatedController extends BasicController{
activtyTemplatedService.update(req);
return new ApiResponse.ApiResponseBuilder()
.code(SUCCESS)
.data(req)
.message(Message.buildApiMessage(BizObjName.ACTIVITY_TEMPLATED,
OperationName.UPDATE, Message.SUCCESS))
.build();
... ...
... ... @@ -11,14 +11,8 @@ import com.yohobuy.platform.common.util.DateUtil;
import com.yohobuy.platform.common.util.IntegerUtils;
import com.yohobuy.platform.dal.cms.IWebShareDao;
import com.yohobuy.platform.dal.cms.model.WebShare;
import com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorDetailMapper;
import com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorMapper;
import com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorTableMapper;
import com.yohobuy.platform.dal.operations.ActivtyTemplatedMapper;
import com.yohobuy.platform.dal.operations.model.ActivtyTemplated;
import com.yohobuy.platform.dal.operations.model.ActivtyTemplatedFloor;
import com.yohobuy.platform.dal.operations.model.ActivtyTemplatedFloorDetail;
import com.yohobuy.platform.dal.operations.model.ActivtyTemplatedFloorTable;
import com.yohobuy.platform.dal.operations.*;
import com.yohobuy.platform.dal.operations.model.*;
import com.yohobuy.platform.model.cms.bo.WebShareBO;
import com.yohobuy.platform.model.common.CheckResult;
import com.yohobuy.platform.model.common.PageResponseVO;
... ... @@ -27,6 +21,7 @@ import com.yohobuy.platform.model.operations.consistant.ActivtyTemplatedStatus;
import com.yohobuy.platform.model.operations.consistant.FloorDetailStatus;
import com.yohobuy.platform.model.operations.consistant.LogActionType;
import com.yohobuy.platform.model.operations.consistant.TempCompParamType;
import com.yohobuy.platform.model.operations.request.ActivityTemplateLinkBo;
import com.yohobuy.platform.model.operations.request.ActivityTemplatedPageBo;
import com.yohobuy.platform.model.users.response.UserInfoResponseBO;
import com.yohobuy.platform.operations.constants.CommonStatus;
... ... @@ -84,6 +79,9 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo>
@Autowired
private ActivtyTemplatedFloorDetailMapper atfdMapper;
@Autowired
private ActivtyTemplateLinkMapper activityTemplateLinkMapper;
private static Convert convert = new BeanConvert();
@Value("${activity.url:http://activity.yoho.cn/feature/}")
... ... @@ -337,12 +335,43 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo>
return null;
}
logger.info("in getById, ActivtyTemplated id {}, title {}, status {}", id, templated.getTitle(), templated.getStatus());
List<ActivtyTemplatedFloorBo> floorBos = atfService.getByTemplatedId(templated.getId());
List<ActivtyTemplateLink> atlList = activityTemplateLinkMapper.selectActivityTemplateLinkList(id);
if (CollectionUtils.isEmpty(atlList)){
return null;
}
ActivtyTemplateLink activtyTemplateLink = getCurrentTemplateId(atlList);
List<ActivtyTemplatedFloorBo> floorBos = atfService.getByTemplatedId(activtyTemplateLink.getTemplateId());
ActivtyTemplatedBo templatedBo = ActivtyTemplatedConvert.do2Bo(templated);
templatedBo.setFloors(floorBos);
List<ActivityTemplateLinkBo> linkList = convert.convertFromList(atlList,ActivityTemplateLinkBo.class);
ActivityTemplateLinkBo atlBo = new ActivityTemplateLinkBo();
convert.convertFrom(activtyTemplateLink, atlBo, ActivityTemplateLinkBo.class);
atlBo.setShowTimeStr(DateUtil.int2DateStr(atlBo.getShowTime(),DateUtil.DATE_TIME_FORMAT));
templatedBo.setLinkList(linkList);
templatedBo.setAtLink(atlBo);
return templatedBo;
}
public ActivtyTemplateLink getCurrentTemplateId(List<ActivtyTemplateLink> atlList){
Integer currentTime = DateUtil.getCurrentTimeSeconds();
ActivtyTemplateLink atl = null;
for (ActivtyTemplateLink activtyTemplateLink : atlList){
if (null != activtyTemplateLink.getShowTime() && activtyTemplateLink.getShowTime() < currentTime){
atl = activtyTemplateLink;
break;
}
}
if (atl == null){
for (ActivtyTemplateLink activtyTemplateLink : atlList){
if (null != activtyTemplateLink.getIsDefault() && activtyTemplateLink.getIsDefault() == 1){
atl = activtyTemplateLink;
break;
}
}
}
return atl;
}
public ActivtyTemplatedBo getBaseInfoById(Integer id) {
if (!IntegerUtils.withInBizSign(id)){
... ... @@ -471,9 +500,9 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo>
activtyTemplated.setUpdateUser(this.buildOperatorInfo(bo.getUserInfoResponseBO()));
activtyTemplatedMapper.updateByPrimaryKeySelective(activtyTemplated);
//2.根据模板ID依次删除除主表外其他表的相关数据,activty_templated_floor,activty_templated_floor_detail,activty_templated_floor_table
atfMapper.deleteByTempId(bo.getId());
atftMapper.deleteByTempId(bo.getId());
atfdMapper.deleteByTempId(bo.getId());
atfMapper.deleteByTempId(bo.getTemplateId());
atftMapper.deleteByTempId(bo.getTemplateId());
atfdMapper.deleteByTempId(bo.getTemplateId());
//3.依次将相关数据插入以上相关表中
List<ActivtyTemplatedFloor> atfList = Lists.newArrayList();
... ... @@ -481,14 +510,14 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo>
for(ActivtyTemplatedFloorBo floorBo: bo.getFloors()){
//处理activty_templated_floor表数据
ActivtyTemplatedFloor atf = ActivtyTemplatedFloorConvert.bo2Do(floorBo);
atf.setActivtyTemplatedId(bo.getId());
atf.setActivtyTemplatedId(bo.getTemplateId());
//activty_templated_floor表数据入库
atfMapper.insertSelective(atf);
//处理activty_templated_floor_table表数据
if (StringUtils.isNotBlank(floorBo.getTableComp())){
ActivtyTemplatedFloorTable table = new ActivtyTemplatedFloorTable();
table.setStatus(1);
table.setActivtyTemplatedId(bo.getId());
table.setActivtyTemplatedId(bo.getTemplateId());
table.setFloorId(atf.getId());
table.setTableComp(floorBo.getTableComp());
atftList.add(table);
... ... @@ -497,14 +526,14 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo>
floorBo.setId(atf.getId());
List<ActivtyTemplatedFloorDetail> atfdp = Lists.newArrayList();
if (CollectionUtils.isNotEmpty(floorBo.getParams())) {
atfdp = ActivityTemplatedFloorDetailHelper.buildDetailsOfFloor(bo.getId(), FloorDetailStatus.open.getIntVal(), floorBo);
atfdp = ActivityTemplatedFloorDetailHelper.buildDetailsOfFloor(bo.getTemplateId(), FloorDetailStatus.open.getIntVal(), floorBo);
}
if (CollectionUtils.isNotEmpty(atfdp)){
atfdMapper.insertBatch(atfdp);
}
List<ActivtyTemplatedFloorDetailBo> atfdc = Lists.newArrayList();
if (CollectionUtils.isNotEmpty(floorBo.getComponents())){
atfdc = buildDetailBo(bo.getId(), floorBo.getId(), floorBo.getComponents());
atfdc = buildDetailBo(bo.getTemplateId(), floorBo.getId(), floorBo.getComponents());
}
if (CollectionUtils.isNotEmpty(atfdc)){
atfdService.insertDetailBatch(atfdc);
... ... @@ -687,14 +716,36 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo>
row += activtyTemplatedMapper.insertSelective(templated);
// clone activity templated id(new)
int cloneATId = templated.getId();
//
List<ActivtyTemplatedFloor> floors = atfMapper.selectByTemplatedId(id);
//根据原活动ID查询其默认模板
List<ActivtyTemplateLink> activtyTemplateLinkList = activityTemplateLinkMapper.selectActivityTemplateLinkList(id);
if (CollectionUtils.isEmpty(activtyTemplateLinkList)){
return 0;
}
Integer templateId = 0;
for (ActivtyTemplateLink activtyTemplateLink : activtyTemplateLinkList){
if (activtyTemplateLink.getIsDefault() == 1){
templateId = activtyTemplateLink.getTemplateId();
break;
}
}
if (templateId == 0){
return 0;
}
//生成颗粒活动的默认复制模板
ActivtyTemplateLink activtyTemplateLink = new ActivtyTemplateLink();
activtyTemplateLink.setActivityId(cloneATId);
activtyTemplateLink.setIsDefault(1);
activtyTemplateLink.setTemplateName("默认模板");
activtyTemplateLink.setCreateTime(DateUtil.getCurrentTimeSeconds());
activtyTemplateLink.setShowTime(DateUtil.getCurrentTimeSeconds());
activityTemplateLinkMapper.insertActivityTemplateLink(activtyTemplateLink);
List<ActivtyTemplatedFloor> floors = atfMapper.selectByTemplatedId(templateId);
if (CollectionUtils.isEmpty(floors)){
logger.warn("{}.deepClone floors of id {} is empty", getClass().getSimpleName(),id);
return row;
}
logger.warn("{}.deepClone floors of id {} size {}", getClass().getSimpleName(), id, floors.size());
row += atfService.cloneFloors(id, cloneATId, floors);
row += atfService.cloneFloors(templateId, activtyTemplateLink.getTemplateId(), floors);
//add log
if (row > 0) {
logService.recordLog(id, LogActionType.clone, null, vo.getUserInfoResponseBO());
... ... @@ -833,4 +884,89 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo>
return list;
}
/**
* 添加活动与模板的关联关系
*
* @param req
*/
public Integer addActivityTemplateLink(ActivityTemplateLinkBo req) {
ActivtyTemplateLink activtyTemplateLink = new ActivtyTemplateLink();
convert.convertFrom(req, activtyTemplateLink, ActivtyTemplateLink.class);
activtyTemplateLink.setShowTime(DateUtil.getTimeSeconds(req.getShowTimeStr()));
ActivtyTemplateLink activtyTemplateLinkDefault = activityTemplateLinkMapper.selectDefaultTemplateById(req.getActivityId());
if (activtyTemplateLinkDefault != null){
activtyTemplateLink.setIsDefault(2);
}else {
activtyTemplateLink.setTemplateName("默认模板");
activtyTemplateLink.setIsDefault(1);
}
activtyTemplateLink.setCreateTime(DateUtil.getCurrentTimeSeconds());
activityTemplateLinkMapper.insertActivityTemplateLink(activtyTemplateLink);
if (req.getCopy()){
req.setTemplateId(activtyTemplateLink.getTemplateId());
copyDefaultTemplate(req);
}
return activtyTemplateLink.getTemplateId();
}
public void copyDefaultTemplate(ActivityTemplateLinkBo req){
//查询出默认模板,对默认模板进行复制
ActivtyTemplateLink activtyTemplateLinkDefault = activityTemplateLinkMapper.selectDefaultTemplateById(req.getActivityId());
if (activtyTemplateLinkDefault != null){
List<ActivtyTemplatedFloor> floors = atfMapper.selectByTemplatedId(activtyTemplateLinkDefault.getTemplateId());
atfService.cloneFloors(activtyTemplateLinkDefault.getTemplateId(),req.getTemplateId(),floors);
}
}
public ActivtyTemplatedBo getTemplateInfoByTemplateId(Integer templateId) {
if (!IntegerUtils.withInBizSign(templateId)){
logger.warn("{}.getTemplateInfoByTemplateId param id {}", getClass().getSimpleName(), templateId);
return null;
}
ActivtyTemplateLink activtyTemplateLink = activityTemplateLinkMapper.selectTemplateInfoByTemplateId(templateId);
if (null == activtyTemplateLink){
logger.warn("ActivtyTemplatedService :: getTemplateInfoByTemplateId get no data!");
return null;
}
List<ActivtyTemplateLink> atlList = activityTemplateLinkMapper.selectActivityTemplateLinkList(activtyTemplateLink.getActivityId());
if (CollectionUtils.isEmpty(atlList)){
return null;
}
ActivtyTemplated templated = activtyTemplatedMapper.selectByPrimaryKey(activtyTemplateLink.getActivityId());
if (templated==null){
logger.warn("{}.getTemplateInfoByTemplateId param id {}, ActivtyTemplated not exist in db", getClass().getSimpleName(), activtyTemplateLink.getActivityId());
return null;
}
logger.info("in getTemplateInfoByTemplateId, ActivtyTemplated id {}, title {}, status {}", activtyTemplateLink.getActivityId(), templated.getTitle(), templated.getStatus());
List<ActivtyTemplatedFloorBo> floorBos = atfService.getByTemplatedId(activtyTemplateLink.getTemplateId());
ActivtyTemplatedBo templatedBo = ActivtyTemplatedConvert.do2Bo(templated);
templatedBo.setFloors(floorBos);
List<ActivityTemplateLinkBo> linkList = convert.convertFromList(atlList,ActivityTemplateLinkBo.class);
ActivityTemplateLinkBo atlBo = new ActivityTemplateLinkBo();
convert.convertFrom(activtyTemplateLink, atlBo, ActivityTemplateLinkBo.class);
atlBo.setShowTimeStr(DateUtil.int2DateStr(atlBo.getShowTime(),DateUtil.DATE_TIME_FORMAT));
templatedBo.setLinkList(linkList);
templatedBo.setAtLink(atlBo);
return templatedBo;
}
public void upateActivityTemplateLink(ActivityTemplateLinkBo req) {
ActivtyTemplateLink activtyTemplateLink = new ActivtyTemplateLink();
convert.convertFrom(req, activtyTemplateLink, ActivtyTemplateLink.class);
activtyTemplateLink.setShowTime(DateUtil.getTimeSeconds(req.getShowTimeStr()));
activityTemplateLinkMapper.upateActivityTemplateLink(activtyTemplateLink);
if (req.getCopy()){
copyDefaultTemplate(req);
}
}
public void deleteActivityTemplate(Integer templateId) {
//删除link表
activityTemplateLinkMapper.deleteByTempId(templateId);
//删除其他相关数据
atfMapper.deleteByTempId(templateId);
atftMapper.deleteByTempId(templateId);
atfdMapper.deleteByTempId(templateId);
}
}
... ...
... ... @@ -24,7 +24,7 @@
<dependency>
<groupId>com.yoho.service.platform.model</groupId>
<artifactId>platform-service-model</artifactId>
<version>1.2.3-6.8.4-SNAPSHOT</version>
<version>1.2.3-6.8.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhplatform</groupId>
... ... @@ -54,7 +54,7 @@
<dependency>
<groupId>com.yohobuy.platform</groupId>
<artifactId>platform-common</artifactId>
<version>1.0.3-6.8.4-SNAPSHOT</version>
<version>1.0.3-6.8.5-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
... ...
... ... @@ -121,6 +121,7 @@ datasources:
- com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorMapper
- com.yohobuy.platform.dal.operations.ActivtyTemplatedLogMapper
- com.yohobuy.platform.dal.operations.ActivtyTemplatedMapper
- com.yohobuy.platform.dal.operations.ActivtyTemplateLinkMapper
- com.yohobuy.platform.dal.operations.TemplatedComponentMapper
- com.yohobuy.platform.dal.operations.TemplatedComponentParamMapper
- com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorTableMapper
... ...
... ... @@ -119,6 +119,7 @@ datasources:
- com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorMapper
- com.yohobuy.platform.dal.operations.ActivtyTemplatedLogMapper
- com.yohobuy.platform.dal.operations.ActivtyTemplatedMapper
- com.yohobuy.platform.dal.operations.ActivtyTemplateLinkMapper
- com.yohobuy.platform.dal.operations.TemplatedComponentMapper
- com.yohobuy.platform.dal.operations.TemplatedComponentParamMapper
- com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorTableMapper
... ...