更新点赞

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

View File

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

View File

@ -10,6 +10,7 @@ import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"github.com/sirupsen/logrus"
)
@ -38,8 +39,24 @@ func (this *FriendListView) CreateView(t *model.TestCase) fyne.CanvasObject {
}
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
split := container.NewHSplit(this.dataList, container.NewVBox(friendListBtn))
split := container.NewHSplit(this.dataList, container.NewVBox(friendListBtn, zanBtn))
split.Offset = 1
//data listener for
@ -61,6 +78,7 @@ func (this *FriendListView) dataListener() {
logrus.Error("unmarshal err")
}
this.friendData = model.NewFriendModelList()
for _, v := range rsp.List {
fm := &model.FriendModel{
Uid: v.UserId,

View File

@ -23,22 +23,6 @@ func (this *FriendZanView) CreateView(t *model.TestCase) fyne.CanvasObject {
//init required
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() {
if err := service.GetPttService().SendToClient(
@ -59,7 +43,7 @@ func (this *FriendZanView) CreateView(t *model.TestCase) fyne.CanvasObject {
if err := service.GetPttService().SendToClient(
string(comm.ModuleFriend),
friend.FriendSubTypeZanList,
&pb.FriendListReq{}); err != nil {
&pb.FriendZanlistReq{}); err != nil {
logrus.Error(err)
}
this.friendData = model.NewFriendModelList()
@ -70,7 +54,7 @@ func (this *FriendZanView) CreateView(t *model.TestCase) fyne.CanvasObject {
this.createList()
// layout
split := container.NewHSplit(this.dataList, container.NewVBox(zanListBtn, zanBtn, receiveBtn))
split := container.NewHSplit(this.dataList, container.NewVBox( zanListBtn, receiveBtn))
split.Offset = 1
this.dataListener()

View File

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

View File

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

View File

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