feat:完善项目信息
This commit is contained in:
@ -10,7 +10,42 @@ import (
|
||||
|
||||
type Auth struct{}
|
||||
|
||||
type authForm struct {
|
||||
ParentID string `json:"parent_id" form:"parent_id"`
|
||||
Kind int `json:"kind" form:"kind" binding:"required"`
|
||||
Name string `json:"name" form:"name" binding:"required"`
|
||||
Auth string `json:"auth" form:"auth" binding:"required"`
|
||||
Sort int `json:"sort" form:"sort"`
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
}
|
||||
|
||||
func (*Auth) Index(c *gin.Context) {
|
||||
data, err := auth.NewInstance()(api.GetSession()(c).(*session.Admin)).Index()
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Auth) Add(c *gin.Context) {
|
||||
form := &struct {
|
||||
RoleID string `json:"role_id" form:"role_id" binding:"required"`
|
||||
AuthIDs []string `json:"auth_ids" form:"auth_ids" binding:"required"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (*Auth) Edit(c *gin.Context) {
|
||||
form := &struct {
|
||||
RoleID string `json:"role_id" form:"role_id" binding:"required"`
|
||||
AuthIDs []string `json:"auth_ids" form:"auth_ids" binding:"required"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (*Auth) Delete(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"SciencesServer/app/api/admin/controller/department"
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/app/session"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@ -13,14 +12,21 @@ type Department struct{}
|
||||
type departmentForm struct {
|
||||
ParentID string `json:"parent_id" form:"parent_id"`
|
||||
Name string `json:"name" form:"name" binding:"required"`
|
||||
Contact string `json:"contact" form:"contact_title"`
|
||||
Contact string `json:"contact" form:"contact"`
|
||||
ContactMobile string `json:"contact_mobile" form:"contact_mobile"`
|
||||
Status int `json:"status" form:"status" binding:"required"`
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
}
|
||||
|
||||
func (a *Department) Index(c *gin.Context) {
|
||||
data, err := department.NewInstance()(api.GetSession()(c).(*session.Admin)).Index()
|
||||
form := &struct {
|
||||
FilterID string `json:"filter_id" form:"filter_id"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := department.NewInstance()(api.GetSession()(c).(*session.Admin)).Index((&api.IDStringForm{ID: form.FilterID}).Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ type (
|
||||
Link string `json:"path" form:"path"`
|
||||
Component string `json:"component" form:"component"`
|
||||
Icon string `json:"icon" form:"icon"`
|
||||
Auth int `json:"auth" form:"auth"`
|
||||
Auth string `json:"auth" form:"auth"`
|
||||
Sort int `json:"sort" form:"sort"`
|
||||
IsCache int `json:"is_cache" form:"is_cache"`
|
||||
Hidden int `json:"hidden" form:"hidden"`
|
||||
|
@ -107,38 +107,48 @@ func (a *Tenant) MemberBind(c *gin.Context) {
|
||||
|
||||
func (a *Tenant) Menu(c *gin.Context) {
|
||||
form := &struct {
|
||||
TenantID uint64 `json:"tenant_id" form:"tenant_id" binding:"required"`
|
||||
TenantID string `json:"tenant_id" form:"tenant_id" binding:"required"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := tenant.NewMenu()(api.GetSession()(c).(*session.Admin)).List(form.TenantID)
|
||||
data, err := tenant.NewMenu()(api.GetSession()(c).(*session.Admin)).List((&api.IDStringForm{ID: form.TenantID}).Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (a *Tenant) MenuBind(c *gin.Context) {
|
||||
form := &struct {
|
||||
TenantID uint64 `json:"tenant_id" form:"tenant_id" binding:"required"`
|
||||
MenuIDs []uint64 `json:"menu_ids" form:"menu_ids" binding:"required"`
|
||||
TenantID string `json:"tenant_id" form:"tenant_id" binding:"required"`
|
||||
MenuIDs []string `json:"menu_ids" form:"menu_ids" binding:"required"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := tenant.NewMenu()(api.GetSession()(c).(*session.Admin)).Bind(form.TenantID, form.MenuIDs)
|
||||
menuIDs := make([]uint64, 0)
|
||||
|
||||
for _, v := range form.MenuIDs {
|
||||
menuIDs = append(menuIDs, (&api.IDStringForm{ID: v}).Convert())
|
||||
}
|
||||
err := tenant.NewMenu()(api.GetSession()(c).(*session.Admin)).Bind((&api.IDStringForm{ID: form.TenantID}).Convert(), menuIDs)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (a *Tenant) AuthBind(c *gin.Context) {
|
||||
form := &struct {
|
||||
TenantID uint64 `json:"tenant_id" form:"tenant_id" binding:"required"`
|
||||
AuthIDs []uint64 `json:"auth_ids" form:"auth_ids" binding:"required"`
|
||||
TenantID string `json:"tenant_id" form:"tenant_id" binding:"required"`
|
||||
AuthIDs []string `json:"auth_ids" form:"auth_ids" binding:"required"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := tenant.NewAuth()(api.GetSession()(c).(*session.Admin)).Bind(form.TenantID, form.AuthIDs)
|
||||
authIDs := make([]uint64, 0)
|
||||
|
||||
for _, v := range form.AuthIDs {
|
||||
authIDs = append(authIDs, (&api.IDStringForm{ID: v}).Convert())
|
||||
}
|
||||
err := tenant.NewAuth()(api.GetSession()(c).(*session.Admin)).Bind((&api.IDStringForm{ID: form.TenantID}).Convert(), authIDs)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
@ -11,12 +11,14 @@ import (
|
||||
type User struct{}
|
||||
|
||||
type userForm struct {
|
||||
Account string `json:"account" form:"account" binding:"required"`
|
||||
Account string `json:"account" form:"account"`
|
||||
Name string `json:"name" form:"name" binding:"required"`
|
||||
Mobile string `json:"mobile" form:"mobile" binding:"required"`
|
||||
Gender int `json:"gender" form:"gender" binding:"required"`
|
||||
Status int `json:"status" form:"status" binding:"required"`
|
||||
DepartmentID string `json:"department_id" form:"department_id"`
|
||||
RoleIDs []string `json:"role_ids" form:"role_ids"`
|
||||
Email string `json:"email" form:"email"`
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
}
|
||||
|
||||
@ -81,8 +83,8 @@ func (a *User) Add(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
err := user.NewInstance()(api.GetSession()(c).(*session.Admin)).Add(&user.InstanceForm{
|
||||
Account: form.Account, Name: form.Name, Mobile: form.Mobile, Password: form.Password,
|
||||
Remark: form.Remark, Gender: form.Gender, DepartmentID: form.departmentInfo(), RoleIDs: form.RoleInfo(),
|
||||
Account: form.Account, Name: form.Name, Mobile: form.Mobile, Password: form.Password, Status: form.Status,
|
||||
Email: form.Email, Remark: form.Remark, Gender: form.Gender, DepartmentID: form.departmentInfo(), RoleIDs: form.RoleInfo(),
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
@ -97,8 +99,8 @@ func (a *User) Edit(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
err := user.NewInstance()(api.GetSession()(c).(*session.Admin)).Edit(&user.InstanceForm{
|
||||
ID: form.Convert(), Account: form.Account, Name: form.Name, Mobile: form.Mobile,
|
||||
Remark: form.Remark, Gender: form.Gender, DepartmentID: form.departmentInfo(), RoleIDs: form.RoleInfo(),
|
||||
ID: form.Convert(), Account: form.Account, Name: form.Name, Mobile: form.Mobile, Status: form.Status,
|
||||
Email: form.Email, Remark: form.Remark, Gender: form.Gender, DepartmentID: form.departmentInfo(), RoleIDs: form.RoleInfo(),
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
@ -107,7 +109,7 @@ func (a *User) Password(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
Password string `json:"password" form:"password" binding:"required"`
|
||||
RepeatPwd string `json:"repeat_pwd" form:"repeat_pwd" binding:"required"`
|
||||
RepeatPwd string `json:"repeat_pwd" form:"repeat_pwd"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
|
Reference in New Issue
Block a user