66 "image/png"
77 "strconv"
88
9- "github.com/juggleim/jugglechat-server/apimodels "
9+ "github.com/juggleim/jugglechat-server/apis/models "
1010 "github.com/juggleim/jugglechat-server/errs"
1111 "github.com/juggleim/jugglechat-server/services"
1212 "github.com/juggleim/jugglechat-server/utils"
@@ -17,7 +17,7 @@ import (
1717)
1818
1919func CreateGroup (ctx * gin.Context ) {
20- req := apimodels .Group {}
20+ req := models .Group {}
2121 if err := ctx .BindJSON (& req ); err != nil {
2222 ErrorHttpResp (ctx , errs .IMErrorCode_APP_REQ_BODY_ILLEGAL )
2323 return
@@ -30,7 +30,7 @@ func CreateGroup(ctx *gin.Context) {
3030 }
3131 memberIds = ids
3232 }
33- code , grpInfo := services .CreateGroup (services .ToCtx (ctx ), & apimodels .GroupMembersReq {
33+ code , grpInfo := services .CreateGroup (services .ToCtx (ctx ), & models .GroupMembersReq {
3434 GroupName : req .GroupName ,
3535 GroupPortrait : req .GroupPortrait ,
3636 MemberIds : memberIds ,
@@ -39,20 +39,20 @@ func CreateGroup(ctx *gin.Context) {
3939 ErrorHttpResp (ctx , code )
4040 return
4141 }
42- SuccessHttpResp (ctx , & apimodels .Group {
42+ SuccessHttpResp (ctx , & models .Group {
4343 GroupId : grpInfo .GroupId ,
4444 GroupName : grpInfo .GroupName ,
4545 GroupPortrait : grpInfo .GroupPortrait ,
4646 })
4747}
4848
4949func UpdateGroup (ctx * gin.Context ) {
50- req := apimodels .Group {}
50+ req := models .Group {}
5151 if err := ctx .BindJSON (& req ); err != nil {
5252 ErrorHttpResp (ctx , errs .IMErrorCode_APP_REQ_BODY_ILLEGAL )
5353 return
5454 }
55- code := services .UpdateGroup (services .ToCtx (ctx ), & apimodels .GroupInfo {
55+ code := services .UpdateGroup (services .ToCtx (ctx ), & models .GroupInfo {
5656 GroupId : req .GroupId ,
5757 GroupName : req .GroupName ,
5858 GroupPortrait : req .GroupPortrait ,
@@ -65,7 +65,7 @@ func UpdateGroup(ctx *gin.Context) {
6565}
6666
6767func DissolveGroup (ctx * gin.Context ) {
68- req := apimodels .Group {}
68+ req := models .Group {}
6969 if err := ctx .BindJSON (& req ); err != nil {
7070 ErrorHttpResp (ctx , errs .IMErrorCode_APP_REQ_BODY_ILLEGAL )
7171 return
@@ -79,7 +79,7 @@ func DissolveGroup(ctx *gin.Context) {
7979}
8080
8181func QuitGroup (ctx * gin.Context ) {
82- req := apimodels .Group {}
82+ req := models .Group {}
8383 if err := ctx .BindJSON (& req ); err != nil {
8484 ErrorHttpResp (ctx , errs .IMErrorCode_APP_REQ_BODY_ILLEGAL )
8585 return
@@ -93,7 +93,7 @@ func QuitGroup(ctx *gin.Context) {
9393}
9494
9595func AddGrpMembers (ctx * gin.Context ) {
96- req := apimodels .Group {}
96+ req := models .Group {}
9797 if err := ctx .BindJSON (& req ); err != nil {
9898 ErrorHttpResp (ctx , errs .IMErrorCode_APP_REQ_BODY_ILLEGAL )
9999 return
@@ -102,7 +102,7 @@ func AddGrpMembers(ctx *gin.Context) {
102102 for _ , user := range req .GrpMembers {
103103 memberIds = append (memberIds , user .UserId )
104104 }
105- code := services .AddGrpMembers (services .ToCtx (ctx ), & apimodels .GroupMembersReq {
105+ code := services .AddGrpMembers (services .ToCtx (ctx ), & models .GroupMembersReq {
106106 GroupId : req .GroupId ,
107107 MemberIds : memberIds ,
108108 })
@@ -114,12 +114,12 @@ func AddGrpMembers(ctx *gin.Context) {
114114}
115115
116116func DelGrpMembers (ctx * gin.Context ) {
117- req := apimodels .Group {}
117+ req := models .Group {}
118118 if err := ctx .BindJSON (& req ); err != nil || req .GroupId == "" || len (req .MemberIds ) <= 0 {
119119 ErrorHttpResp (ctx , errs .IMErrorCode_APP_REQ_BODY_ILLEGAL )
120120 return
121121 }
122- code := services .DelGrpMembers (services .ToCtx (ctx ), & apimodels .GroupMembersReq {
122+ code := services .DelGrpMembers (services .ToCtx (ctx ), & models .GroupMembersReq {
123123 GroupId : req .GroupId ,
124124 MemberIds : req .MemberIds ,
125125 })
@@ -157,12 +157,12 @@ func QryMyGroups(ctx *gin.Context) {
157157 ErrorHttpResp (ctx , code )
158158 return
159159 }
160- ret := & apimodels .Groups {
160+ ret := & models .Groups {
161161 Offset : grps .Offset ,
162- Items : []* apimodels .Group {},
162+ Items : []* models .Group {},
163163 }
164164 for _ , grp := range grps .Items {
165- ret .Items = append (ret .Items , & apimodels .Group {
165+ ret .Items = append (ret .Items , & models .Group {
166166 GroupId : grp .GroupId ,
167167 GroupName : grp .GroupName ,
168168 GroupPortrait : grp .GroupPortrait ,
@@ -188,12 +188,12 @@ func QryGrpMembers(ctx *gin.Context) {
188188 ErrorHttpResp (ctx , code )
189189 return
190190 }
191- ret := & apimodels .GroupMembersResp {
192- Items : []* apimodels .GroupMember {},
191+ ret := & models .GroupMembersResp {
192+ Items : []* models .GroupMember {},
193193 }
194194 for _ , member := range members .Items {
195- ret .Items = append (ret .Items , & apimodels .GroupMember {
196- UserObj : apimodels .UserObj {
195+ ret .Items = append (ret .Items , & models .GroupMember {
196+ UserObj : models .UserObj {
197197 UserId : member .UserId ,
198198 Nickname : member .Nickname ,
199199 Avatar : member .Avatar ,
@@ -205,7 +205,7 @@ func QryGrpMembers(ctx *gin.Context) {
205205}
206206
207207func CheckGroupMembers (ctx * gin.Context ) {
208- req := apimodels .CheckGroupMembersReq {}
208+ req := models .CheckGroupMembersReq {}
209209 if err := ctx .BindJSON (& req ); err != nil {
210210 ErrorHttpResp (ctx , errs .IMErrorCode_APP_REQ_BODY_ILLEGAL )
211211 return
@@ -219,7 +219,7 @@ func CheckGroupMembers(ctx *gin.Context) {
219219}
220220
221221func SearchGroupMembers (ctx * gin.Context ) {
222- req := apimodels .SearchGroupMembersReq {}
222+ req := models .SearchGroupMembersReq {}
223223 if err := ctx .BindJSON (& req ); err != nil || req .GroupId == "" || req .Key == "" {
224224 ErrorHttpResp (ctx , errs .IMErrorCode_APP_REQ_BODY_ILLEGAL )
225225 return
@@ -233,12 +233,12 @@ func SearchGroupMembers(ctx *gin.Context) {
233233}
234234
235235func SetGrpAnnouncement (ctx * gin.Context ) {
236- req := apimodels .GroupAnnouncement {}
236+ req := models .GroupAnnouncement {}
237237 if err := ctx .BindJSON (& req ); err != nil {
238238 ErrorHttpResp (ctx , errs .IMErrorCode_APP_REQ_BODY_ILLEGAL )
239239 return
240240 }
241- code := services .SetGrpAnnouncement (services .ToCtx (ctx ), & apimodels .GroupAnnouncement {
241+ code := services .SetGrpAnnouncement (services .ToCtx (ctx ), & models .GroupAnnouncement {
242242 GroupId : req .GroupId ,
243243 Content : req .Content ,
244244 })
@@ -256,14 +256,14 @@ func GetGrpAnnouncement(ctx *gin.Context) {
256256 ErrorHttpResp (ctx , code )
257257 return
258258 }
259- SuccessHttpResp (ctx , & apimodels .GroupAnnouncement {
259+ SuccessHttpResp (ctx , & models .GroupAnnouncement {
260260 GroupId : grpAnnounce .GroupId ,
261261 Content : grpAnnounce .Content ,
262262 })
263263}
264264
265265func SetGrpDisplayName (ctx * gin.Context ) {
266- req := apimodels .SetGroupDisplayNameReq {}
266+ req := models .SetGroupDisplayNameReq {}
267267 if err := ctx .BindJSON (& req ); err != nil {
268268 ErrorHttpResp (ctx , errs .IMErrorCode_APP_REQ_BODY_ILLEGAL )
269269 return
0 commit comments