Commit b201a75e by 兰国旗

Merge branch 'gsb-marketplat' of gitlab.gongsibao.com:jiangyong/zhichan into gsb-marketplat

parents 79244fdf 21a37a10
...@@ -24,13 +24,8 @@ class CtlBase { ...@@ -24,13 +24,8 @@ class CtlBase {
const up = await this.service.delete(pobj); const up = await this.service.delete(pobj);
return system.getResult(up); return system.getResult(up);
} }
async bulkDelete(ids) {
var en = await this.service.bulkDelete(ids);
return system.getResult(en);
}
async findAndCountAll(pobj, qobj, req) { async findAndCountAll(pobj, qobj, req) {
//设置查询条件 //设置查询条件
pobj.search.company_id = pobj.company_id;
const rs = await this.service.findAndCountAll(pobj); const rs = await this.service.findAndCountAll(pobj);
return system.getResult(rs); return system.getResult(rs);
} }
......
...@@ -6,7 +6,39 @@ var cacheBaseComp = null; ...@@ -6,7 +6,39 @@ var cacheBaseComp = null;
class FormInfoCtl extends CtlBase { class FormInfoCtl extends CtlBase {
constructor() { constructor() {
super("formmag", CtlBase.getServiceName(FormInfoCtl)); super("formmag", CtlBase.getServiceName(FormInfoCtl));
this.forminfoSve = system.getObject('service.configmag.forminfoSve');
} }
/**
* 重写查询方法
* @param pobj
* @returns {Promise<{msg: string, data: *, bizmsg: string, status: number}>}
*/
async findAndCountAll(pobj) {
let result = await this.forminfoSve.findByCompanyId(pobj);
return result;
}
/**
* 重写保存方法
* @param pobj
* @returns {Promise<void>}
*/
async create(pobj){
let result = await this.forminfoSve.createForm(pobj);
return result;
}
/**
* 重写添加方法
* @param pobj
* @returns {Promise<void>}
*/
async update(pobj) {
let result = await this.forminfoSve.updateForm(pobj);
return result;
}
} }
module.exports = FormInfoCtl; module.exports = FormInfoCtl;
...@@ -6,7 +6,17 @@ var cacheBaseComp = null; ...@@ -6,7 +6,17 @@ var cacheBaseComp = null;
class FormItemCtl extends CtlBase { class FormItemCtl extends CtlBase {
constructor() { constructor() {
super("configmag", CtlBase.getServiceName(FormItemCtl)); super("configmag", CtlBase.getServiceName(FormItemCtl));
this.formitemSve = system.getObject("service.configmag.formitemSve");
} }
/**
* 重写添加方法
* @param pobj
* @returns {Promise<void>}
*/
// async create(pobj){
//
// }
} }
module.exports = FormItemCtl; module.exports = FormItemCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
var cacheBaseComp = null;
class FormsubmitrecordCtl extends CtlBase {
constructor() {
super("formsubrecordmag", CtlBase.getServiceName(FormsubmitrecordCtl));
this.formsubmitrecordSve = system.getObject("service.configmag.formsubmitrecordSve")
}
/**
* 重写查询
* @param pobj
* @returns {Promise<*>}
*/
async findAndCountAll(pobj){
let result = this.formsubmitrecordSve.findAllRecord(pobj);
return result;
}
}
module.exports = FormsubmitrecordCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
var cacheBaseComp = null;
class FormsubrecordCtl extends CtlBase {
constructor() {
super("formsubrecordmag", CtlBase.getServiceName(FormsubrecordCtl));
}
}
module.exports = FormsubrecordCtl;
...@@ -16,7 +16,18 @@ class LaunchchannelCtl extends CtlBase { ...@@ -16,7 +16,18 @@ class LaunchchannelCtl extends CtlBase {
*/ */
async create(pobj){ async create(pobj){
const result = await this.launchchannelSve.createChannel(pobj); const result = await this.launchchannelSve.createChannel(pobj);
return system.getResult(result); return result;
}
/**
* 重写查询
* @param pobj
* @returns {Promise<{msg: string, data: *, bizmsg: string, status: number}>}
*/
async findAndCountAll(pobj){
pobj.search.company_id = pobj.company_id;
const result = await this.launchchannelSve.findByCompanyId(pobj);
return result;
} }
} }
......
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
var cacheBaseComp = null;
class FormInfoCtl extends CtlBase {
constructor() {
super("templateinfomag", CtlBase.getServiceName(FormInfoCtl));
this.templateinfoSve = system.getObject('service.template.templateinfoSve');
}
/**
* 重写查询方法
* @param pobj
* @returns {Promise<{msg: string, data: *, bizmsg: string, status: number}>}
*/
async findAndCountAll(pobj) {
let result = await this.templateinfoSve.findByCompanyId(pobj);
return result;
}
/**
* 重写保存方法
* @param pobj
* @returns {Promise<void>}
*/
async create(pobj){
let result = await this.templateinfoSve.createTemplate(pobj);
return result;
}
}
module.exports = FormInfoCtl;
...@@ -13,7 +13,8 @@ module.exports = (db, DataTypes) => { ...@@ -13,7 +13,8 @@ module.exports = (db, DataTypes) => {
notes: DataTypes.STRING, notes: DataTypes.STRING,
user_id: DataTypes.STRING(100), user_id: DataTypes.STRING(100),
user_name: DataTypes.STRING(100), //user_name 用户名称 user_name: DataTypes.STRING(100), //user_name 用户名称
company_id: DataTypes.INTEGER(11) //user_name 用户名称 company_id: DataTypes.INTEGER(11),
record_num:DataTypes.INTEGER(11)
}, { }, {
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
......
...@@ -7,46 +7,35 @@ ...@@ -7,46 +7,35 @@
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("formitem", { return db.define("formitem", {
form_id: {//表单id form_id: {//表单id
allowNull: false,
type: DataTypes.INTEGER type: DataTypes.INTEGER
}, },
code: {//表单编码 code: {//表单编码
allowNull: false,
type: DataTypes.STRING type: DataTypes.STRING
}, },
name: {//表单名称 name: {//表单名称
allowNull: false,
type: DataTypes.STRING type: DataTypes.STRING
}, },
item_type: {//表单类型 item_type: {//表单类型
allowNull: false,
type: DataTypes.STRING type: DataTypes.STRING
}, },
item_type_name: {//表单类型名称 item_type_name: {//表单类型名称
allowNull: false,
type: DataTypes.STRING type: DataTypes.STRING
}, },
config_params: {//表单配置参数 config_params: {//表单配置参数
allowNull: false,
type: DataTypes.JSON type: DataTypes.JSON
}, },
is_enableed: {//显示状态 is_enabled: {//显示状态
allowNull: false,
type: DataTypes.INTEGER type: DataTypes.INTEGER
}, },
is_required: {//是否必填 is_required: {//是否必填
allowNull: false,
type: DataTypes.INTEGER type: DataTypes.INTEGER
}, },
sequence: {//次序 sequence: {//次序
allowNull: false,
type: DataTypes.INTEGER type: DataTypes.INTEGER
}, },
notes: {//备注 notes: {//备注
allowNull: false,
type: DataTypes.STRING() type: DataTypes.STRING()
}, },
company_id: DataTypes.INTEGER(11)
}, { }, {
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
......
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
class ForminfoService extends ServiceBase { class ForminfoService extends ServiceBase {
constructor() { constructor() {
super("common", ServiceBase.getDaoName(ForminfoService)); super("configmag", ServiceBase.getDaoName(ForminfoService));
} }
async createTemplate(pobj){ /**
var ab = pobj.actionBody; * 根据company_id 查询
var code = await this.getBusUid("tp"); * @param pobj
var name = "营销模板"; * @returns {Promise<void>}
ab.code = code; */
ab.name = name; async findByCompanyId(pobj) {
return this.create(ab); if (pobj.company_id) {
} pobj.search.company_id = pobj.company_id;
}
let result = await this.findAndCountAll(pobj);
return system.getResult(result);
}
/**
* 创建表单
* @param pobj
* @returns {Promise<void>}
*/
async createForm(pobj){
if(!pobj.name){
return system.getResult(null,'name can not be empty');
}
if(!pobj.form_describe){
return system.getResult(null,'form_describe can not be empty');
}
let items = '';
// if(!pobj.form_item){
// return 'form_item can not be empty';
// }
const formItem = this.composeItem(items);
if(formItem.status != 0){
return formItem;
}
let code = await this.getBusUid("fm")
let formData = {
name:pobj.name,
code:code,
form_describe:pobj.form_describe,
form_item:formItem.data,
user_id:pobj.user_id,
user_name:pobj.username
}
let result = await this.create(formData);
return system.getResul(result);
}
/**
*
* @param pobj
* @returns {Promise<void>}
*/
async updateForm(pobj) {
return null;
}
//表单项 数据重组
async composeItem(obj){
return system.getResultSuccess();
}
} }
module.exports = ForminfoService; module.exports = ForminfoService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class ForminfoService extends ServiceBase {
constructor() {
super("configmag", ServiceBase.getDaoName(ForminfoService));
}
/**
* 根据company_id 查询
* @param pobj
* @returns {Promise<void>}
*/
async findAllRecord(pobj) {
let pageSize = Number(pobj.pageInfo.pageSize || 20);
if (pageSize > 50) {
pageSize = 50;
}
var pageIndex = Number(pobj.pageInfo.pageNo || 1);
var from = pageIndex == 1 ? 0 : Number((pageIndex - 1) * pageSize);
let sql = `select record.created_at,info.user_name name,info.notes,record.record_status_name from c_form_submit_record record left join c_form_info info on info.id = record.form_id where info.deleted_at is NULL`;
let countSql = `select count(*) count from c_form_submit_record record left join c_form_info info on info.id = record.form_id where info.deleted_at is NULL`;
if(pobj.record_status_name){
sql += ` AND record.record_status_name = '${pobj.record_status_name}'`
countSql += ` AND record.record_status_name = '${pobj.record_status_name}'`
}
sql += ` order by info.id desc LIMIT ${pageSize} OFFSET ${from}`;
countSql += ` order by info.id desc LIMIT ${pageSize} OFFSET ${from}`;
let result = await this.customQuery(sql);
let countResult = await this.customQuery(countSql);
let resData ={
results:{
count:countResult[0].count,
rows:result
}
}
return system.getResult(resData);
}
}
module.exports = ForminfoService;
\ No newline at end of file
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
class LaunchchannelService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(LaunchchannelService));
}
/** class LaunchchannelService extends ServiceBase {
* 根据company_id 和 code 去重 constructor() {
* @param pobj super("common", ServiceBase.getDaoName(LaunchchannelService));
* @returns {Promise<{msg: string, data: *, bizmsg: string, status: number}|{msg: *, data: *, status: *}>}
*/
async createChannel(pobj){
if(!pobj.company_id){
return system.getResult(null,'company_id can not be empty');
}
if(!pobj.name){
return system.getResult(null,'name can not be empty');
}
if(!pobj.code){
return system.getResult(null,'code can not be empty');
}
let whereParams = {
code:pobj.code,
company_id:pobj.company_id
} }
let searchResult = await this.findOne(whereParams,[]);
if(searchResult){ /**
return null; * 根据company_id 和 code 去重
* @param pobj
* @returns {Promise<{msg: string, data: *, bizmsg: string, status: number}|{msg: *, data: *, status: *}>}
*/
async createChannel(pobj) {
if (!pobj.company_id) {
return system.getResult(null, 'company_id can not be empty');
}
if (!pobj.name) {
return system.getResult(null, 'name can not be empty');
}
if (!pobj.code) {
return system.getResult(null, 'code can not be empty');
}
let whereParams = {
code: pobj.code,
company_id: pobj.company_id
}
let searchResult = await this.findOne(whereParams, []);
if (searchResult) {
return system.getResult(null,'渠道已存在,请勿重复添加');
}
let channelData = {
name: pobj.name,
code: pobj.code,
user_id: pobj.userid,
user_name: pobj.username,
company_id: pobj.company_id
}
let result = await this.create(channelData);
return system.getResult(result);
} }
let channelData = {
name:pobj.name, /**
code:pobj.code, * 根据company_id 查询
user_id:pobj.userid, * @param pobj
user_name:pobj.username, * @returns {Promise<null|[]>}
company_id:pobj.company_id */
async findByCompanyId(pobj) {
if (pobj.company_id) {
pobj.search.company_id = pobj.company_id;
}
let reuslt = await this.findAndCountAll(pobj);
return system.getResult(reuslt);
} }
let result= await this.create(channelData);
return result;
}
} }
module.exports = LaunchchannelService; module.exports = LaunchchannelService;
\ No newline at end of file
...@@ -6,7 +6,10 @@ class TemplateinfoService extends ServiceBase { ...@@ -6,7 +6,10 @@ class TemplateinfoService extends ServiceBase {
super("template", ServiceBase.getDaoName(TemplateinfoService)); super("template", ServiceBase.getDaoName(TemplateinfoService));
} }
async findAndCountAll(obj){ async findByCompanyId(obj){
if(obj.company_id){
obj.search.company_id = obj.company_id;
}
var res = await this.dao.findAndCountAll(obj); var res = await this.dao.findAndCountAll(obj);
return system.getResultSuccess(res); return system.getResultSuccess(res);
} }
...@@ -145,7 +148,6 @@ class TemplateinfoService extends ServiceBase { ...@@ -145,7 +148,6 @@ class TemplateinfoService extends ServiceBase {
await this.dao.update(updateObj); await this.dao.update(updateObj);
return system.getResultSuccess(); return system.getResultSuccess();
} }
} }
module.exports = TemplateinfoService; 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