Commit ab6a9800 by 庄冰

模板接口

parent d466837c
......@@ -15,10 +15,10 @@ class TemplateinfoService extends ServiceBase {
* @param {*} pobj
*/
async createTemplate(pobj){
var ab = pobj.actionBody;
var ab = {};
var xctx = pobj.xctx;
var code = await this.getBusUid("mt");
var name = "营销模板";
var code = await this.getBusUid("mt");//自动生成模板编码
var name = "营销模板";//模板名称
ab.code = code;
ab.name = name;
ab.user_id=xctx.credid;
......@@ -28,6 +28,11 @@ class TemplateinfoService extends ServiceBase {
var res = await this.create(ab);
return system.getResultSuccess(res);
}
/**
* 根据模板编码获取模板信息
* 编辑模板时使用此接口
* @param {*} pobj
*/
async findOneByCode(pobj){
var ab = pobj.actionBody;
var xctx = pobj.xctx;
......@@ -58,6 +63,7 @@ class TemplateinfoService extends ServiceBase {
if(!ab.hasOwnProperty("template_content")){
return system.getResultFail(-102,"模板内容不能为空");
}
//根据模板编码获取模板信息
var templateInfo = await this.dao.model.findOne({
where:{code:ab.code},raw:true
});
......@@ -98,8 +104,13 @@ class TemplateinfoService extends ServiceBase {
await this.dao.update({id:templateInfo.id,is_enabled:ab.is_enabled});
return system.getResultSuccess();
}
/**
* 编辑模板tdk信息
* @param {*} pobj
*/
async editTemplateTdk(pobj){
var ab = pobj.actionBody;
var updateObj = {};
var xctx = pobj.xctx;
if(!ab){
return system.getResultFail(-100,"参数错误");
......@@ -110,23 +121,28 @@ class TemplateinfoService extends ServiceBase {
if(!ab.title){
return system.getResultFail(-102,"网页标题不能为空");
}
updateObj.title = ab.title;
if(!ab.keyword){
return system.getResultFail(-103,"关键词不能为空");
}
updateObj.keyword = ab.keyword;
if(!ab.pic_url){
return system.getResultFail(-104,"网页图标不能为空");
}
updateObj.pic_url = ab.pic_url;
if(!ab.describe){
return system.getResultFail(-105,"描述不能为空");
}
updateObj.describe = ab.describe;
//根据模板编码获取模板信息
var templateInfo = await this.dao.model.findOne({
where:{code:ab.code},raw:true
});
if(!templateInfo || !templateInfo.id){
return system.getResultFail(-300,"未知模板");
}
ab.id = templateInfo.id;
await this.dao.update(ab);
updateObj.id = templateInfo.id;
await this.dao.update(updateObj);
return system.getResultSuccess();
}
......
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