Commit 3a9ffb59 by 庄冰

temp

parent ee4040ef
......@@ -25,6 +25,7 @@ class Template extends APIBase {
async opActionProcess(pobj, action_type, req) {
var opResult = null;
var self = this;
pobj.xctx = req.xctx;
switch (action_type) {
case "test"://测试
opResult = system.getResultSuccess("测试接口");
......@@ -32,6 +33,12 @@ class Template extends APIBase {
case "createTemplate"://创建模板
opResult = await this.templateinfoSve.createTemplate(pobj);
break;
case "findAndCountAll"://模板列表查询
opResult = await this.templateinfoSve.findAndCountAll(pobj.actionBody);
break;
case "editTemplateTdk"://编辑模板TDK
opResult = await this.templateinfoSve.editTemplateTdk(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -102,7 +102,7 @@ class Dao {
if (search) {
Object.keys(search).forEach(k => {
// console.log(search[k], ":search[k]search[k]search[k]");
if (search[k] && search[k] != 'undefined' && search[k] != "") {
if ((search[k] && search[k] != 'undefined' && search[k] != "") || search[k] === 0) {
if ((k.indexOf("Date") >= 0 || k.indexOf("_at") >= 0)) {
if (search[k] != "" && search[k]) {
var stdate = new Date(search[k][0]);
......@@ -110,6 +110,9 @@ class Dao {
qc.where[k] = { [this.db.Op.between]: [stdate, enddate] };
}
}
else if (k.indexOf("is_enabled") >= 0) {
qc.where[k] = search[k];
}
else if (k.indexOf("id") >= 0) {
qc.where[k] = search[k];
}
......
......@@ -12,13 +12,14 @@ module.exports = (db, DataTypes) => {
title: DataTypes.STRING,
keyword: DataTypes.STRING,
describe: DataTypes.STRING,
link_url: DataTypes.STRING,
pic_url: DataTypes.STRING,
is_enabled: DataTypes.INTEGER,
template_content: DataTypes.STRING,
form_id: DataTypes.INTEGER,
notes: DataTypes.STRING,
user_id: DataTypes.STRING(100),
user_name: DataTypes.STRING(100), //user_name 用户名称
company_id: DataTypes.INTEGER,
}, {
paranoid: true,//假的删除
underscored: true,
......
......@@ -5,14 +5,55 @@ class TemplateinfoService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(TemplateinfoService));
}
/**
* 创建模板
* @param {*} pobj
*/
async createTemplate(pobj){
var ab = pobj.actionBody;
var code = await this.getBusUid("tp");
var xctx = pobj.xctx;
var code = await this.getBusUid("mt");
var name = "营销模板";
ab.code = code;
ab.name = name;
ab.user_id=xctx.credid;
ab.user_name=xctx.username;
ab.company_id=xctx.companyid;
ab.is_enabled=0;
return this.create(ab);
}
async editTemplateTdk(pobj){
var ab = pobj.actionBody;
var xctx = pobj.xctx;
if(!ab){
return system.getResultFail(-100,"参数错误");
}
if(!ab.code){
return system.getResultFail(-101,"模板编码不能为空");
}
if(!ab.title){
return system.getResultFail(-102,"网页标题不能为空");
}
if(!ab.keyword){
return system.getResultFail(-103,"关键词不能为空");
}
if(!ab.pic_url){
return system.getResultFail(-104,"网页图标不能为空");
}
if(!ab.describe){
return system.getResultFail(-105,"描述不能为空");
}
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);
return system.getResultSuccess();
}
}
module.exports = TemplateinfoService;
\ 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