Commit de66155a by 王昆

gsb

parent 58b78bef
var system = require("../../../system") var system = require("../../../system")
const settings = require("../../../../config/settings") const settings = require("../../../../config/settings")
const CtlBase = require("../../ctlms.base"); const CtlBase = require("../../ctlms.base");
const md5 = require("MD5"); const validation = system.getObject("util.validation");
const uuidv4 = require('uuid/v4');
const logCtl = system.getObject("web.common.oplogCtl");
class MerchantUserCtl extends CtlBase { class MerchantUserCtl extends CtlBase {
constructor() { constructor() {
super(); super();
this.userSve = system.getObject("service.uc.userSve"); this.userSve = system.getObject("service.uc.userSve");
this.redisClient = system.getObject("util.redisClient");
} }
async save(params, pobj2, req) {
try {
params.uctype_id = this.trim(params.uctype_id);
params.real_name = this.trim(params.real_name);
params.password = this.trim(params.password);
params.ucname = this.trim(params.ucname);
params.mobile = this.trim(params.mobile);
if (!params.uctype_id) {
return system.getResult(null, "请选择商户");
}
if (!params.real_name) {
return system.getResult(null, "请选择商户");
}
validation.check(params, "real_name", {name: "姓名", is_require: true});
validation.check(params, "mobile", {name: "联系电话", is_require: true});
validation.check(params, "ucname", {name: "用户名", is_require: true});
return await this.userSve.saveMerchantUser(params);
} catch (error) {
let msg = error.message;
if (msg.startsWith("bpo-validation-error:")) {
return system.getResult(null, msg.replace("bpo-validation-error:", ""));
}
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/** /**
* 启用禁用 * 启用禁用
* @param {*} params * @param {*} params
...@@ -28,13 +54,6 @@ class MerchantUserCtl extends CtlBase { ...@@ -28,13 +54,6 @@ class MerchantUserCtl extends CtlBase {
} }
} }
async delUser(params, pobj2, req) {
try {
return await this.userSve.delUser(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/** /**
* 根据pid查出子目录 * 根据pid查出子目录
......
...@@ -43,28 +43,28 @@ class Validation { ...@@ -43,28 +43,28 @@ class Validation {
} }
let v = data[field]; let v = data[field];
if (rule.is_require && !v) { if (rule.is_require && !v) {
this.error(data, `${rule.name}为空`); this.error(data, `${rule.name}为空`);
} }
if (rule.maxLen && v.length > rule.maxLen) { if (rule.maxLen && v.length > rule.maxLen) {
this.error(data, `${rule.name}长度不允许超过${rule.maxLen}`); this.error(data, `${rule.name}长度不允许超过${rule.maxLen}`);
} }
if (rule.minLen && v.length < rule.minLen) { if (rule.minLen && v.length < rule.minLen) {
this.error(data, `${rule.name}长度不允许少于${rule.minLen}`); this.error(data, `${rule.name}长度不允许少于${rule.minLen}`);
} }
if (rule.eqLen && v.length != rule.eqLen) { if (rule.eqLen && v.length != rule.eqLen) {
this.error(data, `${rule.name}长度为${rule.eqLen}`); this.error(data, `${rule.name}长度为${rule.eqLen}`);
} }
if (rule.is_number && isNaN(v)) { if (rule.is_number && isNaN(v)) {
this.error(data, `${rule.name}需要填写数字类型`); this.error(data, `${rule.name}需要填写数字类型`);
} }
if (rule.is_mobile && this.PATTERN.PHONE_PATTERN.test(v)) { if (rule.is_mobile && this.PATTERN.PHONE_PATTERN.test(v)) {
this.error(data, `${rule.name}格式错误`); this.error(data, `${rule.name}格式错误`);
} }
if (rule.dics && rule.dics.indexOf(v) == -1) { if (rule.dics && rule.dics.indexOf(v) == -1) {
this.error(data, `${rule.name}${v} 错误`); this.error(data, `${rule.name}[${v}] 不存在`);
} }
if(rule.arr_require && (!v || v.length == 0)) { if(rule.arr_require && (!v || v.length == 0)) {
this.error(data, `${rule.name}:数据为空`); this.error(data, `${rule.name}为空`);
} }
} }
...@@ -72,7 +72,7 @@ class Validation { ...@@ -72,7 +72,7 @@ class Validation {
if(data.errors) { if(data.errors) {
data.errors.push(msg); data.errors.push(msg);
} else { } else {
throw new Error(`bpo-validation-error:${msg}`); throw new Error(`field-validation-error:${msg}`);
} }
} }
} }
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
## index. 首页 ## index. 首页
  1 [待开发](/doc/index/index1.md)   1 [待开发](/doc/index/index1.md)
## 用户中心
  1 [登录](/doc/uc/login.md)
## 产品 ## 产品
  1 [产品接口](/doc/product/product.md)   1 [产品接口](/doc/product/product.md)
......
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