Commit 64ce8c0b by 孙亚楠

Merge branch 'esign-admin' of gitlab.gongsibao.com:jiangyong/zhichan into esign-admin

parents 35de34ae 0a617808
var system = require("../../../system")
const settings = require("../../../../config/settings")
const CtlBase = require("../../ctlms.base");
const md5 = require("MD5");
const uuidv4 = require('uuid/v4');
const logCtl = system.getObject("web.common.oplogCtl");
class MerchantUserCtl extends CtlBase {
constructor() {
super();
this.merchantSve = system.getObject("service.merchant.merchantSve");
}
async merchantOfList(params, pobj2, req) {
try {
return await this.merchantSve.merchantOfList(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async addModifyMerchants(params, pobj2, req) {
try {
return await this.merchantSve.addModifyMerchants(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async merchantSuggest(params, pobj2, req) {
try {
return await this.merchantSve.merchantSuggest(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async auditMerchant(params, pobj2, req) {
try {
return await this.merchantSve.auditMerchant(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = MerchantUserCtl;
var system = require("../../../system")
const settings = require("../../../../config/settings")
const CtlBase = require("../../ctlms.base");
const md5 = require("MD5");
const uuidv4 = require('uuid/v4');
const logCtl = system.getObject("web.common.oplogCtl");
class MerchantUserCtl extends CtlBase {
constructor() {
super();
this.merchantSve = system.getObject("service.merchant.merchantSve");
}
async merchanttradesOfList(params, pobj2, req) {
try {
return await this.merchantSve.merchanttradesOfList(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async addMerchanttrades(params, pobj2, req) {
try {
return await this.merchantSve.addMerchanttrades(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async auditMerchanttrade(params, pobj2, req) {
try {
return await this.merchantSve.auditMerchanttrade(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async merchanttradesOfListAll(params, pobj2, req) {
try {
return await this.merchantSve.merchanttradesOfListAll(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = MerchantUserCtl;
var system = require("../../../system")
const settings = require("../../../../config/settings")
const CtlBase = require("../../ctlms.base");
const validation = system.getObject("util.validation");
class MerchantUserCtl extends CtlBase {
constructor() {
super();
this.userSve = system.getObject("service.uc.userSve");
}
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 {*} pobj2
* @param {*} req
*/
async enabled(params, pobj2, req) {
try {
params.id = Number(params.id || 0);
params.enabled = Number(params.enabled || 0);
return await this.userSve.enabled(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 根据pid查出子目录
* @param {*} params
*/
async page(params, pobj2, req) {
try {
params.uctypeId = params.deliver_id;
return await this.userSve.page(params);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = MerchantUserCtl;
\ No newline at end of file
var system = require("../../../system") var system = require("../../../system")
const settings = require("../../../../config/settings")
const CtlBase = require("../../ctlms.base"); const CtlBase = require("../../ctlms.base");
const md5 = require("MD5");
const uuidv4 = require('uuid/v4');
const logCtl = system.getObject("web.common.oplogCtl");
class ProductCtl extends CtlBase { class ProductCtl extends CtlBase {
constructor() { constructor() {
super(); super();
this.userSve = system.getObject("service.uc.userSve"); this.prodSve = system.getObject("service.product.productSve");
this.redisClient = system.getObject("util.redisClient"); this.redisClient = system.getObject("util.redisClient");
} }
async test(pobj, pobj2, req, res) { async getPage (pobj, pobj2, req) {
console.log(pobj);
try { try {
let rs = {test: 1}; let res = await this.prodSve.getPage(pobj)
return system.getResultSuccess(rs); return res
} catch (error) { } catch (error) {
console.log(error); return system.getResultFail(500, err.message)
return system.getResultFail(500, "接口异常:" + error.message); }
}
async getAllDic (pobj, pobj2, req) {
try {
let res = await this.prodSve.getAllDic(pobj)
return res
} catch (error) {
return system.getResultFail(500, err.message)
}
}
async getByIds (pobj, pobj2, req) {
try {
let res = await this.prodSve.getByIds(pobj)
return res
} catch (error) {
return system.getResultFail(500, err.message)
}
}
async getItems (pobj, pobj2, req) {
try {
let res = await this.prodSve.getItems(pobj)
return res
} catch (error) {
return system.getResultFail(500, err.message)
}
}
async createOrUpdate (pobj, pobj2, req) {
try {
let res = await this.prodSve.createOrUpdate(pobj)
return res
} catch (error) {
return system.getResultFail(500, err.message)
} }
} }
} }
......
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
class UserService extends ServiceBase {
constructor() {
super();
}
async merchantOfList(params) {
try {
return await this.callms("sve_merchant", "merchantOfList", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async addModifyMerchants(params) {
try {
return await this.callms("sve_merchant", "addModifyMerchants", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async merchantSuggest(params) {
try {
return await this.callms("sve_merchant", "merchantSuggest", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async auditMerchant(params) {
try {
return await this.callms("sve_merchant", "auditMerchant", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = UserService;
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
class UserService extends ServiceBase {
constructor() {
super();
}
async merchanttradesOfList(params) {
try {
return await this.callms("sve_merchant", "merchanttradesOfList", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async addMerchanttrades(params) {
try {
return await this.callms("sve_merchant", "addMerchanttrades", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async auditMerchanttrade(params) {
try {
return await this.callms("sve_merchant", "auditMerchanttrade", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async merchanttradesOfListAll(params) {
try {
return await this.callms("sve_merchant", "merchanttradesOfListAll", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = UserService;
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
class ProductService extends ServiceBase {
constructor() {
super();
}
async getPage (params) {
try {
return await this.callms("engine_product", "getPage", params)
} catch (error) {
throw error
}
}
async getAllDic (params) {
try {
return await this.callms("engine_product", "getAllDic", params)
} catch (error) {
throw error
}
}
async getByIds (params) {
try {
return await this.callms("engine_product", "getByIds", params)
} catch (error) {
throw error
}
}
async getItems (params) {
try {
return await this.callms("engine_product", "getItems", params)
} catch (error) {
throw error
}
}
async createOrUpdate (params) {
try {
return await this.callms("engine_product", "createOrUpdate", params)
} catch (error) {
throw error
}
}
}
module.exports = ProductService;
\ No newline at end of file
...@@ -186,7 +186,7 @@ class System { ...@@ -186,7 +186,7 @@ class System {
let local = "http://127.0.0.1"; let local = "http://127.0.0.1";
let dev = "http://39.107.234.14"; let dev = "http://39.107.234.14";
return { return {
// 签约引擎 // 产品引擎
engine_product: local + ":3571" + path, engine_product: local + ":3571" + path,
// 计费引擎 // 计费引擎
engine_fee: local + ":3103" + path, engine_fee: local + ":3103" + path,
...@@ -196,9 +196,9 @@ class System { ...@@ -196,9 +196,9 @@ class System {
engine_sign: local + ":3103" + path, engine_sign: local + ":3103" + path,
// 用户服务 // 用户服务
sve_uc: local + ":3651" + path, sve_uc: dev + ":3651" + path,
// 商户服务 // 商户服务
sve_merchant: dev + ":3103" + path, sve_merchant: local + ":3652" + path,
// 订单服务 // 订单服务
sve_order: dev + ":3653" + path, sve_order: dev + ":3653" + path,
} }
......
...@@ -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,60 +2,70 @@ ...@@ -2,60 +2,70 @@
var system = require("../../base/system"); var system = require("../../base/system");
var fs = require('fs'); var fs = require('fs');
var marked = require("marked"); var marked = require("marked");
const os = require("os")
module.exports = function (app) { module.exports = function (app) {
app.get('/doc', function (req, res) { app.get('/doc', function (req, res) {
var path = process.cwd() + "/app/front/entry/public/apidoc/README.md"; // var path = process.cwd() + "/app/front/entry/public/apidoc/README.md";
// var path = process.cwd() + "/xgg-saas-platform/app/front/entry/public/apidoc/README.md"; // var path = process.cwd() + "/esign-admin/app/front/entry/public/apidoc/README.md";
fs.readFile(path, function(err, data){ var path = `${process.cwd()}${os.type == 'Windows_NT' ?
if(err){ "/esign-admin/app/front/entry/public/apidoc/README.md" :
"/app/front/entry/public/apidoc/README.md"}`;
fs.readFile(path, function (err, data) {
if (err) {
console.log(err); console.log(err);
res.send("文件不存在!"); res.send("文件不存在!");
} else{ } else {
console.log(data); console.log(data);
str = marked(data.toString()); str = marked(data.toString());
res.render('apidoc',{str}); res.render('apidoc', { str });
} }
}); });
}); });
app.get('/doc/:forder', function (req, res) { app.get('/doc/:forder', function (req, res) {
var path = process.cwd() + "/app/front/entry/public/apidoc/README.md"; // var path = process.cwd() + "/app/front/entry/public/apidoc/README.md";
// var path = process.cwd() + "/xgg-saas-platform/app/front/entry/public/apidoc/README.md"; // var path = process.cwd() + "/esign-admin/app/front/entry/public/apidoc/README.md";
var path = `${process.cwd()}${os.type == 'Windows_NT' ?
"/esign-admin/app/front/entry/public/apidoc/README.md" :
"/app/front/entry/public/apidoc/README.md"}`;
fs.readFile(path, function(err, data){ fs.readFile(path, function (err, data) {
if(err){ if (err) {
console.log(err); console.log(err);
res.send("文件不存在!"); res.send("文件不存在!");
} else{ } else {
console.log(data); console.log(data);
str = marked(data.toString()); str = marked(data.toString());
res.render('apidoc',{str}); res.render('apidoc', { str });
} }
}); });
}); });
app.get('/doc/:forder/:fileName', function (req, res) { app.get('/doc/:forder/:fileName', function (req, res) {
var forder = req.params["forder"]; var forder = req.params["forder"];
var fileName = req.params["fileName"] || "README.md"; var fileName = req.params["fileName"] || "README.md";
var path = process.cwd() + "/app/front/entry/public/apidoc"; // var path = process.cwd() + "/app/front/entry/public/apidoc";
// var path = process.cwd() + "/xgg-saas-platform/app/front/entry/public/apidoc"; // var path = process.cwd() + "/esign-admin/app/front/entry/public/apidoc";
if(forder) { var path = `${process.cwd()}${os.type == 'Windows_NT' ?
path = path + "/" + forder + "/" + fileName; "/esign-admin/app/front/entry/public/apidoc" :
"/app/front/entry/public/apidoc"}`;
if (forder) {
path = path + "/" + forder + "/" + fileName;
} else { } else {
path = path + "/" + fileName; path = path + "/" + fileName;
} }
fs.readFile(path, function(err, data){ fs.readFile(path, function (err, data) {
if(err){ if (err) {
console.log(err); console.log(err);
res.send("文件不存在!"); res.send("文件不存在!");
} else{ } else {
console.log(data); console.log(data);
str = marked(data.toString()); str = marked(data.toString());
console.log(str); console.log(str);
res.render('apidoc',{str}); res.render('apidoc', { str });
} }
}); });
}); });
}; };
...@@ -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)
......
[返回主目录](/doc)
<a name="menu">目录</a>
1. [新增/修改](#save)
1. [激活冻结](#enabled)
1. [列表页](#page)
## **<a name="add"> 添加</a>**
[返回到目录](#menu)
##### URL
[/web/uc/userCtl/addUser]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"org_id": 3, // 组织机构id
"isMain": 0, // 是否主管
"ucname": "guodegang10", // 用户名/登录名
"password": "123", // 密码
"mobile": "13811112222", // 手机号
"realName": "郭德纲10", // 姓名
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {},
"requestid": "2dc587798f974902b06123ce34c39090"
}
```
## **<a name="upd"> 更新</a>**
[返回到目录](#menu)
##### URL
[/web/uc/userCtl/updUser]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"id": "17", // 用户id
"org_id": 3, // 组织机构id
"isMain": 0, // 是否主管
"mobile": "13811112222", // 手机号
"realName": "郭德纲10", // 姓名
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {},
"requestid": "007fd384e47641d2a71e9f3ef6292843"
}
```
## **<a name="enabled"> 启用禁用</a>**
[返回到目录](#menu)
##### URL
[/web/uc/userCtl/enabled]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"id": 1, //记录ID 必传
"enabled": 0, // 0禁用 1启用
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {},
"requestid": "007fd384e47641d2a71e9f3ef6292843"
}
```
[返回主目录](/doc)
<a name="menu">目录</a>
1. [登录](#login)
1. [登录信息](#currentUser)
## **<a name="login"> 登录</a>**
[返回到目录](#menu)
##### URL
[/web/uc/userCtl/login]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"loginName": "admin",
"password": "123123"
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"loginName": "admin", // 登录名
"mobile": "13012341234", // 手机号
"real_name": "admin测试", // 姓名
"key": "xxx." // 登录key,HEADER esignadminsid
}
}
```
## **<a name="currentUser"> 登录信息</a>**
[返回到目录](#menu)
##### URL
[/web/uc/userCtl/currentUser]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"loginName": "admin", // 登录名
"mobile": "13012341234", // 手机号
"real_name": "admin测试", // 姓名
}
}
```
[返回主目录](/doc) [返回主目录](/doc)
<a name="menu">目录</a> <a name="menu">目录</a>
1. [添加](#add) 1. [](#add)
1. [更新](#upd) 1. [更新](#upd)
1. [启用禁用](#enabled) 1. [启用禁用](#enabled)
1. [删除](#del) 1. [删除](#del)
......
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