Merge pull request #486 from go-admin-team/dev

Dev
This commit is contained in:
wenjianzhang authored and GitHub committed 2021-07-14 11:40:05 +08:00
commit a7fa7e079b
5 files changed
+57 -20

No files matched your search

+2 -2
View File
@@ -101,7 +101,7 @@ func (e SysUser) Get(c *gin.Context) {
// @Security Bearer // @Security Bearer
func (e SysUser) Insert(c *gin.Context) { func (e SysUser) Insert(c *gin.Context) {
s := service.SysUser{} s := service.SysUser{}
req := dto.SysUserControl{} req :=dto.SysUserInsertReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req, binding.JSON). Bind(&req, binding.JSON).
@@ -136,7 +136,7 @@ func (e SysUser) Insert(c *gin.Context) {
// @Security Bearer // @Security Bearer
func (e SysUser) Update(c *gin.Context) { func (e SysUser) Update(c *gin.Context) {
s := service.SysUser{} s := service.SysUser{}
req := dto.SysUserControl{} req :=dto.SysUserUpdateReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(&req). Bind(&req).
+50 -13
View File
@@ -72,8 +72,8 @@ func (s *UpdateSysUserAvatarReq) Generate(model *models.SysUser) {
} }
type UpdateSysUserStatusReq struct { type UpdateSysUserStatusReq struct {
UserId int `json:"userId" comment:"用户ID" binding:"required"` // 用户ID UserId int `json:"userId" comment:"用户ID" vd:"required"` // 用户ID
Status string `json:"status" comment:"状态" binding:"required"` Status string `json:"status" comment:"状态" vd:"required"`
common.ControlBy common.ControlBy
} }
@@ -88,24 +88,24 @@ func (s *UpdateSysUserStatusReq) Generate(model *models.SysUser) {
model.Status = s.Status model.Status = s.Status
} }
type SysUserControl struct { type SysUserInsertReq struct {
UserId int `json:"userId" comment:"用户ID"` // 用户ID UserId int `json:"userId" comment:"用户ID"` // 用户ID
Username string `json:"username" comment:"用户名" binding:"required"` Username string `json:"username" comment:"用户名" vd:"required"`
Password string `json:"password" comment:"密码"` Password string `json:"password" comment:"密码"`
NickName string `json:"nickName" comment:"昵称" binding:"required"` NickName string `json:"nickName" comment:"昵称" vd:"required"`
Phone string `json:"phone" comment:"手机号" binding:"required"` Phone string `json:"phone" comment:"手机号" vd:"required"`
RoleId int `json:"roleId" comment:"角色ID"` RoleId int `json:"roleId" comment:"角色ID"`
Avatar string `json:"avatar" comment:"头像"` Avatar string `json:"avatar" comment:"头像"`
Sex string `json:"sex" comment:"性别"` Sex string `json:"sex" comment:"性别"`
Email string `json:"email" comment:"邮箱" binding:"required,email"` Email string `json:"email" comment:"邮箱" vd:"required,email"`
DeptId int `json:"deptId" comment:"部门" binding:"required"` DeptId int `json:"deptId" comment:"部门" vd:"required"`
PostId int `json:"postId" comment:"岗位"` PostId int `json:"postId" comment:"岗位"`
Remark string `json:"remark" comment:"备注"` Remark string `json:"remark" comment:"备注"`
Status string `json:"status" comment:"状态" binding:"required" default:"1"` Status string `json:"status" comment:"状态" vd:"required" default:"1"`
common.ControlBy common.ControlBy
} }
func (s *SysUserControl) Generate(model *models.SysUser) { func (s *SysUserInsertReq) Generate(model *models.SysUser) {
if s.UserId != 0 { if s.UserId != 0 {
model.UserId = s.UserId model.UserId = s.UserId
} }
@@ -123,7 +123,44 @@ func (s *SysUserControl) Generate(model *models.SysUser) {
model.Status = s.Status model.Status = s.Status
} }
func (s *SysUserControl) GetId() interface{} { func (s *SysUserInsertReq) GetId() interface{} {
return s.UserId
}
type SysUserUpdateReq struct {
UserId int `json:"userId" comment:"用户ID"` // 用户ID
Username string `json:"username" comment:"用户名" vd:"required"`
NickName string `json:"nickName" comment:"昵称" vd:"required"`
Phone string `json:"phone" comment:"手机号" vd:"required"`
RoleId int `json:"roleId" comment:"角色ID"`
Avatar string `json:"avatar" comment:"头像"`
Sex string `json:"sex" comment:"性别"`
Email string `json:"email" comment:"邮箱" vd:"required,email"`
DeptId int `json:"deptId" comment:"部门" vd:"required"`
PostId int `json:"postId" comment:"岗位"`
Remark string `json:"remark" comment:"备注"`
Status string `json:"status" comment:"状态" vd:"required" default:"1"`
common.ControlBy
}
func (s *SysUserUpdateReq) Generate(model *models.SysUser) {
if s.UserId != 0 {
model.UserId = s.UserId
}
model.Username = s.Username
model.NickName = s.NickName
model.Phone = s.Phone
model.RoleId = s.RoleId
model.Avatar = s.Avatar
model.Sex = s.Sex
model.Email = s.Email
model.DeptId = s.DeptId
model.PostId = s.PostId
model.Remark = s.Remark
model.Status = s.Status
}
func (s *SysUserUpdateReq) GetId() interface{} {
return s.UserId return s.UserId
} }
@@ -146,6 +183,6 @@ func (s *SysUserById) GenerateM() (common.ActiveRecord, error) {
// PassWord 密码 // PassWord 密码
type PassWord struct { type PassWord struct {
NewPassword string `json:"newPassword" binding:"required"` NewPassword string `json:"newPassword" vd:"required"`
OldPassword string `json:"oldPassword" binding:"required"` OldPassword string `json:"oldPassword" vd:"required"`
} }
+2 -2
View File
@@ -60,7 +60,7 @@ func (e *SysUser) Get(d *dto.SysUserById, p *actions.DataPermission, model *mode
} }
// Insert 创建SysUser对象 // Insert 创建SysUser对象
func (e *SysUser) Insert(c *dto.SysUserControl) error { func (e *SysUser) Insert(c *dto.SysUserInsertReq) error {
var err error var err error
var data models.SysUser var data models.SysUser
var i int64 var i int64
@@ -84,7 +84,7 @@ func (e *SysUser) Insert(c *dto.SysUserControl) error {
} }
// Update 修改SysUser对象 // Update 修改SysUser对象
func (e *SysUser) Update(c *dto.SysUserControl, p *actions.DataPermission) error { func (e *SysUser) Update(c *dto.SysUserUpdateReq, p *actions.DataPermission) error {
var err error var err error
var model models.SysUser var model models.SysUser
db := e.Orm.Scopes( db := e.Orm.Scopes(
+1 -1
View File
@@ -2,7 +2,7 @@ package global
const ( const (
// Version go-admin version info // Version go-admin version info
Version = "2.0.0-beta.9" Version = "2.0.0-beta.11"
) )
var ( var (
+2 -2
View File
@@ -8,7 +8,7 @@ require (
github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5 github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5
github.com/bytedance/go-tagexpr/v2 v2.7.12 github.com/bytedance/go-tagexpr/v2 v2.7.12
github.com/casbin/casbin/v2 v2.25.1 github.com/casbin/casbin/v2 v2.25.1
github.com/gin-gonic/gin v1.7.1 github.com/gin-gonic/gin v1.7.2
github.com/go-admin-team/go-admin-core v1.3.6 github.com/go-admin-team/go-admin-core v1.3.6
github.com/go-admin-team/go-admin-core/sdk v1.3.6 github.com/go-admin-team/go-admin-core/sdk v1.3.6
github.com/google/uuid v1.2.0 github.com/google/uuid v1.2.0
@@ -28,7 +28,7 @@ require (
gorm.io/driver/mysql v1.0.4-0.20201206014609-ae5fd10184f6 gorm.io/driver/mysql v1.0.4-0.20201206014609-ae5fd10184f6
gorm.io/driver/postgres v1.0.6-0.20201208020313-1ed927cfab53 gorm.io/driver/postgres v1.0.6-0.20201208020313-1ed927cfab53
gorm.io/driver/sqlite v1.1.5-0.20201206014648-c84401fbe3ba gorm.io/driver/sqlite v1.1.5-0.20201206014648-c84401fbe3ba
gorm.io/gorm v1.21.10 gorm.io/gorm v1.21.11
) )
//replace ( //replace (