Commit 11d23aab by 任晓松

Merge remote-tracking branch 'origin/gsb-marketplat' into gsb-marketplat

parents 93a60318 215c7e00
......@@ -33,6 +33,19 @@ class TemplateinfoCtl extends CtlBase {
return result;
}
/**
* 根据id获取模板信息
* @param {*} pobj
*/
async getTemplateInfoById(pobj){
let result = await this.templateinfoSve.getTemplateInfoById(pobj);
return result;
}
async setTemplateBusinessId(pobj){
let result = await this.templateinfoSve.setTemplateBusinessId(pobj);
return result;
}
/**
* 重写保存方法
* @param pobj
* @returns {Promise<void>}
......
......@@ -6,13 +6,15 @@
*/
module.exports = (db, DataTypes) => {
return db.define("formsubmitrecord", {
template_id: DataTypes.INTEGER(11),///模板id
business_code:DataTypes.STRING(100),
template_id: DataTypes.INTEGER(11),//模板id
templatelink_id: DataTypes.INTEGER(11),//模板链接id
form_id: DataTypes.INTEGER(11),//表单id
record_status: DataTypes.STRING(60),//记录状态 1未读 2已读 3无效
record_status_name: DataTypes.STRING(60),//记录状态名称
templatelink_snapshot:DataTypes.JSON,//模板链接快照
record_content:DataTypes.JSON,//记录内容
push_status:DataTypes.INTEGER,//推送状态 0:未推送,1:已推送 2:异常
}, {
paranoid: true,//假的删除
underscored: true,
......
......@@ -16,6 +16,7 @@ module.exports = (db, DataTypes) => {
is_enabled: DataTypes.INTEGER,
template_content: DataTypes.JSON,
form_id: DataTypes.INTEGER,
business_code:DataTypes.STRING,
notes: DataTypes.STRING,
user_id: DataTypes.STRING(100),
user_name: DataTypes.STRING(100), //user_name 用户名称
......
......@@ -32,7 +32,17 @@ class FormsubmitrecordService extends ServiceBase {
where:{code:ab.link_code},raw:true
});
if(!linkInfo || !linkInfo.id){
return system.getResultFail(-300,"未知模板链接")
return system.getResultFail(-300,"未知模板链接");
}
if(!linkInfo.template_id){
return system.getResultFail(-301,"链接模板信息错误")
}
var templateinfo = await this.templateinfoDao.model.findOne{
where:{id:linkInfo.template_id},raw:true,
attributes:["id","business_code"]
};
if(!templateinfo || !templateinfo.id){
return system.getResultFail(-500,"未知模板信息");
}
//获取表单信息
var forminfo = await this.forminfoDao.model.findOne({
......@@ -55,7 +65,7 @@ class FormsubmitrecordService extends ServiceBase {
template_id:linkInfo.template_id,templatelink_id:linkInfo.id,
form_id:forminfo.id,record_status:1,templatelink_snapshot:linkInfo,
form_snapshot:{forminfo:forminfo,formitems:formitems},
record_content:params
record_content:params,business_code:templateinfo.business_code
}
await this.dao.create(addObj);//创建记录
return system.getResultSuccess();
......
......@@ -48,6 +48,36 @@ class TemplateinfoService extends ServiceBase {
});
return system.getResultSuccess(templateInfo);
}
async getTemplateInfoById(pobj){
var ab = pobj;
if(!ab){
return system.getResultFail(-100,"参数错误");
}
if(!ab.id){
return system.getResultFail(-101,"模板ID不能为空");
}
var templateInfo = await this.dao.model.findOne({
where:{id:ab.id},raw:true
});
return system.getResultSuccess(templateInfo);
}
async setTemplateBusinessId(pobj){
var ab = pobj;
if(!ab){
return system.getResultFail(-100,"参数错误");
}
if(!ab.id){
return system.getResultFail(-101,"模板ID不能为空");
}
if(!ab.business_code){
return system.getResultFail(-102,"商品ID不能为空");
}
await this.dao.update({id:ab.id,business_code:ab.business_code});
var templateInfo = await this.dao.model.findOne({
where:{id:ab.id},raw:true
});
return system.getResultSuccess(templateInfo);
}
/**
* 根据模板编码获取模板信息(模板调用)
* 编辑模板时使用此接口
......@@ -92,7 +122,11 @@ class TemplateinfoService extends ServiceBase {
// if(templateInfo.is_enabled===1){
// return system.getResultFail(-301,"该模板正在使用中,不能执行此操作");
// }
await this.dao.update({id:templateInfo.id,template_content:ab.template_content});
var updateObj = {id:templateInfo.id,template_content:ab.template_content};
if(ab.form_id){
updateObj["form_id"] = ab.form_id;
}
await this.dao.update(updateObj);
return system.getResultSuccess();
}
/**
......
......@@ -75,7 +75,7 @@ class System {
},
body: data
}, function (error, response, body) {
rtn.statusCode = response.statusCode
rtn.statusCode = response && response.statusCode?response.statusCode : "";
if (!error) {
if (body) {
rtn.data = body
......
......@@ -11,6 +11,7 @@ class LogClient {
return u;
}
async log(pobj, req, rtninfo, errinfo) {
try {
rtninfo.requestId = this.getUUID()
req.params.param = pobj
//第三个字段应该存公司id
......@@ -23,6 +24,10 @@ class LogClient {
}).catch(e => {
console.log("log.....fail")
})
} catch (error) {
console.log(error);
}
}
}
module.exports = LogClient;
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