user.api 18.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
syntax = "v1"

info(
    title: "天联鹰蜓"
    desc: "天联鹰蜓"
    author: "email"
    email: "email"
    version: "v1"
)

// 小程序接口
@server(
    prefix: v1
    group: user
)
service Core {
    @doc "用户申请加入公司"
    @handler miniUserApplyJoinCompany
    post /mini/user/apply_join_company(MiniUserApplyJoinCompanyRequest) returns (MiniUserApplyJoinCompanyResponse)
    @doc "用户登录"
    @handler miniUserLogin
    post /mini/user/login (MiniUserLoginRequest) returns (MiniUserLoginResponse)
}
@server(
    prefix: v1
    group: user
    middleware: LogRequest
    jwt: MiniAuth
)
service Core {
    @doc "切换账号"
    @handler miniUserSwitchAccount
    post /mini/user/switch_account (MiniUserSwitchAccountRequest) returns (MiniUserLoginResponse)
    @doc "用户信息"
    @handler miniUserInfo
    post /mini/user/info (MiniUserInfoRequest) returns (MiniUserInfoResponse)
    @doc "编辑用户信息"
    @handler miniEditUserInfo
    post /mini/user/info/edit (MiniEditUserInfoRequest) returns (MiniEditUserInfoResponse)
    @doc "用户统计"
    @handler miniUserStatistics
    post /mini/user/statistics (UserStatisticsRequest) returns (UserStatisticsResponse)
    @doc "用户审核列表"
    @handler miniUserAuditList
    post /mini/user/audit_list (UserSearchRequest)returns(UserSearchResponse)
    @doc "用户审核"
    @handler miniUserAudit
    post /mini/user/audit (MiniUserAuditRequest)
    @doc "部门用户列表"
    @handler miniUserDepartmentUsers
    post /mini/user/department_users (MiniUserDepartmentUsersRequest)
    @doc "用户列表"
    @handler miniUsersList
    post /mini/user/user_list (MiniUsersListRequest)
    @doc "用户快讯"
    @handler miniUserNews
    post /mini/user/news (MiniUserNewsRequest)returns(MiniUserNewsResposne)
    @doc "我关注人发布的信息"
    @handler miniUserMyFollowingNews
    post /mini/user/my_following_news (MiniUserNewsRequest)returns(MiniUserNewsResposne)
    @doc "关注我的人"
    @handler miniUserFollower
    post /mini/user/follower (MiniUserFollowedSearchRequest)returns(MiniUserFollowedSearchResponse)
    @doc "我关注的人"
    @handler miniUserFollowing
    post /mini/user/following (MiniUserFollowedSearchRequest)returns(MiniUserFollowedSearchResponse)
    @doc "我关注的人-最新未读列表(未读标红)"
    @handler miniUserFollowingLatestUnreadList
    post /mini/user/following/latest_unread_list (MiniUserFollowedSearchRequest)returns(MiniUserFollowedSearchResponse)
    @doc "我关注的人-标记已读"
    @handler miniUserFollowingMarkRead
    post /mini/user/following/mark_read (MiniUserFollowingMarkReadRequest)
    @doc "关注"
    @handler miniUserFollow
    post /mini/user/follow (FollowRequest)
    @doc "取消关注"
    @handler miniUserUnFollow
    post /mini/user/unfollow (FollowRequest)
    @doc "我点赞的-文章或评论列表"
    @handler miniMyLike
    post /mini/user/mylike (MiniMyLikeRequest)returns (MiniMyLikeResponse)
    @doc "我被点赞-文章或评论列表"
    @handler miniMyBeLiked
    post /mini/user/mybeliked (MiniBeLikedRequest)returns (MiniBeLikedResponse)
}

type(
    MiniEditUserInfoRequest{
        Avatar *string `json:"avatar"`
    }
    MiniEditUserInfoResponse{

    }
)

type(
    MiniUserLoginRequest {
        LoginType           string `json:"loginType"`                    // 登录类型 wechat-login whchat-phone-login  phone-password-login phone-smscode-login
        WechatAuthCode      string `json:"wechatAuthcode,optional"`      // 微信登录 授权码
        WechatEncryptedData string `json:"wechatEncryptedData,optional"` // 微信登录 加密数据
        WechatIV            string `json:"wechatIV,optional"`            // 微信登录 加密算法初始向量
        Phone               string `json:"phone,optional"`               // 手机号
        Password            string `json:"password,optional"`            // 密码
        SmsCode             string `json:"smsCode,optional"`             // 短信验证码
    }
    MiniUserLoginResponse {
        Token string `json:"token"` // x-token
        Phone string `json:"phone"` // 手机号
        Message string `json:"message"` // 失败消息(审核中,注册成功等待审核)
        Success bool `json:"success"`  //  成功标识
    }
    MiniUserSwitchAccountRequest{
        CompanyId int64 `json:"companyId,string"`
    }

    MiniUserInfoRequest {
        //MyStatisticsFlag bool `json:"myStatisticsFlag"` // true:返回统计信息 false;统计信息不返回
    }
    MiniUserInfoResponse {
        User      *UserItem  `json:"user,omitempty"` // 用户信息
        Accounts  []Account `json:"accounts"`       // 公司账号
        Auths     []Auth `json:"auths"` // 权限列表
    }
    MiniUserApplyJoinCompanyRequest{
        Phone string `json:"phone"` 
        Code  string `json:"code"`
        IsFromQr bool `json:"isFromQr,optional"` // true:扫码添加 false:手动查找添加
    }
    MiniUserApplyJoinCompanyResponse{
        Token string `json:"token"` // x-token
    }
    MiniUserAuditRequest{
        UserId int64 `json:"userId"` // 用户ID
        Status int `json:"status"`   // 审核状态 1:审核通过 2:拒绝
    }
    MiniUserDepartmentUsersRequest{

    }
    MiniUserDepartmentUsersResponse{
        Departments []*Department `json:"departments"`
        Users       []*UserItem       `json:"users"`
    }
    MiniUsersListRequest{
        ArticleId int64 `json:"articleId,optional"`   // 按文章ID(返回文章可见的用户)
        RoleId    int64 `json:"roleId,optional"`      // 按角色角色关联的用户
    }
    MiniUserNewsRequest{
        AuthorId int64 `json:"authorId,optional"`   // 特定作者ID
        LastArticleId int64 `json:"lastArticleId,optional"`// 最后文章ID
        Size int `json:"size"` // 数量
    }
    MiniUserNewsResposne{
        List   []UserNewsItem    `json:"list"`
        LastArticleId int64 `json:"lastArticleId"`// 最后文章ID
    }
    UserNewsItem{
        NewsId int64 `json:"newsId"` // 快讯ID
        Type   string `json:"type"`  // 快讯类型 文章:Article 讨论:Discuss ...
        Title  string `json:"title"` // 标题
        Summary string `json:"summary"` // 快讯概要
        Time   int64 `json:"time"`      // 时间
        ReadFlag bool `json:"readFlag"` // 已读标识 true:已读 false:未读
        Images []string `json:"images"` // 图片列表
        Author UserItem `json:"author"` // 作者
    }
    MiniUserFollowedSearchRequest{
        Page int  `json:"page,optional"`
        Size int  `json:"size,optional"`
        Name string `json:"name,optional"`
    }
    MiniUserFollowedSearchResponse{
        List   []*UserFollowItem    `json:"users"`
        Total  int64          `json:"total"`
    }

    MiniUserFollowingMarkReadRequest{
        UserId int64 `json:"userId"`
    }

    UserItem {
        Id           int64   `json:"id,omitempty"`           // 用户ID
        CompanyId    int64   `json:"companyId,string,omitempty"`    // 公司ID
        CompanyName  string `json:"companyName,omitempty"`   // 公司名称
        CompanyCode  string `json:"companyCode,omitempty"`   // 公司编码(邀请码)
        CompanyLogo  *string `json:"companyLogo,omitempty"`   // 公司LOGO
        //DepartmentId int64   `json:"departmentId,omitempty"` // 部门ID
        //Roles        []int64 `json:"roleId,omitempty"`       // 角色
        Flag         int     `json:"flag,omitempty"`         // 标识 1:管理员 2:普通用户 (有绑定角色是管理员)
        Name         string  `json:"name,omitempty"`         // 名称
        Avatar       *string  `json:"avatar,omitempty"`       // 头像
        Phone        string  `json:"phone,omitempty"`        // 手机号 唯一
        Position     string  `json:"position,omitempty"`     // 职位
        Enable       int     `json:"enable,omitempty"`       // 启用状态 1:启用 2:禁用
        AuditStatus  *int    `json:"auditStatus,omitempty"`  // 审核状态 0:待审核 1:审核通过 2:拒绝
        AuditAt      int64   `json:"auditAt,omitempty"`     // 审核时间
        Follower     []int64 `json:"followers,omitempty"`    // 关注我的人 (冗余)
        Following    []int64 `json:"following,omitempty"`    // 我关注的人 (冗余)
        Departments  []int64 `json:"departments,omitempty"`  // 所属部门
        AccountFrom  string  `json:"accountFrom,omitempty"`  // 账号来源 后台新增、扫码注册
    }
    Account {
        CompanyId    int64   `json:"companyId,string"`    // 公司ID
        CompanyName  string  `json:"companyName"`   // 公司名称
        Logo         string  `json:"logo"`    // 公司图标
        UserId       int64   `json:"userId"`  // 用户ID
        Name         string  `json:"name"`    // 名称
        Position     string  `json:"position"`// 职位
    }
    Department struct {
        Id int64 `json:"id,omitempty"`               // 部门ID
        CompanyId int64 `json:"companyId"`           // 公司ID
        ParentId int64 `json:"parentId"`             // 父级ID
        Name string `json:"name"`                    // 部门名称
        UserIds []int64 `json:"userIds"`             // 部门下的用户
    }
    UserSearchRequest{
        Page int  `json:"page,optional"`
        Size int  `json:"size,optional"`
        AuditFlag *int `json:"auditFlag,optional"` // 按审核状态 0:待审核 1:审核通过 2:拒绝
    }
    UserSearchResponse{
        List []*UserItem `json:"list"`
        Total int64 `json:"total"`
    }
    FollowRequest{
        UserId int64 `json:"userId"`
    }
    UserFollowItem struct {
        Id             int64  `json:"id"`             // 用户ID
        Name           string `json:"name"`           // 名称
        CompanyName    string `json:"companyName"`    // 公司名称
        Avatar         string `json:"avatar"`         // 头像
        Position       string `json:"position"`       // 职位
        Followed       bool   `json:"followed"`       // 关注
        MutualFollowed bool   `json:"mutualFollowed"` // 互相关注标识
        ReadFlag       bool   `json:"readFlag"`         // 已读标识 true:已读 false:未读(小红点)
    }
)



// 1.我点赞的文章或评论  2.我的文章或评论被点赞
type (
    MiniMyLikeRequest{
        Page int  `json:"page"`
        Size int  `json:"size"`
    }

    MiniMyLikeResponse {
        List  []MyLikeItem     `json:"list"`
        Total int64            `json:"total"`
    }

    MyLikeItem {
        UserId              int64                 `json:"userId"`       // 发布人id
        ArticleId           int64                 `json:"articleId"`    // 文章id
        CommentId           int64                 `json:"commentId"`    // 评论id
        CreatedAt           int64                 `json:"createdAt"`    // 创建时间
        User                *SimpleUser           `json:"user"`         // 发布人
        Article             *SimpleArticle        `json:"article"`      // 文章
        Comment             *SimpleComment        `json:"comment"`      // 评论
    }

    SimpleComment {
        Id             int64             `json:"id"`
        Content        string            `json:"content"`        // 评论内容
        Show           int               `json:"show"`           // 评论的展示状态(0显示、1不显示)
        AtWho          []CommentAtWho    `json:"atWho"`          // 填写评论时@的人
        MatchUrl       map[string]string `json:"matchUrl"`       // 评论内容中的url文本
        CountReply     int               `json:"countReply"`     // 用户回复数量
        CountUserLove  int               `json:"countUserLove"`  // 用户点赞数量
    }

    MiniBeLikedRequest{
        Page int  `json:"page"`
        Size int  `json:"size"`
    }

    MiniBeLikedResponse {
        List  []MyBeLikedItem     `json:"list"`
        Total int64            `json:"total"`
    }

    MyBeLikedItem {
        UserId              int64                 `json:"userId"`       // 点赞人id
        ArticleId           int64                 `json:"articleId"`    // 文章id
        CommentId           int64                 `json:"commentId"`    // 评论id
        CreatedAt           int64                 `json:"createdAt"`    // 创建时间
        User                *SimpleUser           `json:"user"`         // 点赞人
        Article             *SimpleArticle        `json:"article"`      // 文章
        Comment             *SimpleComment        `json:"comment"`      // 评论
    }

)


// 后台接口
@server(
    prefix: v1
    group: user
    middleware: LoginStatusCheck,LogRequest
    jwt: SystemAuth
)
service Core {
    @doc "系统用户信息"
    @handler systemUserInfo
    post /system/user/info(SystemUserInfoRequest) returns (SystemUserInfoResponse)
    @doc "用户统计"
    @handler systemUserStatistics
    post /system/user/statistics (UserStatisticsRequest) returns (UserStatisticsResponse)
    @doc "用户列表"
    @handler systemUsersList
    post /system/user/user_list (MiniUsersListRequest)

    @doc "用户详情"
    @handler systemUserGet
    get /system/user/:id (SystemUserGetRequest) returns (SystemUserGetResponse)
    @doc "更新用户"
    @handler systemUserUpdate
    put /system/user/:id (SystemUserUpdateRequest) returns (SystemUserUpdateResponse)
    @doc "搜索用户"
    @handler systemUserSearch
    post /system/user/search (SystemUserSearchRequest) returns (SystemUserSearchResponse)


    @doc "系统账号详情"
    @handler systemUserAccountGet
    get /system/account/:id (SystemUserAccountGetRequest) returns (SystemUserAccountGetResponse)
    @doc "系统新增账号"
    @handler systemUserAccountSave
    post /system/account (SystemUserAccountSaveRequest) returns (SystemUserAccountSaveResponse)
    @doc "系统启用/禁用账号"
    @handler systemUserAccountEnable
    post /system/account/enable (SystemUserAccountEnableRequest) returns (SystemUserAccountEnableResponse)
    @doc "系统更新账号"
    @handler systemUserAccountUpdate
    put /system/account/:id (SystemUserAccountUpdateRequest) returns (SystemUserAccountUpdateResponse)
    @doc "系统搜索账号"
    @handler systemUserAccountSearch
    post /system/account/search (SystemUserAccountSearchRequest) returns (SystemUserAccountSearchResponse)
}

type(
    SystemUserInfoRequest{
        Token string `header:"x-mmm-accesstoken"`
    }
    SystemUserInfoResponse{
        UserId   int64  `json:"userId"`
        UserName string `json:"userName"`
        Avatar   string `json:"avatar"`
        CompanyId   int64  `json:"companyId"`
        CompanyName string `json:"companyName"`
        Code  string `json:"code"`
    }
    UserStatisticsRequest{
        UserId int64 `json:"userId,optional"`
        ItemFlag int `json:"itemFlag"` //0:默认查询所有 1:他的帖子  2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳
    }
    UserStatisticsResponse{
        TotalArticle int `json:"totalArticle"` // 累计发布文章
        TotalComment int `json:"totalComment"` // 累计发布评论
        TotalLoved   int `json:"totalLoved"` // 累计赞别人
        TotalBeLoved int `json:"totalBeLoved"` // 累计收到的赞
    }
    StatisticsItem{
        ItemFlag int `json:"itemFlag"`     // 1:他的帖子  2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳
        Value    float64    `json:"value"` // 统计值
    }

    SystemUserGetRequest {
        Id int64 `path:"id"`
    }
    SystemUserGetResponse struct{
        User SystemUser `json:"user"`
    }
    SystemUser struct{
        Id           int64   `json:"id"`           // 用户ID
        Name         string  `json:"name"`         // 名称
        Avatar       string  `json:"avatar"`       // 头像
        Phone        string  `json:"phone"`        // 手机号 唯一
        Position     string  `json:"position"`     // 职位
        Enable       int     `json:"enable"`       // 启用状态 1:启用 2:禁用
        Departments  []int64 `json:"departments"`  // 所属部门
        AccountFrom  string  `json:"accountFrom"`  // 账号来源 后台新增、扫码注册
        CreatedAt    int64   `json:"createdAt"`    // 注册时间
        Roles        []int64 `json:"roles"`        // 角色
        RolesDesc    string  `json:"rolesDesc"`    // 角色描述
        DepartmentsDesc string `json:"departmentsDesc"` // 部门描述
    }

    SystemUserUpdateRequest struct{
        Id int64 `path:"id"`
        Avatar       string  `json:"avatar,optional"`       // 头像
        Position     string  `json:"position"`     // 职位
        Departments  []int64 `json:"departments"`  // 所属部门
    }
    SystemUserUpdateResponse struct{}

    SystemUserSearchRequest struct{
        Page int  `json:"page"`
        Size int  `json:"size"`
        Name         string  `json:"name,optional"`         // 名称
        Phone        string  `json:"phone,optional"`        // 手机号 唯一
        Position     string  `json:"position,optional"`     // 职位
        Enable       int     `json:"enable,optional"`       // 启用状态 1:启用 2:禁用
        DepartmentId int64   `json:"departmentId,optional"`  // 所属部门
    }
    SystemUserSearchResponse{
        List []SystemUser  `json:"list"`
        Total int64 `json:"total"`
    }

    SystemUserAccountGetRequest {
        Id int64 `path:"id"`
    }
    SystemUserAccountGetResponse struct{
        User SystemUser `json:"user"`
    }

    SystemUserAccountSaveRequest struct{
        Name         string  `json:"name"`         // 名称
        Phone        string  `json:"phone"`        // 手机号 唯一
        Enable       int     `json:"enable"`       // 启用状态 1:启用 2:禁用
        Roles        []int64 `json:"roles"`        // 角色
    }
    SystemUserAccountSaveResponse struct{

    }
    SystemUserAccountEnableRequest struct{
        UserIds []int64 `json:"userIds"` // 用户ID列表
        Status  int `json:"status"`      // 状态 1:启用 2:禁用
    }
    SystemUserAccountEnableResponse struct{

    }
    SystemUserAccountUpdateRequest struct{
        Id int64 `path:"id"`
        Name string `json:"name"`        // 姓名
        Roles  []int64 `json:"roles"`    // 权限角色
        Status  int `json:"enable"`      // 状态 1:启用 2:禁用
    }
    SystemUserAccountUpdateResponse struct{}

    SystemUserAccountSearchRequest struct{
        Page int  `json:"page"`
        Size int  `json:"size"`
        Name         string  `json:"name,optional"`         // 名称
        Phone        string  `json:"phone,optional"`        // 手机号 唯一
        RoleId       int64   `json:"roleId,optional"`       // 角色权限
        Enable       int     `json:"enable,optional"` // 启用状态 1:启用 2:禁用
        BeginTime    int64    `json:"beginTime,optional"`   // 注册日期-开始
        EndTime      int64    `json:"endTime,optional"`     // 注册日期-结束
    }
    SystemUserAccountSearchResponse{
        List []SystemUser  `json:"list"`
        Total int64 `json:"total"`
    }
)