Commit a7d8bc98 authored by 廖旭伟's avatar 廖旭伟

統一項目和模板的接口格式

parent 2eb8e9b9
......@@ -14,4 +14,6 @@ import lombok.Data;
public class GoviewMasterplateVo extends BaseEntityLong {
/** 项目数据 */
private String content;
/*** 项目名称 */
private String projectName;
}
\ No newline at end of file
package com.mortals.xhx.module.goview.service.impl;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.goview.model.*;
import com.mortals.xhx.module.goview.service.GoviewMasterplateDataService;
import com.mortals.xhx.module.goview.service.GoviewProjectDataService;
import com.mortals.xhx.module.goview.service.GoviewProjectService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
......@@ -32,6 +34,21 @@ public class GoviewMasterplateServiceImpl extends AbstractCRUDServiceImpl<Goview
@Autowired
private GoviewMasterplateDataService goviewMasterplateDataService;
@Override
protected void saveBefore(GoviewMasterplateEntity entity, Context context) throws AppException {
this.validData(entity, context);
entity.setState(-1);
}
@Override
protected void findAfter(GoviewMasterplateEntity params, PageInfo pageInfo, Context context, List<GoviewMasterplateEntity> list) throws AppException {
if(CollectionUtils.isNotEmpty(list)){
for(GoviewMasterplateEntity item:list){
item.setProjectName(item.getMasterplateName());
}
}
}
@Override
protected void removeAfter(Long[] ids, Context context, int result) throws AppException {
List<Long> masterplateIdList = new ArrayList<>();
......
......@@ -347,4 +347,68 @@ public class GoviewProjectAPi extends BaseJsonBodyController {
ret.put("data", model);
return ret.toJSONString();
}
/**
* 发布为模板
* @param entity
* @return
*/
@PostMapping({"publish/masterplate"})
public String publishMasterplate(@RequestBody GoviewProjectEntity entity) {
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "发布模板";
int code=1;
try {
if(entity.getId()==null){
throw new AppException("项目ID不能为空");
}
goviewProjectService.publishMasterplate(entity.getId(), context);
model.put("id", entity.getId());
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);
code = -1;
}
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();
}
@RequestMapping(
value = {"delete"},
method = {RequestMethod.POST, RequestMethod.GET}
)
public String delete(Long[] id) {
Context context = this.getContext();
if (id == null) {
return this.createFailJsonResp("请至少选择一条记录");
} else {
Map<String, Object> model = new HashMap();
int code = 1;
String busiDesc = "删除項目";
try {
int iRet = this.goviewProjectService.remove(id, context);
model.put("message_info", "項目信息删除成功!删除条数:" + iRet);
this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + StringUtils.converArray2Str(id) + "]");
} catch (Exception var7) {
code = -1;
this.doException(this.request, busiDesc, model, var7);
}
JSONObject ret = new JSONObject();
ret.put("code", Integer.valueOf(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