admin

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Index

Constants

This section is empty.

Variables

View Source
var CreateAdminRouter = router.Handler(func(c router.Context) {
	var (
		input CreateAdminParams
		err   error
	)

	defer func() {
		c.ResponseFunc(err, func() schema.Response {
			return CreateAdmin(input, false)
		})
	}()

	if err = c.ShouldBindJSON(&input); err != nil {
		return
	}

	adminInfo := model.Admin{
		Id: c.Uid(),
	}

	if err = database.Db.Where(&adminInfo).First(&adminInfo).Error; err != nil {
		if err == gorm.ErrRecordNotFound {
			err = exception.AdminNotExist
			return
		}
		return
	}

	if adminInfo.IsSuper == false {
		err = exception.AdminNotSuper
		return
	}

})
View Source
var DeleteAdminByIdRouter = router.Handler(func(c router.Context) {
	id := c.Param("admin_id")

	c.ResponseFunc(nil, func() schema.Response {
		return DeleteAdminById(helper.NewContext(&c), id)
	})
})
View Source
var GetAccessionRouter = router.Handler(func(c router.Context) {
	c.ResponseFunc(nil, func() schema.Response {
		return GetAccession()
	})
})
View Source
var GetAdminInfoByIdRouter = router.Handler(func(c router.Context) {
	adminId := c.Param("admin_id")

	c.ResponseFunc(nil, func() schema.Response {
		return GetAdminInfoById(helper.NewContext(&c), adminId)
	})
})
View Source
var GetAdminInfoRouter = router.Handler(func(c router.Context) {
	c.ResponseFunc(nil, func() schema.Response {
		return GetAdminInfo(helper.NewContext(&c))
	})
})
View Source
var GetListRouter = router.Handler(func(c router.Context) {
	var (
		input Query
	)

	c.ResponseFunc(c.ShouldBindQuery(&input), func() schema.Response {
		return GetList(helper.NewContext(&c), input)
	})
})
View Source
var LoginRouter = router.Handler(func(c router.Context) {
	var (
		input SignInParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return Login(input)
	})
})
View Source
var UpdatePasswordRouter = router.Handler(func(c router.Context) {
	var (
		input UpdatePasswordParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return UpdatePassword(helper.NewContext(&c), input)
	})
})
View Source
var UpdateRouter = router.Handler(func(c router.Context) {
	var (
		input UpdateParams
	)

	id := c.Param("admin_id")

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return Update(helper.NewContext(&c), id, input)
	})
})

Functions

func CreateAdmin

func CreateAdmin(input CreateAdminParams, isSuper bool) (res schema.Response)

创建管理员

func DeleteAdminByAccount

func DeleteAdminByAccount(account string)

func DeleteAdminById

func DeleteAdminById(c helper.Context, adminId string) (res schema.Response)

func GetAccession

func GetAccession() (res schema.Response)

func GetAdminInfo

func GetAdminInfo(c helper.Context) (res schema.Response)

func GetAdminInfoById

func GetAdminInfoById(c helper.Context, adminId string) (res schema.Response)

func GetList

func GetList(c helper.Context, input Query) (res schema.Response)

func Login

func Login(input SignInParams) (res schema.Response)

func Update

func Update(c helper.Context, adminId string, input UpdateParams) (res schema.Response)

func UpdatePassword

func UpdatePassword(c helper.Context, input UpdatePasswordParams) (res schema.Response)

Types

type CreateAdminParams

type CreateAdminParams struct {
	Account  string `json:"account" valid:"required~请输入管理员账号"`  // 管理员账号,登陆凭证
	Password string `json:"password" valid:"required~请输入管理员密码"` // 管理员密码
	Name     string `json:"name" valid:"required~请输入管理员名称"`     // 管理员名称,注册后不可修改
}

type Query

type Query struct {
	schema.Query
	Status *model.AdminStatus `json:"status"` // 管理员状态
}

type SignInParams

type SignInParams struct {
	Username string
	Password string
}

type UpdateParams

type UpdateParams struct {
	Status    *model.AdminStatus `json:"status"`    // 管理员状态
	Name      *string            `json:"name"`      // 管理员名字
	Accession *[]string          `json:"accession"` // 管理员的权限
}

type UpdatePasswordParams

type UpdatePasswordParams struct {
	OldPassword     string `json:"old_password" valid:"required~请输入旧密码"`      // 旧密码
	NewPassword     string `json:"new_password" valid:"required~请输入新密码"`      // 新密码
	ConfirmPassword string `json:"confirm_password" valid:"required~请输入确认密码"` // 确认密码
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL