Commit 46934cb4 by 王勇飞

pp

parent 770ccfd2
...@@ -20,7 +20,18 @@ module.exports = (db, DataTypes) => { ...@@ -20,7 +20,18 @@ module.exports = (db, DataTypes) => {
allowNull: true, allowNull: true,
values: Object.keys(appconfig.pdict.sex), values: Object.keys(appconfig.pdict.sex),
}, },
mobile: DataTypes.STRING, // mobile: DataTypes.STRING,
mobile: {
type: DataTypes.STRING,
allowNull: true,
set(value) {
this.setDataValue('mobile', system.encryptStr(value));
},
get() {
const resValue = system.decryptStr(this.getDataValue('mobile'));
return resValue ? resValue : null;
}
},
mail: { mail: {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
...@@ -77,46 +88,46 @@ module.exports = (db, DataTypes) => { ...@@ -77,46 +88,46 @@ module.exports = (db, DataTypes) => {
defaultValue: false defaultValue: false
} }
}, { }, {
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
version: true, version: true,
freezeTableName: true, freezeTableName: true,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'p_user', tableName: 'p_user',
validate: { validate: {
}, },
indexes: [ indexes: [
// Create a unique index on email // Create a unique index on email
// { // {
// unique: true, // unique: true,
// fields: ['email'] // fields: ['email']
// }, // },
// //
// // Creates a gin index on data with the jsonb_path_ops operator // // Creates a gin index on data with the jsonb_path_ops operator
// { // {
// fields: ['data'], // fields: ['data'],
// using: 'gin', // using: 'gin',
// operator: 'jsonb_path_ops' // operator: 'jsonb_path_ops'
// }, // },
// //
// // By default index name will be [table]_[fields] // // By default index name will be [table]_[fields]
// // Creates a multi column partial index // // Creates a multi column partial index
// { // {
// name: 'public_by_author', // name: 'public_by_author',
// fields: ['author', 'status'], // fields: ['author', 'status'],
// where: { // where: {
// status: 'public' // status: 'public'
// } // }
// }, // },
// //
// // A BTREE index with a ordered field // // A BTREE index with a ordered field
// { // {
// name: 'title_index', // name: 'title_index',
// method: 'BTREE', // method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}] // fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// } // }
] ]
}); });
} }
const system = require("../../../system"); const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const appconfig=system.getSysConfig(); const appconfig = system.getSysConfig();
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("company", { return db.define("company", {
code:{//存放简码 code: {//存放简码
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
}, },
...@@ -26,54 +26,61 @@ module.exports = (db, DataTypes) => { ...@@ -26,54 +26,61 @@ module.exports = (db, DataTypes) => {
phone: { phone: {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
set(value) {
this.setDataValue('phone', system.encryptStr(value));
},
get() {
const resValue = system.decryptStr(this.getDataValue('phone'));
return resValue ? resValue : null;
}
}, },
licenseUrl: { licenseUrl: {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
}, },
orgJson: DataTypes.TEXT,//功能清 orgJson: DataTypes.TEXT,//功能清
appids:DataTypes.STRING, appids: DataTypes.STRING,
}, { }, {
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
version: true, version: true,
freezeTableName: true, freezeTableName: true,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'p_company', tableName: 'p_company',
validate: { validate: {
}, },
indexes: [ indexes: [
// Create a unique index on email // Create a unique index on email
// { // {
// unique: true, // unique: true,
// fields: ['email'] // fields: ['email']
// }, // },
// //
// // Creates a gin index on data with the jsonb_path_ops operator // // Creates a gin index on data with the jsonb_path_ops operator
// { // {
// fields: ['data'], // fields: ['data'],
// using: 'gin', // using: 'gin',
// operator: 'jsonb_path_ops' // operator: 'jsonb_path_ops'
// }, // },
// //
// // By default index name will be [table]_[fields] // // By default index name will be [table]_[fields]
// // Creates a multi column partial index // // Creates a multi column partial index
// { // {
// name: 'public_by_author', // name: 'public_by_author',
// fields: ['author', 'status'], // fields: ['author', 'status'],
// where: { // where: {
// status: 'public' // status: 'public'
// } // }
// }, // },
// //
// // A BTREE index with a ordered field // // A BTREE index with a ordered field
// { // {
// name: 'title_index', // name: 'title_index',
// method: 'BTREE', // method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}] // fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// } // }
] ]
}); });
} }
...@@ -60,7 +60,7 @@ class TxHandler { ...@@ -60,7 +60,7 @@ class TxHandler {
params.salesmanOpcode = salesmanInfo.opath; params.salesmanOpcode = salesmanInfo.opath;
params.salesmanId = salesmanInfo.userId; params.salesmanId = salesmanInfo.userId;
params.clerkName = salesmanInfo.userName; params.clerkName = salesmanInfo.userName;
params.clerkPhone = salesmanInfo.mobile; params.clerkPhone = system.encryptStr(salesmanInfo.mobile);
params.servicerCode = salesmanInfo.compId params.servicerCode = salesmanInfo.compId
} }
var rtn = await rc.execPost3({ "d": params }, requrl); var rtn = await rc.execPost3({ "d": params }, requrl);
......
...@@ -304,7 +304,7 @@ class System { ...@@ -304,7 +304,7 @@ class System {
*/ */
static encryptStr(opStr) { static encryptStr(opStr) {
if (!opStr) { if (!opStr) {
return "opStr is empty"; return "";
} }
let keyHex = cryptoJS.enc.Utf8.parse(settings.encrypt_key); let keyHex = cryptoJS.enc.Utf8.parse(settings.encrypt_key);
let ivHex = cryptoJS.enc.Utf8.parse(settings.encrypt_secret.substring(0, 8)); let ivHex = cryptoJS.enc.Utf8.parse(settings.encrypt_secret.substring(0, 8));
...@@ -317,7 +317,7 @@ class System { ...@@ -317,7 +317,7 @@ class System {
*/ */
static decryptStr(opStr) { static decryptStr(opStr) {
if (!opStr) { if (!opStr) {
return "opStr is empty"; return "";
} }
let keyHex = cryptoJS.enc.Utf8.parse(settings.encrypt_key); let keyHex = cryptoJS.enc.Utf8.parse(settings.encrypt_key);
let ivHex = cryptoJS.enc.Utf8.parse(settings.encrypt_secret.substring(0, 8)); let ivHex = cryptoJS.enc.Utf8.parse(settings.encrypt_secret.substring(0, 8));
......
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