Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Created by WebStorm.
* User: nirongxu
* Date: 2019-03-20
* Description: 文件描述
*/
const Service = require('egg/index').Service;
class UserService extends Service {
// 修改用户信息
async editUserInfo(options) {
let {id} = options
options.status = options.status ? "1": "0"
let results
await this.ctx.model.SystemUser.update(options, {
where: {
id//查询条件
}
}).then(ok => {
console.log(ok);
results = {
code: 200,
message: '修改成功'
/**
* Created by WebStorm.
* User: Administrator
* Date: 2019/4/26
* Description: 文件描述
*/
const Service = require('egg/index').Service;
class RoleService extends Service {
// 获取角色列表
async getRoleList() {
let {ctx} = this
let result
await this.ctx.model.SystemRole.findAndCountAll().then(async res => {
result = res
for (let i = 0; i < result.rows.length; i++) {
if (result.rows[i].name === '超级管理员') {
result.rows[i].dataValues.disabled = true
}
}
}).catch(err => {
console.log(err);
/**
* Created by WebStorm.
* User: nirongxu
* Date: 2019-02-01
* Description: 文件描述
*/
const Service = require('egg/index').Service;
class UserService extends Service {
// 登录查询账号
async findUsername(username) {
let user = await this.ctx.model.SystemUser.findOne({
where: {username}
})
return user;
}
// 登录查询个人信息
async getUserInfor(info) {
let {ctx} = this
let userInfo;
await this.ctx.model.SystemUser.findOne({
where: {id: info.message.id}
/**
* Created by WebStorm.
* User: nirongxu
* Date: 2019-03-17
* Description: 文件描述
*/
const Service = require('egg/index').Service;
const {cryptoMd5} = require('../../extend/helper');
class RegisterService extends Service {
async userRegister(options){
let {ctx} = this
let {username, password} = options
let keys = this.config.keys;
let results = ''
await this.ctx.model.SystemUser.findOne({
where: {
username//查询条件
}
}).then(async result=> {
if (!result) {
options.password = await cryptoMd5(password, keys)
await ctx.model.SystemUser.create(options).then(ok => {