正在显示
46 个修改的文件
包含
2361 行增加
和
109 行删除
| @@ -25,4 +25,4 @@ Redis: | @@ -25,4 +25,4 @@ Redis: | ||
| 25 | Type: node | 25 | Type: node |
| 26 | Pass: | 26 | Pass: |
| 27 | DB: | 27 | DB: |
| 28 | - DataSource: host=114.55.200.59 user=postgres password=eagle1010 dbname=su_enterprise_platform_preonline port=31543 sslmode=disable TimeZone=Asia/Shanghai | 28 | + DataSource: host=114.55.200.59 user=postgres password=eagle1010 dbname=su_enterprise_platform port=31543 sslmode=disable TimeZone=Asia/Shanghai |
| 1 | +package auth | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/logic/auth" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemAuthChangePasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.ChangePasswordRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := auth.NewSystemAuthChangePasswordLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemAuthChangePassword(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package auth | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/logic/auth" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemAuthEditUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.EditUserInfoRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := auth.NewSystemAuthEditUserInfoLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemAuthEditUserInfo(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package auth | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/logic/auth" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemAuthResetPasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.ResetPasswordRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := auth.NewSystemAuthResetPasswordLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemAuthResetPassword(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package role | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/logic/role" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemMenuListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.MenuListRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := role.NewSystemMenuListLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemMenuList(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package role | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/logic/role" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemRoleDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.RoleDeleteRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := role.NewSystemRoleDeleteLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemRoleDelete(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package role | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/logic/role" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemRoleGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.RoleGetRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := role.NewSystemRoleGetLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemRoleGet(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package role | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/logic/role" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemRoleSaveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.RoleSaveRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := role.NewSystemRoleSaveLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemRoleSave(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package role | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/logic/role" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemRoleSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.RoleSearchRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := role.NewSystemRoleSearchLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemRoleSearch(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package role | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/logic/role" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemRoleUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.RoleUpdateRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := role.NewSystemRoleUpdateLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemRoleUpdate(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| @@ -9,6 +9,8 @@ import ( | @@ -9,6 +9,8 @@ import ( | ||
| 9 | company "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/company" | 9 | company "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/company" |
| 10 | department "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/department" | 10 | department "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/department" |
| 11 | employee "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/employee" | 11 | employee "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/employee" |
| 12 | + role "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/role" | ||
| 13 | + user "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/user" | ||
| 12 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | 14 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" |
| 13 | 15 | ||
| 14 | "github.com/zeromicro/go-zero/rest" | 16 | "github.com/zeromicro/go-zero/rest" |
| @@ -45,6 +47,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -45,6 +47,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 45 | }, | 47 | }, |
| 46 | { | 48 | { |
| 47 | Method: http.MethodPost, | 49 | Method: http.MethodPost, |
| 50 | + Path: "/auth/edit_user_info", | ||
| 51 | + Handler: auth.SystemAuthEditUserInfoHandler(serverCtx), | ||
| 52 | + }, | ||
| 53 | + { | ||
| 54 | + Method: http.MethodPost, | ||
| 55 | + Path: "/auth/change_password", | ||
| 56 | + Handler: auth.SystemAuthChangePasswordHandler(serverCtx), | ||
| 57 | + }, | ||
| 58 | + { | ||
| 59 | + Method: http.MethodPost, | ||
| 60 | + Path: "/auth/reset_password", | ||
| 61 | + Handler: auth.SystemAuthResetPasswordHandler(serverCtx), | ||
| 62 | + }, | ||
| 63 | + { | ||
| 64 | + Method: http.MethodPost, | ||
| 48 | Path: "/auth/switch_company", | 65 | Path: "/auth/switch_company", |
| 49 | Handler: auth.SystemAuthSwitchCompanyHandler(serverCtx), | 66 | Handler: auth.SystemAuthSwitchCompanyHandler(serverCtx), |
| 50 | }, | 67 | }, |
| @@ -59,6 +76,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -59,6 +76,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 59 | []rest.Middleware{serverCtx.LogRequest}, | 76 | []rest.Middleware{serverCtx.LogRequest}, |
| 60 | []rest.Route{ | 77 | []rest.Route{ |
| 61 | { | 78 | { |
| 79 | + Method: http.MethodPost, | ||
| 80 | + Path: "/user/company_users", | ||
| 81 | + Handler: user.UserCompanyUsersHandler(serverCtx), | ||
| 82 | + }, | ||
| 83 | + }..., | ||
| 84 | + ), | ||
| 85 | + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | ||
| 86 | + rest.WithPrefix("/v1"), | ||
| 87 | + ) | ||
| 88 | + | ||
| 89 | + server.AddRoutes( | ||
| 90 | + rest.WithMiddlewares( | ||
| 91 | + []rest.Middleware{serverCtx.LogRequest}, | ||
| 92 | + []rest.Route{ | ||
| 93 | + { | ||
| 62 | Method: http.MethodGet, | 94 | Method: http.MethodGet, |
| 63 | Path: "/system/company_info", | 95 | Path: "/system/company_info", |
| 64 | Handler: company.SystemCompanyInfoHandler(serverCtx), | 96 | Handler: company.SystemCompanyInfoHandler(serverCtx), |
| @@ -135,6 +167,46 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -135,6 +167,46 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 135 | []rest.Route{ | 167 | []rest.Route{ |
| 136 | { | 168 | { |
| 137 | Method: http.MethodGet, | 169 | Method: http.MethodGet, |
| 170 | + Path: "/role/:id", | ||
| 171 | + Handler: role.SystemRoleGetHandler(serverCtx), | ||
| 172 | + }, | ||
| 173 | + { | ||
| 174 | + Method: http.MethodPost, | ||
| 175 | + Path: "/role", | ||
| 176 | + Handler: role.SystemRoleSaveHandler(serverCtx), | ||
| 177 | + }, | ||
| 178 | + { | ||
| 179 | + Method: http.MethodDelete, | ||
| 180 | + Path: "/role/:id", | ||
| 181 | + Handler: role.SystemRoleDeleteHandler(serverCtx), | ||
| 182 | + }, | ||
| 183 | + { | ||
| 184 | + Method: http.MethodPut, | ||
| 185 | + Path: "/role/:id", | ||
| 186 | + Handler: role.SystemRoleUpdateHandler(serverCtx), | ||
| 187 | + }, | ||
| 188 | + { | ||
| 189 | + Method: http.MethodPost, | ||
| 190 | + Path: "/role/search", | ||
| 191 | + Handler: role.SystemRoleSearchHandler(serverCtx), | ||
| 192 | + }, | ||
| 193 | + { | ||
| 194 | + Method: http.MethodPost, | ||
| 195 | + Path: "/menu/list", | ||
| 196 | + Handler: role.SystemMenuListHandler(serverCtx), | ||
| 197 | + }, | ||
| 198 | + }..., | ||
| 199 | + ), | ||
| 200 | + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | ||
| 201 | + rest.WithPrefix("/v1/system"), | ||
| 202 | + ) | ||
| 203 | + | ||
| 204 | + server.AddRoutes( | ||
| 205 | + rest.WithMiddlewares( | ||
| 206 | + []rest.Middleware{serverCtx.LogRequest}, | ||
| 207 | + []rest.Route{ | ||
| 208 | + { | ||
| 209 | + Method: http.MethodGet, | ||
| 138 | Path: "/system/app/:id", | 210 | Path: "/system/app/:id", |
| 139 | Handler: app.SystemAppGetHandler(serverCtx), | 211 | Handler: app.SystemAppGetHandler(serverCtx), |
| 140 | }, | 212 | }, |
| @@ -144,7 +216,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -144,7 +216,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 144 | Handler: app.SystemAppSearchHandler(serverCtx), | 216 | Handler: app.SystemAppSearchHandler(serverCtx), |
| 145 | }, | 217 | }, |
| 146 | { | 218 | { |
| 147 | - Method: http.MethodGet, | 219 | + Method: http.MethodPost, |
| 148 | Path: "/system/app/set_config", | 220 | Path: "/system/app/set_config", |
| 149 | Handler: app.SystemAppSetConfigHandler(serverCtx), | 221 | Handler: app.SystemAppSetConfigHandler(serverCtx), |
| 150 | }, | 222 | }, |
| 1 | +package user | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/logic/user" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func UserCompanyUsersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.CompanyUsersRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := user.NewUserCompanyUsersLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.UserCompanyUsers(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| @@ -72,7 +72,7 @@ func (l *SystemAppSearchLogic) SystemAppSearch(req *types.SystemAppSearchRequest | @@ -72,7 +72,7 @@ func (l *SystemAppSearchLogic) SystemAppSearch(req *types.SystemAppSearchRequest | ||
| 72 | CompanyId: token.CompanyId, | 72 | CompanyId: token.CompanyId, |
| 73 | AppId: app.Id, | 73 | AppId: app.Id, |
| 74 | Status: domain.Enable, | 74 | Status: domain.Enable, |
| 75 | - VisibleFlag: domain.VisibleAll, | 75 | + VisibleFlag: domain.VisibleParts, |
| 76 | VisibleUsers: make([]int64, 0), | 76 | VisibleUsers: make([]int64, 0), |
| 77 | VisibleGroups: make([]int64, 0), | 77 | VisibleGroups: make([]int64, 0), |
| 78 | AppConfig: domain.AppConfig{}, | 78 | AppConfig: domain.AppConfig{}, |
| @@ -2,6 +2,9 @@ package app | @@ -2,6 +2,9 @@ package app | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/transaction" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/xerr" | ||
| 5 | 8 | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | 9 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | 10 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" |
| @@ -24,6 +27,26 @@ func NewSystemAppSetConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) | @@ -24,6 +27,26 @@ func NewSystemAppSetConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) | ||
| 24 | } | 27 | } |
| 25 | 28 | ||
| 26 | func (l *SystemAppSetConfigLogic) SystemAppSetConfig(req *types.SystemAppSetConfigRequest) (resp *types.SystemAppSetConfigResponse, err error) { | 29 | func (l *SystemAppSetConfigLogic) SystemAppSetConfig(req *types.SystemAppSetConfigRequest) (resp *types.SystemAppSetConfigResponse, err error) { |
| 30 | + var ( | ||
| 31 | + conn = l.svcCtx.DefaultDBConn() | ||
| 32 | + companyApp *domain.SysCompanyApp | ||
| 33 | + //app *domain.SysApp | ||
| 34 | + ) | ||
| 35 | + if companyApp, err = l.svcCtx.CompanyAppRepository.FindOne(l.ctx, conn, req.AppId); err != nil { | ||
| 36 | + return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + companyApp.VisibleFlag = req.VisibleFlag | ||
| 40 | + companyApp.VisibleUsers = req.VisibleUsers | ||
| 41 | + companyApp.VisibleDepartments = req.VisibleDepartments | ||
| 27 | 42 | ||
| 43 | + // 更新 | ||
| 44 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 45 | + companyApp, err = l.svcCtx.CompanyAppRepository.UpdateWithVersion(l.ctx, conn, companyApp) | ||
| 46 | + return err | ||
| 47 | + }, true); err != nil { | ||
| 48 | + return nil, xerr.NewErrMsg("更新失败") | ||
| 49 | + } | ||
| 50 | + resp = &types.SystemAppSetConfigResponse{} | ||
| 28 | return | 51 | return |
| 29 | } | 52 | } |
| 1 | +package auth | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/contextdata" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/transaction" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/xerr" | ||
| 9 | + | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 12 | + | ||
| 13 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 14 | +) | ||
| 15 | + | ||
| 16 | +type SystemAuthChangePasswordLogic struct { | ||
| 17 | + logx.Logger | ||
| 18 | + ctx context.Context | ||
| 19 | + svcCtx *svc.ServiceContext | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +func NewSystemAuthChangePasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemAuthChangePasswordLogic { | ||
| 23 | + return &SystemAuthChangePasswordLogic{ | ||
| 24 | + Logger: logx.WithContext(ctx), | ||
| 25 | + ctx: ctx, | ||
| 26 | + svcCtx: svcCtx, | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (l *SystemAuthChangePasswordLogic) SystemAuthChangePassword(req *types.ChangePasswordRequest) (resp *types.ChangePasswordResponse, err error) { | ||
| 31 | + var ( | ||
| 32 | + conn = l.svcCtx.DefaultDBConn() | ||
| 33 | + user *domain.SysUser | ||
| 34 | + token = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 35 | + ) | ||
| 36 | + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, token.UserId); err != nil { | ||
| 37 | + return nil, xerr.NewErrMsgErr("用户不存在", err) | ||
| 38 | + } | ||
| 39 | + if req.OldPassword != user.Password { | ||
| 40 | + return nil, xerr.NewErrMsgErr("旧密码有误", err) | ||
| 41 | + } | ||
| 42 | + if req.NewPassword != req.ConfirmPassword { | ||
| 43 | + return nil, xerr.NewErrMsgErr("输入的密码不一致", err) | ||
| 44 | + } | ||
| 45 | + user.Password = req.ConfirmPassword | ||
| 46 | + if err = transaction.MustUseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 47 | + if user, err = l.svcCtx.UserRepository.UpdateWithVersion(l.ctx, conn, user); err != nil { | ||
| 48 | + return err | ||
| 49 | + } | ||
| 50 | + return nil | ||
| 51 | + }); err != nil { | ||
| 52 | + return nil, xerr.NewErrMsgErr("更新失败", err) | ||
| 53 | + } | ||
| 54 | + return | ||
| 55 | +} |
| 1 | +package auth | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/contextdata" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/transaction" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/xerr" | ||
| 9 | + | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 12 | + | ||
| 13 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 14 | +) | ||
| 15 | + | ||
| 16 | +type SystemAuthEditUserInfoLogic struct { | ||
| 17 | + logx.Logger | ||
| 18 | + ctx context.Context | ||
| 19 | + svcCtx *svc.ServiceContext | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +func NewSystemAuthEditUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemAuthEditUserInfoLogic { | ||
| 23 | + return &SystemAuthEditUserInfoLogic{ | ||
| 24 | + Logger: logx.WithContext(ctx), | ||
| 25 | + ctx: ctx, | ||
| 26 | + svcCtx: svcCtx, | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (l *SystemAuthEditUserInfoLogic) SystemAuthEditUserInfo(req *types.EditUserInfoRequest) (resp *types.UserInfoResponse, err error) { | ||
| 31 | + var ( | ||
| 32 | + conn = l.svcCtx.DefaultDBConn() | ||
| 33 | + user *domain.SysUser | ||
| 34 | + token = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 35 | + ) | ||
| 36 | + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, token.UserId); err != nil { | ||
| 37 | + return nil, xerr.NewErrMsgErr("用户不存在", err) | ||
| 38 | + } | ||
| 39 | + if req.Phone != nil { | ||
| 40 | + if user, err = l.svcCtx.UserRepository.FindOneByPhone(l.ctx, conn, *req.Phone); err != nil { | ||
| 41 | + return nil, xerr.NewErrMsgErr("手机号已被占用", err) | ||
| 42 | + } | ||
| 43 | + user.Phone = *req.Phone | ||
| 44 | + } | ||
| 45 | + if req.Name != nil { | ||
| 46 | + user.Name = *req.Name | ||
| 47 | + } | ||
| 48 | + if req.Avatar != nil { | ||
| 49 | + user.Avatar = *req.Avatar | ||
| 50 | + } | ||
| 51 | + if err = transaction.MustUseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 52 | + if user, err = l.svcCtx.UserRepository.UpdateWithVersion(l.ctx, conn, user); err != nil { | ||
| 53 | + return err | ||
| 54 | + } | ||
| 55 | + return nil | ||
| 56 | + }); err != nil { | ||
| 57 | + return nil, xerr.NewErrMsgErr("更新失败", err) | ||
| 58 | + } | ||
| 59 | + return | ||
| 60 | +} |
| @@ -44,7 +44,7 @@ func (l *SystemAuthLoginLogic) SystemAuthLogin(req *types.AuthLoginRequest) (res | @@ -44,7 +44,7 @@ func (l *SystemAuthLoginLogic) SystemAuthLogin(req *types.AuthLoginRequest) (res | ||
| 44 | company *domain.SysCompany | 44 | company *domain.SysCompany |
| 45 | ) | 45 | ) |
| 46 | if user, err = l.svcCtx.UserRepository.FindOneByPhone(l.ctx, conn, req.Phone); err != nil { | 46 | if user, err = l.svcCtx.UserRepository.FindOneByPhone(l.ctx, conn, req.Phone); err != nil { |
| 47 | - return nil, xerr.NewErr(err) | 47 | + return nil, xerr.NewErrMsgErr("账号不存在", err) |
| 48 | } | 48 | } |
| 49 | switch req.LoginType { | 49 | switch req.LoginType { |
| 50 | case LoginTypeWechatLogin: | 50 | case LoginTypeWechatLogin: |
| 1 | +package auth | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/contextdata" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/gateway/smslib" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/transaction" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/xerr" | ||
| 10 | + | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 13 | + | ||
| 14 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 15 | +) | ||
| 16 | + | ||
| 17 | +type SystemAuthResetPasswordLogic struct { | ||
| 18 | + logx.Logger | ||
| 19 | + ctx context.Context | ||
| 20 | + svcCtx *svc.ServiceContext | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +func NewSystemAuthResetPasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemAuthResetPasswordLogic { | ||
| 24 | + return &SystemAuthResetPasswordLogic{ | ||
| 25 | + Logger: logx.WithContext(ctx), | ||
| 26 | + ctx: ctx, | ||
| 27 | + svcCtx: svcCtx, | ||
| 28 | + } | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +func (l *SystemAuthResetPasswordLogic) SystemAuthResetPassword(req *types.ResetPasswordRequest) (resp *types.ResetPasswordResponse, err error) { | ||
| 32 | + var ( | ||
| 33 | + conn = l.svcCtx.DefaultDBConn() | ||
| 34 | + user *domain.SysUser | ||
| 35 | + token = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 36 | + ) | ||
| 37 | + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, token.UserId); err != nil { | ||
| 38 | + return nil, xerr.NewErrMsgErr("用户不存在", err) | ||
| 39 | + } | ||
| 40 | + var ( | ||
| 41 | + skipCheckSmsCode bool = false | ||
| 42 | + ) | ||
| 43 | + if l.svcCtx.Config.DebugSmsCode != "" && l.svcCtx.Config.DebugSmsCode == req.Code { | ||
| 44 | + skipCheckSmsCode = true | ||
| 45 | + } | ||
| 46 | + if _, err = l.svcCtx.SmsService.CheckSmsCode(l.ctx, smslib.RequestCheckSmsCode{Phone: user.Phone, Code: req.Code}); err != nil && !skipCheckSmsCode { | ||
| 47 | + return nil, xerr.NewErrMsgErr(err.Error(), err) | ||
| 48 | + } | ||
| 49 | + if req.NewPassword != req.ConfirmPassword { | ||
| 50 | + return nil, xerr.NewErrMsgErr("输入的密码不一致", err) | ||
| 51 | + } | ||
| 52 | + user.Password = req.ConfirmPassword | ||
| 53 | + if err = transaction.MustUseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 54 | + if user, err = l.svcCtx.UserRepository.UpdateWithVersion(l.ctx, conn, user); err != nil { | ||
| 55 | + return err | ||
| 56 | + } | ||
| 57 | + return nil | ||
| 58 | + }); err != nil { | ||
| 59 | + return nil, xerr.NewErrMsgErr("更新失败", err) | ||
| 60 | + } | ||
| 61 | + return | ||
| 62 | +} |
| @@ -2,6 +2,9 @@ package auth | @@ -2,6 +2,9 @@ package auth | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/contextdata" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/xerr" | ||
| 5 | 8 | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | 9 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | 10 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" |
| @@ -24,7 +27,36 @@ func NewSystemAuthSwitchCompanyLogic(ctx context.Context, svcCtx *svc.ServiceCon | @@ -24,7 +27,36 @@ func NewSystemAuthSwitchCompanyLogic(ctx context.Context, svcCtx *svc.ServiceCon | ||
| 24 | } | 27 | } |
| 25 | 28 | ||
| 26 | func (l *SystemAuthSwitchCompanyLogic) SystemAuthSwitchCompany(req *types.SwitchCompanyRequest) (resp *types.AuthLoginResponse, err error) { | 29 | func (l *SystemAuthSwitchCompanyLogic) SystemAuthSwitchCompany(req *types.SwitchCompanyRequest) (resp *types.AuthLoginResponse, err error) { |
| 27 | - // todo: add your logic here and delete this line | ||
| 28 | - | 30 | + var ( |
| 31 | + conn = l.svcCtx.DefaultDBConn() | ||
| 32 | + company *domain.SysCompany | ||
| 33 | + user *domain.SysUser | ||
| 34 | + employee *domain.SysEmployee | ||
| 35 | + token = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 36 | + ) | ||
| 37 | + if employee, err = l.svcCtx.EmployeeRepository.FindOneByUserId(l.ctx, conn, req.CompanyId, token.UserId); err != nil { | ||
| 38 | + return nil, xerr.NewErrMsgErr("账号不存在", err) | ||
| 39 | + } | ||
| 40 | + if employee.AccountStatus != domain.Enable { | ||
| 41 | + return nil, xerr.NewErrMsgErr("账号已被禁用", err) | ||
| 42 | + } | ||
| 43 | + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, employee.UserId); err != nil { | ||
| 44 | + return nil, xerr.NewErrMsgErr("账号不存在", err) | ||
| 45 | + } | ||
| 46 | + if company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, employee.CompanyId); err != nil { | ||
| 47 | + return nil, xerr.NewErrMsgErr("账号不存在", err) | ||
| 48 | + } | ||
| 49 | + if company.Status != domain.Enable { | ||
| 50 | + return nil, xerr.NewErrMsgErr("公司已被禁用", err) | ||
| 51 | + } | ||
| 52 | + userToken := contextdata.UserToken{ | ||
| 53 | + CompanyId: employee.CompanyId, | ||
| 54 | + UserId: user.Id, | ||
| 55 | + EmployeeId: employee.Id, | ||
| 56 | + } | ||
| 57 | + tokenStr, _ := userToken.GenerateToken(l.svcCtx.Config.SystemAuth.AccessSecret, l.svcCtx.Config.SystemAuth.AccessExpire) | ||
| 58 | + resp = &types.AuthLoginResponse{ | ||
| 59 | + Token: tokenStr, | ||
| 60 | + } | ||
| 29 | return | 61 | return |
| 30 | } | 62 | } |
| @@ -3,6 +3,7 @@ package auth | @@ -3,6 +3,7 @@ package auth | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | "github.com/samber/lo" | 5 | "github.com/samber/lo" |
| 6 | + "github.com/zeromicro/go-zero/core/collection" | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/xerr" | 8 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/xerr" |
| 8 | 9 | ||
| @@ -31,8 +32,7 @@ func (l *SystemAuthUserInfoLogic) SystemAuthUserInfo(req *types.UserInfoRequest) | @@ -31,8 +32,7 @@ func (l *SystemAuthUserInfoLogic) SystemAuthUserInfo(req *types.UserInfoRequest) | ||
| 31 | conn = l.svcCtx.DefaultDBConn() | 32 | conn = l.svcCtx.DefaultDBConn() |
| 32 | company *domain.SysCompany | 33 | company *domain.SysCompany |
| 33 | user *domain.SysUser | 34 | user *domain.SysUser |
| 34 | - employee *domain.SysEmployee | ||
| 35 | - companies []types.Company | 35 | + companies []types.AccountInfo |
| 36 | ) | 36 | ) |
| 37 | if company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, req.CompanyId); err != nil { | 37 | if company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, req.CompanyId); err != nil { |
| 38 | return nil, xerr.NewErr(err) | 38 | return nil, xerr.NewErr(err) |
| @@ -40,30 +40,110 @@ func (l *SystemAuthUserInfoLogic) SystemAuthUserInfo(req *types.UserInfoRequest) | @@ -40,30 +40,110 @@ func (l *SystemAuthUserInfoLogic) SystemAuthUserInfo(req *types.UserInfoRequest) | ||
| 40 | if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.UserId); err != nil { | 40 | if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.UserId); err != nil { |
| 41 | return nil, xerr.NewErr(err) | 41 | return nil, xerr.NewErr(err) |
| 42 | } | 42 | } |
| 43 | - if employee, err = l.svcCtx.EmployeeRepository.FindOne(l.ctx, conn, req.EmployeeId); err != nil { | ||
| 44 | - return nil, xerr.NewErr(err) | ||
| 45 | - } | ||
| 46 | if _, employees, _ := l.svcCtx.EmployeeRepository.FindByUserId(l.ctx, conn, req.UserId); len(employees) > 0 { | 43 | if _, employees, _ := l.svcCtx.EmployeeRepository.FindByUserId(l.ctx, conn, req.UserId); len(employees) > 0 { |
| 47 | for _, e := range employees { | 44 | for _, e := range employees { |
| 48 | - if c, _ := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, e.CompanyId); c != nil { | ||
| 49 | - companies = append(companies, NewTypesCompany(c)) | 45 | + if findOne, _ := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, e.CompanyId); findOne != nil && findOne.Status == domain.Enable { |
| 46 | + companies = append(companies, types.AccountInfo{ | ||
| 47 | + Company: NewTypesCompany(findOne), | ||
| 48 | + Selected: findOne.Id == company.Id, | ||
| 49 | + }) | ||
| 50 | } | 50 | } |
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | + | ||
| 53 | resp = &types.UserInfoResponse{ | 54 | resp = &types.UserInfoResponse{ |
| 54 | - Id: user.Id, | ||
| 55 | - Name: user.Name, | ||
| 56 | - Phone: user.Phone, | ||
| 57 | - Company: &types.Company{ | ||
| 58 | - Id: company.Id, | ||
| 59 | - Name: company.Name, | ||
| 60 | - }, | ||
| 61 | - EmployeeInfo: lo.ToPtr(NewTypesEmployee(employee)), | ||
| 62 | - CompanyList: companies, | 55 | + Id: user.Id, |
| 56 | + Name: user.Name, | ||
| 57 | + Phone: user.Phone, | ||
| 58 | + Avatar: user.Avatar, | ||
| 59 | + Accounts: companies, | ||
| 60 | + Menus: l.GetUserAuthMenus(user.Id, company.Id, user.Phone == company.BaseInfo.ContactPhone), | ||
| 61 | + Apps: l.GetUserApps(user.Id, company.Id), | ||
| 63 | } | 62 | } |
| 64 | return | 63 | return |
| 65 | } | 64 | } |
| 66 | 65 | ||
| 66 | +func (l *SystemAuthUserInfoLogic) GetUserAuthMenus(userId int64, companyId int64, isCompanyAdmin bool) []types.Menu { | ||
| 67 | + var ( | ||
| 68 | + conn = l.svcCtx.DefaultDBConn() | ||
| 69 | + ) | ||
| 70 | + var typesMenus = make([]types.Menu, 0) | ||
| 71 | + var menusSet = collection.NewSet() | ||
| 72 | + _, roles, _ := l.svcCtx.RoleRepository.FindByEmployee(l.ctx, conn, companyId, userId, domain.NewQueryOptions().WithFindOnly()) | ||
| 73 | + var hasAllAuth bool | ||
| 74 | + for _, role := range roles { | ||
| 75 | + if !lo.Contains(role.AuthUsers, userId) { | ||
| 76 | + continue | ||
| 77 | + } | ||
| 78 | + if role.AuthRange == domain.AuthRangeAll { | ||
| 79 | + hasAllAuth = true | ||
| 80 | + } | ||
| 81 | + menusSet.Add(lo.ToAnySlice(role.Menus)...) | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + menuLazyLoad := domain.NewLazyLoadService(domain.FineOneMenu) | ||
| 85 | + menuIds := menusSet.KeysInt64() | ||
| 86 | + if isCompanyAdmin || hasAllAuth { | ||
| 87 | + for _, menu := range domain.DefaultMenus { | ||
| 88 | + typesMenus = append(typesMenus, types.NewTypesMenu(menu)) | ||
| 89 | + } | ||
| 90 | + } else { | ||
| 91 | + for _, menuId := range menuIds { | ||
| 92 | + if menu, _ := menuLazyLoad.Load(l.ctx, conn, menuId); menu != nil { | ||
| 93 | + typesMenus = append(typesMenus, types.NewTypesMenu(menu)) | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + // TODO:先给所有菜单,后期修改 | ||
| 98 | + if len(typesMenus) == 0 { | ||
| 99 | + for _, menu := range domain.DefaultMenus { | ||
| 100 | + typesMenus = append(typesMenus, types.NewTypesMenu(menu)) | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + return typesMenus | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +func (l *SystemAuthUserInfoLogic) GetUserApps(userId int64, companyId int64) []types.SystemAppItem { | ||
| 107 | + var ( | ||
| 108 | + conn = l.svcCtx.DefaultDBConn() | ||
| 109 | + typesApps = make([]types.SystemAppItem, 0) | ||
| 110 | + companyApps []*domain.SysCompanyApp | ||
| 111 | + err error | ||
| 112 | + ) | ||
| 113 | + | ||
| 114 | + if _, companyApps, err = l.svcCtx.CompanyAppRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().MustWithKV("companyId", companyId)); err != nil { | ||
| 115 | + return typesApps | ||
| 116 | + } | ||
| 117 | + lazyApp := domain.NewLazyLoadService(l.svcCtx.AppRepository.FindOne) | ||
| 118 | + for _, companyApp := range companyApps { | ||
| 119 | + var app, _ = lazyApp.Load(l.ctx, conn, companyApp.AppId) | ||
| 120 | + if app == nil { | ||
| 121 | + continue | ||
| 122 | + } | ||
| 123 | + typeApp := types.NewTypesSystemAppItem(app, companyApp) | ||
| 124 | + // 有指定用户权限 | ||
| 125 | + if len(companyApp.VisibleUsers) > 0 && lo.Contains(companyApp.VisibleUsers, userId) { | ||
| 126 | + typeApp.HasAuth = true | ||
| 127 | + } | ||
| 128 | + // 有部门权限 | ||
| 129 | + if !(typeApp.HasAuth) && len(companyApp.VisibleDepartments) > 0 { | ||
| 130 | + _, departments, _ := l.svcCtx.UserDepartmentRepository.FindByUser(l.ctx, conn, companyId, []int64{userId}) | ||
| 131 | + if lo.ContainsBy(departments, func(item *domain.SysUserDepartment) bool { | ||
| 132 | + for _, id := range companyApp.VisibleDepartments { | ||
| 133 | + if id == item.DepartmentId { | ||
| 134 | + return true | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + return false | ||
| 138 | + }) { | ||
| 139 | + typeApp.HasAuth = true | ||
| 140 | + } | ||
| 141 | + } | ||
| 142 | + typesApps = append(typesApps, typeApp) | ||
| 143 | + } | ||
| 144 | + return typesApps | ||
| 145 | +} | ||
| 146 | + | ||
| 67 | func NewDomainSysEmployee(item types.Employee) *domain.SysEmployee { | 147 | func NewDomainSysEmployee(item types.Employee) *domain.SysEmployee { |
| 68 | return &domain.SysEmployee{} | 148 | return &domain.SysEmployee{} |
| 69 | } | 149 | } |
| @@ -100,7 +100,7 @@ func (l *SystemEmployeeUpdateLogic) SystemEmployeeUpdate(req *types.EmployeeUpda | @@ -100,7 +100,7 @@ func (l *SystemEmployeeUpdateLogic) SystemEmployeeUpdate(req *types.EmployeeUpda | ||
| 100 | 100 | ||
| 101 | return nil | 101 | return nil |
| 102 | }); err != nil { | 102 | }); err != nil { |
| 103 | - | 103 | + return nil, xerr.NewErrMsgErr("更新失败", err) |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | return | 106 | return |
| 1 | +package role | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 6 | + | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 9 | + | ||
| 10 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +type SystemMenuListLogic struct { | ||
| 14 | + logx.Logger | ||
| 15 | + ctx context.Context | ||
| 16 | + svcCtx *svc.ServiceContext | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +func NewSystemMenuListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemMenuListLogic { | ||
| 20 | + return &SystemMenuListLogic{ | ||
| 21 | + Logger: logx.WithContext(ctx), | ||
| 22 | + ctx: ctx, | ||
| 23 | + svcCtx: svcCtx, | ||
| 24 | + } | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +func (l *SystemMenuListLogic) SystemMenuList(req *types.MenuListRequest) (resp *types.MenuListResponse, err error) { | ||
| 28 | + // todo: add your logic here and delete this line | ||
| 29 | + resp = &types.MenuListResponse{} | ||
| 30 | + for _, menu := range domain.DefaultMenus { | ||
| 31 | + resp.List = append(resp.List, types.NewTypesMenu(menu)) | ||
| 32 | + } | ||
| 33 | + return | ||
| 34 | +} |
| 1 | +package role | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/transaction" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/xerr" | ||
| 8 | + | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 11 | + | ||
| 12 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +type SystemRoleDeleteLogic struct { | ||
| 16 | + logx.Logger | ||
| 17 | + ctx context.Context | ||
| 18 | + svcCtx *svc.ServiceContext | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +func NewSystemRoleDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemRoleDeleteLogic { | ||
| 22 | + return &SystemRoleDeleteLogic{ | ||
| 23 | + Logger: logx.WithContext(ctx), | ||
| 24 | + ctx: ctx, | ||
| 25 | + svcCtx: svcCtx, | ||
| 26 | + } | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +func (l *SystemRoleDeleteLogic) SystemRoleDelete(req *types.RoleDeleteRequest) (resp *types.RoleDeleteResponse, err error) { | ||
| 30 | + var ( | ||
| 31 | + conn = l.svcCtx.DefaultDBConn() | ||
| 32 | + dm *domain.SysRole | ||
| 33 | + ) | ||
| 34 | + if dm, err = l.svcCtx.RoleRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 35 | + return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 36 | + } | ||
| 37 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 38 | + if dm, err = l.svcCtx.RoleRepository.Delete(l.ctx, conn, dm); err != nil { | ||
| 39 | + return err | ||
| 40 | + } | ||
| 41 | + return nil | ||
| 42 | + }, true); err != nil { | ||
| 43 | + return nil, xerr.NewErrMsgErr("移除失败", err) | ||
| 44 | + } | ||
| 45 | + return | ||
| 46 | +} |
| 1 | +package role | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/xerr" | ||
| 7 | + | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 10 | + | ||
| 11 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type SystemRoleGetLogic struct { | ||
| 15 | + logx.Logger | ||
| 16 | + ctx context.Context | ||
| 17 | + svcCtx *svc.ServiceContext | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func NewSystemRoleGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemRoleGetLogic { | ||
| 21 | + return &SystemRoleGetLogic{ | ||
| 22 | + Logger: logx.WithContext(ctx), | ||
| 23 | + ctx: ctx, | ||
| 24 | + svcCtx: svcCtx, | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (l *SystemRoleGetLogic) SystemRoleGet(req *types.RoleGetRequest) (resp *types.RoleGetResponse, err error) { | ||
| 29 | + var ( | ||
| 30 | + conn = l.svcCtx.DefaultDBConn() | ||
| 31 | + dm *domain.SysRole | ||
| 32 | + ) | ||
| 33 | + // 货号唯一 | ||
| 34 | + if dm, err = l.svcCtx.RoleRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 35 | + return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 36 | + } | ||
| 37 | + userLazyLoad := domain.NewLazyLoadService(l.svcCtx.UserRepository.FindOne) | ||
| 38 | + menuLazyLoad := domain.NewLazyLoadService(domain.FineOneMenu) | ||
| 39 | + role := NewTypesSysRole(dm) | ||
| 40 | + for _, userId := range dm.AuthUsers { | ||
| 41 | + if user, _ := userLazyLoad.Load(l.ctx, conn, userId); user != nil { | ||
| 42 | + role.AuthUsers = append(role.AuthUsers, types.NewTypesUser(user)) | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + for _, menuId := range dm.Menus { | ||
| 46 | + if menu, _ := menuLazyLoad.Load(l.ctx, conn, menuId); menu != nil { | ||
| 47 | + role.Menus = append(role.Menus, types.NewTypesMenu(menu)) | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | + resp = &types.RoleGetResponse{ | ||
| 51 | + Role: role, | ||
| 52 | + } | ||
| 53 | + return | ||
| 54 | +} |
| 1 | +package role | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/contextdata" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/transaction" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/xerr" | ||
| 9 | + | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 12 | + | ||
| 13 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 14 | +) | ||
| 15 | + | ||
| 16 | +type SystemRoleSaveLogic struct { | ||
| 17 | + logx.Logger | ||
| 18 | + ctx context.Context | ||
| 19 | + svcCtx *svc.ServiceContext | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +func NewSystemRoleSaveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemRoleSaveLogic { | ||
| 23 | + return &SystemRoleSaveLogic{ | ||
| 24 | + Logger: logx.WithContext(ctx), | ||
| 25 | + ctx: ctx, | ||
| 26 | + svcCtx: svcCtx, | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (l *SystemRoleSaveLogic) SystemRoleSave(req *types.RoleSaveRequest) (resp *types.RoleSaveResponse, err error) { | ||
| 31 | + var ( | ||
| 32 | + //conn = l.svcCtx.DefaultDBConn() | ||
| 33 | + dm *domain.SysRole | ||
| 34 | + token = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 35 | + ) | ||
| 36 | + // 唯一判断 | ||
| 37 | + | ||
| 38 | + dm = NewDomainSysRole(token.CompanyId, req.Role) | ||
| 39 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 40 | + dm, err = l.svcCtx.RoleRepository.Insert(l.ctx, conn, dm) | ||
| 41 | + return err | ||
| 42 | + }, true); err != nil { | ||
| 43 | + return nil, xerr.NewErrMsg("保存失败") | ||
| 44 | + } | ||
| 45 | + resp = &types.RoleSaveResponse{} | ||
| 46 | + return | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +func NewDomainSysRole(companyId int64, item types.Role) *domain.SysRole { | ||
| 50 | + menus := domain.Values(item.Menus, func(item types.Menu) int64 { | ||
| 51 | + return item.Id | ||
| 52 | + }) | ||
| 53 | + users := domain.Values(item.AuthUsers, func(item types.User) int64 { | ||
| 54 | + return item.Id | ||
| 55 | + }) | ||
| 56 | + if item.AuthRange == 0 { | ||
| 57 | + if len(menus) == len(domain.DefaultMenus) { | ||
| 58 | + item.AuthRange = domain.AuthRangeAll | ||
| 59 | + } else { | ||
| 60 | + item.AuthRange = domain.AuthRangePart | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + return &domain.SysRole{ | ||
| 64 | + CompanyId: companyId, | ||
| 65 | + Name: item.Name, | ||
| 66 | + Menus: menus, | ||
| 67 | + AuthUsers: users, | ||
| 68 | + AuthRange: item.AuthRange, | ||
| 69 | + } | ||
| 70 | +} | ||
| 71 | + | ||
| 72 | +func NewTypesSysRole(item *domain.SysRole) types.Role { | ||
| 73 | + return types.Role{ | ||
| 74 | + Id: item.Id, | ||
| 75 | + Name: item.Name, | ||
| 76 | + AuthRange: item.AuthRange, | ||
| 77 | + UpdatedAt: item.UpdatedAt, | ||
| 78 | + } | ||
| 79 | +} |
| 1 | +package role | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 6 | + | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 9 | + | ||
| 10 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +type SystemRoleSearchLogic struct { | ||
| 14 | + logx.Logger | ||
| 15 | + ctx context.Context | ||
| 16 | + svcCtx *svc.ServiceContext | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +func NewSystemRoleSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemRoleSearchLogic { | ||
| 20 | + return &SystemRoleSearchLogic{ | ||
| 21 | + Logger: logx.WithContext(ctx), | ||
| 22 | + ctx: ctx, | ||
| 23 | + svcCtx: svcCtx, | ||
| 24 | + } | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +func (l *SystemRoleSearchLogic) SystemRoleSearch(req *types.RoleSearchRequest) (resp *types.RoleSearchResponse, err error) { | ||
| 28 | + var ( | ||
| 29 | + conn = l.svcCtx.DefaultDBConn() | ||
| 30 | + dms []*domain.SysRole | ||
| 31 | + total int64 | ||
| 32 | + ) | ||
| 33 | + | ||
| 34 | + queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size). | ||
| 35 | + WithKV("userName", req.UserName). | ||
| 36 | + WithKV("roleName", req.RoleName) | ||
| 37 | + | ||
| 38 | + total, dms, err = l.svcCtx.RoleRepository.Find(l.ctx, conn, queryOptions) | ||
| 39 | + list := make([]types.Role, 0) | ||
| 40 | + userLazyLoad := domain.NewLazyLoadService(l.svcCtx.UserRepository.FindOne) | ||
| 41 | + menuLazyLoad := domain.NewLazyLoadService(domain.FineOneMenu) | ||
| 42 | + for i := range dms { | ||
| 43 | + role := NewTypesSysRole(dms[i]) | ||
| 44 | + for j, userId := range dms[i].AuthUsers { | ||
| 45 | + // 超过十名的不查用户信息 | ||
| 46 | + if j > 5 { | ||
| 47 | + role.AuthUsers = append(role.AuthUsers, types.NewTypesUser(&domain.SysUser{Id: userId})) | ||
| 48 | + } | ||
| 49 | + if user, _ := userLazyLoad.Load(l.ctx, conn, userId); user != nil { | ||
| 50 | + role.AuthUsers = append(role.AuthUsers, types.NewTypesUser(user)) | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | + for _, menuId := range dms[i].Menus { | ||
| 54 | + if menu, _ := menuLazyLoad.Load(l.ctx, conn, menuId); menu != nil { | ||
| 55 | + role.Menus = append(role.Menus, types.NewTypesMenu(menu)) | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + list = append(list, role) | ||
| 59 | + } | ||
| 60 | + resp = &types.RoleSearchResponse{ | ||
| 61 | + List: list, | ||
| 62 | + Total: total, | ||
| 63 | + } | ||
| 64 | + return | ||
| 65 | +} |
| 1 | +package role | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/transaction" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/xerr" | ||
| 8 | + | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 11 | + | ||
| 12 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +type SystemRoleUpdateLogic struct { | ||
| 16 | + logx.Logger | ||
| 17 | + ctx context.Context | ||
| 18 | + svcCtx *svc.ServiceContext | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +func NewSystemRoleUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemRoleUpdateLogic { | ||
| 22 | + return &SystemRoleUpdateLogic{ | ||
| 23 | + Logger: logx.WithContext(ctx), | ||
| 24 | + ctx: ctx, | ||
| 25 | + svcCtx: svcCtx, | ||
| 26 | + } | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +func (l *SystemRoleUpdateLogic) SystemRoleUpdate(req *types.RoleUpdateRequest) (resp *types.RoleUpdateResponse, err error) { | ||
| 30 | + var ( | ||
| 31 | + conn = l.svcCtx.DefaultDBConn() | ||
| 32 | + dm *domain.SysRole | ||
| 33 | + ) | ||
| 34 | + if dm, err = l.svcCtx.RoleRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 35 | + return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 36 | + } | ||
| 37 | + // 不可编辑判断 | ||
| 38 | + | ||
| 39 | + // 赋值 | ||
| 40 | + menus := domain.Values(req.Role.Menus, func(item types.Menu) int64 { | ||
| 41 | + return item.Id | ||
| 42 | + }) | ||
| 43 | + users := domain.Values(req.Role.AuthUsers, func(item types.User) int64 { | ||
| 44 | + return item.Id | ||
| 45 | + }) | ||
| 46 | + | ||
| 47 | + dm.Name = req.Role.Name | ||
| 48 | + dm.Menus = menus | ||
| 49 | + dm.AuthUsers = users | ||
| 50 | + if req.Role.AuthRange == 0 { | ||
| 51 | + if len(menus) == len(domain.DefaultMenus) { | ||
| 52 | + dm.AuthRange = domain.AuthRangeAll | ||
| 53 | + } else { | ||
| 54 | + dm.AuthRange = domain.AuthRangePart | ||
| 55 | + } | ||
| 56 | + } else { | ||
| 57 | + dm.AuthRange = req.Role.AuthRange | ||
| 58 | + } | ||
| 59 | + // 更新 | ||
| 60 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 61 | + dm, err = l.svcCtx.RoleRepository.UpdateWithVersion(l.ctx, conn, dm) | ||
| 62 | + return err | ||
| 63 | + }, true); err != nil { | ||
| 64 | + return nil, xerr.NewErrMsg("更新失败") | ||
| 65 | + } | ||
| 66 | + resp = &types.RoleUpdateResponse{} | ||
| 67 | + return | ||
| 68 | +} |
| 1 | +package user | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/contextdata" | ||
| 7 | + | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/types" | ||
| 10 | + | ||
| 11 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type UserCompanyUsersLogic struct { | ||
| 15 | + logx.Logger | ||
| 16 | + ctx context.Context | ||
| 17 | + svcCtx *svc.ServiceContext | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func NewUserCompanyUsersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserCompanyUsersLogic { | ||
| 21 | + return &UserCompanyUsersLogic{ | ||
| 22 | + Logger: logx.WithContext(ctx), | ||
| 23 | + ctx: ctx, | ||
| 24 | + svcCtx: svcCtx, | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (l *UserCompanyUsersLogic) UserCompanyUsers(req *types.CompanyUsersRequest) (resp *types.CompanyUsersResponse, err error) { | ||
| 29 | + var ( | ||
| 30 | + conn = l.svcCtx.DefaultDBConn() | ||
| 31 | + users []*domain.SysUser | ||
| 32 | + //total int64 | ||
| 33 | + token = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 34 | + ) | ||
| 35 | + options := domain.NewQueryOptions().MustWithKV("companyId", token.CompanyId).WithFindOnly() | ||
| 36 | + _, users, _ = l.svcCtx.UserRepository.Find(l.ctx, conn, options) | ||
| 37 | + resp = &types.CompanyUsersResponse{ | ||
| 38 | + List: make([]types.User, 0), | ||
| 39 | + } | ||
| 40 | + for _, user := range users { | ||
| 41 | + resp.List = append(resp.List, types.NewTypesUser(user)) | ||
| 42 | + } | ||
| 43 | + return | ||
| 44 | +} |
cmd/ep/system/api/internal/types/app.go
0 → 100644
| 1 | +package types | ||
| 2 | + | ||
| 3 | +import "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 4 | + | ||
| 5 | +func NewTypesSystemAppItem(item *domain.SysApp, cp *domain.SysCompanyApp) SystemAppItem { | ||
| 6 | + return SystemAppItem{ | ||
| 7 | + Id: cp.Id, | ||
| 8 | + Code: item.Code, | ||
| 9 | + Name: item.Name, | ||
| 10 | + Logo: item.Logo, | ||
| 11 | + Description: item.Description, | ||
| 12 | + Type: item.Type, | ||
| 13 | + VersionNumber: item.VersionNumber, | ||
| 14 | + Status: cp.Status, | ||
| 15 | + VisibleFlag: cp.VisibleFlag, | ||
| 16 | + VisibleUsers: cp.VisibleUsers, | ||
| 17 | + Sort: cp.Sort, | ||
| 18 | + } | ||
| 19 | +} |
cmd/ep/system/api/internal/types/menu.go
0 → 100644
| 1 | +package types | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain" | ||
| 5 | +) | ||
| 6 | + | ||
| 7 | +func NewTypesMenu(m *domain.SysMenu) Menu { | ||
| 8 | + return Menu{ | ||
| 9 | + Id: m.Id, | ||
| 10 | + ParentId: m.ParentId, | ||
| 11 | + Name: m.Name, | ||
| 12 | + Code: m.Code, | ||
| 13 | + Sort: m.Sort, | ||
| 14 | + MenuType: m.MenuType, | ||
| 15 | + Icon: m.Icon, | ||
| 16 | + } | ||
| 17 | +} |
| @@ -2,9 +2,10 @@ | @@ -2,9 +2,10 @@ | ||
| 2 | package types | 2 | package types |
| 3 | 3 | ||
| 4 | type User struct { | 4 | type User struct { |
| 5 | - Id int64 `json:"id"` // 用户ID | ||
| 6 | - Name string `json:"name"` // 用户名称 | ||
| 7 | - Phone string `json:"phone,optional,omitempty"` // 用户手机号 | 5 | + Id int64 `json:"id,optional"` // 用户ID |
| 6 | + Name string `json:"name,optional"` // 用户名称 | ||
| 7 | + Phone string `json:"phone,optional,omitempty"` // 用户手机号 | ||
| 8 | + Avatar string `json:"avatar,optional,omitempty"` // 头像 | ||
| 8 | } | 9 | } |
| 9 | 10 | ||
| 10 | type CompanyRegisterRequest struct { | 11 | type CompanyRegisterRequest struct { |
| @@ -36,16 +37,53 @@ type UserInfoRequest struct { | @@ -36,16 +37,53 @@ type UserInfoRequest struct { | ||
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | type UserInfoResponse struct { | 39 | type UserInfoResponse struct { |
| 39 | - Id int64 `json:"id"` // 用户ID | ||
| 40 | - Name string `json:"name"` // 用户名称 | ||
| 41 | - Phone string `json:"phone"` // 用户手机号 | ||
| 42 | - EmployeeInfo *Employee `json:"employeeInfo"` // 职员信息 | ||
| 43 | - Company *Company `json:"company"` // 当前公司信息 | ||
| 44 | - CompanyList []Company `json:"companies"` // 拥有的公司 | 40 | + Id int64 `json:"id"` // 用户ID |
| 41 | + Avatar string `json:"avatar"` // 头像 | ||
| 42 | + Name string `json:"name"` // 用户名称 | ||
| 43 | + Phone string `json:"phone"` // 用户手机号 | ||
| 44 | + Accounts []AccountInfo `json:"accounts"` // 账号列表 | ||
| 45 | + Apps []SystemAppItem `json:"apps"` // 应用列表 | ||
| 46 | + Menus []Menu `json:"menus"` // 有权限的菜单 | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +type AccountInfo struct { | ||
| 50 | + Company Company `json:"company"` // 公司 | ||
| 51 | + Selected bool `json:"selected"` // 当前选择的账号 | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +type EditUserInfoRequest struct { | ||
| 55 | + Avatar *string `json:"avatar,optional"` // 头像 | ||
| 56 | + Name *string `json:"name,optional"` // 用户名称 | ||
| 57 | + Phone *string `json:"phone,optional"` // 用户手机号 | ||
| 58 | +} | ||
| 59 | + | ||
| 60 | +type ChangePasswordRequest struct { | ||
| 61 | + OldPassword string `json:"oldPassword,optional"` // 旧密码 | ||
| 62 | + NewPassword string `json:"newPassword"` // 新密码 | ||
| 63 | + ConfirmPassword string `json:"confirmPassword"` // 确认密码 | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +type ChangePasswordResponse struct { | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | +type ResetPasswordRequest struct { | ||
| 70 | + Code string `json:"code"` // 验证码 | ||
| 71 | + NewPassword string `json:"newPassword"` // 新密码 | ||
| 72 | + ConfirmPassword string `json:"confirmPassword"` // 确认密码 | ||
| 73 | +} | ||
| 74 | + | ||
| 75 | +type ResetPasswordResponse struct { | ||
| 45 | } | 76 | } |
| 46 | 77 | ||
| 47 | type SwitchCompanyRequest struct { | 78 | type SwitchCompanyRequest struct { |
| 48 | - CompanyId int64 `json:"companyId"` // 公司ID | 79 | + CompanyId int64 `json:"companyId,string"` // 公司ID |
| 80 | +} | ||
| 81 | + | ||
| 82 | +type CompanyUsersRequest struct { | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +type CompanyUsersResponse struct { | ||
| 86 | + List []User `json:"list"` // 用户列表 | ||
| 49 | } | 87 | } |
| 50 | 88 | ||
| 51 | type SystemCompanyInfoRequest struct { | 89 | type SystemCompanyInfoRequest struct { |
| @@ -142,8 +180,71 @@ type DepartmentImportResponse struct { | @@ -142,8 +180,71 @@ type DepartmentImportResponse struct { | ||
| 142 | } | 180 | } |
| 143 | 181 | ||
| 144 | type Role struct { | 182 | type Role struct { |
| 145 | - Id int64 `json:"id"` // 角色ID | ||
| 146 | - Name string `json:"name"` // 角色名称 | 183 | + Id int64 `json:"id,optional,omitempty"` // 角色ID |
| 184 | + Name string `json:"name,optional,omitempty"` // 角色名称 | ||
| 185 | + Menus []Menu `json:"menus,optional,omitempty"` // 菜单列表 | ||
| 186 | + AuthUsers []User `json:"users,optional,omitempty"` // 拥护该角色的用户列表 user_id 列表 | ||
| 187 | + AuthRange int `json:"authRange,optional,omitempty,option=0|1|2"` // 权限范围(1:全部权限 2:部分权限) | ||
| 188 | + UpdatedAt int64 `json:"updatedAt,optional,omitempty"` // 更新时间 | ||
| 189 | +} | ||
| 190 | + | ||
| 191 | +type RoleGetRequest struct { | ||
| 192 | + Id int64 `path:"id"` | ||
| 193 | +} | ||
| 194 | + | ||
| 195 | +type RoleGetResponse struct { | ||
| 196 | + Role Role `json:"role"` | ||
| 197 | +} | ||
| 198 | + | ||
| 199 | +type RoleSaveRequest struct { | ||
| 200 | + Role Role `json:"role"` | ||
| 201 | +} | ||
| 202 | + | ||
| 203 | +type RoleSaveResponse struct { | ||
| 204 | +} | ||
| 205 | + | ||
| 206 | +type RoleDeleteRequest struct { | ||
| 207 | + Id int64 `path:"id"` | ||
| 208 | +} | ||
| 209 | + | ||
| 210 | +type RoleDeleteResponse struct { | ||
| 211 | +} | ||
| 212 | + | ||
| 213 | +type RoleUpdateRequest struct { | ||
| 214 | + Id int64 `path:"id"` | ||
| 215 | + Role Role `json:"role"` | ||
| 216 | +} | ||
| 217 | + | ||
| 218 | +type RoleUpdateResponse struct { | ||
| 219 | +} | ||
| 220 | + | ||
| 221 | +type RoleSearchRequest struct { | ||
| 222 | + Page int `json:"page"` | ||
| 223 | + Size int `json:"size"` | ||
| 224 | + RoleName string `json:"rolename,optional"` // 角色名称 | ||
| 225 | + UserName string `json:"userName,optional"` // 用户名称 | ||
| 226 | +} | ||
| 227 | + | ||
| 228 | +type RoleSearchResponse struct { | ||
| 229 | + List []Role `json:"list"` | ||
| 230 | + Total int64 `json:"total"` | ||
| 231 | +} | ||
| 232 | + | ||
| 233 | +type MenuListRequest struct { | ||
| 234 | +} | ||
| 235 | + | ||
| 236 | +type MenuListResponse struct { | ||
| 237 | + List []Menu `json:"list"` | ||
| 238 | +} | ||
| 239 | + | ||
| 240 | +type Menu struct { | ||
| 241 | + Id int64 `json:"id,optional,omitempty"` // 菜单ID | ||
| 242 | + ParentId int64 `json:"parentId,optional"` // 父级ID | ||
| 243 | + Name string `json:"name,optional,omitempty"` // 菜单名称 | ||
| 244 | + Code string `json:"code,optional,omitempty"` // 菜单编码 | ||
| 245 | + MenuType string `json:"menuType,optional,omitempty"` // 菜单类型 (目录catalog、菜单menu、按钮button) | ||
| 246 | + Icon string `json:"icon,optional,omitempty"` // 图标 | ||
| 247 | + Sort int64 `json:"sort,optional,omitempty"` // 排序 | ||
| 147 | } | 248 | } |
| 148 | 249 | ||
| 149 | type Group struct { | 250 | type Group struct { |
| @@ -186,11 +287,14 @@ type SystemAppItem struct { | @@ -186,11 +287,14 @@ type SystemAppItem struct { | ||
| 186 | VisibleFlag int `json:"visibleFlag,omitempty"` // 1:全员可见 2:部分可见 | 287 | VisibleFlag int `json:"visibleFlag,omitempty"` // 1:全员可见 2:部分可见 |
| 187 | VisibleUsers []int64 `json:"visibleUsers,omitempty"` // 可见的用户 所有用户:空 部分用户:用户ID列表 | 288 | VisibleUsers []int64 `json:"visibleUsers,omitempty"` // 可见的用户 所有用户:空 部分用户:用户ID列表 |
| 188 | Sort int `json:"sort,omitempty"` // 排序 | 289 | Sort int `json:"sort,omitempty"` // 排序 |
| 290 | + HasAuth bool `json:"hasAuth"` // true:用户有权限 false:用户无权限 | ||
| 189 | } | 291 | } |
| 190 | 292 | ||
| 191 | type SystemAppSetConfigRequest struct { | 293 | type SystemAppSetConfigRequest struct { |
| 192 | - VisibleFlag int `json:"visibleFlag"` // 1:全员可见 2:部分可见 | ||
| 193 | - VisibleUsers []int64 `json:"visibleUsers"` // 可见的用户 所有用户:空 部分用户:用户ID列表 | 294 | + AppId int64 `json:"id"` // 公司应用ID |
| 295 | + VisibleFlag int `json:"visibleFlag"` // 1:全员可见 2:部分可见 | ||
| 296 | + VisibleUsers []int64 `json:"visibleUsers"` // 可见的用户 所有用户:空 部分用户:用户ID列表 | ||
| 297 | + VisibleDepartments []int64 `json:"visibleDepartments"` // 可见的部门 部门ID列表 | ||
| 194 | } | 298 | } |
| 195 | 299 | ||
| 196 | type SystemAppSetConfigResponse struct { | 300 | type SystemAppSetConfigResponse struct { |
cmd/ep/system/api/internal/types/user.go
0 → 100644
cmd/ep/system/deploy/database/v2.sql
0 → 100644
| 1 | + | ||
| 2 | +syntax = "v1" | ||
| 3 | + | ||
| 4 | +info( | ||
| 5 | + title: "xx实例" | ||
| 6 | + desc: "xx实例" | ||
| 7 | + author: "author" | ||
| 8 | + email: "email" | ||
| 9 | + version: "v1" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +@server( | ||
| 13 | + prefix: v1 | ||
| 14 | + group: sys_company_app | ||
| 15 | + jwt: JwtAuth | ||
| 16 | +) | ||
| 17 | +service Core { | ||
| 18 | + @doc "详情" | ||
| 19 | + @handler sys_company_appGet | ||
| 20 | + get /sys_company_app/:id (SysCompanyAppGetRequest) returns (SysCompanyAppGetResponse) | ||
| 21 | + @doc "保存" | ||
| 22 | + @handler sys_company_appSave | ||
| 23 | + post /sys_company_app (SysCompanyAppSaveRequest) returns (SysCompanyAppSaveResponse) | ||
| 24 | + @doc "删除" | ||
| 25 | + @handler sys_company_appDelete | ||
| 26 | + delete /sys_company_app/:id (SysCompanyAppDeleteRequest) returns (SysCompanyAppDeleteResponse) | ||
| 27 | + @doc "更新" | ||
| 28 | + @handler sys_company_appUpdate | ||
| 29 | + put /sys_company_app/:id (SysCompanyAppUpdateRequest) returns (SysCompanyAppUpdateResponse) | ||
| 30 | + @doc "搜索" | ||
| 31 | + @handler sys_company_appSearch | ||
| 32 | + post /sys_company_app/search (SysCompanyAppSearchRequest) returns (SysCompanyAppSearchResponse) | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +type ( | ||
| 36 | + SysCompanyAppGetRequest { | ||
| 37 | + Id int64 `path:"id"` | ||
| 38 | + } | ||
| 39 | + SysCompanyAppGetResponse struct{ | ||
| 40 | + SysCompanyApp SysCompanyAppItem `json:"sys_company_app"` | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + SysCompanyAppSaveRequest struct{ | ||
| 44 | + SysCompanyApp SysCompanyAppItem `json:"sys_company_app"` | ||
| 45 | + } | ||
| 46 | + SysCompanyAppSaveResponse struct{} | ||
| 47 | + | ||
| 48 | + SysCompanyAppDeleteRequest struct{ | ||
| 49 | + Id int64 `path:"id"` | ||
| 50 | + } | ||
| 51 | + SysCompanyAppDeleteResponse struct{} | ||
| 52 | + | ||
| 53 | + SysCompanyAppUpdateRequest struct{ | ||
| 54 | + Id int64 `path:"id"` | ||
| 55 | + SysCompanyApp SysCompanyAppItem `json:"sys_company_app"` | ||
| 56 | + } | ||
| 57 | + SysCompanyAppUpdateResponse struct{} | ||
| 58 | + | ||
| 59 | + SysCompanyAppSearchRequest struct{ | ||
| 60 | + Page int `json:"page"` | ||
| 61 | + Size int `json:"size"` | ||
| 62 | + } | ||
| 63 | + SysCompanyAppSearchResponse{ | ||
| 64 | + List []SysCompanyAppItem `json:"list"` | ||
| 65 | + Total int64 `json:"total"` | ||
| 66 | + } | ||
| 67 | + SysCompanyAppItem struct{ | ||
| 68 | + | ||
| 69 | + } | ||
| 70 | +) | ||
| 71 | + | ||
| 72 | +// logic CRUD | ||
| 73 | +// Save | ||
| 74 | + //var ( | ||
| 75 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 76 | + // dm *domain.SysCompanyApp | ||
| 77 | + //) | ||
| 78 | + //// 唯一判断 | ||
| 79 | + | ||
| 80 | + //dm = NewDomainSysCompanyApp(req.SysCompanyApp) | ||
| 81 | + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 82 | + // dm, err = l.svcCtx.SysCompanyAppRepository.Insert(l.ctx, conn, dm) | ||
| 83 | + // return err | ||
| 84 | + //}, true); err != nil { | ||
| 85 | + // return nil, xerr.NewErrMsg("保存失败") | ||
| 86 | + //} | ||
| 87 | + ////resp = &types.SysCompanyAppSaveResponse{} | ||
| 88 | + //return | ||
| 89 | + | ||
| 90 | +//func NewDomainSysCompanyApp(item types.SysCompanyAppItem) *domain.SysCompanyApp { | ||
| 91 | +// return &domain.SysCompanyApp{ | ||
| 92 | + | ||
| 93 | +// } | ||
| 94 | +//} | ||
| 95 | +// | ||
| 96 | +//func NewTypesSysCompanyApp(item *domain.SysCompanyApp) types.SysCompanyAppItem { | ||
| 97 | +// return types.SysCompanyAppItem{ | ||
| 98 | +// Id: item.Id, | ||
| 99 | +// } | ||
| 100 | +//} | ||
| 101 | + | ||
| 102 | +// Get | ||
| 103 | + //var ( | ||
| 104 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 105 | + // dm *domain.SysCompanyApp | ||
| 106 | + //) | ||
| 107 | + //// 货号唯一 | ||
| 108 | + //if dm, err = l.svcCtx.SysCompanyAppRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 109 | + // return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 110 | + //} | ||
| 111 | + //resp = &types.SysCompanyAppGetResponse{ | ||
| 112 | + // SysCompanyApp: NewTypesSysCompanyApp(dm), | ||
| 113 | + //} | ||
| 114 | + //return | ||
| 115 | + | ||
| 116 | +// Delete | ||
| 117 | + //var ( | ||
| 118 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 119 | + // dm *domain.SysCompanyApp | ||
| 120 | + //) | ||
| 121 | + //if dm, err = l.svcCtx.SysCompanyAppRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 122 | + // return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 123 | + //} | ||
| 124 | + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 125 | + // if dm, err = l.svcCtx.SysCompanyAppRepository.Delete(l.ctx, conn, dm); err != nil { | ||
| 126 | + // return err | ||
| 127 | + // } | ||
| 128 | + // return nil | ||
| 129 | + //}, true); err != nil { | ||
| 130 | + // return nil, xerr.NewErrMsgErr("移除失败", err) | ||
| 131 | + //} | ||
| 132 | + //return | ||
| 133 | + | ||
| 134 | +// Search | ||
| 135 | + //var ( | ||
| 136 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 137 | + // dms []*domain.SysCompanyApp | ||
| 138 | + // total int64 | ||
| 139 | + //) | ||
| 140 | + // | ||
| 141 | + //queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size). | ||
| 142 | + // WithKV("", "") | ||
| 143 | + | ||
| 144 | + //total, dms, err = l.svcCtx.SysCompanyAppRepository.Find(l.ctx, conn, queryOptions) | ||
| 145 | + //list := make([]types.SysCompanyAppItem, 0) | ||
| 146 | + //for i := range dms { | ||
| 147 | + // list = append(list, NewTypesSysCompanyApp(dms[i])) | ||
| 148 | + //} | ||
| 149 | + //resp = &types.SysCompanyAppSearchResponse{ | ||
| 150 | + // List: list, | ||
| 151 | + // Total: total, | ||
| 152 | + //} | ||
| 153 | + //return | ||
| 154 | + | ||
| 155 | +// Update | ||
| 156 | + //var ( | ||
| 157 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 158 | + // dm *domain.SysCompanyApp | ||
| 159 | + //) | ||
| 160 | + //if dm, err = l.svcCtx.SysCompanyAppRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 161 | + // return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 162 | + //} | ||
| 163 | + //// 不可编辑判断 | ||
| 164 | + | ||
| 165 | + //// 赋值 | ||
| 166 | + | ||
| 167 | + //// 更新 | ||
| 168 | + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 169 | + // dm, err = l.svcCtx.SysCompanyAppRepository.UpdateWithVersion(l.ctx, conn, dm) | ||
| 170 | + // return err | ||
| 171 | + //}, true); err != nil { | ||
| 172 | + // return nil, xerr.NewErrMsg("更新失败") | ||
| 173 | + //} | ||
| 174 | + //resp = &types.SysCompanyAppUpdateResponse{} | ||
| 175 | + //return |
| 1 | + | ||
| 2 | +syntax = "proto3"; | ||
| 3 | + | ||
| 4 | +option go_package ="./pb"; | ||
| 5 | + | ||
| 6 | +package pb; | ||
| 7 | + | ||
| 8 | +message SysCompanyAppGetReq { | ||
| 9 | + int64 Id = 1; | ||
| 10 | +} | ||
| 11 | +message SysCompanyAppGetResp{ | ||
| 12 | + SysCompanyAppItem SysCompanyApp = 1; | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +message SysCompanyAppSaveReq { | ||
| 16 | + | ||
| 17 | +} | ||
| 18 | +message SysCompanyAppSaveResp{ | ||
| 19 | + | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +message SysCompanyAppDeleteReq { | ||
| 23 | + int64 Id = 1; | ||
| 24 | +} | ||
| 25 | +message SysCompanyAppDeleteResp{ | ||
| 26 | + | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +message SysCompanyAppUpdateReq { | ||
| 30 | + int64 Id = 1; | ||
| 31 | +} | ||
| 32 | +message SysCompanyAppUpdateResp{ | ||
| 33 | + | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +message SysCompanyAppSearchReq { | ||
| 37 | + int64 PageNumber = 1; | ||
| 38 | + int64 PageSize = 2; | ||
| 39 | +} | ||
| 40 | +message SysCompanyAppSearchResp{ | ||
| 41 | + repeated SysCompanyAppItem List =1; | ||
| 42 | + int64 Total =2; | ||
| 43 | +} | ||
| 44 | +message SysCompanyAppItem { | ||
| 45 | + | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +service SysCompanyAppService { | ||
| 49 | + rpc SysCompanyAppGet(SysCompanyAppGetReq) returns(SysCompanyAppGetResp); | ||
| 50 | + rpc SysCompanyAppSave(SysCompanyAppSaveReq) returns(SysCompanyAppSaveResp); | ||
| 51 | + rpc SysCompanyAppDelete(SysCompanyAppDeleteReq) returns(SysCompanyAppDeleteResp); | ||
| 52 | + rpc SysCompanyAppUpdate(SysCompanyAppUpdateReq) returns(SysCompanyAppUpdateResp); | ||
| 53 | + rpc SysCompanyAppSearch(SysCompanyAppSearchReq) returns(SysCompanyAppSearchResp); | ||
| 54 | +} |
| @@ -17,7 +17,7 @@ service Core { | @@ -17,7 +17,7 @@ service Core { | ||
| 17 | post /system/app/search (SystemAppSearchRequest) returns (SystemAppSearchResponse) | 17 | post /system/app/search (SystemAppSearchRequest) returns (SystemAppSearchResponse) |
| 18 | @doc "应用-设置配置" | 18 | @doc "应用-设置配置" |
| 19 | @handler systemAppSetConfig | 19 | @handler systemAppSetConfig |
| 20 | - get /system/app/set_config (SystemAppSetConfigRequest) returns (SystemAppSetConfigResponse) | 20 | + post /system/app/set_config (SystemAppSetConfigRequest) returns (SystemAppSetConfigResponse) |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | type ( | 23 | type ( |
| @@ -52,14 +52,17 @@ type ( | @@ -52,14 +52,17 @@ type ( | ||
| 52 | VisibleFlag int `json:"visibleFlag,omitempty"` // 1:全员可见 2:部分可见 | 52 | VisibleFlag int `json:"visibleFlag,omitempty"` // 1:全员可见 2:部分可见 |
| 53 | VisibleUsers []int64 `json:"visibleUsers,omitempty"` // 可见的用户 所有用户:空 部分用户:用户ID列表 | 53 | VisibleUsers []int64 `json:"visibleUsers,omitempty"` // 可见的用户 所有用户:空 部分用户:用户ID列表 |
| 54 | Sort int `json:"sort,omitempty"` // 排序 | 54 | Sort int `json:"sort,omitempty"` // 排序 |
| 55 | + HasAuth bool `json:"hasAuth"` // true:用户有权限 false:用户无权限 | ||
| 55 | } | 56 | } |
| 56 | ) | 57 | ) |
| 57 | 58 | ||
| 58 | // 应用-设置配置 | 59 | // 应用-设置配置 |
| 59 | type( | 60 | type( |
| 60 | SystemAppSetConfigRequest{ | 61 | SystemAppSetConfigRequest{ |
| 61 | - VisibleFlag int `json:"visibleFlag"` // 1:全员可见 2:部分可见 | ||
| 62 | - VisibleUsers []int64 `json:"visibleUsers"` // 可见的用户 所有用户:空 部分用户:用户ID列表 | 62 | + AppId int64 `json:"id"` // 公司应用ID |
| 63 | + VisibleFlag int `json:"visibleFlag"` // 1:全员可见 2:部分可见 | ||
| 64 | + VisibleUsers []int64 `json:"visibleUsers"` // 可见的用户 所有用户:空 部分用户:用户ID列表 | ||
| 65 | + VisibleDepartments []int64 `json:"visibleDepartments"` // 可见的部门 部门ID列表 | ||
| 63 | } | 66 | } |
| 64 | SystemAppSetConfigResponse{ | 67 | SystemAppSetConfigResponse{ |
| 65 | SystemApp SystemAppItem `json:"app"` | 68 | SystemApp SystemAppItem `json:"app"` |
| @@ -2,7 +2,94 @@ syntax = "v1" | @@ -2,7 +2,94 @@ syntax = "v1" | ||
| 2 | 2 | ||
| 3 | type( | 3 | type( |
| 4 | Role{ | 4 | Role{ |
| 5 | - Id int64 `json:"id"` // 角色ID | ||
| 6 | - Name string `json:"name"` // 角色名称 | 5 | + Id int64 `json:"id,optional,omitempty"` // 角色ID |
| 6 | + Name string `json:"name,optional,omitempty"` // 角色名称 | ||
| 7 | + Menus []Menu `json:"menus,optional,omitempty"` // 菜单列表 | ||
| 8 | + AuthUsers []User `json:"users,optional,omitempty"` // 拥护该角色的用户列表 user_id 列表 | ||
| 9 | + AuthRange int `json:"authRange,optional,omitempty,option=0|1|2"` // 权限范围(1:全部权限 2:部分权限) | ||
| 10 | + UpdatedAt int64 `json:"updatedAt,optional,omitempty"` // 更新时间 | ||
| 11 | + } | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +@server( | ||
| 15 | + prefix: v1/system | ||
| 16 | + group: role | ||
| 17 | + middleware: LogRequest | ||
| 18 | + jwt: SystemAuth | ||
| 19 | +) | ||
| 20 | +service Core { | ||
| 21 | + @doc "角色-详情" | ||
| 22 | + @handler systemRoleGet | ||
| 23 | + get /role/:id (RoleGetRequest) returns (RoleGetResponse) | ||
| 24 | + @doc "角色-保存" | ||
| 25 | + @handler systemRoleSave | ||
| 26 | + post /role (RoleSaveRequest) returns (RoleSaveResponse) | ||
| 27 | + @doc "角色-删除" | ||
| 28 | + @handler systemRoleDelete | ||
| 29 | + delete /role/:id (RoleDeleteRequest) returns (RoleDeleteResponse) | ||
| 30 | + @doc "角色-更新" | ||
| 31 | + @handler systemRoleUpdate | ||
| 32 | + put /role/:id (RoleUpdateRequest) returns (RoleUpdateResponse) | ||
| 33 | + @doc "角色-搜索" | ||
| 34 | + @handler systemRoleSearch | ||
| 35 | + post /role/search (RoleSearchRequest) returns (RoleSearchResponse) | ||
| 36 | + | ||
| 37 | + @doc "菜单-列表" | ||
| 38 | + @handler systemMenuList | ||
| 39 | + post /menu/list (MenuListRequest) returns (MenuListResponse) | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +type ( | ||
| 43 | + RoleGetRequest { | ||
| 44 | + Id int64 `path:"id"` | ||
| 45 | + } | ||
| 46 | + RoleGetResponse struct{ | ||
| 47 | + Role Role `json:"role"` | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + RoleSaveRequest struct{ | ||
| 51 | + Role Role `json:"role"` | ||
| 52 | + } | ||
| 53 | + RoleSaveResponse struct{} | ||
| 54 | + | ||
| 55 | + RoleDeleteRequest struct{ | ||
| 56 | + Id int64 `path:"id"` | ||
| 57 | + } | ||
| 58 | + RoleDeleteResponse struct{} | ||
| 59 | + | ||
| 60 | + RoleUpdateRequest struct{ | ||
| 61 | + Id int64 `path:"id"` | ||
| 62 | + Role Role `json:"role"` | ||
| 63 | + } | ||
| 64 | + RoleUpdateResponse struct{} | ||
| 65 | + | ||
| 66 | + RoleSearchRequest struct{ | ||
| 67 | + Page int `json:"page"` | ||
| 68 | + Size int `json:"size"` | ||
| 69 | + RoleName string `json:"rolename,optional"` // 角色名称 | ||
| 70 | + UserName string `json:"userName,optional"` // 用户名称 | ||
| 71 | + } | ||
| 72 | + RoleSearchResponse{ | ||
| 73 | + List []Role `json:"list"` | ||
| 74 | + Total int64 `json:"total"` | ||
| 75 | + } | ||
| 76 | +) | ||
| 77 | + | ||
| 78 | +// 菜单列表 | ||
| 79 | +type( | ||
| 80 | + MenuListRequest{ | ||
| 81 | + | ||
| 82 | + } | ||
| 83 | + MenuListResponse{ | ||
| 84 | + List []Menu `json:"list"` | ||
| 85 | + } | ||
| 86 | + Menu{ | ||
| 87 | + Id int64 `json:"id,optional,omitempty"` // 菜单ID | ||
| 88 | + ParentId int64 `json:"parentId,optional"` // 父级ID | ||
| 89 | + Name string `json:"name,optional,omitempty"` // 菜单名称 | ||
| 90 | + Code string `json:"code,optional,omitempty"` // 菜单编码 | ||
| 91 | + MenuType string `json:"menuType,optional,omitempty"` // 菜单类型 (目录catalog、菜单menu、按钮button) | ||
| 92 | + Icon string `json:"icon,optional,omitempty"` // 图标 | ||
| 93 | + Sort int64 `json:"sort,optional,omitempty"` // 排序 | ||
| 7 | } | 94 | } |
| 8 | ) | 95 | ) |
| @@ -34,16 +34,39 @@ service Core { | @@ -34,16 +34,39 @@ service Core { | ||
| 34 | @doc "系统用户信息" | 34 | @doc "系统用户信息" |
| 35 | @handler systemAuthUserInfo | 35 | @handler systemAuthUserInfo |
| 36 | post /auth/user_info(UserInfoRequest) returns (UserInfoResponse) | 36 | post /auth/user_info(UserInfoRequest) returns (UserInfoResponse) |
| 37 | + @doc "修改用户信息" | ||
| 38 | + @handler systemAuthEditUserInfo | ||
| 39 | + post /auth/edit_user_info(EditUserInfoRequest) returns (UserInfoResponse) | ||
| 40 | + @doc "修改密码" | ||
| 41 | + @handler systemAuthChangePassword | ||
| 42 | + post /auth/change_password(ChangePasswordRequest) returns (ChangePasswordResponse) | ||
| 43 | + @doc "重置密码" | ||
| 44 | + @handler systemAuthResetPassword | ||
| 45 | + post /auth/reset_password(ResetPasswordRequest) returns (ResetPasswordResponse) | ||
| 37 | @doc "系统用户信息" | 46 | @doc "系统用户信息" |
| 38 | @handler systemAuthSwitchCompany | 47 | @handler systemAuthSwitchCompany |
| 39 | post /auth/switch_company(SwitchCompanyRequest) returns (AuthLoginResponse) | 48 | post /auth/switch_company(SwitchCompanyRequest) returns (AuthLoginResponse) |
| 49 | + | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +@server( | ||
| 53 | + prefix: v1 | ||
| 54 | + group: user | ||
| 55 | + middleware: LogRequest | ||
| 56 | + jwt: SystemAuth | ||
| 57 | +) | ||
| 58 | +service Core { | ||
| 59 | + @doc "公司用户列表" | ||
| 60 | + @handler userCompanyUsers | ||
| 61 | + post /user/company_users(CompanyUsersRequest) returns (CompanyUsersResponse) | ||
| 40 | } | 62 | } |
| 41 | 63 | ||
| 42 | type( | 64 | type( |
| 43 | User{ | 65 | User{ |
| 44 | - Id int64 `json:"id"` // 用户ID | ||
| 45 | - Name string `json:"name"` // 用户名称 | ||
| 46 | - Phone string `json:"phone,optional,omitempty"` // 用户手机号 | 66 | + Id int64 `json:"id,optional"` // 用户ID |
| 67 | + Name string `json:"name,optional"` // 用户名称 | ||
| 68 | + Phone string `json:"phone,optional,omitempty"` // 用户手机号 | ||
| 69 | + Avatar string `json:"avatar,optional,omitempty"`// 头像 | ||
| 47 | } | 70 | } |
| 48 | ) | 71 | ) |
| 49 | 72 | ||
| @@ -81,17 +104,71 @@ type( | @@ -81,17 +104,71 @@ type( | ||
| 81 | EmployeeId int64 `json:"employeeId,optional"` | 104 | EmployeeId int64 `json:"employeeId,optional"` |
| 82 | } | 105 | } |
| 83 | UserInfoResponse{ | 106 | UserInfoResponse{ |
| 84 | - Id int64 `json:"id"` // 用户ID | ||
| 85 | - Name string `json:"name"` // 用户名称 | ||
| 86 | - Phone string `json:"phone"` // 用户手机号 | ||
| 87 | - EmployeeInfo *Employee `json:"employeeInfo"` // 职员信息 | ||
| 88 | - Company *Company `json:"company"` // 当前公司信息 | ||
| 89 | - CompanyList []Company `json:"companies"` // 拥有的公司 | 107 | + Id int64 `json:"id"` // 用户ID |
| 108 | + Avatar string `json:"avatar"` // 头像 | ||
| 109 | + Name string `json:"name"` // 用户名称 | ||
| 110 | + Phone string `json:"phone"` // 用户手机号 | ||
| 111 | + Accounts []AccountInfo `json:"accounts"` // 账号列表 | ||
| 112 | + Apps []SystemAppItem `json:"apps"` // 应用列表 | ||
| 113 | + Menus []Menu `json:"menus"` // 有权限的菜单 | ||
| 90 | } | 114 | } |
| 115 | + AccountInfo{ | ||
| 116 | + //EmployeeId int64 `json:"employeeId"` // 职员ID | ||
| 117 | + Company Company `json:"company"` // 公司 | ||
| 118 | + Selected bool `json:"selected"` // 当前选择的账号 | ||
| 119 | + } | ||
| 120 | +) | ||
| 121 | + | ||
| 122 | +// 修改用户信息 | ||
| 123 | +type( | ||
| 124 | + EditUserInfoRequest{ | ||
| 125 | + Avatar *string `json:"avatar,optional"` // 头像 | ||
| 126 | + Name *string `json:"name,optional"` // 用户名称 | ||
| 127 | + Phone *string `json:"phone,optional"` // 用户手机号 | ||
| 128 | + //Password *string `json:"password,optional"` // 密码base64((MD5)) | ||
| 129 | + } | ||
| 130 | +// UserInfoResponse{ | ||
| 131 | +// | ||
| 132 | +// } | ||
| 91 | ) | 133 | ) |
| 134 | + | ||
| 135 | +// 修改密码 | ||
| 136 | +type( | ||
| 137 | + ChangePasswordRequest{ | ||
| 138 | + OldPassword string `json:"oldPassword,optional"` // 旧密码 | ||
| 139 | + NewPassword string `json:"newPassword"` // 新密码 | ||
| 140 | + ConfirmPassword string `json:"confirmPassword"` // 确认密码 | ||
| 141 | + } | ||
| 142 | + ChangePasswordResponse{ | ||
| 143 | + | ||
| 144 | + } | ||
| 145 | +) | ||
| 146 | + | ||
| 147 | +// 重置密码 | ||
| 148 | +type( | ||
| 149 | + ResetPasswordRequest{ | ||
| 150 | + Code string `json:"code"` // 验证码 | ||
| 151 | + NewPassword string `json:"newPassword"` // 新密码 | ||
| 152 | + ConfirmPassword string `json:"confirmPassword"` // 确认密码 | ||
| 153 | + } | ||
| 154 | + ResetPasswordResponse{ | ||
| 155 | + | ||
| 156 | + } | ||
| 157 | +) | ||
| 158 | + | ||
| 92 | // 切换公司请求 | 159 | // 切换公司请求 |
| 93 | type( | 160 | type( |
| 94 | SwitchCompanyRequest{ | 161 | SwitchCompanyRequest{ |
| 95 | - CompanyId int64 `json:"companyId"` // 公司ID | 162 | + CompanyId int64 `json:"companyId,string"` // 公司ID |
| 163 | + } | ||
| 164 | +) | ||
| 165 | + | ||
| 166 | +// 公司用户搜索 | ||
| 167 | +type( | ||
| 168 | + CompanyUsersRequest{ | ||
| 169 | + | ||
| 170 | + } | ||
| 171 | + CompanyUsersResponse{ | ||
| 172 | + List []User `json:"list"` // 用户列表 | ||
| 96 | } | 173 | } |
| 97 | ) | 174 | ) |
| @@ -15,6 +15,34 @@ | @@ -15,6 +15,34 @@ | ||
| 15 | "application/json" | 15 | "application/json" |
| 16 | ], | 16 | ], |
| 17 | "paths": { | 17 | "paths": { |
| 18 | + "v1/auth/change_password": { | ||
| 19 | + "post": { | ||
| 20 | + "summary": "修改密码", | ||
| 21 | + "operationId": "systemAuthChangePassword", | ||
| 22 | + "responses": { | ||
| 23 | + "200": { | ||
| 24 | + "description": "A successful response.", | ||
| 25 | + "schema": { | ||
| 26 | + "$ref": "#/definitions/ChangePasswordResponse" | ||
| 27 | + } | ||
| 28 | + } | ||
| 29 | + }, | ||
| 30 | + "parameters": [ | ||
| 31 | + { | ||
| 32 | + "name": "body", | ||
| 33 | + "in": "body", | ||
| 34 | + "required": true, | ||
| 35 | + "schema": { | ||
| 36 | + "$ref": "#/definitions/ChangePasswordRequest" | ||
| 37 | + } | ||
| 38 | + } | ||
| 39 | + ], | ||
| 40 | + "requestBody": {}, | ||
| 41 | + "tags": [ | ||
| 42 | + "auth" | ||
| 43 | + ] | ||
| 44 | + } | ||
| 45 | + }, | ||
| 18 | "v1/auth/company_sign_up": { | 46 | "v1/auth/company_sign_up": { |
| 19 | "post": { | 47 | "post": { |
| 20 | "summary": "公司注册", | 48 | "summary": "公司注册", |
| @@ -43,6 +71,34 @@ | @@ -43,6 +71,34 @@ | ||
| 43 | ] | 71 | ] |
| 44 | } | 72 | } |
| 45 | }, | 73 | }, |
| 74 | + "v1/auth/edit_user_info": { | ||
| 75 | + "post": { | ||
| 76 | + "summary": "修改用户信息", | ||
| 77 | + "operationId": "systemAuthEditUserInfo", | ||
| 78 | + "responses": { | ||
| 79 | + "200": { | ||
| 80 | + "description": "A successful response.", | ||
| 81 | + "schema": { | ||
| 82 | + "$ref": "#/definitions/UserInfoResponse" | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + }, | ||
| 86 | + "parameters": [ | ||
| 87 | + { | ||
| 88 | + "name": "body", | ||
| 89 | + "in": "body", | ||
| 90 | + "required": true, | ||
| 91 | + "schema": { | ||
| 92 | + "$ref": "#/definitions/EditUserInfoRequest" | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + ], | ||
| 96 | + "requestBody": {}, | ||
| 97 | + "tags": [ | ||
| 98 | + "auth" | ||
| 99 | + ] | ||
| 100 | + } | ||
| 101 | + }, | ||
| 46 | "v1/auth/login": { | 102 | "v1/auth/login": { |
| 47 | "post": { | 103 | "post": { |
| 48 | "summary": "系统用户登录", | 104 | "summary": "系统用户登录", |
| @@ -71,6 +127,62 @@ | @@ -71,6 +127,62 @@ | ||
| 71 | ] | 127 | ] |
| 72 | } | 128 | } |
| 73 | }, | 129 | }, |
| 130 | + "v1/auth/reset_password": { | ||
| 131 | + "post": { | ||
| 132 | + "summary": "重置密码", | ||
| 133 | + "operationId": "systemAuthResetPassword", | ||
| 134 | + "responses": { | ||
| 135 | + "200": { | ||
| 136 | + "description": "A successful response.", | ||
| 137 | + "schema": { | ||
| 138 | + "$ref": "#/definitions/ResetPasswordResponse" | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + }, | ||
| 142 | + "parameters": [ | ||
| 143 | + { | ||
| 144 | + "name": "body", | ||
| 145 | + "in": "body", | ||
| 146 | + "required": true, | ||
| 147 | + "schema": { | ||
| 148 | + "$ref": "#/definitions/ResetPasswordRequest" | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + ], | ||
| 152 | + "requestBody": {}, | ||
| 153 | + "tags": [ | ||
| 154 | + "auth" | ||
| 155 | + ] | ||
| 156 | + } | ||
| 157 | + }, | ||
| 158 | + "v1/auth/switch_company": { | ||
| 159 | + "post": { | ||
| 160 | + "summary": "系统用户信息", | ||
| 161 | + "operationId": "systemAuthSwitchCompany", | ||
| 162 | + "responses": { | ||
| 163 | + "200": { | ||
| 164 | + "description": "A successful response.", | ||
| 165 | + "schema": { | ||
| 166 | + "$ref": "#/definitions/AuthLoginResponse" | ||
| 167 | + } | ||
| 168 | + } | ||
| 169 | + }, | ||
| 170 | + "parameters": [ | ||
| 171 | + { | ||
| 172 | + "name": "body", | ||
| 173 | + "in": "body", | ||
| 174 | + "required": true, | ||
| 175 | + "schema": { | ||
| 176 | + "$ref": "#/definitions/SwitchCompanyRequest" | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + ], | ||
| 180 | + "requestBody": {}, | ||
| 181 | + "tags": [ | ||
| 182 | + "auth" | ||
| 183 | + ] | ||
| 184 | + } | ||
| 185 | + }, | ||
| 74 | "v1/auth/user_info": { | 186 | "v1/auth/user_info": { |
| 75 | "post": { | 187 | "post": { |
| 76 | "summary": "系统用户信息", | 188 | "summary": "系统用户信息", |
| @@ -781,9 +893,202 @@ | @@ -781,9 +893,202 @@ | ||
| 781 | "employee" | 893 | "employee" |
| 782 | ] | 894 | ] |
| 783 | } | 895 | } |
| 896 | + }, | ||
| 897 | + "v1/system/menu/list": { | ||
| 898 | + "post": { | ||
| 899 | + "summary": "菜单-列表", | ||
| 900 | + "operationId": "systemMenuList", | ||
| 901 | + "responses": { | ||
| 902 | + "200": { | ||
| 903 | + "description": "A successful response.", | ||
| 904 | + "schema": { | ||
| 905 | + "$ref": "#/definitions/MenuListResponse" | ||
| 906 | + } | ||
| 907 | + } | ||
| 908 | + }, | ||
| 909 | + "parameters": [ | ||
| 910 | + { | ||
| 911 | + "name": "body", | ||
| 912 | + "in": "body", | ||
| 913 | + "required": true, | ||
| 914 | + "schema": { | ||
| 915 | + "$ref": "#/definitions/MenuListRequest" | ||
| 916 | + } | ||
| 917 | + } | ||
| 918 | + ], | ||
| 919 | + "requestBody": {}, | ||
| 920 | + "tags": [ | ||
| 921 | + "role" | ||
| 922 | + ] | ||
| 923 | + } | ||
| 924 | + }, | ||
| 925 | + "v1/system/role": { | ||
| 926 | + "post": { | ||
| 927 | + "summary": "角色-保存", | ||
| 928 | + "operationId": "systemRoleSave", | ||
| 929 | + "responses": { | ||
| 930 | + "200": { | ||
| 931 | + "description": "A successful response.", | ||
| 932 | + "schema": { | ||
| 933 | + "$ref": "#/definitions/RoleSaveResponse" | ||
| 934 | + } | ||
| 935 | + } | ||
| 936 | + }, | ||
| 937 | + "parameters": [ | ||
| 938 | + { | ||
| 939 | + "name": "body", | ||
| 940 | + "in": "body", | ||
| 941 | + "required": true, | ||
| 942 | + "schema": { | ||
| 943 | + "$ref": "#/definitions/RoleSaveRequest" | ||
| 944 | + } | ||
| 945 | + } | ||
| 946 | + ], | ||
| 947 | + "requestBody": {}, | ||
| 948 | + "tags": [ | ||
| 949 | + "role" | ||
| 950 | + ] | ||
| 951 | + } | ||
| 952 | + }, | ||
| 953 | + "v1/system/role/search": { | ||
| 954 | + "post": { | ||
| 955 | + "summary": "角色-搜索", | ||
| 956 | + "operationId": "systemRoleSearch", | ||
| 957 | + "responses": { | ||
| 958 | + "200": { | ||
| 959 | + "description": "A successful response.", | ||
| 960 | + "schema": { | ||
| 961 | + "$ref": "#/definitions/RoleSearchResponse" | ||
| 962 | + } | ||
| 963 | + } | ||
| 964 | + }, | ||
| 965 | + "parameters": [ | ||
| 966 | + { | ||
| 967 | + "name": "body", | ||
| 968 | + "in": "body", | ||
| 969 | + "required": true, | ||
| 970 | + "schema": { | ||
| 971 | + "$ref": "#/definitions/RoleSearchRequest" | ||
| 972 | + } | ||
| 973 | + } | ||
| 974 | + ], | ||
| 975 | + "requestBody": {}, | ||
| 976 | + "tags": [ | ||
| 977 | + "role" | ||
| 978 | + ] | ||
| 979 | + } | ||
| 980 | + }, | ||
| 981 | + "v1/system/role/{id}": { | ||
| 982 | + "get": { | ||
| 983 | + "summary": "角色-详情", | ||
| 984 | + "operationId": "systemRoleGet", | ||
| 985 | + "responses": { | ||
| 986 | + "200": { | ||
| 987 | + "description": "A successful response.", | ||
| 988 | + "schema": { | ||
| 989 | + "$ref": "#/definitions/RoleGetResponse" | ||
| 990 | + } | ||
| 991 | + } | ||
| 992 | + }, | ||
| 993 | + "parameters": [ | ||
| 994 | + { | ||
| 995 | + "name": "id", | ||
| 996 | + "in": "path", | ||
| 997 | + "required": true, | ||
| 998 | + "type": "string" | ||
| 999 | + } | ||
| 1000 | + ], | ||
| 1001 | + "requestBody": {}, | ||
| 1002 | + "tags": [ | ||
| 1003 | + "role" | ||
| 1004 | + ] | ||
| 1005 | + }, | ||
| 1006 | + "delete": { | ||
| 1007 | + "summary": "角色-删除", | ||
| 1008 | + "operationId": "systemRoleDelete", | ||
| 1009 | + "responses": { | ||
| 1010 | + "200": { | ||
| 1011 | + "description": "A successful response.", | ||
| 1012 | + "schema": { | ||
| 1013 | + "$ref": "#/definitions/RoleDeleteResponse" | ||
| 1014 | + } | ||
| 1015 | + } | ||
| 1016 | + }, | ||
| 1017 | + "parameters": [ | ||
| 1018 | + { | ||
| 1019 | + "name": "id", | ||
| 1020 | + "in": "path", | ||
| 1021 | + "required": true, | ||
| 1022 | + "type": "string" | ||
| 1023 | + }, | ||
| 1024 | + { | ||
| 1025 | + "name": "body", | ||
| 1026 | + "in": "body", | ||
| 1027 | + "required": true, | ||
| 1028 | + "schema": { | ||
| 1029 | + "$ref": "#/definitions/RoleDeleteRequest" | ||
| 1030 | + } | ||
| 1031 | + } | ||
| 1032 | + ], | ||
| 1033 | + "requestBody": {}, | ||
| 1034 | + "tags": [ | ||
| 1035 | + "role" | ||
| 1036 | + ] | ||
| 1037 | + }, | ||
| 1038 | + "put": { | ||
| 1039 | + "summary": "角色-更新", | ||
| 1040 | + "operationId": "systemRoleUpdate", | ||
| 1041 | + "responses": { | ||
| 1042 | + "200": { | ||
| 1043 | + "description": "A successful response.", | ||
| 1044 | + "schema": { | ||
| 1045 | + "$ref": "#/definitions/RoleUpdateResponse" | ||
| 1046 | + } | ||
| 1047 | + } | ||
| 1048 | + }, | ||
| 1049 | + "parameters": [ | ||
| 1050 | + { | ||
| 1051 | + "name": "id", | ||
| 1052 | + "in": "path", | ||
| 1053 | + "required": true, | ||
| 1054 | + "type": "string" | ||
| 1055 | + }, | ||
| 1056 | + { | ||
| 1057 | + "name": "body", | ||
| 1058 | + "in": "body", | ||
| 1059 | + "required": true, | ||
| 1060 | + "schema": { | ||
| 1061 | + "$ref": "#/definitions/RoleUpdateRequest" | ||
| 1062 | + } | ||
| 1063 | + } | ||
| 1064 | + ], | ||
| 1065 | + "requestBody": {}, | ||
| 1066 | + "tags": [ | ||
| 1067 | + "role" | ||
| 1068 | + ] | ||
| 1069 | + } | ||
| 784 | } | 1070 | } |
| 785 | }, | 1071 | }, |
| 786 | "definitions": { | 1072 | "definitions": { |
| 1073 | + "AccountInfo": { | ||
| 1074 | + "type": "object", | ||
| 1075 | + "properties": { | ||
| 1076 | + "company": { | ||
| 1077 | + "$ref": "#/definitions/Company", | ||
| 1078 | + "description": " 公司" | ||
| 1079 | + }, | ||
| 1080 | + "selected": { | ||
| 1081 | + "type": "boolean", | ||
| 1082 | + "format": "boolean", | ||
| 1083 | + "description": " 当前选择的账号" | ||
| 1084 | + } | ||
| 1085 | + }, | ||
| 1086 | + "title": "AccountInfo", | ||
| 1087 | + "required": [ | ||
| 1088 | + "company", | ||
| 1089 | + "selected" | ||
| 1090 | + ] | ||
| 1091 | + }, | ||
| 787 | "AuthLoginRequest": { | 1092 | "AuthLoginRequest": { |
| 788 | "type": "object", | 1093 | "type": "object", |
| 789 | "properties": { | 1094 | "properties": { |
| @@ -821,6 +1126,32 @@ | @@ -821,6 +1126,32 @@ | ||
| 821 | "token" | 1126 | "token" |
| 822 | ] | 1127 | ] |
| 823 | }, | 1128 | }, |
| 1129 | + "ChangePasswordRequest": { | ||
| 1130 | + "type": "object", | ||
| 1131 | + "properties": { | ||
| 1132 | + "oldPassword": { | ||
| 1133 | + "type": "string", | ||
| 1134 | + "description": " 旧密码" | ||
| 1135 | + }, | ||
| 1136 | + "newPassword": { | ||
| 1137 | + "type": "string", | ||
| 1138 | + "description": " 新密码" | ||
| 1139 | + }, | ||
| 1140 | + "confirmPassword": { | ||
| 1141 | + "type": "string", | ||
| 1142 | + "description": " 确认密码" | ||
| 1143 | + } | ||
| 1144 | + }, | ||
| 1145 | + "title": "ChangePasswordRequest", | ||
| 1146 | + "required": [ | ||
| 1147 | + "newPassword", | ||
| 1148 | + "confirmPassword" | ||
| 1149 | + ] | ||
| 1150 | + }, | ||
| 1151 | + "ChangePasswordResponse": { | ||
| 1152 | + "type": "object", | ||
| 1153 | + "title": "ChangePasswordResponse" | ||
| 1154 | + }, | ||
| 824 | "Company": { | 1155 | "Company": { |
| 825 | "type": "object", | 1156 | "type": "object", |
| 826 | "properties": { | 1157 | "properties": { |
| @@ -1175,6 +1506,24 @@ | @@ -1175,6 +1506,24 @@ | ||
| 1175 | "type": "object", | 1506 | "type": "object", |
| 1176 | "title": "DepartmentUpdateResponse" | 1507 | "title": "DepartmentUpdateResponse" |
| 1177 | }, | 1508 | }, |
| 1509 | + "EditUserInfoRequest": { | ||
| 1510 | + "type": "object", | ||
| 1511 | + "properties": { | ||
| 1512 | + "avatar": { | ||
| 1513 | + "$ref": "#/definitions/string", | ||
| 1514 | + "description": " 头像" | ||
| 1515 | + }, | ||
| 1516 | + "name": { | ||
| 1517 | + "$ref": "#/definitions/string", | ||
| 1518 | + "description": " 用户名称" | ||
| 1519 | + }, | ||
| 1520 | + "phone": { | ||
| 1521 | + "$ref": "#/definitions/string", | ||
| 1522 | + "description": " 用户手机号" | ||
| 1523 | + } | ||
| 1524 | + }, | ||
| 1525 | + "title": "EditUserInfoRequest" | ||
| 1526 | + }, | ||
| 1178 | "Employee": { | 1527 | "Employee": { |
| 1179 | "type": "object", | 1528 | "type": "object", |
| 1180 | "properties": { | 1529 | "properties": { |
| @@ -1182,6 +1531,10 @@ | @@ -1182,6 +1531,10 @@ | ||
| 1182 | "type": "integer", | 1531 | "type": "integer", |
| 1183 | "format": "int64" | 1532 | "format": "int64" |
| 1184 | }, | 1533 | }, |
| 1534 | + "userId": { | ||
| 1535 | + "type": "integer", | ||
| 1536 | + "format": "int64" | ||
| 1537 | + }, | ||
| 1185 | "name": { | 1538 | "name": { |
| 1186 | "type": "string", | 1539 | "type": "string", |
| 1187 | "description": " 姓名" | 1540 | "description": " 姓名" |
| @@ -1237,6 +1590,7 @@ | @@ -1237,6 +1590,7 @@ | ||
| 1237 | "title": "Employee", | 1590 | "title": "Employee", |
| 1238 | "required": [ | 1591 | "required": [ |
| 1239 | "id", | 1592 | "id", |
| 1593 | + "userId", | ||
| 1240 | "name", | 1594 | "name", |
| 1241 | "code", | 1595 | "code", |
| 1242 | "phone", | 1596 | "phone", |
| @@ -1255,16 +1609,14 @@ | @@ -1255,16 +1609,14 @@ | ||
| 1255 | "employeeList": { | 1609 | "employeeList": { |
| 1256 | "type": "array", | 1610 | "type": "array", |
| 1257 | "items": { | 1611 | "items": { |
| 1258 | - "type": "integer", | ||
| 1259 | - "format": "int64" | 1612 | + "type": "string" |
| 1260 | }, | 1613 | }, |
| 1261 | "description": " 职员列表" | 1614 | "description": " 职员列表" |
| 1262 | }, | 1615 | }, |
| 1263 | "departments": { | 1616 | "departments": { |
| 1264 | "type": "array", | 1617 | "type": "array", |
| 1265 | "items": { | 1618 | "items": { |
| 1266 | - "type": "integer", | ||
| 1267 | - "format": "int64" | 1619 | + "type": "string" |
| 1268 | }, | 1620 | }, |
| 1269 | "description": " 部门列表" | 1621 | "description": " 部门列表" |
| 1270 | } | 1622 | } |
| @@ -1374,7 +1726,10 @@ | @@ -1374,7 +1726,10 @@ | ||
| 1374 | "description": " 按部门过滤" | 1726 | "description": " 按部门过滤" |
| 1375 | } | 1727 | } |
| 1376 | }, | 1728 | }, |
| 1377 | - "title": "EmployeeSearchRequest" | 1729 | + "title": "EmployeeSearchRequest", |
| 1730 | + "required": [ | ||
| 1731 | + "departmentId" | ||
| 1732 | + ] | ||
| 1378 | }, | 1733 | }, |
| 1379 | "EmployeeSearchResponse": { | 1734 | "EmployeeSearchResponse": { |
| 1380 | "type": "object", | 1735 | "type": "object", |
| @@ -1463,6 +1818,98 @@ | @@ -1463,6 +1818,98 @@ | ||
| 1463 | "name" | 1818 | "name" |
| 1464 | ] | 1819 | ] |
| 1465 | }, | 1820 | }, |
| 1821 | + "Menu": { | ||
| 1822 | + "type": "object", | ||
| 1823 | + "properties": { | ||
| 1824 | + "id": { | ||
| 1825 | + "type": "integer", | ||
| 1826 | + "format": "int64", | ||
| 1827 | + "description": " 菜单ID" | ||
| 1828 | + }, | ||
| 1829 | + "parentId": { | ||
| 1830 | + "type": "integer", | ||
| 1831 | + "format": "int64", | ||
| 1832 | + "description": " 父级ID" | ||
| 1833 | + }, | ||
| 1834 | + "name": { | ||
| 1835 | + "type": "string", | ||
| 1836 | + "description": " 菜单名称" | ||
| 1837 | + }, | ||
| 1838 | + "code": { | ||
| 1839 | + "type": "string", | ||
| 1840 | + "description": " 菜单编码" | ||
| 1841 | + }, | ||
| 1842 | + "menuType": { | ||
| 1843 | + "type": "string", | ||
| 1844 | + "description": " 菜单类型 (目录catalog、菜单menu、按钮button)" | ||
| 1845 | + }, | ||
| 1846 | + "icon": { | ||
| 1847 | + "type": "string", | ||
| 1848 | + "description": " 图标" | ||
| 1849 | + }, | ||
| 1850 | + "sort": { | ||
| 1851 | + "type": "integer", | ||
| 1852 | + "format": "int64", | ||
| 1853 | + "description": " 排序" | ||
| 1854 | + } | ||
| 1855 | + }, | ||
| 1856 | + "title": "Menu", | ||
| 1857 | + "required": [ | ||
| 1858 | + "id", | ||
| 1859 | + "parentId", | ||
| 1860 | + "name", | ||
| 1861 | + "code", | ||
| 1862 | + "menuType", | ||
| 1863 | + "icon", | ||
| 1864 | + "sort" | ||
| 1865 | + ] | ||
| 1866 | + }, | ||
| 1867 | + "MenuListRequest": { | ||
| 1868 | + "type": "object", | ||
| 1869 | + "title": "MenuListRequest" | ||
| 1870 | + }, | ||
| 1871 | + "MenuListResponse": { | ||
| 1872 | + "type": "object", | ||
| 1873 | + "properties": { | ||
| 1874 | + "list": { | ||
| 1875 | + "type": "array", | ||
| 1876 | + "items": { | ||
| 1877 | + "$ref": "#/definitions/Menu" | ||
| 1878 | + } | ||
| 1879 | + } | ||
| 1880 | + }, | ||
| 1881 | + "title": "MenuListResponse", | ||
| 1882 | + "required": [ | ||
| 1883 | + "list" | ||
| 1884 | + ] | ||
| 1885 | + }, | ||
| 1886 | + "ResetPasswordRequest": { | ||
| 1887 | + "type": "object", | ||
| 1888 | + "properties": { | ||
| 1889 | + "code": { | ||
| 1890 | + "type": "string", | ||
| 1891 | + "description": " 验证码" | ||
| 1892 | + }, | ||
| 1893 | + "newPassword": { | ||
| 1894 | + "type": "string", | ||
| 1895 | + "description": " 新密码" | ||
| 1896 | + }, | ||
| 1897 | + "confirmPassword": { | ||
| 1898 | + "type": "string", | ||
| 1899 | + "description": " 确认密码" | ||
| 1900 | + } | ||
| 1901 | + }, | ||
| 1902 | + "title": "ResetPasswordRequest", | ||
| 1903 | + "required": [ | ||
| 1904 | + "code", | ||
| 1905 | + "newPassword", | ||
| 1906 | + "confirmPassword" | ||
| 1907 | + ] | ||
| 1908 | + }, | ||
| 1909 | + "ResetPasswordResponse": { | ||
| 1910 | + "type": "object", | ||
| 1911 | + "title": "ResetPasswordResponse" | ||
| 1912 | + }, | ||
| 1466 | "Role": { | 1913 | "Role": { |
| 1467 | "type": "object", | 1914 | "type": "object", |
| 1468 | "properties": { | 1915 | "properties": { |
| @@ -1474,12 +1921,179 @@ | @@ -1474,12 +1921,179 @@ | ||
| 1474 | "name": { | 1921 | "name": { |
| 1475 | "type": "string", | 1922 | "type": "string", |
| 1476 | "description": " 角色名称" | 1923 | "description": " 角色名称" |
| 1924 | + }, | ||
| 1925 | + "menus": { | ||
| 1926 | + "type": "array", | ||
| 1927 | + "items": { | ||
| 1928 | + "$ref": "#/definitions/Menu" | ||
| 1929 | + }, | ||
| 1930 | + "description": " 菜单列表" | ||
| 1931 | + }, | ||
| 1932 | + "users": { | ||
| 1933 | + "type": "array", | ||
| 1934 | + "items": { | ||
| 1935 | + "$ref": "#/definitions/User" | ||
| 1936 | + }, | ||
| 1937 | + "description": " 拥护该角色的用户列表 user_id 列表" | ||
| 1938 | + }, | ||
| 1939 | + "authRange": { | ||
| 1940 | + "type": "integer", | ||
| 1941 | + "format": "int32", | ||
| 1942 | + "description": " 权限范围(1:全部权限 2:部分权限)" | ||
| 1943 | + }, | ||
| 1944 | + "updatedAt": { | ||
| 1945 | + "type": "integer", | ||
| 1946 | + "format": "int64", | ||
| 1947 | + "description": " 更新时间" | ||
| 1477 | } | 1948 | } |
| 1478 | }, | 1949 | }, |
| 1479 | "title": "Role", | 1950 | "title": "Role", |
| 1480 | "required": [ | 1951 | "required": [ |
| 1481 | "id", | 1952 | "id", |
| 1482 | - "name" | 1953 | + "name", |
| 1954 | + "menus", | ||
| 1955 | + "users", | ||
| 1956 | + "authRange", | ||
| 1957 | + "updatedAt" | ||
| 1958 | + ] | ||
| 1959 | + }, | ||
| 1960 | + "RoleDeleteRequest": { | ||
| 1961 | + "type": "object", | ||
| 1962 | + "properties": { | ||
| 1963 | + "id": { | ||
| 1964 | + "type": "integer", | ||
| 1965 | + "format": "int64" | ||
| 1966 | + } | ||
| 1967 | + }, | ||
| 1968 | + "title": "RoleDeleteRequest", | ||
| 1969 | + "required": [ | ||
| 1970 | + "id" | ||
| 1971 | + ] | ||
| 1972 | + }, | ||
| 1973 | + "RoleDeleteResponse": { | ||
| 1974 | + "type": "object", | ||
| 1975 | + "title": "RoleDeleteResponse" | ||
| 1976 | + }, | ||
| 1977 | + "RoleGetRequest": { | ||
| 1978 | + "type": "object", | ||
| 1979 | + "properties": { | ||
| 1980 | + "id": { | ||
| 1981 | + "type": "integer", | ||
| 1982 | + "format": "int64" | ||
| 1983 | + } | ||
| 1984 | + }, | ||
| 1985 | + "title": "RoleGetRequest", | ||
| 1986 | + "required": [ | ||
| 1987 | + "id" | ||
| 1988 | + ] | ||
| 1989 | + }, | ||
| 1990 | + "RoleGetResponse": { | ||
| 1991 | + "type": "object", | ||
| 1992 | + "properties": { | ||
| 1993 | + "role": { | ||
| 1994 | + "$ref": "#/definitions/Role" | ||
| 1995 | + } | ||
| 1996 | + }, | ||
| 1997 | + "title": "RoleGetResponse", | ||
| 1998 | + "required": [ | ||
| 1999 | + "role" | ||
| 2000 | + ] | ||
| 2001 | + }, | ||
| 2002 | + "RoleSaveRequest": { | ||
| 2003 | + "type": "object", | ||
| 2004 | + "properties": { | ||
| 2005 | + "role": { | ||
| 2006 | + "$ref": "#/definitions/Role" | ||
| 2007 | + } | ||
| 2008 | + }, | ||
| 2009 | + "title": "RoleSaveRequest", | ||
| 2010 | + "required": [ | ||
| 2011 | + "role" | ||
| 2012 | + ] | ||
| 2013 | + }, | ||
| 2014 | + "RoleSaveResponse": { | ||
| 2015 | + "type": "object", | ||
| 2016 | + "title": "RoleSaveResponse" | ||
| 2017 | + }, | ||
| 2018 | + "RoleSearchRequest": { | ||
| 2019 | + "type": "object", | ||
| 2020 | + "properties": { | ||
| 2021 | + "page": { | ||
| 2022 | + "type": "integer", | ||
| 2023 | + "format": "int32" | ||
| 2024 | + }, | ||
| 2025 | + "size": { | ||
| 2026 | + "type": "integer", | ||
| 2027 | + "format": "int32" | ||
| 2028 | + }, | ||
| 2029 | + "rolename": { | ||
| 2030 | + "type": "string", | ||
| 2031 | + "description": " 角色名称" | ||
| 2032 | + }, | ||
| 2033 | + "userName": { | ||
| 2034 | + "type": "string", | ||
| 2035 | + "description": " 用户名称" | ||
| 2036 | + } | ||
| 2037 | + }, | ||
| 2038 | + "title": "RoleSearchRequest", | ||
| 2039 | + "required": [ | ||
| 2040 | + "page", | ||
| 2041 | + "size" | ||
| 2042 | + ] | ||
| 2043 | + }, | ||
| 2044 | + "RoleSearchResponse": { | ||
| 2045 | + "type": "object", | ||
| 2046 | + "properties": { | ||
| 2047 | + "list": { | ||
| 2048 | + "type": "array", | ||
| 2049 | + "items": { | ||
| 2050 | + "$ref": "#/definitions/Role" | ||
| 2051 | + } | ||
| 2052 | + }, | ||
| 2053 | + "total": { | ||
| 2054 | + "type": "integer", | ||
| 2055 | + "format": "int64" | ||
| 2056 | + } | ||
| 2057 | + }, | ||
| 2058 | + "title": "RoleSearchResponse", | ||
| 2059 | + "required": [ | ||
| 2060 | + "list", | ||
| 2061 | + "total" | ||
| 2062 | + ] | ||
| 2063 | + }, | ||
| 2064 | + "RoleUpdateRequest": { | ||
| 2065 | + "type": "object", | ||
| 2066 | + "properties": { | ||
| 2067 | + "id": { | ||
| 2068 | + "type": "integer", | ||
| 2069 | + "format": "int64" | ||
| 2070 | + }, | ||
| 2071 | + "role": { | ||
| 2072 | + "$ref": "#/definitions/Role" | ||
| 2073 | + } | ||
| 2074 | + }, | ||
| 2075 | + "title": "RoleUpdateRequest", | ||
| 2076 | + "required": [ | ||
| 2077 | + "id", | ||
| 2078 | + "role" | ||
| 2079 | + ] | ||
| 2080 | + }, | ||
| 2081 | + "RoleUpdateResponse": { | ||
| 2082 | + "type": "object", | ||
| 2083 | + "title": "RoleUpdateResponse" | ||
| 2084 | + }, | ||
| 2085 | + "SwitchCompanyRequest": { | ||
| 2086 | + "type": "object", | ||
| 2087 | + "properties": { | ||
| 2088 | + "companyId": { | ||
| 2089 | + "type": "integer", | ||
| 2090 | + "format": "int64", | ||
| 2091 | + "description": " 公司ID" | ||
| 2092 | + } | ||
| 2093 | + }, | ||
| 2094 | + "title": "SwitchCompanyRequest", | ||
| 2095 | + "required": [ | ||
| 2096 | + "companyId" | ||
| 1483 | ] | 2097 | ] |
| 1484 | }, | 2098 | }, |
| 1485 | "SystemAppGetRequest": { | 2099 | "SystemAppGetRequest": { |
| @@ -1714,13 +2328,16 @@ | @@ -1714,13 +2328,16 @@ | ||
| 1714 | "phone": { | 2328 | "phone": { |
| 1715 | "type": "string", | 2329 | "type": "string", |
| 1716 | "description": " 用户手机号" | 2330 | "description": " 用户手机号" |
| 2331 | + }, | ||
| 2332 | + "avatar": { | ||
| 2333 | + "type": "string", | ||
| 2334 | + "description": " 头像" | ||
| 1717 | } | 2335 | } |
| 1718 | }, | 2336 | }, |
| 1719 | "title": "User", | 2337 | "title": "User", |
| 1720 | "required": [ | 2338 | "required": [ |
| 1721 | - "id", | ||
| 1722 | - "name", | ||
| 1723 | - "phone" | 2339 | + "phone", |
| 2340 | + "avatar" | ||
| 1724 | ] | 2341 | ] |
| 1725 | }, | 2342 | }, |
| 1726 | "UserInfoRequest": { | 2343 | "UserInfoRequest": { |
| @@ -1749,6 +2366,10 @@ | @@ -1749,6 +2366,10 @@ | ||
| 1749 | "format": "int64", | 2366 | "format": "int64", |
| 1750 | "description": " 用户ID" | 2367 | "description": " 用户ID" |
| 1751 | }, | 2368 | }, |
| 2369 | + "avatar": { | ||
| 2370 | + "type": "string", | ||
| 2371 | + "description": " 头像" | ||
| 2372 | + }, | ||
| 1752 | "name": { | 2373 | "name": { |
| 1753 | "type": "string", | 2374 | "type": "string", |
| 1754 | "description": " 用户名称" | 2375 | "description": " 用户名称" |
| @@ -1757,30 +2378,29 @@ | @@ -1757,30 +2378,29 @@ | ||
| 1757 | "type": "string", | 2378 | "type": "string", |
| 1758 | "description": " 用户手机号" | 2379 | "description": " 用户手机号" |
| 1759 | }, | 2380 | }, |
| 1760 | - "employeeInfo": { | ||
| 1761 | - "$ref": "#/definitions/Employee", | ||
| 1762 | - "description": " 职员信息" | ||
| 1763 | - }, | ||
| 1764 | - "company": { | ||
| 1765 | - "$ref": "#/definitions/Company", | ||
| 1766 | - "description": " 当前公司信息" | 2381 | + "accounts": { |
| 2382 | + "type": "array", | ||
| 2383 | + "items": { | ||
| 2384 | + "$ref": "#/definitions/AccountInfo" | ||
| 2385 | + }, | ||
| 2386 | + "description": " 账号列表" | ||
| 1767 | }, | 2387 | }, |
| 1768 | - "companies": { | 2388 | + "apps": { |
| 1769 | "type": "array", | 2389 | "type": "array", |
| 1770 | "items": { | 2390 | "items": { |
| 1771 | - "$ref": "#/definitions/Company" | 2391 | + "$ref": "#/definitions/SystemAppItem" |
| 1772 | }, | 2392 | }, |
| 1773 | - "description": " 拥有的公司" | 2393 | + "description": " 应用列表" |
| 1774 | } | 2394 | } |
| 1775 | }, | 2395 | }, |
| 1776 | "title": "UserInfoResponse", | 2396 | "title": "UserInfoResponse", |
| 1777 | "required": [ | 2397 | "required": [ |
| 1778 | "id", | 2398 | "id", |
| 2399 | + "avatar", | ||
| 1779 | "name", | 2400 | "name", |
| 1780 | "phone", | 2401 | "phone", |
| 1781 | - "employeeInfo", | ||
| 1782 | - "company", | ||
| 1783 | - "companies" | 2402 | + "accounts", |
| 2403 | + "apps" | ||
| 1784 | ] | 2404 | ] |
| 1785 | } | 2405 | } |
| 1786 | }, | 2406 | }, |
| @@ -8,20 +8,21 @@ import ( | @@ -8,20 +8,21 @@ import ( | ||
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | type SysCompanyApp struct { | 10 | type SysCompanyApp struct { |
| 11 | - Id int64 // 唯一标识 | ||
| 12 | - CompanyId int64 // 公司表ID | ||
| 13 | - AppId int64 // 应用ID | ||
| 14 | - Status int // 1:启用、2:停用 | ||
| 15 | - VisibleFlag int // 1:全员可见 2:部分可见 | ||
| 16 | - VisibleUsers []int64 `gorm:"type:jsonb;serializer:json"` // 可见的用户 所有用户:空 部分用户:用户ID列表 | ||
| 17 | - VisibleGroups []int64 `gorm:"type:jsonb;serializer:json"` // 可见的用户组 所有用户:空 部分用户:用户ID列表 | ||
| 18 | - AppConfig domain.AppConfig `gorm:"type:jsonb;serializer:json"` // 应用配置 | ||
| 19 | - Sort int // 排序 | ||
| 20 | - CreatedAt int64 | ||
| 21 | - UpdatedAt int64 | ||
| 22 | - DeletedAt int64 | ||
| 23 | - Version int | ||
| 24 | - IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` | 11 | + Id int64 // 唯一标识 |
| 12 | + CompanyId int64 // 公司表ID | ||
| 13 | + AppId int64 // 应用ID | ||
| 14 | + Status int // 1:启用、2:停用 | ||
| 15 | + VisibleFlag int // 1:全员可见 2:部分可见 | ||
| 16 | + VisibleUsers []int64 `gorm:"type:jsonb;serializer:json"` // 可见的用户 所有用户:空 部分用户:用户ID列表 | ||
| 17 | + VisibleGroups []int64 `gorm:"type:jsonb;serializer:json"` // 可见的用户组 所有用户:空 部分用户:用户ID列表 | ||
| 18 | + VisibleDepartments []int64 `gorm:"type:jsonb;serializer:json"` // 可见的部门 部门ID列表 | ||
| 19 | + AppConfig domain.AppConfig `gorm:"type:jsonb;serializer:json"` // 应用配置 | ||
| 20 | + Sort int // 排序 | ||
| 21 | + CreatedAt int64 | ||
| 22 | + UpdatedAt int64 | ||
| 23 | + DeletedAt int64 | ||
| 24 | + Version int | ||
| 25 | + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` | ||
| 25 | } | 26 | } |
| 26 | 27 | ||
| 27 | func (m *SysCompanyApp) TableName() string { | 28 | func (m *SysCompanyApp) TableName() string { |
| @@ -13,6 +13,7 @@ type SysRole struct { | @@ -13,6 +13,7 @@ type SysRole struct { | ||
| 13 | Name string // 公司名称 | 13 | Name string // 公司名称 |
| 14 | Menus []int64 `gorm:"type:jsonb;serializer:json"` // 菜单列表 | 14 | Menus []int64 `gorm:"type:jsonb;serializer:json"` // 菜单列表 |
| 15 | AuthUsers []int64 `gorm:"type:jsonb;serializer:json"` // 拥护该角色的用户列表 | 15 | AuthUsers []int64 `gorm:"type:jsonb;serializer:json"` // 拥护该角色的用户列表 |
| 16 | + AuthRange int | ||
| 16 | CreatedAt int64 | 17 | CreatedAt int64 |
| 17 | UpdatedAt int64 | 18 | UpdatedAt int64 |
| 18 | DeletedAt int64 | 19 | DeletedAt int64 |
| @@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "fmt" | ||
| 5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
| 6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
| 7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
| @@ -169,7 +170,7 @@ func (repository *SysRoleRepository) FindByEmployee(ctx context.Context, conn tr | @@ -169,7 +170,7 @@ func (repository *SysRoleRepository) FindByEmployee(ctx context.Context, conn tr | ||
| 169 | total int64 | 170 | total int64 |
| 170 | ) | 171 | ) |
| 171 | queryFunc := func() (interface{}, error) { | 172 | queryFunc := func() (interface{}, error) { |
| 172 | - tx = tx.Model(&ms).Where("company_id = ?", companyId).Where("auth_users @> '[?]'", userId).Order("id desc") | 173 | + tx = tx.Model(&ms).Where("company_id = ?", companyId).Where(fmt.Sprintf("auth_users @> '[%d]'", userId)).Order("id desc") |
| 173 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | 174 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { |
| 174 | return dms, tx.Error | 175 | return dms, tx.Error |
| 175 | } | 176 | } |
| @@ -6,19 +6,20 @@ import ( | @@ -6,19 +6,20 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type SysCompanyApp struct { | 8 | type SysCompanyApp struct { |
| 9 | - Id int64 // 唯一标识 | ||
| 10 | - CompanyId int64 `json:",omitempty"` // 公司表ID | ||
| 11 | - AppId int64 `json:",omitempty"` // 应用ID | ||
| 12 | - Status int `json:",omitempty"` // 1:启用、2:停用 | ||
| 13 | - VisibleFlag int `json:",omitempty"` // 1:全员可见 2:部分可见 | ||
| 14 | - VisibleUsers []int64 `json:",omitempty"` // 可见的用户 所有用户:空 部分用户:用户ID列表 | ||
| 15 | - VisibleGroups []int64 `json:",omitempty"` // 可见的用户组 所有用户:空 部分用户:用户ID列表 | ||
| 16 | - AppConfig AppConfig `json:",omitempty"` // 应用配置 | ||
| 17 | - Sort int `json:",omitempty"` // 排序 | ||
| 18 | - CreatedAt int64 `json:",omitempty"` | ||
| 19 | - UpdatedAt int64 `json:",omitempty"` | ||
| 20 | - DeletedAt int64 `json:",omitempty"` | ||
| 21 | - Version int `json:",omitempty"` | 9 | + Id int64 // 唯一标识 |
| 10 | + CompanyId int64 `json:",omitempty"` // 公司表ID | ||
| 11 | + AppId int64 `json:",omitempty"` // 应用ID | ||
| 12 | + Status int `json:",omitempty"` // 1:启用、2:停用 | ||
| 13 | + VisibleFlag int `json:",omitempty"` // 1:全员可见 2:部分可见 | ||
| 14 | + VisibleUsers []int64 `json:",omitempty"` // 可见的用户 所有用户:空 部分用户:用户ID列表 | ||
| 15 | + VisibleDepartments []int64 `json:",omitempty"` // 可见的部门 部门ID列表 | ||
| 16 | + VisibleGroups []int64 `json:",omitempty"` // 可见的用户组 所有用户:空 部分用户:用户ID列表 | ||
| 17 | + AppConfig AppConfig `json:",omitempty"` // 应用配置 | ||
| 18 | + Sort int `json:",omitempty"` // 排序 | ||
| 19 | + CreatedAt int64 `json:",omitempty"` | ||
| 20 | + UpdatedAt int64 `json:",omitempty"` | ||
| 21 | + DeletedAt int64 `json:",omitempty"` | ||
| 22 | + Version int `json:",omitempty"` | ||
| 22 | } | 23 | } |
| 23 | 24 | ||
| 24 | type SysCompanyAppRepository interface { | 25 | type SysCompanyAppRepository interface { |
| @@ -9,9 +9,10 @@ import ( | @@ -9,9 +9,10 @@ import ( | ||
| 9 | type SysRole struct { | 9 | type SysRole struct { |
| 10 | Id int64 `json:",omitempty"` // 唯一标识 | 10 | Id int64 `json:",omitempty"` // 唯一标识 |
| 11 | CompanyId int64 `json:"companyId"` // 公司ID | 11 | CompanyId int64 `json:"companyId"` // 公司ID |
| 12 | - Name string `json:",omitempty"` // 公司名称 | 12 | + Name string `json:",omitempty"` // 角色名称 |
| 13 | Menus []int64 `json:",omitempty"` // 菜单列表 | 13 | Menus []int64 `json:",omitempty"` // 菜单列表 |
| 14 | AuthUsers []int64 `json:",omitempty"` // 拥护该角色的用户列表 | 14 | AuthUsers []int64 `json:",omitempty"` // 拥护该角色的用户列表 |
| 15 | + AuthRange int `json:",omitempty"` // 权限范围(1:全部权限 2:部分权限) | ||
| 15 | CreatedAt int64 `json:",omitempty"` | 16 | CreatedAt int64 `json:",omitempty"` |
| 16 | UpdatedAt int64 `json:",omitempty"` | 17 | UpdatedAt int64 `json:",omitempty"` |
| 17 | DeletedAt int64 `json:",omitempty"` | 18 | DeletedAt int64 `json:",omitempty"` |
| @@ -58,24 +59,39 @@ type SysMenu struct { | @@ -58,24 +59,39 @@ type SysMenu struct { | ||
| 58 | Version int `json:"version,omitempty"` | 59 | Version int `json:"version,omitempty"` |
| 59 | } | 60 | } |
| 60 | 61 | ||
| 62 | +const ( | ||
| 63 | + AuthRangeAll = 1 // 全部权限 | ||
| 64 | + AuthRangePart = 2 // 部分权限 | ||
| 65 | +) | ||
| 66 | + | ||
| 61 | var DefaultMenus []*SysMenu = []*SysMenu{ | 67 | var DefaultMenus []*SysMenu = []*SysMenu{ |
| 62 | - NewMenu(10, "工作台", "SYSTEM_WORKBENCH", 0, 1), | 68 | + //NewMenu(10, "工作台", "SYSTEM_WORKBENCH", 0, 1), |
| 63 | //NewMenu(40, "通知公告", "SYSTEM_NOTICE", 0, 1), | 69 | //NewMenu(40, "通知公告", "SYSTEM_NOTICE", 0, 1), |
| 64 | //NewMenu(60, "系统日志", "SYSTEM_LOG", 0, 1), | 70 | //NewMenu(60, "系统日志", "SYSTEM_LOG", 0, 1), |
| 65 | 71 | ||
| 66 | NewMenu(20, "组织架构", "SYSTEM_ORGANIZATION", 0, 2), | 72 | NewMenu(20, "组织架构", "SYSTEM_ORGANIZATION", 0, 2), |
| 67 | - NewMenu(21, "成员", "SYSTEM_ORGANIZATION_EMPLOYEE", 20, 1), | ||
| 68 | - NewMenu(22, "部门", "SYSTEM_ORGANIZATION_DEPARTMENT", 20, 2), | ||
| 69 | - NewMenu(22, "用户组", "SYSTEM_ORGANIZATION_GROUP", 20, 3), | 73 | + NewMenu(21, "成员与部门", "SYSTEM_ORGANIZATION_EMPLOYEE-DEPARTMENT", 20, 1), |
| 74 | + //NewMenu(22, "部门", "SYSTEM_ORGANIZATION_DEPARTMENT", 20, 2), | ||
| 75 | + //NewMenu(22, "用户组", "SYSTEM_ORGANIZATION_GROUP", 20, 3), | ||
| 70 | 76 | ||
| 71 | NewMenu(30, "应用管理", "SYSTEM_APP-MANAGER", 0, 3), | 77 | NewMenu(30, "应用管理", "SYSTEM_APP-MANAGER", 0, 3), |
| 72 | - NewMenu(31, "应用中心", "SYSTEM_APP-MANAGER_APP", 30, 1), | 78 | + NewMenu(31, "应用中心", "SYSTEM_APP-MANAGER_APP-CENTER", 30, 1), |
| 79 | + NewMenu(32, "应用配置", "SYSTEM_APP-MANAGER_APP-CENTER_SET", 30, 1).WithMenuTypeButton(), | ||
| 73 | 80 | ||
| 74 | - NewMenu(50, "企业设置", "SYSTEM_COMPANY-SETTING", 0, 5), | 81 | + NewMenu(50, "企业设置", "SYSTEM_COMPANY-SETTING", 0, 4), |
| 75 | NewMenu(51, "企业信息", "SYSTEM_COMPANY-SETTING_INFO", 50, 1), | 82 | NewMenu(51, "企业信息", "SYSTEM_COMPANY-SETTING_INFO", 50, 1), |
| 76 | NewMenu(52, "管理员权限", "SYSTEM_COMPANY-SETTING_ADMIN-AUTH", 50, 2), | 83 | NewMenu(52, "管理员权限", "SYSTEM_COMPANY-SETTING_ADMIN-AUTH", 50, 2), |
| 77 | } | 84 | } |
| 78 | 85 | ||
| 86 | +func FineOneMenu(ctx context.Context, conn transaction.Conn, menuId int64) (*SysMenu, error) { | ||
| 87 | + for _, menu := range DefaultMenus { | ||
| 88 | + if menu.Id == menuId { | ||
| 89 | + return menu, nil | ||
| 90 | + } | ||
| 91 | + } | ||
| 92 | + return nil, ErrNotFound | ||
| 93 | +} | ||
| 94 | + | ||
| 79 | func NewMenu(id int64, name, code string, pid int64, sort int64) *SysMenu { | 95 | func NewMenu(id int64, name, code string, pid int64, sort int64) *SysMenu { |
| 80 | return &SysMenu{ | 96 | return &SysMenu{ |
| 81 | Id: id, | 97 | Id: id, |
| @@ -83,5 +99,11 @@ func NewMenu(id int64, name, code string, pid int64, sort int64) *SysMenu { | @@ -83,5 +99,11 @@ func NewMenu(id int64, name, code string, pid int64, sort int64) *SysMenu { | ||
| 83 | Code: code, | 99 | Code: code, |
| 84 | ParentId: pid, | 100 | ParentId: pid, |
| 85 | Sort: sort, | 101 | Sort: sort, |
| 102 | + MenuType: "menu", | ||
| 86 | } | 103 | } |
| 87 | } | 104 | } |
| 105 | + | ||
| 106 | +func (m *SysMenu) WithMenuTypeButton() *SysMenu { | ||
| 107 | + m.MenuType = "button" | ||
| 108 | + return m | ||
| 109 | +} |
| @@ -31,6 +31,7 @@ type SysUserRepository interface { | @@ -31,6 +31,7 @@ type SysUserRepository interface { | ||
| 31 | FindOneByPhone(ctx context.Context, conn transaction.Conn, phone string) (*SysUser, error) | 31 | FindOneByPhone(ctx context.Context, conn transaction.Conn, phone string) (*SysUser, error) |
| 32 | FindOneUnscoped(ctx context.Context, conn transaction.Conn, id int64) (*SysUser, error) | 32 | FindOneUnscoped(ctx context.Context, conn transaction.Conn, id int64) (*SysUser, error) |
| 33 | Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*SysUser, error) | 33 | Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*SysUser, error) |
| 34 | + //FindByCompany(ctx context.Context, conn transaction.Conn, companyId int64,queryOptions map[string]interface{}) (int64, []*SysUser, error) | ||
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | func NewDomainSysUser(phone string, name string, password string) *SysUser { | 37 | func NewDomainSysUser(phone string, name string, password string) *SysUser { |
-
请 注册 或 登录 后发表评论