Skip to content

Commit

Permalink
v1.3.5: mod user break change
Browse files Browse the repository at this point in the history
  • Loading branch information
mizuki1412 committed Mar 31, 2022
1 parent f0a5f3a commit 0965f48
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BINARY=go-core-kit
VERSION=1.3.2
VERSION=1.3.5
DATE=`date +%FT%T%z`
.PHONY: init build

Expand Down
2 changes: 1 addition & 1 deletion mod/user/action/role/department_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func departmentDel(ctx *context.Context) {
if val, ok := department.Extend.Map["immutable"]; ok && val.(bool) {
panic(exception.New("该部门不可删除"))
}
dao.Delete(department)
dao.DeleteOff(department)
ctx.JsonSuccess(nil)
}

Expand Down
2 changes: 1 addition & 1 deletion mod/user/action/role/role_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func del(ctx *context.Context) {
if us != nil && len(us) > 0 {
panic(exception.New("角色下还有用户,不能删除"))
}
dao.Delete(role)
dao.DeleteOff(role)
ctx.JsonSuccess(nil)
}

Expand Down
2 changes: 1 addition & 1 deletion mod/user/action/user/user_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func updateUserInfo(ctx *context.Context) {
}
user.Pwd.Set(cryptokit.MD5(params.NewPwd.String))
}
// todo usercenter
//todo usercenter
dao.Update(u)
ctx.JsonSuccess(nil)
}
5 changes: 5 additions & 0 deletions mod/user/dao/userdao/userdao.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/Masterminds/squirrel"
"github.com/mizuki1412/go-core-kit/class/exception"
"github.com/mizuki1412/go-core-kit/library/stringkit"
"github.com/mizuki1412/go-core-kit/mod/user/dao/departmentdao"
"github.com/mizuki1412/go-core-kit/mod/user/dao/roledao"
"github.com/mizuki1412/go-core-kit/mod/user/model"
"github.com/mizuki1412/go-core-kit/service/sqlkit"
Expand Down Expand Up @@ -33,8 +34,12 @@ func (dao *Dao) cascade(obj *model.User) {
if obj.Role != nil {
obj.Role = roledao.New(dao.Schema).FindById(obj.Role.Id)
}
if obj.Department != nil {
obj.Department = departmentdao.New(dao.Schema).FindById(obj.Department.Id)
}
case ResultNone:
obj.Role = nil
obj.Department = nil
}
}
func (dao *Dao) scan(sql string, args []any) []*model.User {
Expand Down
3 changes: 1 addition & 2 deletions mod/user/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"github.com/mizuki1412/go-core-kit/service/restkit/router"
)

/*** 用户、部门、角色模块 */

// All 用户、部门、角色模块
func All() []func(r *router.Router) {
return []func(r *router.Router){user.Init, role.Init, smscode.Init}
}
7 changes: 4 additions & 3 deletions mod/user/model/department.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
)

type Department struct {
Id int32 `json:"id" db:"id" pk:"true" tablename:"department" autoincrement:"true"`
No class.String `json:"no,omitempty" db:"no"`
Id int32 `autoincrement:"true" json:"id" db:"id" pk:"true" tablename:"department"`
No class.String `json:"no,omitempty" db:"no" description:"编号"`
Name class.String `json:"name,omitempty" db:"name"`
Descr class.String `json:"descr,omitempty" db:"descr"`
Descr class.String `json:"descr,omitempty" db:"descr" description:"描述"`
Parent *Department `json:"parent,omitempty" db:"parent"`
Extend class.MapString `json:"extend,omitempty" db:"extend"`
CreateDt class.Time `json:"createDt,omitempty" db:"createdt"`
Off class.Bool `json:"off,omitempty" db:"off"`
Children []*Department `json:"children"`
}

Expand Down
4 changes: 3 additions & 1 deletion mod/user/model/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ type Role struct {
Name class.String `json:"name,omitempty" db:"name"`
Description class.String `json:"description,omitempty" db:"description"`
Privileges class.ArrString `json:"privileges,omitempty" db:"privileges"`
Extend class.MapString `json:"extend,omitempty" db:"extend"`
CreateDt class.Time `json:"createDt,omitempty" db:"createdt"`
Off class.Bool `json:"off,omitempty" db:"off"`
Extend class.MapString `json:"extend,omitempty" db:"extend" description:"immutable:不可删除"`
}

func (th *Role) Scan(value any) error {
Expand Down
25 changes: 13 additions & 12 deletions mod/user/model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ import (
)

type User struct {
Id int32 `json:"id,omitempty" db:"id" pk:"true" tablename:"admin_user" autoincrement:"true"`
Role *Role `json:"role,omitempty" db:"role"`
Username class.String `json:"username,omitempty" db:"username"`
Name class.String `json:"name,omitempty" db:"name"`
Phone class.String `json:"phone,omitempty" db:"phone"`
Pwd class.String `json:"-" db:"pwd"`
Gender class.Int32 `json:"gender" db:"gender"`
Image class.String `json:"image,omitempty" db:"image"`
Address class.String `json:"address,omitempty" db:"address"`
Off class.Int32 `json:"off" db:"off"`
Extend class.MapString `json:"extend,omitempty" db:"extend" description:""`
CreateDt class.Time `json:"createDt,omitempty" db:"createdt"`
Id int32 `json:"id,omitempty" db:"id" pk:"true" tablename:"admin_user" autoincrement:"true"`
Role *Role `json:"role,omitempty" db:"role"`
Department *Department `json:"department,omitempty" db:"department"`
Username class.String `json:"username,omitempty" db:"username"`
Name class.String `json:"name,omitempty" db:"name"`
Phone class.String `json:"phone,omitempty" db:"phone"`
Pwd class.String `json:"-" db:"pwd"`
Gender class.Int32 `json:"gender,omitempty" db:"gender" description:"1-nan,2-nv"`
Image class.String `json:"image,omitempty" db:"image" description:"头像"`
Address class.String `json:"address,omitempty" db:"address"`
Off class.Int32 `json:"off,omitempty" db:"off" description:"冻结 1, 删除 -1"`
Extend class.MapString `json:"extend,omitempty" db:"extend" description:"权限剔除privilegeExclude:[]"`
CreateDt class.Time `json:"createDt,omitempty" db:"createdt"`
}

const UserOffOK = 0
Expand Down

0 comments on commit 0965f48

Please sign in to comment.