更新点赞

This commit is contained in:
wh_zcy 2022-08-10 16:42:36 +08:00
parent fcc53d71c6
commit 646cabda56
8 changed files with 41 additions and 33 deletions

View File

@ -4,7 +4,7 @@ services:
name: 外网 name: 外网
url: ws://119.3.89.14:7891/gateway url: ws://119.3.89.14:7891/gateway
- service: - service:
sid: 2 sid: "dfz"
name: 赵长远 name: 赵长远
url: ws://10.0.0.238:7891/gateway url: ws://10.0.0.238:7891/gateway
- service: - service:
@ -12,6 +12,6 @@ services:
name: 内网 name: 内网
url: ws://10.0.0.9:7891/gateway url: ws://10.0.0.9:7891/gateway
- service: - service:
sid: 4 sid: "dfmxf"
name: service4 name: 梅雄风
url: ws://10.0.0.101:7891/gateway url: ws://10.0.0.85:7891/gateway

View File

@ -20,7 +20,7 @@ type ConfigServiceImpl struct {
} }
type ServiceConf struct { type ServiceConf struct {
SId int32 `yaml:"sid"` SId string `yaml:"sid"`
Name string `yaml:"name"` Name string `yaml:"name"`
Url string `yaml:"url"` Url string `yaml:"url"`
} }
@ -71,7 +71,7 @@ func (c *ConfigServiceImpl) Unmarshal() error {
srvConf := &ServiceConf{} srvConf := &ServiceConf{}
switch kk { switch kk {
case "sid": case "sid":
srvConf.SId = vv[kk].(int32) srvConf.SId = vv[kk].(string)
case "name": case "name":
srvConf.Name = vv[kk].(string) srvConf.Name = vv[kk].(string)
case "url": case "url":

View File

@ -10,6 +10,7 @@ import (
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
"fyne.io/fyne/v2/container" "fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget" "fyne.io/fyne/v2/widget"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -38,8 +39,24 @@ func (this *FriendListView) CreateView(t *model.TestCase) fyne.CanvasObject {
} }
friendListBtn := widget.NewButton("好友列表", friendList) friendListBtn := widget.NewButton("好友列表", friendList)
//点赞
zanBtn := widget.NewButtonWithIcon("点赞", theme.ConfirmIcon(), func() {
if err := service.GetPttService().SendToClient(
t.MainType,
friend.FriendSubTypeZan,
&pb.FriendZanReq{
FriendId: this.selFriendIds[0],
},
); err != nil {
logrus.Error(err)
return
}
this.applyListBtnFun()
})
// layout // layout
split := container.NewHSplit(this.dataList, container.NewVBox(friendListBtn)) split := container.NewHSplit(this.dataList, container.NewVBox(friendListBtn, zanBtn))
split.Offset = 1 split.Offset = 1
//data listener for //data listener for
@ -61,6 +78,7 @@ func (this *FriendListView) dataListener() {
logrus.Error("unmarshal err") logrus.Error("unmarshal err")
} }
this.friendData = model.NewFriendModelList()
for _, v := range rsp.List { for _, v := range rsp.List {
fm := &model.FriendModel{ fm := &model.FriendModel{
Uid: v.UserId, Uid: v.UserId,

View File

@ -23,22 +23,6 @@ func (this *FriendZanView) CreateView(t *model.TestCase) fyne.CanvasObject {
//init required //init required
this.initFriendList() this.initFriendList()
//点赞
zanBtn := widget.NewButtonWithIcon("点赞", theme.ConfirmIcon(), func() {
if err := service.GetPttService().SendToClient(
t.MainType,
t.SubType,
&pb.FriendZanReq{
FriendId: this.selFriendIds[0],
},
); err != nil {
logrus.Error(err)
return
}
this.applyListBtnFun()
})
receiveBtn := widget.NewButtonWithIcon("获赞", theme.ConfirmIcon(), func() { receiveBtn := widget.NewButtonWithIcon("获赞", theme.ConfirmIcon(), func() {
if err := service.GetPttService().SendToClient( if err := service.GetPttService().SendToClient(
@ -59,7 +43,7 @@ func (this *FriendZanView) CreateView(t *model.TestCase) fyne.CanvasObject {
if err := service.GetPttService().SendToClient( if err := service.GetPttService().SendToClient(
string(comm.ModuleFriend), string(comm.ModuleFriend),
friend.FriendSubTypeZanList, friend.FriendSubTypeZanList,
&pb.FriendListReq{}); err != nil { &pb.FriendZanlistReq{}); err != nil {
logrus.Error(err) logrus.Error(err)
} }
this.friendData = model.NewFriendModelList() this.friendData = model.NewFriendModelList()
@ -70,7 +54,7 @@ func (this *FriendZanView) CreateView(t *model.TestCase) fyne.CanvasObject {
this.createList() this.createList()
// layout // layout
split := container.NewHSplit(this.dataList, container.NewVBox(zanListBtn, zanBtn, receiveBtn)) split := container.NewHSplit(this.dataList, container.NewVBox( zanListBtn, receiveBtn))
split.Offset = 1 split.Offset = 1
this.dataListener() this.dataListener()

View File

@ -164,7 +164,7 @@ func (ui *MainWindowImpl) createChooseServerWindow(
d.Hide() d.Hide()
dialog.ShowError(err, parent) dialog.ShowError(err, parent)
} else { } else {
ch <- fmt.Sprintf("%d:%s", s.SId, s.Name) ch <- fmt.Sprintf("%s:%s", s.SId, s.Name)
} }
}) })
return btn return btn
@ -191,7 +191,7 @@ func (ui *MainWindowImpl) createChooseServerWindow(
func (ui *MainWindowImpl) createLoginWin(sid, sname string) { func (ui *MainWindowImpl) createLoginWin(sid, sname string) {
//form //form
account := widget.NewEntry() account := widget.NewEntry()
account.Text = "user8120" //default account account.Text = "user8080" //default account
// account.Validator = validation.NewRegexp(`^(\s*)$`, "account required") // account.Validator = validation.NewRegexp(`^(\s*)$`, "account required")
// password := widget.NewPasswordEntry() // password := widget.NewPasswordEntry()
items := []*widget.FormItem{ items := []*widget.FormItem{
@ -210,7 +210,7 @@ func (ui *MainWindowImpl) createLoginWin(sid, sname string) {
dialog.ShowError(err, ui.w) dialog.ShowError(err, ui.w)
} else { } else {
ui.w.SetTitle(fmt.Sprintf("%s[%d]", sname, sid)) ui.w.SetTitle(fmt.Sprintf("%s[%s]", sname, sid))
ui.connService.ListenerPush() ui.connService.ListenerPush()
//show mainwindow //show mainwindow
// logrus.Debug(rsp) // logrus.Debug(rsp)

View File

@ -272,10 +272,10 @@ var (
Rsp: &pb.FriendSearchResp{}, Rsp: &pb.FriendSearchResp{},
Enabled: true, Enabled: true,
}, },
ff(comm.ModuleFriend, friend.FriendSubTypeZanList):{ ff(comm.ModuleFriend, friend.FriendSubTypeZanList): {
Desc: "点赞好友", Desc: "点赞好友",
MainType: string(comm.ModuleFriend), MainType: string(comm.ModuleFriend),
SubType: friend.FriendSubTypeSearch, SubType: friend.FriendSubTypeZanList,
Enabled: true, Enabled: true,
}, },
} }

View File

@ -11,7 +11,7 @@ import (
// 点赞 // 点赞
func (this *apiComp) ZanCheck(session comm.IUserSession, req *pb.FriendZanReq) (code pb.ErrorCode) { func (this *apiComp) ZanCheck(session comm.IUserSession, req *pb.FriendZanReq) (code pb.ErrorCode) {
if req.FriendId == ""{ if req.FriendId == "" {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
return return
@ -33,6 +33,12 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (code
return return
} }
// 不能给自己点赞
if req.FriendId == self.Uid {
code = pb.ErrorCode_FriendZanSelf
return
}
// 好友是否被点赞 // 好友是否被点赞
if _, ok := utils.Find(self.ZanIds, req.FriendId); ok { if _, ok := utils.Find(self.ZanIds, req.FriendId); ok {
code = pb.ErrorCode_FriendZaned code = pb.ErrorCode_FriendZaned
@ -43,7 +49,7 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (code
self.ZanIds = append(self.ZanIds, req.FriendId) self.ZanIds = append(self.ZanIds, req.FriendId)
if err = this.moduleFriend.modelFriend.Change(req.FriendId, map[string]interface{}{ if err = this.moduleFriend.modelFriend.Change(req.FriendId, map[string]interface{}{
"zanIds": self.ZanIds, "ZanIds": self.ZanIds,
}); err != nil { }); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return