mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-12 04:03:44 +08:00
增加注册强制邀请码开关、微信内登录自动获取openid开关
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package admin
|
||||
|
||||
import (
|
||||
@@ -103,7 +102,7 @@ func (c *cRole) UpdatePermissions(ctx context.Context, req *role.UpdatePermissio
|
||||
}
|
||||
|
||||
// DataScopeSelect 获取数据权限选项
|
||||
func (c *cRole) DataScopeSelect(ctx context.Context, req *role.DataScopeSelectReq) (res *role.DataScopeSelectRes, err error) {
|
||||
func (c *cRole) DataScopeSelect(ctx context.Context, _ *role.DataScopeSelectReq) (res *role.DataScopeSelectRes, err error) {
|
||||
data := service.AdminRole().DataScopeSelect(ctx)
|
||||
res = new(role.DataScopeSelectRes)
|
||||
res.List = data
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package common
|
||||
|
||||
import (
|
||||
@@ -43,7 +42,7 @@ func (c *cEms) SendTest(ctx context.Context, req *common.SendTestEmailReq) (res
|
||||
}
|
||||
|
||||
// SendBindEms 发送换绑邮件
|
||||
func (c *cSms) SendBindEms(ctx context.Context, req *common.SendBindEmsReq) (res *common.SendBindEmsRes, err error) {
|
||||
func (c *cSms) SendBindEms(ctx context.Context, _ *common.SendBindEmsReq) (res *common.SendBindEmsRes, err error) {
|
||||
var (
|
||||
memberId = contexts.GetUserId(ctx)
|
||||
models *entity.AdminMember
|
||||
|
||||
@@ -36,7 +36,6 @@ func (c *cSite) Config(ctx context.Context, _ *common.SiteConfigReq) (res *commo
|
||||
Version: consts.VersionApp,
|
||||
WsAddr: c.getWsAddr(ctx, request),
|
||||
Domain: c.getDomain(ctx, request),
|
||||
//InviteUrl: "http://192.168.1.27:8001/#/login?scope=register&inviteCode=",
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package sys
|
||||
|
||||
import (
|
||||
@@ -46,7 +45,7 @@ func (c *cConfig) UpdateConfig(ctx context.Context, req *config.UpdateReq) (res
|
||||
}
|
||||
|
||||
// TypeSelect 数据类型选项
|
||||
func (c *cConfig) TypeSelect(ctx context.Context, req *config.TypeSelectReq) (res config.TypeSelectRes, err error) {
|
||||
func (c *cConfig) TypeSelect(_ context.Context, _ *config.TypeSelectReq) (res config.TypeSelectRes, err error) {
|
||||
for _, v := range consts.ConfigTypes {
|
||||
res = append(res, form.Select{
|
||||
Value: v,
|
||||
@@ -58,8 +57,8 @@ func (c *cConfig) TypeSelect(ctx context.Context, req *config.TypeSelectReq) (re
|
||||
}
|
||||
|
||||
// GetCash 获取指定分组的配置
|
||||
func (c *cConfig) GetCash(ctx context.Context, req *config.GetCashReq) (res *config.GetCashRes, err error) {
|
||||
func (c *cConfig) GetCash(ctx context.Context, _ *config.GetCashReq) (res *config.GetCashRes, err error) {
|
||||
res = new(config.GetCashRes)
|
||||
res.GetConfigModel, err = service.SysConfig().GetConfigByGroup(ctx, sysin.GetConfigInp{Group: "cash"})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package sys
|
||||
|
||||
import (
|
||||
@@ -99,7 +98,7 @@ func (c *cCronGroup) Status(ctx context.Context, req *cron.GroupStatusReq) (res
|
||||
}
|
||||
|
||||
// Select 选项
|
||||
func (c *cCronGroup) Select(ctx context.Context, req *cron.GroupSelectReq) (res *cron.GroupSelectRes, err error) {
|
||||
func (c *cCronGroup) Select(ctx context.Context, _ *cron.GroupSelectReq) (res *cron.GroupSelectRes, err error) {
|
||||
data, err := service.SysCronGroup().Select(ctx, sysin.CronGroupSelectInp{})
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package sys
|
||||
|
||||
import (
|
||||
@@ -21,7 +20,7 @@ var (
|
||||
type cDictType struct{}
|
||||
|
||||
// Tree 树
|
||||
func (c *cDictType) Tree(ctx context.Context, req *dict.TypeTreeReq) (res *dict.TypeTreeRes, err error) {
|
||||
func (c *cDictType) Tree(ctx context.Context, _ *dict.TypeTreeReq) (res *dict.TypeTreeRes, err error) {
|
||||
res = new(dict.TypeTreeRes)
|
||||
res.List, err = service.SysDictType().Tree(ctx)
|
||||
return
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package sys
|
||||
|
||||
import (
|
||||
@@ -22,7 +21,7 @@ var Log = sLog{}
|
||||
type sLog struct{}
|
||||
|
||||
// Clear 清空日志
|
||||
func (c *sLog) Clear(ctx context.Context, req *log.ClearReq) (res *log.ClearRes, err error) {
|
||||
func (c *sLog) Clear(ctx context.Context, _ *log.ClearReq) (res *log.ClearRes, err error) {
|
||||
err = gerror.New("暂时考虑到安全问题,请到数据库清空")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package member
|
||||
|
||||
import (
|
||||
@@ -18,7 +17,7 @@ var (
|
||||
|
||||
type cMember struct{}
|
||||
|
||||
func (c *cMember) GetIdByCode(ctx context.Context, req *member.GetIdByCodeReq) (res *member.GetIdByCodeRes, err error) {
|
||||
func (c *cMember) GetIdByCode(ctx context.Context, _ *member.GetIdByCodeReq) (res *member.GetIdByCodeRes, err error) {
|
||||
g.RequestFromCtx(ctx).Response.Writeln("Hello World api member!")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ var (
|
||||
type cNotify struct{}
|
||||
|
||||
// AliPay 支付宝回调
|
||||
func (c *cNotify) AliPay(ctx context.Context, req *pay.NotifyAliPayReq) (res *pay.NotifyAliPayRes, err error) {
|
||||
func (c *cNotify) AliPay(ctx context.Context, _ *pay.NotifyAliPayReq) (res *pay.NotifyAliPayRes, err error) {
|
||||
_, err = service.Pay().Notify(ctx, payin.PayNotifyInp{PayType: consts.PayTypeAliPay})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -30,7 +30,7 @@ func (c *cNotify) AliPay(ctx context.Context, req *pay.NotifyAliPayReq) (res *pa
|
||||
}
|
||||
|
||||
// WxPay 微信支付回调
|
||||
func (c *cNotify) WxPay(ctx context.Context, req *pay.NotifyWxPayReq) (res *pay.NotifyWxPayRes, err error) {
|
||||
func (c *cNotify) WxPay(ctx context.Context, _ *pay.NotifyWxPayReq) (res *pay.NotifyWxPayRes, err error) {
|
||||
_, err = service.Pay().Notify(ctx, payin.PayNotifyInp{PayType: consts.PayTypeWxPay})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -42,7 +42,7 @@ func (c *cNotify) WxPay(ctx context.Context, req *pay.NotifyWxPayReq) (res *pay.
|
||||
}
|
||||
|
||||
// QQPay QQ支付回调
|
||||
func (c *cNotify) QQPay(ctx context.Context, req *pay.NotifyQQPayReq) (res *pay.NotifyQQPayRes, err error) {
|
||||
func (c *cNotify) QQPay(ctx context.Context, _ *pay.NotifyQQPayReq) (res *pay.NotifyQQPayRes, err error) {
|
||||
_, err = service.Pay().Notify(ctx, payin.PayNotifyInp{PayType: consts.PayTypeQQPay})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package user
|
||||
|
||||
import (
|
||||
@@ -18,7 +17,7 @@ var (
|
||||
|
||||
type cHello struct{}
|
||||
|
||||
func (c *cHello) Hello(ctx context.Context, req *user.HelloReq) (res *user.HelloRes, err error) {
|
||||
func (c *cHello) Hello(ctx context.Context, _ *user.HelloReq) (res *user.HelloRes, err error) {
|
||||
g.RequestFromCtx(ctx).Response.Writeln("Hello World api member!")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package base
|
||||
|
||||
import (
|
||||
@@ -20,7 +19,7 @@ var Site = cSite{}
|
||||
|
||||
type cSite struct{}
|
||||
|
||||
func (a *cSite) Index(ctx context.Context, req *base.SiteIndexReq) (res *base.SiteIndexRes, err error) {
|
||||
func (a *cSite) Index(ctx context.Context, _ *base.SiteIndexReq) (res *base.SiteIndexRes, err error) {
|
||||
service.View().Render(ctx, model.View{Data: g.Map{
|
||||
"name": "HotGo",
|
||||
"version": consts.VersionApp,
|
||||
|
||||
@@ -437,6 +437,11 @@ func (s *sAdminMember) Edit(ctx context.Context, in adminin.MemberEditInp) (err
|
||||
return
|
||||
}
|
||||
|
||||
config, err := service.SysConfig().GetLogin(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 修改
|
||||
if in.Id > 0 {
|
||||
if s.VerifySuperId(ctx, in.Id) {
|
||||
@@ -462,17 +467,20 @@ func (s *sAdminMember) Edit(ctx context.Context, in adminin.MemberEditInp) (err
|
||||
|
||||
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||
if _, err = mod.Where("id", in.Id).Data(in).Update(); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return
|
||||
}
|
||||
|
||||
// 更新岗位
|
||||
return dao.AdminMemberPost.UpdatePostIds(ctx, in.Id, in.PostIds)
|
||||
if err = dao.AdminMemberPost.UpdatePostIds(ctx, in.Id, in.PostIds); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
}
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
// 新增用户时的额外属性
|
||||
var data adminin.MemberAddInp
|
||||
data.MemberEditInp = in
|
||||
data.Salt = grand.S(6)
|
||||
data.InviteCode = grand.S(12)
|
||||
data.PasswordHash = gmd5.MustEncryptString(data.Password + data.Salt)
|
||||
@@ -484,14 +492,24 @@ func (s *sAdminMember) Edit(ctx context.Context, in adminin.MemberEditInp) (err
|
||||
return
|
||||
}
|
||||
|
||||
// 默认头像
|
||||
if in.Avatar == "" {
|
||||
in.Avatar = config.Avatar
|
||||
}
|
||||
data.MemberEditInp = in
|
||||
|
||||
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||
id, err := dao.AdminMember.Ctx(ctx).Data(data).InsertAndGetId()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return
|
||||
}
|
||||
|
||||
// 更新岗位
|
||||
return dao.AdminMemberPost.UpdatePostIds(ctx, id, in.PostIds)
|
||||
if err = dao.AdminMemberPost.UpdatePostIds(ctx, id, in.PostIds); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
}
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,17 @@ func init() {
|
||||
|
||||
// Register 账号注册
|
||||
func (s *sAdminSite) Register(ctx context.Context, in adminin.RegisterInp) (err error) {
|
||||
var data adminin.MemberAddInp
|
||||
config, err := service.SysConfig().GetLogin(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if config.ForceInvite == 1 && in.InviteCode == "" {
|
||||
err = gerror.New("请填写邀请码")
|
||||
return
|
||||
}
|
||||
|
||||
var data adminin.MemberAddInp
|
||||
// 默认上级
|
||||
data.Pid = 1
|
||||
|
||||
@@ -52,11 +61,6 @@ func (s *sAdminSite) Register(ctx context.Context, in adminin.RegisterInp) (err
|
||||
data.Pid = pmb.Id
|
||||
}
|
||||
|
||||
config, err := service.SysConfig().GetLogin(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if config.RegisterSwitch != 1 {
|
||||
err = gerror.New("管理员未开放注册")
|
||||
return
|
||||
@@ -123,10 +127,15 @@ func (s *sAdminSite) Register(ctx context.Context, in adminin.RegisterInp) (err
|
||||
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||
id, err := dao.AdminMember.Ctx(ctx).Data(data).InsertAndGetId()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return
|
||||
}
|
||||
|
||||
return dao.AdminMemberPost.UpdatePostIds(ctx, id, config.PostIds)
|
||||
// 更新岗位
|
||||
if err = dao.AdminMemberPost.UpdatePostIds(ctx, id, config.PostIds); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
}
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
@@ -252,6 +261,7 @@ func (s *sAdminSite) handleLogin(ctx context.Context, mb *entity.AdminMember) (r
|
||||
|
||||
// 更新登录信息
|
||||
if _, err = dao.AdminMember.Ctx(ctx).Data(update).Where(do.AdminMember{Id: mb.Id}).Update(); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -162,11 +162,13 @@ type LoginConfig struct {
|
||||
RegisterSwitch int `json:"loginRegisterSwitch"`
|
||||
CaptchaSwitch int `json:"loginCaptchaSwitch"`
|
||||
Avatar string `json:"loginAvatar"`
|
||||
Protocol string `json:"loginProtocol"`
|
||||
Policy string `json:"loginPolicy"`
|
||||
RoleId int64 `json:"loginRoleId"`
|
||||
DeptId int64 `json:"loginDeptId"`
|
||||
PostIds []int64 `json:"loginPostIds"`
|
||||
Protocol string `json:"loginProtocol"`
|
||||
Policy string `json:"loginPolicy"`
|
||||
AutoOpenId int `json:"loginAutoOpenId"`
|
||||
ForceInvite int `json:"loginForceInvite"`
|
||||
}
|
||||
|
||||
///////////// 以下是本地配置
|
||||
|
||||
Reference in New Issue
Block a user