How to use the egg/index.Service function in egg

To help you get started, we’ve selected a few egg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Nirongxu / nodePlatform-eggjs / server / app / service / admin / user.js View on Github external
/**
 * 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: '修改成功'
github Nirongxu / nodePlatform-eggjs / server / app / service / admin / role.js View on Github external
/**
 * 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);
github Nirongxu / nodePlatform-eggjs / server / app / service / admin / login.js View on Github external
/**
 * 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}
github Nirongxu / nodePlatform-eggjs / server / app / service / admin / register.js View on Github external
/**
 * 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 => {