Git Product home page Git Product logo

svc-user's Introduction

svc-user

语言

避免每次开发cms类后台总要重复写用户管理功能代码,svc-user是Go实现的微服务用户系统,grpc+api模式,一对多,统一的用户管理,但角色、权限和菜单隔离。包含 用户、角色、登录、权限、菜单、JWT 等。

推荐开发cms后台可以直接实现业务功能,无需开发任何用户管理的页面功能,通过svc-user统一管理用户角色。如业务功能必须与用户关联,可将grpc服务封装接口给前端实现页面。

高可用:可部署多节点,通过nginx等负载即可。

开发环境依赖

数据表和主要字段

  • users 用户基础表

    • Account string
    • Password string
    • Mobile string
    • Email string
  • infos 用户信息表

    • RealName string
    • Age uint
    • Sex uint
    • Address string
    • IdCard string
  • apps 应用注册表

    • Name string
    • Remark string
    • AppKey string
    • AppSecret string
  • menus 菜单表,权限模板

    • PID uint
    • Code string
    • Name string
    • Uri string
    • Remark string
    • Sequence uint
    • Actions string
    • AppKey string
  • roles 应用角色表

    • Name string
    • Remark string
    • Sequence uint
    • AppKey string
  • roleAuthoritys 角色权限表

    • Code string
    • ActionValue string
    • RoleID uint
  • roleUserMap 角色用户关系表

    • AppKey string
    • UserID uint
    • RoleID uint

API 注释

http://127.0.0.1:8888/docs/swagger/index.html

http://127.0.0.1:8888/docs/proto/

demo

demo

部署

支持

  • 部署 Mysql

配置文件

You should modify /etc/svc-user.yml

listen: 0.0.0.0:8888
logger:
  dir: /var/log/svc-user
  level: 5
  rotate: true
  keepdays: 7
mysql:
  host: 127.0.0.1
  port: 3306
  pass: 123456
  user: root
  name: dvsdb30
redis:
  cluster: false
  addr: 
    - 127.0.0.1:6379
  pass: 123456
smtp:
  host: smtp.exmail.qq.com
  port: 25
  user: [email protected]
  pass: xxx

编译部署

// 依赖protoc和swag
// 更新grpc文档
protoc -I proto --go_out=plugins=grpc:. ./proto/user.proto --doc_out=./docs --doc_opt=html,index.html
protoc --php_out=sdk/php ./proto/user.proto
// 更新API文档
swag init --exclude proto
go build
编辑配置文件
vi /etc/svc-user.yml
启动服务
./svc-user

// rpm打包
sh build.sh 1.0.0.001
rpm包安装启动
systemctl start svc-user

使用

服务启动后访问http://127.0.0.1:8888/ 访问管理后台,默认管理用户root,密码123456,除了root,普通用户无法登录管理后台。

demo

用户使用:

​ 注册账号需要通过邀请码,管理员通过后台工作台生成,注册账号后即可登录所有接入此系统的应用。登录后的权限与菜单管理根据各应用情况区分。

应用开发:

​ 登录后台后 - 应用管理 - 新增,分配appKey和appSecret;通过grpc发起服务调用。管理用户、角色、配置自己的应用菜单或权限模板,可参考examples和sdk目录下的例子。

demo

​ 应用接入开发时,以下公共接口可以直接使用。或通过RPC服务实现自己的接口。

使用php-sdk

将sdk下php目录拷贝到你自己的项目内,引入Api.php进行调用服务。

svc-user's People

Contributors

junbin-yang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.