作者 tangxvhui
正在显示 34 个修改的文件 包含 1121 行增加29 行删除
1 import "core/comment.api" 1 import "core/comment.api"
2 import "core/message.api" 2 import "core/message.api"
3 import "core/article_tag.api" 3 import "core/article_tag.api"
  4 +import "core/user.api"
  5 +import "core/company.api"
  1 +syntax = "v1"
  2 +
  3 +info(
  4 + title: "天联鹰蜓"
  5 + desc: "天联鹰蜓"
  6 + author: "email"
  7 + email: "email"
  8 + version: "v1"
  9 +)
  10 +
  11 +// 小程序接口
  12 +@server(
  13 + prefix: v1
  14 + group: company
  15 +)
  16 +service Core {
  17 + @doc "公司搜索"
  18 + @handler miniCompanySearch
  19 + post /mini/company/search(CompanySearchRequest) returns (CompanySearchResponse)
  20 +}
  21 +
  22 +// 小程序接口
  23 +@server(
  24 + prefix: v1
  25 + group: company
  26 + jwt : SystemAuth
  27 +)
  28 +service Core {
  29 + @doc "公司搜索"
  30 + @handler systemCompanySearch
  31 + post /system/company/search(CompanySearchRequest) returns (CompanySearchResponse)
  32 +}
  33 +
  34 +type (
  35 + CompanySearchRequest struct{
  36 + Page int `json:"page"`
  37 + Size int `json:"size"`
  38 + UserId int64 `json:"userId,optional"` // 按用户搜索
  39 + Code string `json:"code,optional"` // 按编码搜索
  40 + }
  41 + CompanySearchResponse{
  42 + List []Company `json:"list"`
  43 + Total int64 `json:"total"`
  44 + }
  45 + Company struct{
  46 + Id int64 `json:"id,omitempty"` // 唯一标识
  47 + Name string `json:"name,omitempty"` // 名称
  48 + Code string `json:"code,omitempty"` // 编码(搜索使用,4位字母数字)
  49 + Logo string `json:"logo,omitempty"` // 公司LOGO
  50 + }
  51 +)
  1 +syntax = "v1"
  2 +
  3 +info(
  4 + title: "天联鹰蜓"
  5 + desc: "天联鹰蜓"
  6 + author: "email"
  7 + email: "email"
  8 + version: "v1"
  9 +)
  10 +
  11 +// 小程序接口
  12 +@server(
  13 + prefix: v1
  14 + group: user
  15 +)
  16 +service Core {
  17 + @doc "用户申请加入公司"
  18 + @handler miniUserApplyJoinCompany
  19 + post /mini/user/apply-join-company(MiniUserApplyJoinCompanyRequest) returns (MiniUserApplyJoinCompanyResponse)
  20 + @doc "用户登录"
  21 + @handler miniUserLogin
  22 + post /mini/user/login (MiniUserLoginRequest) returns (MiniUserLoginResponse)
  23 +}
  24 +@server(
  25 + prefix: v1
  26 + group: user
  27 + jwt: MiniAuth
  28 +)
  29 +service Core {
  30 + @doc "用户信息"
  31 + @handler miniUserInfo
  32 + post /mini/user/info (MiniUserInfoRequest) returns (MiniUserInfoResponse)
  33 + @doc "用户审核列表"
  34 + @handler miniUserAuditList
  35 + post /mini/user/audit-list (UserSearchRequest)returns(UserSearchResponse)
  36 + @doc "用户审核"
  37 + @handler miniUserAudit
  38 + post /mini/user/audit (MiniUserAuditRequest)
  39 + @doc "部门用户列表"
  40 + @handler miniUserDepartmentUsers
  41 + post /mini/user/department-users (MiniUserDepartmentUsersRequest)returns (MiniUserInfoResponse)
  42 + @doc "关注我的人"
  43 + @handler miniUserFollower
  44 + post /mini/user/follower (UserSearchRequest)returns(UserSearchResponse)
  45 + @doc "我关注的人"
  46 + @handler miniUserFollowing
  47 + post /mini/user/following (UserSearchRequest)returns(UserSearchResponse)
  48 + @doc "关注"
  49 + @handler miniUserFollow
  50 + post /mini/user/follow (FollowRequest)
  51 + @doc "取消关注"
  52 + @handler miniUserUnFollow
  53 + post /mini/user/unfollow (FollowRequest)
  54 +}
  55 +
  56 +type(
  57 + MiniUserLoginRequest {
  58 + LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login
  59 + WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码
  60 + WechatEncryptedData string `json:"wechatEncryptedData,optional"` // 微信登录 加密数据
  61 + WechatIV string `json:"wechatIV,optional"` // 微信登录 加密算法初始向量
  62 + Phone string `json:"phone,optional"` // 手机号
  63 + Password string `json:"password,optional"` // 密码
  64 + SmsCode string `json:"smsCode,optional"` // 短信验证码
  65 + }
  66 + MiniUserLoginResponse {
  67 + Token string `json:"token"` // x-token
  68 + Phone string `json:"phone"` // 手机号
  69 + Message string `json:"message"` // 失败消息(审核中,注册成功等待审核)
  70 + Success bool `json:"success"` // 成功标识
  71 + }
  72 +
  73 + MiniUserInfoRequest {
  74 + //MyStatisticsFlag bool `json:"myStatisticsFlag"` // true:返回统计信息 false;统计信息不返回
  75 + }
  76 + MiniUserInfoResponse {
  77 + User *UserItem `json:"user,omitempty"` // 用户信息
  78 + TotalArticle int64 `json:"totalArticle"` // 累计信息发布
  79 + TotalLoved int64 `json:"totalLoved"` // 累计收到的赞
  80 + TotalAccepted int64 `json:"totalAccepted"` // 累计被采纳
  81 + }
  82 + MiniUserApplyJoinCompanyRequest{
  83 + Phone string `json:"phone"`
  84 + Code string `json:"code"`
  85 + }
  86 + MiniUserApplyJoinCompanyResponse{
  87 +
  88 + }
  89 + MiniUserAuditRequest{
  90 + UserId int64 `json:"userId"` // 用户ID
  91 + }
  92 + MiniUserDepartmentUsersRequest{
  93 +
  94 + }
  95 + MiniUserDepartmentUsersResponse{
  96 + Departments []*Department `json:"departments"`
  97 + Users []*UserItem `json:"users"`
  98 + }
  99 + UserItem {
  100 + CompanyId int64 `json:"companyId,omitempty"` // 公司ID
  101 + DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID
  102 + Roles []int64 `json:"roleId,omitempty"` // 角色
  103 + Flag int `json:"flag,omitempty"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员)
  104 + Name string `json:"name,omitempty"` // 名称
  105 + Avatar string `json:"avatar,omitempty"` // 头像
  106 + Phone string `json:"phone,omitempty"` // 手机号 唯一
  107 + Position string `json:"position,omitempty"` // 职位
  108 + Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用
  109 + AuditStatus int `json:"auditStatus,omitempty"` // 审核状态 0:待审核 1:审核通过 2:拒绝
  110 + Follower []int64 `json:"followers,omitempty"` // 关注我的人 (冗余)
  111 + Following []int64 `json:"following,omitempty"` // 我关注的人 (冗余)
  112 + }
  113 + Department struct {
  114 + Id int64 `json:"id,omitempty"` // 部门ID
  115 + CompanyId int64 `json:"companyId,omitempty"` // 公司ID
  116 + ParentId int64 `json:"parentId,omitempty"` // 父级ID
  117 + Name string `json:"name,omitempty"` // 部门名称
  118 + }
  119 + UserSearchRequest{
  120 + Page int `json:"page,optional"`
  121 + Size int `json:"size,optional"`
  122 + AuditFlag *int `json:"auditFlag,optional"` // 按审核状态 0:待审核 1:审核通过 2:拒绝
  123 + }
  124 + UserSearchResponse{
  125 + List []*UserItem `json:"list"`
  126 + Total int64 `json:"total"`
  127 + }
  128 + FollowRequest{
  129 + UserId int64 `json:"userId"`
  130 + }
  131 +)
  132 +
  133 +
  134 +// 后台接口
  135 +//@server(
  136 +// prefix: v1
  137 +// group: user
  138 +// jwt: SystemAuth
  139 +//)
  140 +//service Core {
  141 +// @doc "系统评论"
  142 +// @handler systemUser
  143 +// get /system/user () returns ()
  144 +//}
  1 +package company
  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/company"
  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 MiniCompanySearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.CompanySearchRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := company.NewMiniCompanySearchLogic(r.Context(), svcCtx)
  21 + resp, err := l.MiniCompanySearch(&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 company
  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/company"
  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 SystemCompanySearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.CompanySearchRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := company.NewSystemCompanySearchLogic(r.Context(), svcCtx)
  21 + resp, err := l.SystemCompanySearch(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
@@ -5,7 +5,9 @@ import ( @@ -5,7 +5,9 @@ import (
5 "net/http" 5 "net/http"
6 6
7 comment "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/comment" 7 comment "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/comment"
  8 + company "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/company"
8 message "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/message" 9 message "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/message"
  10 + user "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/user"
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 11 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
10 12
11 "github.com/zeromicro/go-zero/rest" 13 "github.com/zeromicro/go-zero/rest"
@@ -52,4 +54,90 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -52,4 +54,90 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
52 rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), 54 rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
53 rest.WithPrefix("/v1"), 55 rest.WithPrefix("/v1"),
54 ) 56 )
  57 +
  58 + server.AddRoutes(
  59 + []rest.Route{
  60 + {
  61 + Method: http.MethodPost,
  62 + Path: "/mini/user/apply-join-company",
  63 + Handler: user.MiniUserApplyJoinCompanyHandler(serverCtx),
  64 + },
  65 + {
  66 + Method: http.MethodPost,
  67 + Path: "/mini/user/login",
  68 + Handler: user.MiniUserLoginHandler(serverCtx),
  69 + },
  70 + },
  71 + rest.WithPrefix("/v1"),
  72 + )
  73 +
  74 + server.AddRoutes(
  75 + []rest.Route{
  76 + {
  77 + Method: http.MethodPost,
  78 + Path: "/mini/user/info",
  79 + Handler: user.MiniUserInfoHandler(serverCtx),
  80 + },
  81 + {
  82 + Method: http.MethodPost,
  83 + Path: "/mini/user/audit-list",
  84 + Handler: user.MiniUserAuditListHandler(serverCtx),
  85 + },
  86 + {
  87 + Method: http.MethodPost,
  88 + Path: "/mini/user/audit",
  89 + Handler: user.MiniUserAuditHandler(serverCtx),
  90 + },
  91 + {
  92 + Method: http.MethodPost,
  93 + Path: "/mini/user/department-users",
  94 + Handler: user.MiniUserDepartmentUsersHandler(serverCtx),
  95 + },
  96 + {
  97 + Method: http.MethodPost,
  98 + Path: "/mini/user/follower",
  99 + Handler: user.MiniUserFollowerHandler(serverCtx),
  100 + },
  101 + {
  102 + Method: http.MethodPost,
  103 + Path: "/mini/user/following",
  104 + Handler: user.MiniUserFollowingHandler(serverCtx),
  105 + },
  106 + {
  107 + Method: http.MethodPost,
  108 + Path: "/mini/user/follow",
  109 + Handler: user.MiniUserFollowHandler(serverCtx),
  110 + },
  111 + {
  112 + Method: http.MethodPost,
  113 + Path: "/mini/user/unfollow",
  114 + Handler: user.MiniUserUnFollowHandler(serverCtx),
  115 + },
  116 + },
  117 + rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
  118 + rest.WithPrefix("/v1"),
  119 + )
  120 +
  121 + server.AddRoutes(
  122 + []rest.Route{
  123 + {
  124 + Method: http.MethodPost,
  125 + Path: "/mini/company/search",
  126 + Handler: company.MiniCompanySearchHandler(serverCtx),
  127 + },
  128 + },
  129 + rest.WithPrefix("/v1"),
  130 + )
  131 +
  132 + server.AddRoutes(
  133 + []rest.Route{
  134 + {
  135 + Method: http.MethodPost,
  136 + Path: "/system/company/search",
  137 + Handler: company.SystemCompanySearchHandler(serverCtx),
  138 + },
  139 + },
  140 + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
  141 + rest.WithPrefix("/v1"),
  142 + )
55 } 143 }
  1 +package user
  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/user"
  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 MiniUserApplyJoinCompanyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.MiniUserApplyJoinCompanyRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := user.NewMiniUserApplyJoinCompanyLogic(r.Context(), svcCtx)
  21 + resp, err := l.MiniUserApplyJoinCompany(&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 user
  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/user"
  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 MiniUserAuditHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.MiniUserAuditRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := user.NewMiniUserAuditLogic(r.Context(), svcCtx)
  21 + err := l.MiniUserAudit(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.Ok(w)
  26 + }
  27 + }
  28 +}
  1 +package user
  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/user"
  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 MiniUserAuditListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.UserSearchRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := user.NewMiniUserAuditListLogic(r.Context(), svcCtx)
  21 + resp, err := l.MiniUserAuditList(&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 user
  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/user"
  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 MiniUserDepartmentUsersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.MiniUserDepartmentUsersRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := user.NewMiniUserDepartmentUsersLogic(r.Context(), svcCtx)
  21 + resp, err := l.MiniUserDepartmentUsers(&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 user
  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/user"
  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 MiniUserFollowHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.FollowRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := user.NewMiniUserFollowLogic(r.Context(), svcCtx)
  21 + err := l.MiniUserFollow(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.Ok(w)
  26 + }
  27 + }
  28 +}
  1 +package user
  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/user"
  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 MiniUserFollowerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.UserSearchRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := user.NewMiniUserFollowerLogic(r.Context(), svcCtx)
  21 + resp, err := l.MiniUserFollower(&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 user
  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/user"
  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 MiniUserFollowingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.UserSearchRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := user.NewMiniUserFollowingLogic(r.Context(), svcCtx)
  21 + resp, err := l.MiniUserFollowing(&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 user
  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/user"
  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 MiniUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.MiniUserInfoRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := user.NewMiniUserInfoLogic(r.Context(), svcCtx)
  21 + resp, err := l.MiniUserInfo(&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 user
  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/user"
  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 MiniUserLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.MiniUserLoginRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := user.NewMiniUserLoginLogic(r.Context(), svcCtx)
  21 + resp, err := l.MiniUserLogin(&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 user
  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/user"
  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 MiniUserUnFollowHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.FollowRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := user.NewMiniUserUnFollowLogic(r.Context(), svcCtx)
  21 + err := l.MiniUserUnFollow(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.Ok(w)
  26 + }
  27 + }
  28 +}
  1 +package company
  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 MiniCompanySearchLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniCompanySearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniCompanySearchLogic {
  19 + return &MiniCompanySearchLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniCompanySearchLogic) MiniCompanySearch(req *types.CompanySearchRequest) (resp *types.CompanySearchResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
  1 +package company
  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 SystemCompanySearchLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewSystemCompanySearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemCompanySearchLogic {
  19 + return &SystemCompanySearchLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *SystemCompanySearchLogic) SystemCompanySearch(req *types.CompanySearchRequest) (resp *types.CompanySearchResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
  1 +package user
  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 MiniUserApplyJoinCompanyLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniUserApplyJoinCompanyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUserApplyJoinCompanyLogic {
  19 + return &MiniUserApplyJoinCompanyLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniUserApplyJoinCompanyLogic) MiniUserApplyJoinCompany(req *types.MiniUserApplyJoinCompanyRequest) (resp *types.MiniUserApplyJoinCompanyResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
  1 +package user
  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 MiniUserAuditListLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniUserAuditListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUserAuditListLogic {
  19 + return &MiniUserAuditListLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniUserAuditListLogic) MiniUserAuditList(req *types.UserSearchRequest) (resp *types.UserSearchResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
  1 +package user
  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 MiniUserAuditLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniUserAuditLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUserAuditLogic {
  19 + return &MiniUserAuditLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniUserAuditLogic) MiniUserAudit(req *types.MiniUserAuditRequest) error {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return nil
  30 +}
  1 +package user
  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 MiniUserDepartmentUsersLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniUserDepartmentUsersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUserDepartmentUsersLogic {
  19 + return &MiniUserDepartmentUsersLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUserDepartmentUsersRequest) (resp *types.MiniUserInfoResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
  1 +package user
  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 MiniUserFollowLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniUserFollowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUserFollowLogic {
  19 + return &MiniUserFollowLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniUserFollowLogic) MiniUserFollow(req *types.FollowRequest) error {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return nil
  30 +}
  1 +package user
  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 MiniUserFollowerLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniUserFollowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUserFollowerLogic {
  19 + return &MiniUserFollowerLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniUserFollowerLogic) MiniUserFollower(req *types.UserSearchRequest) (resp *types.UserSearchResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
  1 +package user
  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 MiniUserFollowingLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniUserFollowingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUserFollowingLogic {
  19 + return &MiniUserFollowingLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniUserFollowingLogic) MiniUserFollowing(req *types.UserSearchRequest) (resp *types.UserSearchResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
  1 +package user
  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 MiniUserInfoLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUserInfoLogic {
  19 + return &MiniUserInfoLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniUserInfoLogic) MiniUserInfo(req *types.MiniUserInfoRequest) (resp *types.MiniUserInfoResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
  1 +package user
  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 MiniUserLoginLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniUserLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUserLoginLogic {
  19 + return &MiniUserLoginLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniUserLoginLogic) MiniUserLogin(req *types.MiniUserLoginRequest) (resp *types.MiniUserLoginResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
  1 +package user
  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 MiniUserUnFollowLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniUserUnFollowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUserUnFollowLogic {
  19 + return &MiniUserUnFollowLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniUserUnFollowLogic) MiniUserUnFollow(req *types.FollowRequest) error {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return nil
  30 +}
@@ -62,3 +62,106 @@ type User struct { @@ -62,3 +62,106 @@ type User struct {
62 Avatar string `json:"avatar,omitempty"` // 头像 62 Avatar string `json:"avatar,omitempty"` // 头像
63 Position string `json:"position,omitempty"` // 职位 63 Position string `json:"position,omitempty"` // 职位
64 } 64 }
  65 +
  66 +type MiniUserLoginRequest struct {
  67 + LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login
  68 + WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码
  69 + WechatEncryptedData string `json:"wechatEncryptedData,optional"` // 微信登录 加密数据
  70 + WechatIV string `json:"wechatIV,optional"` // 微信登录 加密算法初始向量
  71 + Phone string `json:"phone,optional"` // 手机号
  72 + Password string `json:"password,optional"` // 密码
  73 + SmsCode string `json:"smsCode,optional"` // 短信验证码
  74 +}
  75 +
  76 +type MiniUserLoginResponse struct {
  77 + Token string `json:"token"` // x-token
  78 + Phone string `json:"phone"` // 手机号
  79 + Message string `json:"message"` // 失败消息(审核中,注册成功等待审核)
  80 + Success bool `json:"success"` // 成功标识
  81 +}
  82 +
  83 +type MiniUserInfoRequest struct {
  84 +}
  85 +
  86 +type MiniUserInfoResponse struct {
  87 + User *UserItem `json:"user,omitempty"` // 用户信息
  88 + TotalArticle int64 `json:"totalArticle"` // 累计信息发布
  89 + TotalLoved int64 `json:"totalLoved"` // 累计收到的赞
  90 + TotalAccepted int64 `json:"totalAccepted"` // 累计被采纳
  91 +}
  92 +
  93 +type MiniUserApplyJoinCompanyRequest struct {
  94 + Phone string `json:"phone"`
  95 + Code string `json:"code"`
  96 +}
  97 +
  98 +type MiniUserApplyJoinCompanyResponse struct {
  99 +}
  100 +
  101 +type MiniUserAuditRequest struct {
  102 + UserId int64 `json:"userId"` // 用户ID
  103 +}
  104 +
  105 +type MiniUserDepartmentUsersRequest struct {
  106 +}
  107 +
  108 +type MiniUserDepartmentUsersResponse struct {
  109 + Departments []*Department `json:"departments"`
  110 + Users []*UserItem `json:"users"`
  111 +}
  112 +
  113 +type UserItem struct {
  114 + CompanyId int64 `json:"companyId,omitempty"` // 公司ID
  115 + DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID
  116 + Roles []int64 `json:"roleId,omitempty"` // 角色
  117 + Flag int `json:"flag,omitempty"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员)
  118 + Name string `json:"name,omitempty"` // 名称
  119 + Avatar string `json:"avatar,omitempty"` // 头像
  120 + Phone string `json:"phone,omitempty"` // 手机号 唯一
  121 + Position string `json:"position,omitempty"` // 职位
  122 + Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用
  123 + AuditStatus int `json:"auditStatus,omitempty"` // 审核状态 0:待审核 1:审核通过 2:拒绝
  124 + Follower []int64 `json:"followers,omitempty"` // 关注我的人 (冗余)
  125 + Following []int64 `json:"following,omitempty"` // 我关注的人 (冗余)
  126 +}
  127 +
  128 +type Department struct {
  129 + Id int64 `json:"id,omitempty"` // 部门ID
  130 + CompanyId int64 `json:"companyId,omitempty"` // 公司ID
  131 + ParentId int64 `json:"parentId,omitempty"` // 父级ID
  132 + Name string `json:"name,omitempty"` // 部门名称
  133 +}
  134 +
  135 +type UserSearchRequest struct {
  136 + Page int `json:"page,optional"`
  137 + Size int `json:"size,optional"`
  138 + AuditFlag *int `json:"auditFlag,optional"` // 按审核状态 0:待审核 1:审核通过 2:拒绝
  139 +}
  140 +
  141 +type UserSearchResponse struct {
  142 + List []*UserItem `json:"list"`
  143 + Total int64 `json:"total"`
  144 +}
  145 +
  146 +type FollowRequest struct {
  147 + UserId int64 `json:"userId"`
  148 +}
  149 +
  150 +type CompanySearchRequest struct {
  151 + Page int `json:"page"`
  152 + Size int `json:"size"`
  153 + UserId int64 `json:"userId,optional"` // 按用户搜索
  154 + Code string `json:"code,optional"` // 按编码搜索
  155 +}
  156 +
  157 +type CompanySearchResponse struct {
  158 + List []Company `json:"list"`
  159 + Total int64 `json:"total"`
  160 +}
  161 +
  162 +type Company struct {
  163 + Id int64 `json:"id,omitempty"` // 唯一标识
  164 + Name string `json:"name,omitempty"` // 名称
  165 + Code string `json:"code,omitempty"` // 编码(搜索使用,4位字母数字)
  166 + Logo string `json:"logo,omitempty"` // 公司LOGO
  167 +}
@@ -13,6 +13,10 @@ func Migrate(db *gorm.DB) { @@ -13,6 +13,10 @@ func Migrate(db *gorm.DB) {
13 &models.ArticleDraft{}, 13 &models.ArticleDraft{},
14 &models.ArticleComment{}, 14 &models.ArticleComment{},
15 &models.UserLoveFlag{}, 15 &models.UserLoveFlag{},
  16 + &models.User{},
  17 + &models.Role{},
  18 + &models.Company{},
  19 + &models.UserFollow{},
16 } 20 }
17 21
18 db.AutoMigrate(modelsList...) 22 db.AutoMigrate(modelsList...)
@@ -9,14 +9,14 @@ import ( @@ -9,14 +9,14 @@ import (
9 9
10 type Company struct { 10 type Company struct {
11 Id int64 // 唯一标识 11 Id int64 // 唯一标识
12 - Name string `json:"name,omitempty"` // 名称  
13 - Code string `json:"code,omitempty"` // 编码(搜索使用,4位字母数字)  
14 - Logo string `json:"logo,omitempty"` // 公司LOGO  
15 -  
16 - CreatedAt int64 `json:"createdAt,omitempty"`  
17 - UpdatedAt int64 `json:"updatedAt,omitempty"`  
18 - DeletedAt int64 `json:"deletedAt,omitempty"`  
19 - Version int `json:"version,omitempty"` 12 + Name string // 名称
  13 + Code string // 编码(搜索使用,4位字母数字)
  14 + Logo string // 公司LOGO
  15 +
  16 + CreatedAt int64
  17 + UpdatedAt int64
  18 + DeletedAt int64
  19 + Version int
20 } 20 }
21 21
22 func (m *Company) TableName() string { 22 func (m *Company) TableName() string {
@@ -4,16 +4,18 @@ import ( @@ -4,16 +4,18 @@ import (
4 "fmt" 4 "fmt"
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 "time" 8 "time"
8 ) 9 )
9 10
10 type Role struct { 11 type Role struct {
11 Id int64 // 唯一标识 12 Id int64 // 唯一标识
12 13
13 - CreatedAt int64 `json:"createdAt,omitempty"`  
14 - UpdatedAt int64 `json:"updatedAt,omitempty"`  
15 - DeletedAt int64 `json:"deletedAt,omitempty"`  
16 - Version int `json:"version,omitempty"` 14 + CreatedAt int64
  15 + UpdatedAt int64
  16 + DeletedAt int64
  17 + Version int
  18 + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
17 } 19 }
18 20
19 func (m *Role) TableName() string { 21 func (m *Role) TableName() string {
@@ -4,28 +4,30 @@ import ( @@ -4,28 +4,30 @@ import (
4 "fmt" 4 "fmt"
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 "time" 8 "time"
8 ) 9 )
9 10
10 type User struct { 11 type User struct {
11 Id int64 // 唯一标识 12 Id int64 // 唯一标识
12 - CompanyId int64 `json:"companyId,omitempty"` // 公司ID  
13 - DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID  
14 - Roles []int64 `json:"roleId,omitempty"` // 角色  
15 - Flag int `json:"flag"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员)  
16 - Name string `json:"name,omitempty"` // 名称  
17 - Avatar string `json:"avatar,omitempty"` // 头像  
18 - Phone string `json:"phone,omitempty"` // 手机号 唯一  
19 - Position string `json:"position,omitempty"` // 职位  
20 - Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用  
21 - AuditStatus int `json:"auditStatus,omitempty"` // 审核状态 0:待审核 1:审核通过 2:拒绝  
22 - Follower []int64 `json:"followers,omitempty"` // 关注我的人 (冗余)  
23 - Following []int64 `json:"following,omitempty"` // 我关注的人 (冗余) 13 + CompanyId int64 // 公司ID
  14 + DepartmentId int64 // 部门ID
  15 + Roles []int64 `gorm:"type:jsonb;serializer:json"` // 角色
  16 + Flag int // 标识 1:管理员 2:普通用户 (有绑定角色是管理员)
  17 + Name string // 名称
  18 + Avatar string // 头像
  19 + Phone string // 手机号 唯一
  20 + Position string // 职位
  21 + Enable int // 启用状态 1:启用 2:禁用
  22 + AuditStatus int // 审核状态 0:待审核 1:审核通过 2:拒绝
  23 + Follower []int64 `gorm:"type:jsonb;serializer:json"` // 关注我的人 (冗余)
  24 + Following []int64 `gorm:"type:jsonb;serializer:json"` // 我关注的人 (冗余)
24 25
25 - CreatedAt int64 `json:"createdAt,omitempty"`  
26 - UpdatedAt int64 `json:"updatedAt,omitempty"`  
27 - DeletedAt int64 `json:"deletedAt,omitempty"`  
28 - Version int `json:"version,omitempty"` 26 + CreatedAt int64
  27 + UpdatedAt int64
  28 + DeletedAt int64
  29 + Version int
  30 + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
29 } 31 }
30 32
31 func (m *User) TableName() string { 33 func (m *User) TableName() string {
@@ -10,7 +10,7 @@ type User struct { @@ -10,7 +10,7 @@ type User struct {
10 CompanyId int64 `json:"companyId,omitempty"` // 公司ID 10 CompanyId int64 `json:"companyId,omitempty"` // 公司ID
11 DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID 11 DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID
12 Roles []int64 `json:"roleId,omitempty"` // 角色 12 Roles []int64 `json:"roleId,omitempty"` // 角色
13 - Flag int `json:"flag"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员) 13 + Flag int `json:"flag,omitempty"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员)
14 Name string `json:"name,omitempty"` // 名称 14 Name string `json:"name,omitempty"` // 名称
15 Avatar string `json:"avatar,omitempty"` // 头像 15 Avatar string `json:"avatar,omitempty"` // 头像
16 Phone string `json:"phone,omitempty"` // 手机号 唯一 16 Phone string `json:"phone,omitempty"` // 手机号 唯一