Commit 71fcd8ba by 孙亚楠

d

parent bea0e9a8
......@@ -11,7 +11,7 @@ class ActionAPI extends APIBase {
this.userSve = system.getObject("service.user.userSve");
this.roleSve = system.getObject("service.role.roleSve");
this.authSve = system.getObject("service.auth.authSve");
this.ssmuserSve = system.getObject("service.user.ssmuserSve");
this.saasplatformuserSve = system.getObject("service.user.saasplatformuserSve");
this.saasmerchantuserSve = system.getObject("service.user.saasmerchantuserSve");
this.saasmerchantappletuserSve = system.getObject("service.user.saasmerchantappletuserSve");
......@@ -35,7 +35,7 @@ class ActionAPI extends APIBase {
try {
result = await this.handleRequest(pobj.action_process, pobj.action_type, pobj.action_body);
} catch (error) {
console.log(error);
console.log(error.stack);
}
return result;
}
......@@ -43,6 +43,22 @@ class ActionAPI extends APIBase {
async handleRequest(action_process, action_type, action_body) {
var opResult = null;
switch (action_type) {
//ssm start
case "addSsm":
opResult = await this.ssmuserSve.addSsm(action_body);
break;
case "updSsm":
opResult = await this.ssmuserSve.updSsm(action_body);
break;
case "querySsmUser":
opResult = await this.ssmuserSve.querySsmUser(action_body);
break;
case "querySsmUsers":
opResult = await this.ssmuserSve.querySsmUsers(action_body);
break;
//ssm end
// saas
case "addSaas":
opResult = await this.saasSve.apiAddSaas(action_body);
......@@ -161,7 +177,6 @@ class ActionAPI extends APIBase {
case "openSaasBusiness":
opResult = await this.saasbusinessSve.openSaasBusiness(action_body);
break;
case "platformLogin":
opResult = await this.saasplatformuserSve.login(action_body);
break;
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class SsmUserDao extends Dao {
constructor() {
super(Dao.getModelName(SsmUserDao));
}
/**
* fn:单查信息查询
* @param params
* @returns {Promise<void>}
*/
async getSingleSsmUser(params){
var sql = [];
sql.push("SELECT * ");
sql.push("FROM ssm_user");
sql.push("WHERE deleted_at IS NULL");
this.setSingleCondition(sql, params);
let res = await this.customQuery(sql.join(" "), params);
return res.length==0?null:res[0];
}
/**
* fn:设置单个查询条件
* @param sql
* @param params
*/
setSingleCondition(sql, params) {
if (!params || !sql) {
return;
}
if (params.id) {
sql.push("AND id = :id");
}
if (params.ucname) {
sql.push("AND ucname = :ucname");
}
if (params.mobile) {
sql.push("AND mobile = :mobile");
}
if (params.realName) {
sql.push("AND realName LIKE :realName");
}
if (params.createBegin) {
sql.push("AND created_at >= :createBegin");
}
if (params.createEnd) {
sql.push("AND created_at <= :createEnd");
}
if (params.isEnabled === 0 || params.isEnabled === 1) {
sql.push("AND isEnabled = :isEnabled");
}
}
/**
* fn:列表查询统计
* @param params
* @returns {Promise<c|number>}
*/
async countByCondition(params) {
var sql = [];
sql.push("SELECT");
sql.push("count(1) as count");
sql.push("FROM ssm_user");
sql.push("WHERE deleted_at IS NULL");
this.setSingleCondition(sql, params);
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return 0;
}
return list[0].count;
}
/**
* fn:查询列表
* @param params
* @returns {Promise<void>}
*/
async getMultipleSsmUser(params) {
var sql = [];
sql.push("SELECT");
sql.push("*");
sql.push("FROM ssm_user");
sql.push("WHERE deleted_at IS NULL");
this.setSingleCondition(sql, params);
sql.push("ORDER BY id DESC");
sql.push("LIMIT :startRow, :pageSize");
return await this.customQuery(sql.join(" "), params) || [];
}
}
module.exports = SsmUserDao;
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("ssmuser", {
ucname: DataTypes.STRING,
mobile: DataTypes.STRING,
realName: DataTypes.STRING,
password: DataTypes.STRING,
isEnabled: {
type: DataTypes.BOOLEAN,
defaultValue: true
}
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'ssm_user',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class SsmuserService extends ServiceBase {
constructor() {
super("user", ServiceBase.getDaoName(SsmuserService));
this.IS_ENABLED =1; //SSM_USER 用户是否可用
}
/**
* fn:添加ssmUser 用户
* @param params
* @returns {Promise<void>}
*/
async addSsm(params){
if (!params.ucname) {
return system.getResult(null, `用户名不能为空`);
}
if (!params.mobile) {
return system.getResult(null, `手机号不能为空`);
}
if (!params.realName) {
return system.getResult(null, `姓名不能为空`);
}
if (!params.password) {
return system.getResult(null, `密码不能为空`);
}else{
params.password = await this.getEncryptStr(params.password);
}
try {
let condition = {
ucname: this.trim(params.ucname)
};
let _ssm = await this.dao.getSingleSsmUser(condition);
if(_ssm){
console.log(`xggsve-uc->ssmuserSve->addSsm(查询用户信息)${JSON.stringify(_ssm)}`);
return system.getResult(null, `用户【${params.ucname}】已存在`);
}
let property = {isEnabled:this.IS_ENABLED};
property.ucname = this.trim(params.ucname);
property.mobile = this.trim(params.mobile);
property.realName = this.trim(params.realName);
property.password = this.trim(params.password);
console.log(`xggsve-uc->ssmuserSve->addSsm(添加用户信息)${JSON.stringify(property)}`);
let res = await this.dao.create(property);
return system.getResult(res);
}catch (e) {
console.log(e);
return system.getResult(null,`系统错误 错误信息${e.stack}`)
}
}
/**
* fn:添加ssmUser 用户
* @param params
* @returns {Promise<void>}
*/
async updSsm(params){
let property = {};
if (params.id) {
property.id = this.trim(params.id);
}
if (params.ucname) {
property.ucname = this.trim(params.ucname);
}
if (params.mobile) {
property.mobile = this.trim(params.mobile);
}
if (params.realName) {
property.realName = this.trim(params.realName);
}
if (params.password) {
property.password = await this.getEncryptStr(params.password);
}
if(params.hasOwnProperty("isEnabled") && (params.isEnabled==1 || params.isEnabled==0)){
property.isEnabled = params.isEnabled;
}
try {
let condition = {
id: this.trim(params.id)
};
let _ssm = await this.dao.getSingleSsmUser(condition);
if(!_ssm){
return system.getResult(null, `用户【${params.ucname}】不存已存在`);
}
console.log(`xggsve-uc->ssmuserSve->updSsm(查询用户信息)${JSON.stringify(_ssm)}`);
console.log(`xggsve-uc->ssmuserSve->updSsm(跟新用户信息)${JSON.stringify(property)}`);
let res = await this.dao.update(property);
return system.getResult(res);
}catch (e) {
console.log(e);
return system.getResult(null,`系统错误 错误信息${e.stack}`)
}
}
/**
* fn:查询用户信息
* @param params
* @returns {Promise<void>}
*/
async querySsmUser(params){
if(!params){
return system.getResult(null, `参数错误 参数:【${JSON.stringify(params)}】`);
}
try{
let _ssm = await this.dao.getSingleSsmUser(params);
if(!_ssm){
return system.getResult(null, `用户【${params.ucname}】不存存在`);
}
console.log(`xggsve-uc->ssmuserSve->updSsm(查询用户信息)${JSON.stringify(_ssm)}`);
this.handleDate(_ssm, ["created_at"], null);
_ssm.isEnabledName = _ssm.isEnabled == 1 ? "已启用" : "未启用";
return system.getResult(_ssm);
}catch (e) {
console.log(e);
return system.getResult(null, `系统错误 错误信息${e.stack}`);
}
}
/**
* fn:ssmuser用户列表
* @param params
* @returns {Promise<void>}
*/
async querySsmUsers(params) {
var result = {
count: 0,
rows: []
};
try{
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
params.startRow = (params.currentPage - 1) * params.pageSize;
var total = await this.dao.countByCondition(params);
if (total == 0) {
return result;
}else{
result.count = total;
}
result.rows = await this.dao.getMultipleSsmUser(params) || [];
if (result.rows) {
for (let item of result.rows) {
this.handleDate(item, ["created_at"], null);
item.isEnabledName = item.isEnabled == 1 ? "已启用" : "未启用";
}
}
return system.getResultSuccess(result);
}catch (e) {
console.log(e);
return system.getResult(null, `系统错误 错误信息${e.stack}`);
}
}
}
module.exports = SsmuserService;
\ 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