正在显示
13 个修改的文件
包含
361 行增加
和
9 行删除
| @@ -7,4 +7,5 @@ import "core/article_tag.api" | @@ -7,4 +7,5 @@ import "core/article_tag.api" | ||
| 7 | import "core/user.api" | 7 | import "core/user.api" |
| 8 | import "core/company.api" | 8 | import "core/company.api" |
| 9 | import "core/article.api" | 9 | import "core/article.api" |
| 10 | -import "core/role.api" | ||
| 10 | +import "core/role.api" | ||
| 11 | +import "core/department.api" |
cmd/discuss/api/dsl/core/department.api
0 → 100644
| 1 | +syntax = "v1" | ||
| 2 | + | ||
| 3 | +info( | ||
| 4 | + title: "部门分组" | ||
| 5 | + desc: "部门分组" | ||
| 6 | + author: "zz" | ||
| 7 | + email: "email" | ||
| 8 | + version: "v1" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +@server( | ||
| 12 | + prefix: v1 | ||
| 13 | + group: department | ||
| 14 | + jwt: SystemAuth | ||
| 15 | +) | ||
| 16 | +service Core { | ||
| 17 | + @doc "部门列表" | ||
| 18 | + @handler systemList | ||
| 19 | + post /system/department/list (DepartmentListRequest) returns (DepartmentListResponse) | ||
| 20 | + | ||
| 21 | + @doc "部门-新增" | ||
| 22 | + @handler systemAdd | ||
| 23 | + post /system/department/add (DepartmentAddRequest) returns (DepartmentGetResponse) | ||
| 24 | + | ||
| 25 | + @doc "部门-详情" | ||
| 26 | + @handler systemGet | ||
| 27 | + get /system/department/:id (DepartmentGetRequest) returns (DepartmentGetResponse) | ||
| 28 | + | ||
| 29 | + @doc "部门-更新" | ||
| 30 | + @handler systemUpdate | ||
| 31 | + put /system/department/:id (DepartmentUpdateRequest) returns (DepartmentGetResponse) | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +type ( | ||
| 35 | + DepartmentAddRequest { | ||
| 36 | + Name string `json:"name"` // 分组名称 | ||
| 37 | + Ids []int64 `json:"ids"` // 用户ID | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + DepartmentGetRequest { | ||
| 41 | + Id int64 `path:"id"` | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + DepartmentGetResponse struct{ | ||
| 45 | + Department Department `json:"department"` | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + DepartmentUpdateRequest { | ||
| 49 | + Id int64 `path:"id"` | ||
| 50 | + Name string `json:"name"` | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + DepartmentListRequest { | ||
| 54 | + Page int `json:"page"` | ||
| 55 | + Size int `json:"size"` | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + DepartmentListResponse { | ||
| 59 | + List []Department `json:"list"` | ||
| 60 | + Total int64 `json:"total"` | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | +) |
| 1 | +package department | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/department" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemAddHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.DepartmentAddRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := department.NewSystemAddLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemAdd(&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 department | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/department" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.DepartmentGetRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := department.NewSystemGetLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemGet(&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 department | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/department" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.DepartmentListRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := department.NewSystemListLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemList(&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 department | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/department" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.DepartmentUpdateRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := department.NewSystemUpdateLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemUpdate(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| @@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
| 7 | article "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/article" | 7 | article "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/article" |
| 8 | comment "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/comment" | 8 | comment "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/comment" |
| 9 | company "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/company" | 9 | company "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/company" |
| 10 | + department "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/department" | ||
| 10 | message "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/message" | 11 | message "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/message" |
| 11 | role "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/role" | 12 | role "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/role" |
| 12 | tags "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/tags" | 13 | tags "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/tags" |
| @@ -310,4 +311,31 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -310,4 +311,31 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 310 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 311 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
| 311 | rest.WithPrefix("/v1"), | 312 | rest.WithPrefix("/v1"), |
| 312 | ) | 313 | ) |
| 314 | + | ||
| 315 | + server.AddRoutes( | ||
| 316 | + []rest.Route{ | ||
| 317 | + { | ||
| 318 | + Method: http.MethodPost, | ||
| 319 | + Path: "/system/department/list", | ||
| 320 | + Handler: department.SystemListHandler(serverCtx), | ||
| 321 | + }, | ||
| 322 | + { | ||
| 323 | + Method: http.MethodPost, | ||
| 324 | + Path: "/system/department/add", | ||
| 325 | + Handler: department.SystemAddHandler(serverCtx), | ||
| 326 | + }, | ||
| 327 | + { | ||
| 328 | + Method: http.MethodGet, | ||
| 329 | + Path: "/system/department/:id", | ||
| 330 | + Handler: department.SystemGetHandler(serverCtx), | ||
| 331 | + }, | ||
| 332 | + { | ||
| 333 | + Method: http.MethodPut, | ||
| 334 | + Path: "/system/department/:id", | ||
| 335 | + Handler: department.SystemUpdateHandler(serverCtx), | ||
| 336 | + }, | ||
| 337 | + }, | ||
| 338 | + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | ||
| 339 | + rest.WithPrefix("/v1"), | ||
| 340 | + ) | ||
| 313 | } | 341 | } |
| 1 | +package department | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 8 | + | ||
| 9 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +type SystemAddLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewSystemAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemAddLogic { | ||
| 19 | + return &SystemAddLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *SystemAddLogic) SystemAdd(req *types.DepartmentAddRequest) (resp *types.DepartmentGetResponse, err error) { | ||
| 27 | + // todo: add your logic here and delete this line | ||
| 28 | + | ||
| 29 | + return | ||
| 30 | +} |
| 1 | +package department | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 8 | + | ||
| 9 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +type SystemGetLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewSystemGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemGetLogic { | ||
| 19 | + return &SystemGetLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *SystemGetLogic) SystemGet(req *types.DepartmentGetRequest) (resp *types.DepartmentGetResponse, err error) { | ||
| 27 | + // todo: add your logic here and delete this line | ||
| 28 | + | ||
| 29 | + return | ||
| 30 | +} |
| 1 | +package department | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 8 | + | ||
| 9 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +type SystemListLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewSystemListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemListLogic { | ||
| 19 | + return &SystemListLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *types.DepartmentListResponse, err error) { | ||
| 27 | + // todo: add your logic here and delete this line | ||
| 28 | + | ||
| 29 | + return | ||
| 30 | +} |
| 1 | +package department | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 8 | + | ||
| 9 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +type SystemUpdateLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewSystemUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUpdateLogic { | ||
| 19 | + return &SystemUpdateLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (resp *types.DepartmentGetResponse, err error) { | ||
| 27 | + // todo: add your logic here and delete this line | ||
| 28 | + | ||
| 29 | + return | ||
| 30 | +} |
| @@ -619,3 +619,31 @@ type Auth struct { | @@ -619,3 +619,31 @@ type Auth struct { | ||
| 619 | Name string `json:"name"` // 名称 | 619 | Name string `json:"name"` // 名称 |
| 620 | Code string `json:"code"` // 编码 | 620 | Code string `json:"code"` // 编码 |
| 621 | } | 621 | } |
| 622 | + | ||
| 623 | +type DepartmentAddRequest struct { | ||
| 624 | + Name string `json:"name"` // 分组名称 | ||
| 625 | + Ids []int64 `json:"ids"` // 用户ID | ||
| 626 | +} | ||
| 627 | + | ||
| 628 | +type DepartmentGetRequest struct { | ||
| 629 | + Id int64 `path:"id"` | ||
| 630 | +} | ||
| 631 | + | ||
| 632 | +type DepartmentGetResponse struct { | ||
| 633 | + Department Department `json:"department"` | ||
| 634 | +} | ||
| 635 | + | ||
| 636 | +type DepartmentUpdateRequest struct { | ||
| 637 | + Id int64 `path:"id"` | ||
| 638 | + Name string `json:"name"` | ||
| 639 | +} | ||
| 640 | + | ||
| 641 | +type DepartmentListRequest struct { | ||
| 642 | + Page int `json:"page"` | ||
| 643 | + Size int `json:"size"` | ||
| 644 | +} | ||
| 645 | + | ||
| 646 | +type DepartmentListResponse struct { | ||
| 647 | + List []Department `json:"list"` | ||
| 648 | + Total int64 `json:"total"` | ||
| 649 | +} |
| @@ -5,14 +5,14 @@ import ( | @@ -5,14 +5,14 @@ import ( | ||
| 5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
| 6 | "gorm.io/gorm" | 6 | "gorm.io/gorm" |
| 7 | "gorm.io/plugin/soft_delete" | 7 | "gorm.io/plugin/soft_delete" |
| 8 | + "time" | ||
| 8 | ) | 9 | ) |
| 9 | 10 | ||
| 10 | type Department struct { | 11 | type Department struct { |
| 11 | - Id int64 // 唯一标识 | ||
| 12 | - CompanyId int64 `json:"companyId,omitempty"` // 公司ID | ||
| 13 | - ParentId int64 `json:"parentId,omitempty"` // 父级ID | ||
| 14 | - Name string `json:"name,omitempty"` // 部门名称 | ||
| 15 | - | 12 | + Id int64 // 唯一标识 |
| 13 | + CompanyId int64 `json:"companyId,omitempty"` // 公司ID | ||
| 14 | + ParentId int64 `json:"parentId,omitempty"` // 父级ID | ||
| 15 | + Name string `json:"name,omitempty"` // 部门名称 | ||
| 16 | CreatedAt int64 `json:"createdAt,omitempty"` | 16 | CreatedAt int64 `json:"createdAt,omitempty"` |
| 17 | UpdatedAt int64 `json:"updatedAt,omitempty"` | 17 | UpdatedAt int64 `json:"updatedAt,omitempty"` |
| 18 | DeletedAt int64 `json:"deletedAt,omitempty"` | 18 | DeletedAt int64 `json:"deletedAt,omitempty"` |
| @@ -25,13 +25,13 @@ func (m *Department) TableName() string { | @@ -25,13 +25,13 @@ func (m *Department) TableName() string { | ||
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | func (m *Department) BeforeCreate(tx *gorm.DB) (err error) { | 27 | func (m *Department) BeforeCreate(tx *gorm.DB) (err error) { |
| 28 | - // m.CreatedAt = time.Now().Unix() | ||
| 29 | - // m.UpdatedAt = time.Now().Unix() | 28 | + m.CreatedAt = time.Now().Unix() |
| 29 | + m.UpdatedAt = time.Now().Unix() | ||
| 30 | return | 30 | return |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | func (m *Department) BeforeUpdate(tx *gorm.DB) (err error) { | 33 | func (m *Department) BeforeUpdate(tx *gorm.DB) (err error) { |
| 34 | - // m.UpdatedAt = time.Now().Unix() | 34 | + m.UpdatedAt = time.Now().Unix() |
| 35 | return | 35 | return |
| 36 | } | 36 | } |
| 37 | 37 |
-
请 注册 或 登录 后发表评论