Commit 48ec80ff authored by 廖旭伟's avatar 廖旭伟

客户作品发布接口

parent 19e0fa32
...@@ -4573,6 +4573,67 @@ data|object|数据对象 ...@@ -4573,6 +4573,67 @@ data|object|数据对象
``` ```
### 客户发布作品
**请求URL:** customer/work/design/release
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 保存或更新客户作品信息:id为空时为新增保存,否则为更新提交
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:-------
id|Long|是|作品id
masterplateName|String|是|模板名称
frontCover|String|是|封面图片地址(相对地址)
**请求样例:**
```
{
"id":6797,
"masterplateName":"c42lp8",
"frontCover":"g3odxd"
}
```
**响应参数:**
参数名称 |参数类型|描述
:---|:---|:------
code|Integer|结果码(-1.失败,1.成功)
msg|String|消息
data|object|数据对象
 id|Long|保存后主键id
 entity|object|保存更新实体
  id|Long|主键ID,主键,自增长
  customerId|Long|客户ID
  createTime|Date|创建时间
  workDesignName|String|作品名称
  workDesignStatus|Integer|作品状态:0:草稿,1:发布
  workDesignDesc|String|作品描述
  updateTime|Date|更新时间
  pictureIds|String|模版引用的图片
  pictureSrcIds|String|模版引用的素材
  pictureBackgroundIds|String|模版引用的背景
  fontIds|String|作品引用的字体
  previewUrl|String|图片预览地址(相对地址)
  draft|String|草稿内容
**响应消息样例:**
```
{
"msg":"发布成功",
"code":1,
"data":{}
}
}
```
### 删除客户设计作品信息 ### 删除客户设计作品信息
**请求URL:** customer/work/design/delete **请求URL:** customer/work/design/delete
......
...@@ -20,4 +20,8 @@ public class CustomerWorkDesignVo extends BaseEntityLong { ...@@ -20,4 +20,8 @@ public class CustomerWorkDesignVo extends BaseEntityLong {
private String updateTimeStr; private String updateTimeStr;
/** 设计内容 */ /** 设计内容 */
private List<JSONObject> designContent; private List<JSONObject> designContent;
/** 发布模板名称 */
private String masterplateName;
/** 发布模板封面 */
private String frontCover;
} }
\ No newline at end of file
package com.mortals.xhx.module.customer.service; package com.mortals.xhx.module.customer.service;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity; import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity;
/** /**
...@@ -11,4 +13,12 @@ import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity; ...@@ -11,4 +13,12 @@ import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity;
*/ */
public interface CustomerWorkDesignService extends ICRUDService<CustomerWorkDesignEntity,Long>{ public interface CustomerWorkDesignService extends ICRUDService<CustomerWorkDesignEntity,Long>{
/**
* 客户发布作品
* @param entity
* @param context
* @return
* @throws AppException
*/
int release(CustomerWorkDesignEntity entity, Context context,String customerName) throws AppException;
} }
\ No newline at end of file
...@@ -4,12 +4,16 @@ import com.mortals.framework.exception.AppException; ...@@ -4,12 +4,16 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.common.code.WorkDesignStatusEnum;
import com.mortals.xhx.common.utils.StringUtils;
import com.mortals.xhx.module.customer.dao.CustomerWorkDesignDao; import com.mortals.xhx.module.customer.dao.CustomerWorkDesignDao;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity; import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignStatEntity; import com.mortals.xhx.module.customer.model.CustomerWorkDesignStatEntity;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignStatQuery; import com.mortals.xhx.module.customer.model.CustomerWorkDesignStatQuery;
import com.mortals.xhx.module.customer.service.CustomerWorkDesignService; import com.mortals.xhx.module.customer.service.CustomerWorkDesignService;
import com.mortals.xhx.module.customer.service.CustomerWorkDesignStatService; import com.mortals.xhx.module.customer.service.CustomerWorkDesignStatService;
import com.mortals.xhx.module.design.model.DesignMasterplateEntity;
import com.mortals.xhx.module.design.service.DesignMasterplateService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -29,6 +33,8 @@ public class CustomerWorkDesignServiceImpl extends AbstractCRUDServiceImpl<Custo ...@@ -29,6 +33,8 @@ public class CustomerWorkDesignServiceImpl extends AbstractCRUDServiceImpl<Custo
@Autowired @Autowired
private CustomerWorkDesignStatService customerWorkDesignStatService; private CustomerWorkDesignStatService customerWorkDesignStatService;
@Autowired
private DesignMasterplateService designMasterplateService;
@Override @Override
protected CustomerWorkDesignEntity findBefore(CustomerWorkDesignEntity params, PageInfo pageInfo, Context context) throws AppException { protected CustomerWorkDesignEntity findBefore(CustomerWorkDesignEntity params, PageInfo pageInfo, Context context) throws AppException {
...@@ -65,4 +71,49 @@ public class CustomerWorkDesignServiceImpl extends AbstractCRUDServiceImpl<Custo ...@@ -65,4 +71,49 @@ public class CustomerWorkDesignServiceImpl extends AbstractCRUDServiceImpl<Custo
customerWorkDesignStatService.update(updateEntity); customerWorkDesignStatService.update(updateEntity);
} }
} }
@Override
public int release(CustomerWorkDesignEntity entity, Context context,String customerName) throws AppException {
if(entity.getId()==null){
throw new AppException("作品信息不能为空");
}
if(StringUtils.isEmpty(entity.getMasterplateName())){
throw new AppException("模板名称不能为空");
}
if(StringUtils.isEmpty(entity.getFrontCover())){
throw new AppException("模板封面图不能为空");
}
CustomerWorkDesignEntity workDesign = this.get(entity.getId());
if(workDesign==null){
throw new AppException("作品不存在或者已被删除");
}
DesignMasterplateEntity newMasterplate = new DesignMasterplateEntity();
newMasterplate.setMasterplateName(entity.getMasterplateName());
List<DesignMasterplateEntity> masterplates = designMasterplateService.find(newMasterplate);
if(CollectionUtils.isNotEmpty(masterplates)){
throw new AppException("模板名称已存在");
}
CustomerWorkDesignEntity updateEntity = new CustomerWorkDesignEntity();
updateEntity.setId(workDesign.getId());
updateEntity.setWorkDesignStatus(WorkDesignStatusEnum.RELEASE.getValue());
updateEntity.setUpdateTime(new Date());
this.update(updateEntity);
newMasterplate.setCustomerId(workDesign.getCustomerId());
newMasterplate.setMasterplateName(entity.getMasterplateName());
newMasterplate.setMasterplateCode(1);
newMasterplate.setCustomerName(customerName);
newMasterplate.setMasterplateDesc(entity.getMasterplateName());
newMasterplate.setMasterplatePath(workDesign.getPreviewUrl());
newMasterplate.setFontIds(workDesign.getFontIds());
newMasterplate.setPictureBackgroundIds(workDesign.getPictureBackgroundIds());
newMasterplate.setPictureIds(workDesign.getPictureIds());
newMasterplate.setPictureSrcIds(workDesign.getPictureSrcIds());
newMasterplate.setMasterplateUseNum(0);
newMasterplate.setPreviewUrl(entity.getFrontCover());
newMasterplate.setDraft(workDesign.getDraft());
newMasterplate.setCreateTime(new Date());
designMasterplateService.save(newMasterplate,context);
return 1;
}
} }
\ No newline at end of file
package com.mortals.xhx.module.customer.web; package com.mortals.xhx.module.customer.web;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.RepeatSubmit;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.IBaseEnum; import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.framework.service.IUser;
import com.mortals.framework.util.DateUtils; import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
...@@ -17,10 +19,8 @@ import com.mortals.xhx.module.customer.service.CustomerWorkDesignService; ...@@ -17,10 +19,8 @@ import com.mortals.xhx.module.customer.service.CustomerWorkDesignService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* *
* 客户作品信息 * 客户作品信息
...@@ -122,4 +122,35 @@ public class CustomerWorkDesignController extends BaseCRUDJsonBodyMappingControl ...@@ -122,4 +122,35 @@ public class CustomerWorkDesignController extends BaseCRUDJsonBodyMappingControl
ret.put("data", model); ret.put("data", model);
return ret.toJSONString(); return ret.toJSONString();
} }
@PostMapping({"release"})
@RepeatSubmit
public String release(@RequestBody CustomerWorkDesignEntity entity) {
if(this.getCurUser()==null||this.getCurUser().getUserType()!= Constant.CUSTOMER_USER){
throw new AppException("非法用户,不可访问");
}
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "客户发布作品";
int code = 1;
try {
this.service.release(entity, context,this.getCurUser().getRealName());
model.put("entity", entity);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + entity.getId() + "]");
} catch (Exception var7) {
this.doException(this.request, busiDesc, model, var7);
model.put("entity", entity);
this.init(model, context);
code = this.saveException(entity, model, context, var7);
}
this.init(model, context);
JSONObject ret = new JSONObject();
ret.put("code", code);
ret.put("msg", model.remove("message_info"));
ret.put("data", model);
return ret.toJSONString();
}
} }
\ No newline at end of file
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