This commit is contained in:
wh_zcy 2022-10-31 15:01:46 +08:00
parent c6c65dc22b
commit 71ab8cd478
63 changed files with 3581 additions and 554 deletions

View File

@ -0,0 +1,57 @@
[
{
"id": 1,
"activity": 1000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 50
}
]
},
{
"id": 2,
"activity": 2000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 60
}
]
},
{
"id": 3,
"activity": 3000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 70
}
]
},
{
"id": 4,
"activity": 4000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 80
}
]
},
{
"id": 5,
"activity": 5000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 100
}
]
}
]

102
bin/json/game_guildlv.json Normal file
View File

@ -0,0 +1,102 @@
[
{
"lv": 1,
"exp": 0,
"member_max": 20
},
{
"lv": 2,
"exp": 1000,
"member_max": 22
},
{
"lv": 3,
"exp": 2000,
"member_max": 24
},
{
"lv": 4,
"exp": 3000,
"member_max": 26
},
{
"lv": 5,
"exp": 4000,
"member_max": 28
},
{
"lv": 6,
"exp": 5000,
"member_max": 30
},
{
"lv": 7,
"exp": 6000,
"member_max": 32
},
{
"lv": 8,
"exp": 7000,
"member_max": 34
},
{
"lv": 9,
"exp": 8000,
"member_max": 36
},
{
"lv": 10,
"exp": 9000,
"member_max": 38
},
{
"lv": 11,
"exp": 10000,
"member_max": 40
},
{
"lv": 12,
"exp": 11000,
"member_max": 42
},
{
"lv": 13,
"exp": 12000,
"member_max": 44
},
{
"lv": 14,
"exp": 13000,
"member_max": 46
},
{
"lv": 15,
"exp": 14000,
"member_max": 48
},
{
"lv": 16,
"exp": 15000,
"member_max": 50
},
{
"lv": 17,
"exp": 16000,
"member_max": 52
},
{
"lv": 18,
"exp": 17000,
"member_max": 54
},
{
"lv": 19,
"exp": 18000,
"member_max": 56
},
{
"lv": 20,
"exp": 19000,
"member_max": 58
}
]

View File

@ -0,0 +1,46 @@
[
{
"id": 1,
"png": "wp_icon_10013"
},
{
"id": 2,
"png": "wp_icon_10014"
},
{
"id": 3,
"png": "wp_icon_10015"
},
{
"id": 4,
"png": "wp_icon_10016"
},
{
"id": 5,
"png": "wp_icon_10017"
},
{
"id": 6,
"png": "wp_icon_10018"
},
{
"id": 7,
"png": "wp_icon_10019"
},
{
"id": 8,
"png": "wp_icon_10020"
},
{
"id": 9,
"png": "wp_icon_10021"
},
{
"id": 10,
"png": "wp_icon_10022"
},
{
"id": 11,
"png": "wp_icon_10023"
}
]

View File

@ -0,0 +1,132 @@
[
{
"id": 1,
"down": 0,
"up": 4,
"SignIn_text": {
"key": "signin1",
"text": "昨日0人签到"
},
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 10
},
{
"a": "attr",
"t": "guildcoin",
"n": 10
}
],
"exp": {
"a": "attr",
"t": "guildexp",
"n": 10
}
},
{
"id": 2,
"down": 5,
"up": 9,
"SignIn_text": {
"key": "signin2",
"text": "昨日5人签到"
},
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 50
},
{
"a": "attr",
"t": "guildcoin",
"n": 50
}
],
"exp": {
"a": "attr",
"t": "guildexp",
"n": 50
}
},
{
"id": 3,
"down": 10,
"up": 14,
"SignIn_text": {
"key": "signin3",
"text": "昨日10人签到"
},
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 100
},
{
"a": "attr",
"t": "guildcoin",
"n": 100
}
],
"exp": {
"a": "attr",
"t": "guildexp",
"n": 100
}
},
{
"id": 4,
"down": 15,
"up": 19,
"SignIn_text": {
"key": "signin4",
"text": "昨日15人签到"
},
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 150
},
{
"a": "attr",
"t": "guildcoin",
"n": 150
}
],
"exp": {
"a": "attr",
"t": "guildexp",
"n": 150
}
},
{
"id": 5,
"down": 20,
"up": 99,
"SignIn_text": {
"key": "signin5",
"text": "昨日20人签到"
},
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 200
},
{
"a": "attr",
"t": "guildcoin",
"n": 200
}
],
"exp": {
"a": "attr",
"t": "guildexp",
"n": 200
}
}
]

View File

@ -0,0 +1,292 @@
[
{
"id": 10001,
"weight": 1000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 50
},
{
"a": "attr",
"t": "guildcoin",
"n": 50
}
],
"sociaty_reward": [
{
"a": "attr",
"t": "guildactive",
"n": 20
},
{
"a": "attr",
"t": "guildexp",
"n": 20
}
],
"contribution": 50
},
{
"id": 10002,
"weight": 1000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 60
},
{
"a": "attr",
"t": "guildcoin",
"n": 50
}
],
"sociaty_reward": [
{
"a": "attr",
"t": "guildactive",
"n": 20
},
{
"a": "attr",
"t": "guildexp",
"n": 20
}
],
"contribution": 50
},
{
"id": 10003,
"weight": 1000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 70
},
{
"a": "attr",
"t": "guildcoin",
"n": 50
}
],
"sociaty_reward": [
{
"a": "attr",
"t": "guildactive",
"n": 20
},
{
"a": "attr",
"t": "guildexp",
"n": 20
}
],
"contribution": 50
},
{
"id": 10004,
"weight": 1000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 80
},
{
"a": "attr",
"t": "guildcoin",
"n": 50
}
],
"sociaty_reward": [
{
"a": "attr",
"t": "guildactive",
"n": 20
},
{
"a": "attr",
"t": "guildexp",
"n": 20
}
],
"contribution": 50
},
{
"id": 10005,
"weight": 1000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 100
},
{
"a": "attr",
"t": "guildcoin",
"n": 50
}
],
"sociaty_reward": [
{
"a": "attr",
"t": "guildactive",
"n": 20
},
{
"a": "attr",
"t": "guildexp",
"n": 20
}
],
"contribution": 50
},
{
"id": 10006,
"weight": 1000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 50
},
{
"a": "attr",
"t": "guildcoin",
"n": 50
}
],
"sociaty_reward": [
{
"a": "attr",
"t": "guildactive",
"n": 20
},
{
"a": "attr",
"t": "guildexp",
"n": 20
}
],
"contribution": 50
},
{
"id": 10007,
"weight": 1000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 60
},
{
"a": "attr",
"t": "guildcoin",
"n": 50
}
],
"sociaty_reward": [
{
"a": "attr",
"t": "guildactive",
"n": 20
},
{
"a": "attr",
"t": "guildexp",
"n": 20
}
],
"contribution": 50
},
{
"id": 10008,
"weight": 1000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 70
},
{
"a": "attr",
"t": "guildcoin",
"n": 50
}
],
"sociaty_reward": [
{
"a": "attr",
"t": "guildactive",
"n": 20
},
{
"a": "attr",
"t": "guildexp",
"n": 20
}
],
"contribution": 50
},
{
"id": 10009,
"weight": 1000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 80
},
{
"a": "attr",
"t": "guildcoin",
"n": 50
}
],
"sociaty_reward": [
{
"a": "attr",
"t": "guildactive",
"n": 20
},
{
"a": "attr",
"t": "guildexp",
"n": 20
}
],
"contribution": 50
},
{
"id": 10010,
"weight": 1000,
"reward": [
{
"a": "attr",
"t": "diamond",
"n": 100
},
{
"a": "attr",
"t": "guildcoin",
"n": 50
}
],
"sociaty_reward": [
{
"a": "attr",
"t": "guildactive",
"n": 20
},
{
"a": "attr",
"t": "guildexp",
"n": 40
}
],
"contribution": 50
}
]

View File

@ -14,7 +14,7 @@
"n": 50 "n": 50
} }
], ],
"sociaty_reword": [ "sociaty_reward": [
{ {
"a": "attr", "a": "attr",
"t": "guildexp", "t": "guildexp",
@ -43,7 +43,7 @@
"n": 50 "n": 50
} }
], ],
"sociaty_reword": [ "sociaty_reward": [
{ {
"a": "attr", "a": "attr",
"t": "guildexp", "t": "guildexp",
@ -72,7 +72,7 @@
"n": 50 "n": 50
} }
], ],
"sociaty_reword": [ "sociaty_reward": [
{ {
"a": "attr", "a": "attr",
"t": "guildexp", "t": "guildexp",
@ -101,7 +101,7 @@
"n": 50 "n": 50
} }
], ],
"sociaty_reword": [ "sociaty_reward": [
{ {
"a": "attr", "a": "attr",
"t": "guildexp", "t": "guildexp",
@ -130,7 +130,7 @@
"n": 50 "n": 50
} }
], ],
"sociaty_reword": [ "sociaty_reward": [
{ {
"a": "attr", "a": "attr",
"t": "guildexp", "t": "guildexp",
@ -159,7 +159,7 @@
"n": 50 "n": 50
} }
], ],
"sociaty_reword": [ "sociaty_reward": [
{ {
"a": "attr", "a": "attr",
"t": "guildexp", "t": "guildexp",
@ -188,7 +188,7 @@
"n": 50 "n": 50
} }
], ],
"sociaty_reword": [ "sociaty_reward": [
{ {
"a": "attr", "a": "attr",
"t": "guildexp", "t": "guildexp",
@ -217,7 +217,7 @@
"n": 50 "n": 50
} }
], ],
"sociaty_reword": [ "sociaty_reward": [
{ {
"a": "attr", "a": "attr",
"t": "guildexp", "t": "guildexp",
@ -246,7 +246,7 @@
"n": 50 "n": 50
} }
], ],
"sociaty_reword": [ "sociaty_reward": [
{ {
"a": "attr", "a": "attr",
"t": "guildexp", "t": "guildexp",
@ -275,7 +275,7 @@
"n": 50 "n": 50
} }
], ],
"sociaty_reword": [ "sociaty_reward": [
{ {
"a": "attr", "a": "attr",
"t": "guildexp", "t": "guildexp",

View File

@ -35,7 +35,9 @@ func NewItemList() *ItemList {
func (f *ItemList) Reset() { func (f *ItemList) Reset() {
f.ItemTotal = 0 f.ItemTotal = 0
f.SelItemIds = []string{} f.SelItemIds = []string{}
f.SelItemId = ""
f.CachedList = NewList("") f.CachedList = NewList("")
f.ItemList.Refresh()
} }
func (f *ItemList) CreateList() *widget.List { func (f *ItemList) CreateList() *widget.List {

View File

@ -19,6 +19,7 @@ import (
type appTester struct { type appTester struct {
appAdapter appAdapter
progress *widget.ProgressBarInfinite
} }
func (a *appTester) GetAppName() string { func (a *appTester) GetAppName() string {
@ -32,6 +33,9 @@ func (a *appTester) disEnabled(t *model.TestCase) bool {
func (a *appTester) LazyInit(service service.PttService, obs observer.Observer) error { func (a *appTester) LazyInit(service service.PttService, obs observer.Observer) error {
a.tabItem = container.NewTabItemWithIcon(common.TOOLBAR_TESTER, theme.DocumentIcon(), nil) a.tabItem = container.NewTabItemWithIcon(common.TOOLBAR_TESTER, theme.DocumentIcon(), nil)
a.progress = widget.NewProgressBarInfinite()
a.progress.Hide()
content := container.NewMax() content := container.NewMax()
title := widget.NewLabel(common.APP_TESTCASE_TITLE) title := widget.NewLabel(common.APP_TESTCASE_TITLE)
intro := widget.NewLabel("") intro := widget.NewLabel("")
@ -40,6 +44,7 @@ func (a *appTester) LazyInit(service service.PttService, obs observer.Observer)
container.NewVBox(title, widget.NewSeparator(), intro), nil, nil, nil, content) container.NewVBox(title, widget.NewSeparator(), intro), nil, nil, nil, content)
setNav := func(t *model.TestCase) { setNav := func(t *model.TestCase) {
defer a.progress.Hide()
viewKey := fmt.Sprintf("%s.%s", t.MainType, t.SubType) viewKey := fmt.Sprintf("%s.%s", t.MainType, t.SubType)
title.SetText(fmt.Sprintf("> %s", viewKey)) title.SetText(fmt.Sprintf("> %s", viewKey))
intro.SetText(t.Desc) intro.SetText(t.Desc)
@ -101,7 +106,7 @@ func (a *appTester) LazyInit(service service.PttService, obs observer.Observer)
} }
split := container.NewHSplit(a.makeNav(setNav), caseContent) split := container.NewHSplit(a.makeNav(setNav), caseContent)
split.Offset = 0.2 split.Offset = 0.2
a.tabItem.Content = split a.tabItem.Content = container.NewBorder(nil, a.progress, nil, nil, split)
return nil return nil
} }
@ -157,8 +162,9 @@ func (a *appTester) makeNav(setNav func(testCase *model.TestCase)) fyne.CanvasOb
if t.SubType == "" { if t.SubType == "" {
return return
} }
a.progress.Start()
setNav(t) a.progress.Show()
go setNav(t)
} }
}, },
} }

View File

@ -113,6 +113,8 @@ var (
ff(comm.ModuleSociaty, sociaty.SociatySubTypeList): &formview.SociatyListView{}, ff(comm.ModuleSociaty, sociaty.SociatySubTypeList): &formview.SociatyListView{},
ff(comm.ModuleSociaty, sociaty.SociatySubTypeCreate): &formview.SociatyCreateView{}, ff(comm.ModuleSociaty, sociaty.SociatySubTypeCreate): &formview.SociatyCreateView{},
ff(comm.ModuleSociaty, sociaty.SociatySubTypeMine): &formview.SociatyMineView{}, ff(comm.ModuleSociaty, sociaty.SociatySubTypeMine): &formview.SociatyMineView{},
ff(comm.ModuleSociaty, sociaty.SociatySubTypeTasklist): &formview.SociatyTasklistView{},
ff(comm.ModuleSociaty, sociaty.SociatySubTypeRank): &formview.SociatyRankView{},
} }
) )
@ -227,6 +229,8 @@ var (
ff(comm.ModuleSociaty, sociaty.SociatySubTypeList), ff(comm.ModuleSociaty, sociaty.SociatySubTypeList),
ff(comm.ModuleSociaty, sociaty.SociatySubTypeCreate), ff(comm.ModuleSociaty, sociaty.SociatySubTypeCreate),
ff(comm.ModuleSociaty, sociaty.SociatySubTypeMine), ff(comm.ModuleSociaty, sociaty.SociatySubTypeMine),
ff(comm.ModuleSociaty, sociaty.SociatySubTypeTasklist),
ff(comm.ModuleSociaty, sociaty.SociatySubTypeRank),
}, },
} }
) )
@ -827,6 +831,9 @@ var (
MainType: string(comm.ModuleSociaty), MainType: string(comm.ModuleSociaty),
SubType: sociaty.SociatySubTypeList, SubType: sociaty.SociatySubTypeList,
Enabled: true, Enabled: true,
Print: func(rsp proto.Message) string {
return "不打印"
},
}, },
ff(comm.ModuleSociaty, sociaty.SociatySubTypeMine): { ff(comm.ModuleSociaty, sociaty.SociatySubTypeMine): {
NavLabel: "我的公会", NavLabel: "我的公会",
@ -835,6 +842,20 @@ var (
SubType: sociaty.SociatySubTypeMine, SubType: sociaty.SociatySubTypeMine,
Enabled: true, Enabled: true,
}, },
ff(comm.ModuleSociaty, sociaty.SociatySubTypeTasklist): {
NavLabel: "任务列表",
Desc: "任务列表",
MainType: string(comm.ModuleSociaty),
SubType: sociaty.SociatySubTypeTasklist,
Enabled: true,
},
ff(comm.ModuleSociaty, sociaty.SociatySubTypeRank): {
NavLabel: "排行榜",
Desc: "排行榜",
MainType: string(comm.ModuleSociaty),
SubType: sociaty.SociatySubTypeRank,
Enabled: true,
},
} }
) )

View File

@ -36,7 +36,7 @@ func (tdt *toyDateTime) Init(obs observer.Observer) error {
), ),
) )
tdt.widget.Resize(fyne.NewSize(ToyWidth, 100)) tdt.widget.Resize(fyne.NewSize(ToyWidth, 150))
// for init // for init
tdt.Run() tdt.Run()

View File

@ -40,11 +40,12 @@ func (this *SociatyCreateView) CreateView(t *model.TestCase) fyne.CanvasObject {
Name: sociatyName.Text, Name: sociatyName.Text,
Icon: icon.Text, Icon: icon.Text,
Notice: notice.Text, Notice: notice.Text,
IsApplyCheck: cast.ToBool(isApplyCheck.Text), IsApplyCheck: isApplyCheck.Checked,
ApplyLv: cast.ToInt32(applyLv.Text), ApplyLv: cast.ToInt32(applyLv.Text),
}); err != nil { }); err != nil {
logrus.Error(err) logrus.Error(err)
} }
} }
this.form.SubmitText = "创建"
return this.form return this.form
} }

View File

@ -30,6 +30,7 @@ func (this *SociatyListView) CreateView(t *model.TestCase) fyne.CanvasObject {
this.itemList.ItemList = this.itemList.CreateList() this.itemList.ItemList = this.itemList.CreateList()
this.sociatyList = func() { this.sociatyList = func() {
this.itemList.Reset()
if err := service.GetPttService().SendToClient( if err := service.GetPttService().SendToClient(
string(comm.ModuleSociaty), string(comm.ModuleSociaty),
sociaty.SociatySubTypeList, sociaty.SociatySubTypeList,
@ -46,6 +47,9 @@ func (this *SociatyListView) CreateView(t *model.TestCase) fyne.CanvasObject {
// 申请 // 申请
applyBtn := widget.NewButton("申请", func() { applyBtn := widget.NewButton("申请", func() {
defer func() {
common.ShowTip("已申请")
}()
selId := this.itemList.SelItemId selId := this.itemList.SelItemId
if selId == "" { if selId == "" {
common.ShowTip("请选择项目") common.ShowTip("请选择项目")
@ -64,15 +68,72 @@ func (this *SociatyListView) CreateView(t *model.TestCase) fyne.CanvasObject {
} }
}) })
//取消申请 //取消申请
cancalApplyBtn := widget.NewButton("取消申请", nil) cancalApplyBtn := widget.NewButton("取消申请", func() {
selId := this.itemList.SelItemId
if selId == "" {
common.ShowTip("请选择项目")
return
}
if err := service.GetPttService().SendToClient(
string(comm.ModuleSociaty),
sociaty.SociatySubTypeApplyCanel,
&pb.SociatyApplyCancelReq{
SociatyId: selId,
}); err != nil {
logrus.Error(err)
}
})
// 设置 // 明细
settingBtn := widget.NewButton("设置", nil) detailBtn := widget.NewButton("明细", nil)
buttonBar := container.NewHBox(refreshBtn, applyBtn, cancalApplyBtn, settingBtn) //过滤
filter := widget.NewSelect([]string{"全部", "满足条件", "无需审批", "申请中"}, func(s string) {
this.itemList.Reset()
var filter pb.SociatyListFilter
if s == "全部" {
filter = pb.SociatyListFilter_ALL
} else if s == "满足条件" {
filter = pb.SociatyListFilter_CONDI
} else if s == "无需审批" {
filter = pb.SociatyListFilter_NOAPPLY
} else if s == "申请中" {
filter = pb.SociatyListFilter_APPLYING
}
if err := service.GetPttService().SendToClient(
string(comm.ModuleSociaty),
sociaty.SociatySubTypeList,
&pb.SociatyListReq{
Filter: filter,
}); err != nil {
logrus.Error(err)
}
})
filter.Selected = "全部"
//搜索
searchEntry := widget.NewEntry()
searchEntry.PlaceHolder = "输入公会名称"
searchBtn := widget.NewButtonWithIcon("", theme.SearchIcon(), func() {
if searchEntry.Text == "" {
common.ShowTip("请输入公会名称")
return
}
this.itemList.Reset()
if err := service.GetPttService().SendToClient(
string(comm.ModuleSociaty),
sociaty.SociatySubTypeSearch,
&pb.SociatySearchReq{
Name: searchEntry.Text,
}); err != nil {
logrus.Error(err)
}
})
buttonBar := container.NewHBox(refreshBtn, applyBtn, cancalApplyBtn, detailBtn, filter)
cBar := container.NewBorder(nil, nil, buttonBar, searchBtn, searchEntry)
// layout // layout
c := container.NewBorder(buttonBar, nil, nil, nil, this.itemList.ItemList) c := container.NewBorder(cBar, nil, nil, nil, this.itemList.ItemList)
//data listener for //data listener for
this.dataListener() this.dataListener()
return c return c
@ -85,10 +146,8 @@ func (this *SociatyListView) dataListener() {
this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{ this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{
OnNotify: func(d interface{}, args ...interface{}) { OnNotify: func(d interface{}, args ...interface{}) {
data := d.(*pb.UserMessage) data := d.(*pb.UserMessage)
if !(data.MainType == string(comm.ModuleSociaty) && if data.MainType == string(comm.ModuleSociaty) &&
data.SubType == sociaty.SociatySubTypeList) { data.SubType == sociaty.SociatySubTypeList {
return
}
rsp := &pb.SociatyListResp{} rsp := &pb.SociatyListResp{}
if !comm.ProtoUnmarshal(data, rsp) { if !comm.ProtoUnmarshal(data, rsp) {
@ -97,12 +156,40 @@ func (this *SociatyListView) dataListener() {
} }
for i, v := range rsp.List { for i, v := range rsp.List {
memberCount := len(v.Members)
var isApplyCheckLbl string
if v.IsApplyCheck {
isApplyCheckLbl = "需要审核"
} else {
isApplyCheckLbl = "无需审核"
}
lbl := fmt.Sprintf("%d - %-15s 等级:%-5d 等级限制:%-5d (%d) %10v", i+1, v.Name, v.Lv, v.ApplyLv, memberCount, isApplyCheckLbl)
item := common.Item{ item := common.Item{
Id: v.Id, Id: v.Id,
Text: fmt.Sprintf("%d - %s lv:%d", i+1, v.Name, v.Lv), Text: lbl,
} }
this.itemList.AddItem(item) this.itemList.AddItem(item)
} }
} else if data.MainType == string(comm.ModuleSociaty) &&
data.SubType == sociaty.SociatySubTypeSearch {
rsp := &pb.SociatySearchResp{}
if !comm.ProtoUnmarshal(data, rsp) {
logrus.Error("unmarshal err")
return
}
for i, v := range rsp.List {
memberCount := len(v.Members)
item := common.Item{
Id: v.Id,
Text: fmt.Sprintf("%d - %s 等级:%d 等级限制:%d %d人", i+1, v.Name, v.Lv, v.ApplyLv, memberCount),
}
this.itemList.AddItem(item)
}
}
}, },
}) })

View File

@ -9,9 +9,11 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/modules/sociaty" "go_dreamfactory/modules/sociaty"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/utils"
"time" "time"
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container" "fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/theme" "fyne.io/fyne/v2/theme"
@ -80,17 +82,65 @@ func (this *SociatyMineView) CreateView(t *model.TestCase) fyne.CanvasObject {
this.sociatyRender(item) this.sociatyRender(item)
this.form.Refresh() this.form.Refresh()
}) })
// 签到
signBtn := widget.NewButton("签到", this.showSignWin)
btns := container.NewHBox(refreshBtn) // 退出
quitBtn := widget.NewButton("退出", func() {
dialog.ShowConfirm("提示", "确定退出公会?", func(b bool) {
if !b {
return
}
if err := service.GetPttService().SendToClient(
t.MainType,
sociaty.SociatySubTypeQuit,
&pb.SociatyQuitReq{},
); err != nil {
logrus.Error(err)
return
}
item = &entryItem{}
}, this.w)
})
btns := container.NewHBox(refreshBtn, signBtn)
//解散公会
jiesanBtn := widget.NewButton("解散", func() {
dialog.ShowConfirm("提示", "确定解散公会?", func(b bool) {
if !b {
return
}
if err := service.GetPttService().SendToClient(
t.MainType,
sociaty.SociatySubTypeDismiss,
&pb.SociatyDismissReq{},
); err != nil {
logrus.Error(err)
return
}
item = &entryItem{}
}, this.w)
})
// 转让 // 转让
zhuanrangBtn := widget.NewButton("转让", nil) zhuanrangBtn := widget.NewButton("转让", nil)
//申请列表 //申请列表
applyListBtn := widget.NewButton("申请审批", this.showSociatyApplyListWin) applyListBtn := widget.NewButton("申请审批", this.showSociatyApplyListWin)
// 任务列表
taskListBtn := widget.NewButton("任务列表", this.showTaskListWin)
defer func() { defer func() {
this.loadSociaty() this.loadSociaty()
time.Sleep(time.Millisecond * 50) //必须要延迟,否则职位获取不到 time.Sleep(time.Millisecond * 30) //必须要延迟,否则职位获取不到
if this.sociaty == nil {
dialog.ShowInformation("提示", "还没有加入任何公会", this.w)
return
}
if this.job == pb.SociatyJob_ADMIN || if this.job == pb.SociatyJob_ADMIN ||
this.job == pb.SociatyJob_VICEPRESIDENT { this.job == pb.SociatyJob_VICEPRESIDENT {
@ -100,15 +150,42 @@ func (this *SociatyMineView) CreateView(t *model.TestCase) fyne.CanvasObject {
if this.job == pb.SociatyJob_PRESIDENT { if this.job == pb.SociatyJob_PRESIDENT {
btns.Add(applyListBtn) btns.Add(applyListBtn)
btns.Add(zhuanrangBtn) btns.Add(zhuanrangBtn)
btns.Add(jiesanBtn)
} else {
btns.Add(quitBtn)
} }
btns.Add(taskListBtn)
this.sociatyRender(item) this.sociatyRender(item)
this.form.Refresh() this.form.Refresh()
}() }()
//成员列表 //成员列表
membersBtn := widget.NewButton("成员", this.showSociatyMemberWin) membersBtn := widget.NewButton("成员列表", this.showSociatyMemberWin)
btns.Add(membersBtn) btns.Add(membersBtn)
// 保存修改
this.form.OnSubmit = func() {
defer func() {
common.ShowTip("公告已更新")
}()
if err := service.GetPttService().SendToClient(
t.MainType,
sociaty.SociatySubTypeSetting,
&pb.SociatySettingReq{
SociatyId: this.sociaty.Id,
Icon: item.icon.Text,
Notice: item.notice.Text,
ApplyLv: cast.ToInt32(item.applyLv.Text),
IsApplyCheck: item.isApplyCheck.Checked,
},
); err != nil {
logrus.Error(err)
return
}
}
this.form.SubmitText = "保存修改"
c := container.NewBorder(btns, nil, nil, nil, this.form) c := container.NewBorder(btns, nil, nil, nil, this.form)
this.dataListener(item) this.dataListener(item)
@ -116,11 +193,18 @@ func (this *SociatyMineView) CreateView(t *model.TestCase) fyne.CanvasObject {
} }
func (this *SociatyMineView) sociatyRender(item *entryItem) { func (this *SociatyMineView) sociatyRender(item *entryItem) {
if this.sociaty == nil {
dialog.ShowInformation("提示", "还没有加入任何公会", this.w)
return
}
if item != nil {
item.sociatyName.Text = this.sociaty.Name item.sociatyName.Text = this.sociaty.Name
item.notice.Text = this.sociaty.Notice item.notice.Text = this.sociaty.Notice
item.icon.Text = this.sociaty.Icon item.icon.Text = this.sociaty.Icon
item.isApplyCheck.Checked = this.sociaty.IsApplyCheck item.isApplyCheck.Checked = this.sociaty.IsApplyCheck
item.applyLv.Text = cast.ToString(this.sociaty.ApplyLv) item.applyLv.Text = cast.ToString(this.sociaty.ApplyLv)
}
} }
func (this *SociatyMineView) dataListener(item *entryItem) { func (this *SociatyMineView) dataListener(item *entryItem) {
@ -177,6 +261,10 @@ func (this *SociatyMineView) showSociatyApplyListWin() {
this.itemList.ItemList = this.itemList.CreateList() this.itemList.ItemList = this.itemList.CreateList()
this.applyListFun = func() { this.applyListFun = func() {
if this.sociaty == nil {
dialog.ShowInformation("提示", "还没有加入任何公会", this.w)
return
}
sociatyId := this.sociaty.Id sociatyId := this.sociaty.Id
if sociatyId == "" { if sociatyId == "" {
common.ShowTip("公会ID空") common.ShowTip("公会ID空")
@ -199,7 +287,7 @@ func (this *SociatyMineView) showSociatyApplyListWin() {
}) })
agreeBtn := widget.NewButton("同意", func() { agreeBtn := widget.NewButton("同意", func() {
defer this.applyListFun() defer this.itemList.Reset()
selId := this.itemList.SelItemId selId := this.itemList.SelItemId
if selId == "" { if selId == "" {
common.ShowTip("请选择项目") common.ShowTip("请选择项目")
@ -215,13 +303,12 @@ func (this *SociatyMineView) showSociatyApplyListWin() {
sociaty.SociatySubTypeAgree, sociaty.SociatySubTypeAgree,
&pb.SociatyAgreeReq{ &pb.SociatyAgreeReq{
Uid: selId, Uid: selId,
SociatyId: sociatyId,
}); err != nil { }); err != nil {
logrus.Error(err) logrus.Error(err)
} }
}) })
refuseBtn := widget.NewButton("拒绝", func() { refuseBtn := widget.NewButton("拒绝", func() {
defer this.applyListFun() defer this.itemList.Reset()
selId := this.itemList.SelItemId selId := this.itemList.SelItemId
if selId == "" { if selId == "" {
common.ShowTip("请选择项目") common.ShowTip("请选择项目")
@ -237,7 +324,6 @@ func (this *SociatyMineView) showSociatyApplyListWin() {
sociaty.SociatySubTypeRefuse, sociaty.SociatySubTypeRefuse,
&pb.SociatyRefuseReq{ &pb.SociatyRefuseReq{
Uid: selId, Uid: selId,
SociatyId: sociatyId,
}); err != nil { }); err != nil {
logrus.Error(err) logrus.Error(err)
} }
@ -295,9 +381,7 @@ func (this *SociatyMineView) showSociatyMemberWin() {
if err := service.GetPttService().SendToClient( if err := service.GetPttService().SendToClient(
string(comm.ModuleSociaty), string(comm.ModuleSociaty),
sociaty.SociatySubTypeMembers, sociaty.SociatySubTypeMembers,
&pb.SociatyMembersReq{ &pb.SociatyMembersReq{}); err != nil {
SociatyId: sociatyId,
}); err != nil {
logrus.Error(err) logrus.Error(err)
} }
} }
@ -362,7 +446,7 @@ func (this *SociatyMineView) memberListen() {
for i, v := range rsp.List { for i, v := range rsp.List {
item := common.Item{ item := common.Item{
Id: v.Uid, Id: v.Uid,
Text: fmt.Sprintf("%d - %s lv:%d", i+1, v.Name, v.Lv), Text: fmt.Sprintf("%d - %s lv:%d %v", i+1, v.Name, v.Lv, v.Job),
} }
this.memberList.AddItem(item) this.memberList.AddItem(item)
} }
@ -370,3 +454,65 @@ func (this *SociatyMineView) memberListen() {
}) })
this.flag3 = true this.flag3 = true
} }
// 签到
func (this *SociatyMineView) showSignWin() {
var lastCount int32
if this.sociaty == nil {
logrus.Error("公会 is nil")
return
}
lastCount = this.sociaty.LastSignCount
card := canvas.NewText(cast.ToString(lastCount), nil)
card.TextSize = 50
btn := widget.NewButton("签到", nil)
btn.OnTapped = func() {
defer btn.Disable()
if err := service.GetPttService().SendToClient(
string(comm.ModuleSociaty),
sociaty.SociatySubTypeSign,
&pb.SociatySignReq{},
); err != nil {
logrus.Error(err)
return
}
}
if _, ok := utils.Findx(this.sociaty.SignIds, this.uid); ok {
btn.Text = "已签到"
btn.Disable()
}
l := container.NewVBox(container.NewCenter(card), btn)
dconf := dialog.NewCustom("签到", "关闭", l, this.w)
dconf.Resize(fyne.NewSize(400, 600))
dconf.Show()
}
// 任务列表
func (this *SociatyMineView) showTaskListWin() {
refreshBtn := widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), func() {
this.memberList.Reset()
this.taskList()
})
btns := container.NewHBox(refreshBtn)
c := container.NewBorder(btns, nil, nil, nil, this.memberList.ItemList)
dconf := dialog.NewCustom("任务", "关闭", c, this.w)
dconf.Resize(fyne.NewSize(800, 500))
dconf.Show()
}
func (this *SociatyMineView) taskList() {
this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{
OnNotify: func(d interface{}, args ...interface{}) {
data := d.(*pb.UserMessage)
if !(data.MainType == string(comm.ModuleSociaty) &&
data.SubType == sociaty.SociatySubTypeMembers) {
return
}
},
})
}

View File

@ -0,0 +1,82 @@
package formview
import (
"fmt"
"go_dreamfactory/cmd/v2/lib/common"
"go_dreamfactory/cmd/v2/model"
"go_dreamfactory/cmd/v2/service"
"go_dreamfactory/cmd/v2/service/observer"
"go_dreamfactory/comm"
"go_dreamfactory/modules/sociaty"
"go_dreamfactory/pb"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"github.com/sirupsen/logrus"
)
type SociatyRankView struct {
rankList func()
BaseformView
itemList *common.ItemList
flag bool
}
func (this *SociatyRankView) CreateView(t *model.TestCase) fyne.CanvasObject {
this.itemList = common.NewItemList()
this.itemList.ItemList = this.itemList.CreateList()
this.rankList = func() {
this.itemList.Reset()
if err := service.GetPttService().SendToClient(
string(comm.ModuleSociaty),
sociaty.SociatySubTypeRank,
&pb.SociatyRankReq{}); err != nil {
logrus.Error(err)
}
}
defer this.rankList()
refreshBtn := widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), func() {
this.itemList.Reset()
this.rankList()
})
buttonBar := container.NewHBox(refreshBtn)
c := container.NewBorder(buttonBar, nil, nil, nil, this.itemList.ItemList)
this.dataListener()
return c
}
func (this *SociatyRankView) dataListener() {
if this.flag {
return
}
this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{
OnNotify: func(d interface{}, args ...interface{}) {
data := d.(*pb.UserMessage)
if !(data.MainType == string(comm.ModuleSociaty) &&
data.SubType == sociaty.SociatySubTypeRank) {
return
}
rsp := &pb.SociatyRankResp{}
if !comm.ProtoUnmarshal(data, rsp) {
logrus.Error("unmarshal err")
return
}
for i, v := range rsp.Rank {
item := common.Item{
Id: v.SociatyId,
Text: fmt.Sprintf("%d - %s 等级:%d 活跃度:%d", i+1, v.Name, v.Lv, v.Activity),
}
this.itemList.AddItem(item)
}
},
})
this.flag = true
}

View File

@ -0,0 +1,108 @@
package formview
import (
"fmt"
"go_dreamfactory/cmd/v2/lib/common"
"go_dreamfactory/cmd/v2/model"
"go_dreamfactory/cmd/v2/service"
"go_dreamfactory/cmd/v2/service/observer"
"go_dreamfactory/comm"
"go_dreamfactory/modules/sociaty"
"go_dreamfactory/pb"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"github.com/sirupsen/logrus"
"github.com/spf13/cast"
)
type SociatyTasklistView struct {
BaseformView
taskList func()
itemList *common.ItemList
flag bool
}
func (this *SociatyTasklistView) CreateView(t *model.TestCase) fyne.CanvasObject {
this.itemList = common.NewItemList()
this.itemList.ItemList = this.itemList.CreateList()
this.taskList = func() {
this.itemList.Reset()
if err := service.GetPttService().SendToClient(
string(comm.ModuleSociaty),
sociaty.SociatySubTypeTasklist,
&pb.SociatyTaskListReq{}); err != nil {
logrus.Error(err)
}
}
defer this.taskList()
refreshBtn := widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), func() {
this.itemList.Reset()
this.taskList()
})
// 领取
receiveBtn := widget.NewButton("", func() {
selId := this.itemList.SelItemId
if selId == "" {
common.ShowTip("请选择项目")
return
}
if err := service.GetPttService().SendToClient(
string(comm.ModuleSociaty),
sociaty.SociatySubTypeReceive,
&pb.SociatyReceiveReq{
TaskId: cast.ToInt32(selId),
}); err != nil {
logrus.Error(err)
}
})
//活跃度领取
activityBtn := widget.NewButton("", nil)
activityVal := canvas.NewText("", nil)
buttonBar := container.NewHBox(refreshBtn, receiveBtn)
c1 := container.NewBorder(buttonBar, nil, nil, nil, this.itemList.ItemList)
c2 := container.NewBorder(nil, nil, nil, nil, container.NewVBox(container.NewCenter(activityVal), activityBtn))
cols := container.NewGridWithColumns(2, c1, c2)
this.dataListener()
return cols
}
func (this *SociatyTasklistView) dataListener() {
if this.flag {
return
}
this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{
OnNotify: func(d interface{}, args ...interface{}) {
data := d.(*pb.UserMessage)
if !(data.MainType == string(comm.ModuleSociaty) &&
data.SubType == sociaty.SociatySubTypeTasklist) {
return
}
rsp := &pb.SociatyTaskListResp{}
if !comm.ProtoUnmarshal(data, rsp) {
logrus.Error("unmarshal err")
return
}
for i, v := range rsp.List {
item := common.Item{
Id: cast.ToString(v.TaskId),
Text: fmt.Sprintf("%d - Id:%v 状态:%d ", i+1, v.TaskId, v.Status),
}
this.itemList.AddItem(item)
}
},
})
this.flag = true
}

View File

@ -25,6 +25,7 @@ const (
const ( const (
RDS_SESSION = "online" RDS_SESSION = "online"
RDS_SOCIATY = "all" RDS_SOCIATY = "all"
RDS_SOCIATYRANK = "rank"
) )
//ERR //ERR
@ -171,6 +172,8 @@ const (
// 公会 // 公会
TableSociaty = "sociaty" TableSociaty = "sociaty"
// 公会任务
TableSociatyTask = "sociatytask"
) )
//RPC服务接口定义处 //RPC服务接口定义处
@ -208,6 +211,8 @@ const (
EventUserChanged core.Event_Key = "event_user_changed" //用户数据变化 EventUserChanged core.Event_Key = "event_user_changed" //用户数据变化
EventTaskChanged core.Event_Key = "event_task_changed" //任务数据变化 EventTaskChanged core.Event_Key = "event_task_changed" //任务数据变化
EventSociatyRankChanged core.Event_Key = "event_sociatyRank_changed" //公会数据变化
) )
const ( const (

View File

@ -208,5 +208,7 @@ type (
ISociaty interface { ISociaty interface {
//会长弹劾处理 //会长弹劾处理
ProcessAccuse(uid, sociatyId string) ProcessAccuse(uid, sociatyId string)
// 公会成员
Members(uid string) (list []*pb.SociatyMemberInfo)
} }
) )

View File

@ -85,7 +85,7 @@ func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.GourmetGetRa
} }
} }
for k := range mapUser { for k := range mapUser {
if user, err := this.module.ModuleUser.GetRmoteUser(k); err == nil && user.Uid != "" { if user, err := this.module.ModuleUser.GetRemoteUser(k); err == nil && user.Uid != "" {
szDbUser = append(szDbUser, user) // 转成user对象 szDbUser = append(szDbUser, user) // 转成user对象
} else { } else {
this.module.Errorf("%v", err) this.module.Errorf("%v", err)

View File

@ -216,7 +216,7 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T
session.GetServiecTag(), session.GetServiecTag(),
comm.Service_Worker, comm.Service_Worker,
string(comm.Rpc_ModuleRtaskSendTask), string(comm.Rpc_ModuleRtaskSendTask),
pb.RPCRTaskReq{Uid: session.GetUserId(), TaskType: int32(rtaskType), Param: params}, pb.RPCRTaskReq{Uid: session.GetUserId(), TaskType: int32(rtaskType),},
nil); err != nil { nil); err != nil {
this.Errorln(err) this.Errorln(err)
} }
@ -358,7 +358,7 @@ func (this *ModuleRtask) Rpc_ModuleRtaskSendTask(ctx context.Context, args *pb.R
err = fmt.Errorf("未查询到用户:%s在线信息!", args.Uid) err = fmt.Errorf("未查询到用户:%s在线信息!", args.Uid)
return return
} else { } else {
this.SendToRtask(session, comm.TaskType(args.TaskType), args.Param...) this.SendToRtask(session, comm.TaskType(args.TaskType),)
session.Push() session.Push()
} }
return return

View File

@ -85,7 +85,7 @@ func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.SmithyGetRan
} }
} }
for k := range mapUser { for k := range mapUser {
if user, err := this.module.ModuleUser.GetRmoteUser(k); err == nil && user.Uid != "" { if user, err := this.module.ModuleUser.GetRemoteUser(k); err == nil && user.Uid != "" {
szDbUser = append(szDbUser, user) // 转成user对象 szDbUser = append(szDbUser, user) // 转成user对象
} else { } else {
this.module.Errorf("%v", err) this.module.Errorf("%v", err)

View File

@ -25,6 +25,10 @@ const (
SociatySubTypeDischarge = "discharge" SociatySubTypeDischarge = "discharge"
SociatySubTypeSettingJob = "settingjob" SociatySubTypeSettingJob = "settingjob"
SociatySubTypeSign = "sign" SociatySubTypeSign = "sign"
SociatySubTypeReceive = "receive"
SociatySubTypeActivityReceive = "activityreceive"
SociatySubTypeRank = "rank"
SociatySubTypeTasklist = "tasklist"
) )
type apiComp struct { type apiComp struct {

View File

@ -10,9 +10,6 @@ import (
// 弹劾会长 // 弹劾会长
func (this *apiComp) AsscuseCheck(session comm.IUserSession, req *pb.SociatyAccuseReq) (code pb.ErrorCode) { func (this *apiComp) AsscuseCheck(session comm.IUserSession, req *pb.SociatyAccuseReq) (code pb.ErrorCode) {
if req.SociatyId == "" {
code = pb.ErrorCode_ReqParameterError
}
return return
} }
@ -21,10 +18,10 @@ func (this *apiComp) Asscuse(session comm.IUserSession, req *pb.SociatyAccuseReq
return return
} }
uid := session.GetUserId() uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty.Id == "" { if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("sociatyId: %s no found", req.SociatyId) this.module.Errorf("uid:%s not in sociaty", uid)
return return
} }

View File

@ -0,0 +1,56 @@
package sociaty
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
// 活跃度领取
func (this *apiComp) ActivityreceiveCheck(session comm.IUserSession, req *pb.SociatyActivityReceiveReq) (code pb.ErrorCode) {
if req.Id == 0 {
code = pb.ErrorCode_ReqParameterError
}
return
}
func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyActivityReceiveReq) (code pb.ErrorCode, data proto.Message) {
if code = this.ActivityreceiveCheck(session, req); code != pb.ErrorCode_Success {
return
}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("uid:%s not in sociaty", uid)
return
}
ggt, err := this.module.configure.getSociatyActivityCfg()
if err != nil || ggt == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
conf, ok := ggt.GetDataMap()[req.Id]
if !ok {
code = pb.ErrorCode_ConfigNoFound
return
}
//是否满足领取条件
if sociaty.Activity < conf.Activity {
this.module.Errorf("弹劾失败:%v", err)
return
}
rsp := &pb.SociatyActivityReceiveResp{
Id: req.Id,
SociatyId: sociaty.Id,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeActivityReceive, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
return
}

View File

@ -10,7 +10,7 @@ import (
// 申请-同意 // 申请-同意
func (this *apiComp) AgreeCheck(session comm.IUserSession, req *pb.SociatyAgreeReq) (code pb.ErrorCode) { func (this *apiComp) AgreeCheck(session comm.IUserSession, req *pb.SociatyAgreeReq) (code pb.ErrorCode) {
if req.Uid == "" || req.SociatyId == "" { if req.Uid == "" {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
return return
@ -20,11 +20,11 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
if code = this.AgreeCheck(session, req); code != pb.ErrorCode_Success { if code = this.AgreeCheck(session, req); code != pb.ErrorCode_Success {
return return
} }
uid:= session.GetUserId() uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty.Id == "" { if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("sociatyId: %s no found", req.SociatyId) this.module.Errorf("uid:%s not in sociaty", uid)
return return
} }

View File

@ -20,6 +20,13 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
if code = this.ApplyCheck(session, req); code != pb.ErrorCode_Success { if code = this.ApplyCheck(session, req); code != pb.ErrorCode_Success {
return return
} }
// 全局配置
ggd := this.module.configure.GetGlobalConf()
if ggd == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
uid := session.GetUserId() uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
@ -29,9 +36,44 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
return return
} }
// 是否达到入会等级
user, err := this.module.ModuleUser.GetRemoteUser(uid)
if err != nil {
return
}
if user == nil {
code = pb.ErrorCode_UserSessionNobeing
return
}
if user.Lv < sociaty.ApplyLv {
code = pb.ErrorCode_SociatyAppyLvNoEnough
return
}
// 是否公会成员
if this.module.modelSociaty.isMember(uid, sociaty) {
code = pb.ErrorCode_SociatyBelongTo
return
}
// 是否已申请
if this.module.modelSociaty.isApplied(uid, sociaty) {
code = pb.ErrorCode_SociatyApplied
return
}
//判断申请人数是否超出最大允许申请数
if len(sociaty.ApplyRecord) >= int(ggd.GuildAcceptApplyMax) {
code = pb.ErrorCode_SociatyApplyMax
return
}
// 申请
if err := this.module.modelSociaty.apply(uid, sociaty); err != nil { if err := this.module.modelSociaty.apply(uid, sociaty); err != nil {
code = pb.ErrorCode_SociatyApply code = pb.ErrorCode_SociatyApply
this.module.Errorf("sociaty %s apply err:%v", req.SociatyId, err) this.module.Errorf("公会申请失败 sociatyId:%s err:%v", req.SociatyId, err)
return return
} }
rsp := &pb.SociatyApplyResp{ rsp := &pb.SociatyApplyResp{

View File

@ -19,6 +19,13 @@ func (this *apiComp) ApplyCancel(session comm.IUserSession, req *pb.SociatyApply
return return
} }
uid := session.GetUserId() uid := session.GetUserId()
if err := this.module.modelSociaty.applyCancel(uid, req.SociatyId); err != nil {
code = pb.ErrorCode_SociatyApplyCanel
this.module.Errorf("申请撤销失败:%v", err)
return
}
rsp := &pb.SociatyApplyResp{ rsp := &pb.SociatyApplyResp{
Uid: uid, Uid: uid,
ScoiatyId: req.SociatyId, ScoiatyId: req.SociatyId,

View File

@ -9,7 +9,7 @@ import (
// 公会转让 // 公会转让
func (this *apiComp) AssignCheck(session comm.IUserSession, req *pb.SociatyAssignReq) (code pb.ErrorCode) { func (this *apiComp) AssignCheck(session comm.IUserSession, req *pb.SociatyAssignReq) (code pb.ErrorCode) {
if req.SociatyId == "" || req.TargetId == "" { if req.TargetId == "" {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
return return
@ -21,10 +21,10 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
} }
uid := session.GetUserId() uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty.Id == "" { if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("sociatyId: %s no found", req.SociatyId) this.module.Errorf("uid:%s not in sociaty", uid)
return return
} }

View File

@ -5,11 +5,16 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
"time" "time"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
// 公会创建 // 公会创建
func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.SociatyCreateReq) (code pb.ErrorCode) { func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.SociatyCreateReq) (code pb.ErrorCode) {
if len(req.Notice) > 150 {
code = pb.ErrorCode_ReqParameterError
}
return return
} }
@ -40,7 +45,6 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
return return
} }
//检查是否已加入公会 //检查是否已加入公会
if userExpand.SociatyId != "" { if userExpand.SociatyId != "" {
code = pb.ErrorCode_SociatyAdded code = pb.ErrorCode_SociatyAdded
@ -48,10 +52,19 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
} }
// CD校验 // CD校验
if this.module.modelSociaty.isInCDHour(userExpand.SociatyCd){
code = pb.ErrorCode_SociatyCDLimit
return
}
//检查钻石 //检查钻石
if user.Diamond < 500 { ggd := this.module.modelSociaty.moduleSociaty.configure.GetGlobalConf()
code = pb.ErrorCode_SociatyDiamondNoEnough if ggd == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{ggd.GuildBuildCos}, true); code != pb.ErrorCode_Success {
return return
} }
@ -88,6 +101,11 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
return return
} }
// 初始化任务
if err := this.module.modelSociatyTask.initSociatyTask(user.Uid, sociaty.Id); err != nil {
this.module.Errorf("初始化玩家任务 err:%v", err)
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeCreate, &pb.SociatyCreateResp{ if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeCreate, &pb.SociatyCreateResp{
Id: sociaty.Id, Id: sociaty.Id,
Uid: uid, Uid: uid,

View File

@ -10,7 +10,7 @@ import (
// 踢出公会 // 踢出公会
func (this *apiComp) DischargeCheck(session comm.IUserSession, req *pb.SociatyDischargeReq) (code pb.ErrorCode) { func (this *apiComp) DischargeCheck(session comm.IUserSession, req *pb.SociatyDischargeReq) (code pb.ErrorCode) {
if req.SociatyId == "" || req.TargetId == "" { if req.TargetId == "" {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
return return
@ -21,10 +21,10 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar
return return
} }
uid := session.GetUserId() uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty.Id == "" { if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("sociatyId: %s no found", req.SociatyId) this.module.Errorf("uid:%s not in sociaty", uid)
return return
} }

View File

@ -10,21 +10,15 @@ import (
// 公会解散 // 公会解散
func (this *apiComp) DismissCheck(session comm.IUserSession, req *pb.SociatyDismissReq) (code pb.ErrorCode) { func (this *apiComp) DismissCheck(session comm.IUserSession, req *pb.SociatyDismissReq) (code pb.ErrorCode) {
if req.SociatyId == "" {
code = pb.ErrorCode_ReqParameterError
}
return return
} }
func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissReq) (code pb.ErrorCode, data proto.Message) {
if code = this.DismissCheck(session, req); code != pb.ErrorCode_Success {
return
}
uid := session.GetUserId() uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty.Id == "" { if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("sociatyId: %s no found", req.SociatyId) this.module.Errorf("uid:%s not in sociaty", uid)
return return
} }
@ -34,25 +28,28 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
return return
} }
if err := this.module.modelSociaty.dismiss(sociaty); err != nil { for _, m := range sociaty.Members {
code = pb.ErrorCode_SociatyDismiss //清除成员任务
this.module.Errorf("sociatyId: %s dismiss err:%v", req.SociatyId, err) this.module.modelSociatyTask.deleTask(sociaty.Id, m.Uid)
return
}
//清除玩家sociatyId //清除玩家sociatyId
for _, v := range sociaty.Members {
update := map[string]interface{}{ update := map[string]interface{}{
"sociatyId": "", "sociatyId": "", //公会ID置空
} }
if err := this.module.ModuleUser.ChangeRemoteUserExpand(m.Uid, update); err != nil {
if err := this.module.ModuleUser.ChangeRemoteUserExpand(v.Uid, update); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
this.module.Errorf("更新玩家公会ID err:%v", err) this.module.Errorf("更新玩家公会ID err:%v", err)
return return
} }
} }
// 删除公会
if err := this.module.modelSociaty.dismiss(sociaty); err != nil {
code = pb.ErrorCode_SociatyDismiss
this.module.Errorf("sociatyId: %s dismiss err:%v", sociaty.Id, err)
return
}
rsp := &pb.SociatyDismissResp{ rsp := &pb.SociatyDismissResp{
Uid: session.GetUserId(), Uid: session.GetUserId(),
SociatyId: sociaty.Id, SociatyId: sociaty.Id,

View File

@ -18,7 +18,7 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.SociatyListReq) (co
} }
rsp := &pb.SociatyListResp{} rsp := &pb.SociatyListResp{}
rsp.List = this.module.modelSociaty.list(&req.Filter) rsp.List = this.module.modelSociaty.list(session.GetUserId(), req.Filter)
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeList, rsp); err != nil { if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeList, rsp); err != nil {
code = pb.ErrorCode_SystemError code = pb.ErrorCode_SystemError

View File

@ -10,20 +10,15 @@ import (
// 公会成员列表 // 公会成员列表
func (this *apiComp) MembersCheck(session comm.IUserSession, req *pb.SociatyMembersReq) (code pb.ErrorCode) { func (this *apiComp) MembersCheck(session comm.IUserSession, req *pb.SociatyMembersReq) (code pb.ErrorCode) {
if req.SociatyId == "" {
code = pb.ErrorCode_ReqParameterError
}
return return
} }
func (this *apiComp) Members(session comm.IUserSession, req *pb.SociatyMembersReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) Members(session comm.IUserSession, req *pb.SociatyMembersReq) (code pb.ErrorCode, data proto.Message) {
if code = this.MembersCheck(session, req); code != pb.ErrorCode_Success { uid := session.GetUserId()
return sociaty := this.module.modelSociaty.getUserSociaty(uid)
}
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
if sociaty.Id == "" { if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("sociatyId: %s no found", req.SociatyId) this.module.Errorf("uid:%s not in sociaty", uid)
return return
} }

View File

@ -20,18 +20,22 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (co
return return
} }
rsp := &pb.SociatyMineResp{}
// 未加入公会 // 已加入公会
if userEx.SociatyId == "" { if userEx.SociatyId != "" {
code = pb.ErrorCode_SociatyNoAdded sociaty := this.module.modelSociaty.getSociaty(userEx.SociatyId)
if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("sociatyId: %s no found", userEx.SociatyId)
return return
} }
sociaty := this.module.modelSociaty.getSociaty(userEx.SociatyId) master := this.module.modelSociaty.getMasterInfo(sociaty)
rsp.Sociaty = sociaty
rsp := &pb.SociatyMineResp{ rsp.Master = master
Sociaty: sociaty,
} }
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeMine, rsp); err != nil { if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeMine, rsp); err != nil {
code = pb.ErrorCode_SystemError code = pb.ErrorCode_SystemError
} }

View File

@ -10,24 +10,18 @@ import (
// 退出公会 // 退出公会
func (this *apiComp) QuitCheck(session comm.IUserSession, req *pb.SociatyQuitReq) (code pb.ErrorCode) { func (this *apiComp) QuitCheck(session comm.IUserSession, req *pb.SociatyQuitReq) (code pb.ErrorCode) {
if req.SociatyId == "" {
code = pb.ErrorCode_ReqParameterError
}
return return
} }
func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (code pb.ErrorCode, data proto.Message) {
if code = this.QuitCheck(session, req); code != pb.ErrorCode_Success { uid := session.GetUserId()
return sociaty := this.module.modelSociaty.getUserSociaty(uid)
}
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
if sociaty.Id == "" { if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("sociatyId: %s no found", req.SociatyId) this.module.Errorf("uid:%s not in sociaty", uid)
return return
} }
uid := session.GetUserId()
if err := this.module.modelSociaty.quit(uid, sociaty); err != nil { if err := this.module.modelSociaty.quit(uid, sociaty); err != nil {
code = pb.ErrorCode_SociatyQuit code = pb.ErrorCode_SociatyQuit
this.module.Errorf("退出公会失败:%v", err) this.module.Errorf("退出公会失败:%v", err)

View File

@ -0,0 +1,26 @@
package sociaty
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
// 公会排行榜
func (this *apiComp) RankCheck(session comm.IUserSession, req *pb.SociatyRankReq) (code pb.ErrorCode) {
return
}
func (this *apiComp) Rank(session comm.IUserSession, req *pb.SociatyRankReq) (code pb.ErrorCode, data proto.Message) {
list := this.module.modelSociaty.rank()
rsp := &pb.SociatyRankResp{
Rank: list,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeRank, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
return
}

View File

@ -0,0 +1,84 @@
package sociaty
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
// 任务奖励领取
func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.SociatyReceiveReq) (code pb.ErrorCode) {
if req.TaskId == 0 {
code = pb.ErrorCode_ReqParameterError
}
return
}
func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveReq) (code pb.ErrorCode, data proto.Message) {
if code = this.ReceiveCheck(session, req); code != pb.ErrorCode_Success {
return
}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("uid:%s not in sociaty", uid)
return
}
// 判断奖励是否已领
sociatyTask := this.module.modelSociaty.getUserTaskList(uid, sociaty.Id)
for _, v := range sociatyTask.List {
if v.TaskId == req.TaskId && v.Status == 1 {
code = pb.ErrorCode_SociatyRewardReceived
return
}
}
//TODO 验证任务是否完成
// 领取
if err := this.module.modelSociatyTask.receive(req.TaskId, uid, sociaty.Id); err != nil {
code = pb.ErrorCode_SociatyRewardReceive
this.module.Errorf("领取任务奖励 err:%v", err)
return
}
//获取奖励配置
ggt, err := this.module.configure.getSociatyTaskCfg()
if err != nil || ggt == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
conf, ok := ggt.GetDataMap()[req.TaskId]
if ok {
// 发放个人奖励
if code = this.module.DispenseRes(session, conf.Reward, true); code != pb.ErrorCode_Success {
this.module.Errorf("发放个人奖励失败 sociatyId:%s uid:%s taskId:%d code:%v", sociaty.Id, uid, req.TaskId, code)
}
}
// 更新公会经验和活跃度
if err := this.module.modelSociaty.updateResourceFromTask(sociaty, conf); err != nil {
this.module.Errorf("更新公会资源 sociatyId:%s uid:%s taskId:%d err:%v", sociaty.Id, uid, req.TaskId, err)
return
}
// 更新成员贡献值
if err := this.module.modelSociaty.updateMemberContribution(uid, conf.Contribution, sociaty); err != nil {
this.module.Errorf("更新成员贡献值 sociatyId:%s uid:%s taskId:%d err:%v", sociaty.Id, uid, req.TaskId, err)
return
}
rsp := &pb.SociatyReceiveResp{
SociatyId: sociaty.Id,
TaskId: req.TaskId,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeReceive, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
return
}

View File

@ -10,7 +10,7 @@ import (
// 申请复查 // 申请复查
func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.SociatyRefuseReq) (code pb.ErrorCode) { func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.SociatyRefuseReq) (code pb.ErrorCode) {
if req.Uid == "" || req.SociatyId == "" { if req.Uid == "" {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
return return
@ -21,10 +21,10 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SociatyRefuseReq)
return return
} }
uid := session.GetUserId() uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty.Id == "" { if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("sociatyId: %s no found", req.SociatyId) this.module.Errorf("uid:%s not in sociaty", uid)
return return
} }

View File

@ -21,7 +21,10 @@ func (this *apiComp) Search(session comm.IUserSession, req *pb.SociatySearchReq)
} }
rsp := &pb.SociatySearchResp{} rsp := &pb.SociatySearchResp{}
rsp.Sociaty = this.module.modelSociaty.findByName(req.Name) sociaty := this.module.modelSociaty.findByName(req.Name)
if sociaty.Id != "" {
rsp.List = append(rsp.List, sociaty)
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSearch, rsp); err != nil { if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSearch, rsp); err != nil {
code = pb.ErrorCode_SystemError code = pb.ErrorCode_SystemError

View File

@ -50,7 +50,7 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe
SociatyId: sociaty.Id, SociatyId: sociaty.Id,
} }
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeAgree, rsp); err != nil { if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSetting, rsp); err != nil {
code = pb.ErrorCode_SystemError code = pb.ErrorCode_SystemError
} }
return return

View File

@ -9,7 +9,7 @@ import (
// 设置职位 // 设置职位
func (this *apiComp) SettingJobCheck(session comm.IUserSession, req *pb.SociatySettingJobReq) (code pb.ErrorCode) { func (this *apiComp) SettingJobCheck(session comm.IUserSession, req *pb.SociatySettingJobReq) (code pb.ErrorCode) {
if req.SociatyId == "" || req.TargetId == "" || req.Job == 0 { if req.TargetId == "" || req.Job == 0 {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
return return
@ -19,20 +19,43 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin
if code = this.SettingJobCheck(session, req); code != pb.ErrorCode_Success { if code = this.SettingJobCheck(session, req); code != pb.ErrorCode_Success {
return return
} }
uid := session.GetUserId() // 全局配置
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) ggd := this.module.configure.GetGlobalConf()
if sociaty.Id == "" { if ggd == nil {
code = pb.ErrorCode_SociatyNoFound code = pb.ErrorCode_ConfigNoFound
this.module.Errorf("sociatyId: %s no found", req.SociatyId)
return return
} }
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("uid:%s not in sociaty", uid)
return
}
// 权限校验
if !this.module.modelSociaty.isRight(uid, sociaty, if !this.module.modelSociaty.isRight(uid, sociaty,
pb.SociatyJob_PRESIDENT) { pb.SociatyJob_PRESIDENT) {
code = pb.ErrorCode_SociatyNoRight code = pb.ErrorCode_SociatyNoRight
return return
} }
// 判断职位人数
jobCount := this.module.modelSociaty.getJobCount(req.Job, sociaty)
if req.Job == pb.SociatyJob_VICEPRESIDENT && jobCount >= int(ggd.GuildViceAllianceLeaderMaxNum) ||
req.Job == pb.SociatyJob_ADMIN && jobCount >= int(ggd.GuildAdministratorsMaxNum) {
code = pb.ErrorCode_SociatyMemberCountLimit
return
}
// 不能设置自己
if uid == req.TargetId {
code = pb.ErrorCode_SociatySelfSetting
return
}
// 设置职位
if err := this.module.modelSociaty.settingJob(req.TargetId, req.Job, sociaty); err != nil { if err := this.module.modelSociaty.settingJob(req.TargetId, req.Job, sociaty); err != nil {
code = pb.ErrorCode_SociatySettingJob code = pb.ErrorCode_SociatySettingJob
this.module.Errorf("设置职位失败:%v", err) this.module.Errorf("设置职位失败:%v", err)

View File

@ -9,9 +9,6 @@ import (
// 签到 // 签到
func (this *apiComp) SignCheck(session comm.IUserSession, req *pb.SociatySignReq) (code pb.ErrorCode) { func (this *apiComp) SignCheck(session comm.IUserSession, req *pb.SociatySignReq) (code pb.ErrorCode) {
if req.SociatyId == "" {
code = pb.ErrorCode_ReqParameterError
}
return return
} }
@ -21,25 +18,55 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (co
} }
uid := session.GetUserId() uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty.Id == "" { if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("sociatyId: %s no found", req.SociatyId) this.module.Errorf("uid:%s not in sociaty", uid)
return return
} }
if this.module.modelSociaty.IsSign(uid, sociaty) {
code = pb.ErrorCode_SociatySigned
return
}
// 签到
if err := this.module.modelSociaty.sign(uid, sociaty); err != nil { if err := this.module.modelSociaty.sign(uid, sociaty); err != nil {
code = pb.ErrorCode_SociatyAgree code = pb.ErrorCode_SociatyAgree
this.module.Errorf("签到失败:%v", err) this.module.Errorf("签到失败:%v", err)
return return
} }
//发奖 ggs, err := this.module.configure.getSociatySignCfg()
if err != nil {
code = pb.ErrorCode_ConfigNoFound
return
}
// 发奖
lastSignCount := sociaty.LastSignCount
var signCfgId int32 //签到配置ID
for _, v := range ggs.GetDataList() {
if lastSignCount >= v.Down && lastSignCount <= v.Up {
// 发放签到奖励
if code = this.module.DispenseRes(session, v.Reward, true); code == pb.ErrorCode_Success {
signCfgId = v.Id
}
}
}
if cfg, ok := ggs.GetDataMap()[signCfgId]; ok {
// 更新公会经验
if cfg.Exp.T == "guildexp" {
if err := this.module.modelSociaty.updateSociatyExp(cfg.Exp.N, sociaty); err != nil {
this.module.Errorf("公会经验更新失败:%v", err)
}
}
}
rsp := &pb.SociatySignResp{ rsp := &pb.SociatySignResp{
Uid: uid, Uid: uid,
SociatyId: req.SociatyId, SociatyId: sociaty.Id,
} }
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSign, rsp); err != nil { if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSign, rsp); err != nil {

View File

@ -0,0 +1,46 @@
package sociaty
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
// 任务列表
func (this *apiComp) TaskListCheck(session comm.IUserSession, req *pb.SociatyTaskListReq) (code pb.ErrorCode) {
return
}
func (this *apiComp) TaskList(session comm.IUserSession, req *pb.SociatyTaskListReq) (code pb.ErrorCode, data proto.Message) {
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
this.module.Errorf("uid:%s not in sociaty", uid)
return
}
rsp := &pb.SociatyTaskListResp{}
defer func() {
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeTasklist, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
}()
sociatyTask := this.module.modelSociatyTask.taskList(uid, sociaty.Id)
if sociatyTask.SociatyId != "" {
var taskList []*pb.SociatyTask
for _, v := range sociatyTask.List {
taskList = append(taskList, &pb.SociatyTask{
TaskId: v.TaskId,
Status: v.Status,
})
}
rsp.List = taskList
}
return
}

View File

@ -1,16 +1,17 @@
package sociaty package sociaty
import ( import (
"fmt"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/modules" "go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
) )
const ( const (
gameSociatyLv = "gameSociatyLv" gameSociatyLv = "game_guildlv.json"
gameSociatyTask = "gameSociatyTask" gameSociatyTask = "game_guildtask.json"
gameSociatySign = "gameSociatySign" gameSociatySign = "game_guildsign.json"
gameSociatyActivity = "gameSociatyActivity" gameSociatyActivity = "game_guildactivity.json"
) )
type configureComp struct { type configureComp struct {
@ -20,10 +21,78 @@ type configureComp struct {
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompConfigure.Init(service, module, comp, options) err = this.MCompConfigure.Init(service, module, comp, options)
err = this.LoadMultiConfigure(map[string]interface{}{ err = this.LoadMultiConfigure(map[string]interface{}{
gameSociatyLv: cfg.NewGameSociatyLv, gameSociatyLv: cfg.NewGameGuildLv,
gameSociatyTask: cfg.NewGameSociatyTask, gameSociatyTask: cfg.NewGameGuildTask,
gameSociatySign: cfg.NewGameSociatySign, gameSociatySign: cfg.NewGameGuildSign,
gameSociatyActivity: cfg.NewGameSociatyActivity, gameSociatyActivity: cfg.NewGameGuildActivity,
}) })
return return
} }
// 等级配置
func (this *configureComp) getSociatyLvCfg() (data *cfg.GameGuildLv, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameSociatyLv); err != nil {
return
} else {
if data, ok = v.(*cfg.GameGuildLv); !ok {
err = fmt.Errorf("%T no is *cfg.GameGuildLv", v)
return
}
}
return
}
// 签到配置
func (this *configureComp) getSociatySignCfg() (data *cfg.GameGuildSign, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameSociatySign); err != nil {
return
} else {
if data, ok = v.(*cfg.GameGuildSign); !ok {
err = fmt.Errorf("%T no is *cfg.GameGuildSign", v)
return
}
}
return
}
// 任务配置
func (this *configureComp) getSociatyTaskCfg() (data *cfg.GameGuildTask, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameSociatyTask); err != nil {
return
} else {
if data, ok = v.(*cfg.GameGuildTask); !ok {
err = fmt.Errorf("%T no is *cfg.GameGuildTask", v)
return
}
}
return
}
// 活跃度配置
func (this *configureComp) getSociatyActivityCfg() (data *cfg.GameGuildActivity, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameSociatyActivity); err != nil {
return
} else {
if data, ok = v.(*cfg.GameGuildActivity); !ok {
err = fmt.Errorf("%T no is *cfg.GameGuildActivity", v)
return
}
}
return
}

View File

@ -6,10 +6,12 @@ import (
"fmt" "fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
event_v2 "go_dreamfactory/lego/sys/event/v2"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils"
"sort" "sort"
"strings" "strings"
"time" "time"
@ -33,6 +35,16 @@ type ModelSociaty struct {
modules.MCompModel modules.MCompModel
moduleSociaty *Sociaty moduleSociaty *Sociaty
service core.IService service core.IService
EventApp *event_v2.App
}
type SociatyListen struct {
event_v2.App
sociatyId string
name string
lv int32
activity int32
ctime int64
} }
func (this *ModelSociaty) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *ModelSociaty) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
@ -40,6 +52,8 @@ func (this *ModelSociaty) Init(service core.IService, module core.IModule, comp
err = this.MCompModel.Init(service, module, comp, options) err = this.MCompModel.Init(service, module, comp, options)
this.moduleSociaty = module.(*Sociaty) this.moduleSociaty = module.(*Sociaty)
this.service = service this.service = service
this.EventApp = event_v2.NewApp()
this.EventApp.Listen(comm.EventSociatyRankChanged, this.rankDataChanged)
return return
} }
@ -51,6 +65,7 @@ func (this *ModelSociaty) create(sociaty *pb.DBSociaty) error {
_id := primitive.NewObjectID().Hex() _id := primitive.NewObjectID().Hex()
sociaty.Id = _id sociaty.Id = _id
sociaty.Ctime = time.Now().Unix() sociaty.Ctime = time.Now().Unix()
sociaty.Lv = 1 //默认1级
if sociaty.Icon == "" { if sociaty.Icon == "" {
sociaty.Icon = "1000" //默认图标 sociaty.Icon = "1000" //默认图标
} }
@ -61,13 +76,35 @@ func (this *ModelSociaty) create(sociaty *pb.DBSociaty) error {
} }
// 公会列表 // 公会列表
func (this *ModelSociaty) list(filter *pb.SociatyListFilter) (list []*pb.DBSociaty) { func (this *ModelSociaty) list(uid string, filter pb.SociatyListFilter) (list []*pb.DBSociaty) {
if pb.SociatyListFilter_ALL == 0 { //所有 user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(uid)
if err != nil {
return
}
if user == nil {
return
}
switch filter {
case pb.SociatyListFilter_ALL: //所有
if err := this.GetList(comm.RDS_SOCIATY, &list); err != nil { if err := this.GetList(comm.RDS_SOCIATY, &list); err != nil {
log.Errorf("sociaty list err:%v", err) log.Errorf("sociaty list err:%v", err)
return return
} }
} else if pb.SociatyListFilter_NOAPPLY == 2 { //无需审批 case pb.SociatyListFilter_CONDI: //满足条件
//玩家等级大于等于公会的申请等级限制
if err := this.GetList(comm.RDS_SOCIATY, &list); err != nil {
log.Errorf("sociaty list err:%v", err)
return
}
var newList []*pb.DBSociaty
for _, v := range list {
if user.Lv >= v.ApplyLv {
newList = append(newList, v)
}
}
return newList
case pb.SociatyListFilter_NOAPPLY: //无需审批
filter := bson.M{ filter := bson.M{
"isApplyCheck": false, "isApplyCheck": false,
} }
@ -78,20 +115,23 @@ func (this *ModelSociaty) list(filter *pb.SociatyListFilter) (list []*pb.DBSocia
list = append(list, sociaty) list = append(list, sociaty)
} }
} }
} else if pb.SociatyListFilter_CONDI == 1 { //满足条件 case pb.SociatyListFilter_APPLYING: //申请中
filter := bson.M{ if err := this.GetList(comm.RDS_SOCIATY, &list); err != nil {
"applyLv": bson.D{ log.Errorf("sociaty list err:%v", err)
{"$gte", 1}, return
}, //玩家等级
} }
cur, err := this.DB.Find(comm.TableSociaty, filter)
for cur.Next(context.TODO()) { var newList []*pb.DBSociaty
sociaty := &pb.DBSociaty{} for _, v := range list {
if err = cur.Decode(sociaty); err != nil { for _, apply := range v.ApplyRecord {
list = append(list, sociaty) if apply.Uid == uid {
newList = append(newList, v)
} }
} }
} }
return newList
}
return return
} }
@ -120,17 +160,23 @@ func (this *ModelSociaty) getSociaty(sociatyId string) (sociaty *pb.DBSociaty) {
return return
} }
// 获取玩家所在的公会
func (this *ModelSociaty) getUserSociaty(uid string) (sociaty *pb.DBSociaty) {
sociaty = &pb.DBSociaty{}
userEx, err := this.moduleSociaty.ModuleUser.GetRemoteUserExpand(uid)
if err != nil {
return
}
if userEx.SociatyId != "" {
return this.getSociaty(userEx.SociatyId)
}
return
}
// 申请公会 // 申请公会
func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) error { func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) error {
// 判断公会审批设置
if this.isMember(uid, sociaty) { if sociaty.IsApplyCheck { //需要审核
return fmt.Errorf("sociaty[%s] as member", sociaty.Id)
}
if this.isApplied(uid, sociaty) {
return fmt.Errorf("sociaty[%s] is applied", sociaty.Id)
}
sociaty.ApplyRecord = append(sociaty.ApplyRecord, &pb.ApplyRecord{ sociaty.ApplyRecord = append(sociaty.ApplyRecord, &pb.ApplyRecord{
Uid: uid, Uid: uid,
Ctime: time.Now().Unix(), Ctime: time.Now().Unix(),
@ -139,6 +185,14 @@ func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) error {
"applyRecord": sociaty.ApplyRecord, "applyRecord": sociaty.ApplyRecord,
} }
return this.updateSociaty(sociaty.Id, update) return this.updateSociaty(sociaty.Id, update)
} else { //无需审核直接入会
if err := this.addMember(uid, sociaty); err != nil {
return err
}
//初始玩家公会任务
this.moduleSociaty.modelSociatyTask.initSociatyTask(uid, sociaty.Id)
}
return nil
} }
// 设置公会 // 设置公会
@ -152,18 +206,13 @@ func (this *ModelSociaty) setting(sociaty *pb.DBSociaty) error {
return this.updateSociaty(sociaty.Id, update) return this.updateSociaty(sociaty.Id, update)
} }
//获取会长
func (this *ModelSociaty) getMaster(sociaty *pb.DBSociaty) *pb.SociatyMember {
for _, m := range sociaty.Members {
if m.Job == pb.SociatyJob_PRESIDENT {
return m
}
}
return nil
}
// 申请撤销 // 申请撤销
func (this *ModelSociaty) applyCancel(uid string, sociaty *pb.DBSociaty) error { func (this *ModelSociaty) applyCancel(uid, sociatyId string) error {
sociaty := this.getSociaty(sociatyId)
if sociaty.Id == "" {
return fmt.Errorf("sociatyId: %s 公会不存在", sociatyId)
}
return this.delFromApplyRecord(uid, sociaty) return this.delFromApplyRecord(uid, sociaty)
} }
@ -226,8 +275,7 @@ func (this *ModelSociaty) isRight(uid string, sociaty *pb.DBSociaty, jobs ...pb.
// 更新公会 // 更新公会
func (this *ModelSociaty) updateSociaty(sociatyId string, update map[string]interface{}) error { func (this *ModelSociaty) updateSociaty(sociatyId string, update map[string]interface{}) error {
this.ChangeList(comm.RDS_SOCIATY, sociatyId, update) return this.ChangeList(comm.RDS_SOCIATY, sociatyId, update)
return nil
} }
// 退出公会 // 退出公会
@ -273,7 +321,16 @@ func (this *ModelSociaty) addMember(uid string, sociaty *pb.DBSociaty) error {
update := map[string]interface{}{ update := map[string]interface{}{
"members": sociaty.Members, "members": sociaty.Members,
} }
return this.updateSociaty(sociaty.Id, update) if err := this.updateSociaty(sociaty.Id, update); err != nil {
return err
}
// 更新玩家公会
updateEx := map[string]interface{}{
"sociatyId": sociaty.Id,
}
return this.moduleSociaty.ModuleUser.ChangeRemoteUserExpand(uid, updateEx)
} }
// 成员列表 // 成员列表
@ -288,6 +345,7 @@ func (this *ModelSociaty) members(sociaty *pb.DBSociaty) (list []*pb.SociatyMemb
Name: user.Name, Name: user.Name,
Avatar: user.Avatar, Avatar: user.Avatar,
Lv: user.Lv, Lv: user.Lv,
Job: m.Job,
OfflineTime: user.Offlinetime, OfflineTime: user.Offlinetime,
}) })
} }
@ -308,7 +366,9 @@ func (this *ModelSociaty) agree(uid string, sociaty *pb.DBSociaty) error {
if err := this.addMember(uid, sociaty); err != nil { if err := this.addMember(uid, sociaty); err != nil {
return err return err
} }
return nil
//初始玩家公会任务
return this.moduleSociaty.modelSociatyTask.initSociatyTask(uid, sociaty.Id)
} }
//拒绝 //拒绝
@ -447,6 +507,7 @@ func (this *ModelSociaty) assign(srcId, targetId string, sociaty *pb.DBSociaty)
// 踢出公会 // 踢出公会
// targetId 踢出目标 // targetId 踢出目标
// 不允许踢出会长
func (this *ModelSociaty) discharge(targetId string, sociaty *pb.DBSociaty) error { func (this *ModelSociaty) discharge(targetId string, sociaty *pb.DBSociaty) error {
for i, m := range sociaty.Members { for i, m := range sociaty.Members {
if m.Uid == targetId { if m.Uid == targetId {
@ -462,6 +523,16 @@ func (this *ModelSociaty) discharge(targetId string, sociaty *pb.DBSociaty) erro
return this.updateSociaty(sociaty.Id, update) return this.updateSociaty(sociaty.Id, update)
} }
//获取职位数
func (this *ModelSociaty) getJobCount(job pb.SociatyJob, sociaty *pb.DBSociaty) (count int) {
for _, m := range sociaty.Members {
if m.Job == job {
count++
}
}
return
}
// 设置职位 // 设置职位
func (this *ModelSociaty) settingJob(targetId string, job pb.SociatyJob, sociaty *pb.DBSociaty) error { func (this *ModelSociaty) settingJob(targetId string, job pb.SociatyJob, sociaty *pb.DBSociaty) error {
for _, m := range sociaty.Members { for _, m := range sociaty.Members {
@ -475,9 +546,29 @@ func (this *ModelSociaty) settingJob(targetId string, job pb.SociatyJob, sociaty
return this.updateSociaty(sociaty.Id, update) return this.updateSociaty(sociaty.Id, update)
} }
// 获取会长信息
func (this *ModelSociaty) getMasterInfo(sociaty *pb.DBSociaty) *pb.SociatyMemberInfo {
for _, m := range sociaty.Members {
if m.Job == pb.SociatyJob_PRESIDENT {
user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(m.Uid)
if err != nil || user.Uid == "" {
continue
}
return &pb.SociatyMemberInfo{
Uid: user.Uid,
Name: user.Name,
Lv: user.Lv,
Avatar: user.Avatar,
OfflineTime: user.Offlinetime,
}
}
}
return nil
}
// 弹劾会长 // 弹劾会长
func (this *ModelSociaty) accuse(sociaty *pb.DBSociaty) error { func (this *ModelSociaty) accuse(sociaty *pb.DBSociaty) error {
master := this.getMaster(sociaty) master := this.getMasterInfo(sociaty)
if master == nil { if master == nil {
return errors.New("会长不存在") return errors.New("会长不存在")
} }
@ -490,7 +581,7 @@ func (this *ModelSociaty) accuse(sociaty *pb.DBSociaty) error {
now := time.Now().Unix() now := time.Now().Unix()
left := now - user.Offlinetime left := now - user.Offlinetime
if left < 7*3600 || user.Offlinetime == 0 { if left < 7*3600 || user.Offlinetime == 0 {
return errors.New("会长很称职") return errors.New("会长很称职,无需弹劾")
} }
return nil return nil
@ -510,8 +601,150 @@ func (this *ModelSociaty) sign(uid string, sociaty *pb.DBSociaty) error {
return this.updateSociaty(sociaty.Id, update) return this.updateSociaty(sociaty.Id, update)
} }
// 签到奖励 // 是否已签到
func (this *ModelSociaty) getSignReward() []*cfg.Gameatn { func (this *ModelSociaty) IsSign(uid string, sociaty *pb.DBSociaty) bool {
if _, ok := utils.Findx(sociaty.SignIds, uid); ok {
return nil return ok
}
return false
}
// 获取玩家任务列表
func (this *ModelSociaty) getUserTaskList(uid, sociatyId string) (sociatyTask *pb.DBSociatyTask) {
sociatyTask = &pb.DBSociatyTask{}
this.moduleSociaty.modelSociatyTask.GetListObj(sociatyId, uid, sociatyTask)
return
}
// 更新公会资源 活跃度、经验
func (this *ModelSociaty) updateResourceFromTask(sociaty *pb.DBSociaty, conf *cfg.GameGuildTaskData) error {
if conf == nil {
return errors.New("配置未找到")
}
exp := sociaty.Exp //经验
activity := sociaty.Activity //活跃度
for _, v := range conf.SociatyReward {
if v.T == "guildactive" {
activity += v.N
} else if v.T == "guildexp" {
exp += v.N
}
}
update := map[string]interface{}{
"exp": exp,
"activity": activity,
}
return this.updateSociaty(sociaty.Id, update)
}
// 更新经验
func (this *ModelSociaty) updateSociatyExp(val int32, sociaty *pb.DBSociaty) error {
exp := sociaty.Exp //经验
exp += val
update := map[string]interface{}{
"exp": exp,
}
return this.updateSociaty(sociaty.Id, update)
}
// 更新成员贡献值
// 任务领取时更新
func (this *ModelSociaty) updateMemberContribution(uid string, val int32, sociaty *pb.DBSociaty) error {
for _, m := range sociaty.Members {
if m.Uid == uid {
m.Contribution += val
}
}
update := map[string]interface{}{
"members": sociaty.Members,
}
return this.updateSociaty(sociaty.Id, update)
}
func (this *ModelSociaty) sort(list []*pb.DBSociatyRank) []*pb.DBSociatyRank {
sort.SliceStable(list, func(i, j int) bool {
if list[i].Lv == list[j].Lv {
if list[i].Activity == list[j].Activity {
return list[i].Ctime > list[j].Ctime
} else {
return list[i].Activity < list[j].Activity
}
}
return list[i].Lv < list[j].Lv
})
return list
}
// 公会等级变化
// 更新排行榜
func (this *ModelSociaty) rankDataChanged(event interface{}, next func(event interface{})) {
var list []*pb.DBSociatyRank
if err := this.GetList(comm.RDS_SOCIATYRANK, &list); err != nil {
log.Errorf("sociaty list err:%v", err)
return
}
data := event.(*SociatyListen)
newRank := &pb.DBSociatyRank{
SociatyId: data.sociatyId,
Name: data.name,
Lv: data.lv,
Activity: data.activity,
Ctime: data.ctime,
}
if len(list) == 0 || len(list) > 0 && len(list) < 20 {
if data != nil {
this.AddList(comm.RDS_SOCIATYRANK, data.sociatyId, newRank)
}
} else {
this.AddList(comm.RDS_SOCIATYRANK, data.sociatyId, newRank)
if err := this.GetList(comm.RDS_SOCIATYRANK, &list); err != nil {
log.Errorf("sociaty list err:%v", err)
return
}
// 排名
tmp := this.sort(list)
//找出20条之后的数据
lastData := append(tmp[:19], tmp[len(tmp)-1:]...)
//删除20之后的数据
delIds := []string{}
for _, v := range lastData {
delIds = append(delIds, v.SociatyId)
}
this.DelListlds(comm.RDS_SOCIATYRANK, delIds...)
}
}
// 排行榜
func (this *ModelSociaty) rank() (rank []*pb.DBSociatyRank) {
var list []*pb.DBSociaty
if err := this.GetList(comm.RDS_SOCIATYRANK, &list); err != nil {
log.Errorf("sociaty list err:%v", err)
return nil
}
for _, v := range list {
rank = append(rank, &pb.DBSociatyRank{
Name: v.Name,
Lv: v.Lv,
Activity: v.Activity,
Ctime: v.Ctime,
})
}
rank = this.sort(rank)
rank = append(rank[:0], rank[19:]...)
return
}
func (this *ModelSociaty) isInCDHour(userCdTime int64) bool {
if userCdTime == 0 {
return false
}
return time.Now().Unix() < userCdTime
} }

View File

@ -0,0 +1,89 @@
package sociaty
import (
"errors"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/utils"
)
type ModelSociatyTask struct {
modules.MCompModel
moduleSociaty *Sociaty
service core.IService
}
func (this *ModelSociatyTask) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.TableName = comm.TableSociaty
err = this.MCompModel.Init(service, module, comp, options)
this.moduleSociaty = module.(*Sociaty)
this.service = service
return
}
// 初始化公会任务 加入成员时初始化
func (this *ModelSociatyTask) initSociatyTask(uid, sociatyId string) error {
ggt, err := this.moduleSociaty.configure.getSociatyTaskCfg()
if err != nil || ggt == nil {
return errors.New("SociatyTaskCfg not found")
}
sociatyTask := &pb.DBSociatyTask{
SociatyId: sociatyId,
Uid: uid,
}
var taskList []*pb.SociatyTask
list := ggt.GetDataList()
// 大于4条配置
if len(list) > 4 {
//随机4条任务
randInts := utils.Numbers(0, len(list)-1, 4)
for _, v := range randInts {
taskList = append(taskList, &pb.SociatyTask{
TaskId: list[v].Id,
})
}
} else {
for _, v := range list {
taskList = append(taskList, &pb.SociatyTask{
TaskId: v.Id,
})
}
}
sociatyTask.List = taskList
return this.moduleSociaty.modelSociatyTask.AddList(sociatyId, uid, sociatyTask)
}
//任务列表
func (this *ModelSociatyTask) taskList(uid, sociatyId string) (task *pb.DBSociatyTask) {
task = &pb.DBSociatyTask{}
this.GetListObj(sociatyId, uid, task)
return
}
// 删除公会任务
func (this *ModelSociatyTask) deleTask(sociatyId, uid string) error {
return this.DelListlds(sociatyId, uid)
}
// 奖励领取
func (this *ModelSociatyTask) receive(taskId int32, sociatyId, uid string) error {
sociatyTask := &pb.DBSociatyTask{}
this.GetListObj(sociatyId, uid, sociatyTask)
for _, t := range sociatyTask.List {
if t.TaskId == taskId {
t.Status = 1 //领取
}
}
update := map[string]interface{}{
"list": sociatyTask.List,
}
return this.ChangeList(sociatyId, uid, update)
}
// 活跃度领取
func (this *ModelSociatyTask) activityReceive() error {
return nil
}

View File

@ -5,6 +5,7 @@ import (
"go_dreamfactory/lego/base" "go_dreamfactory/lego/base"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb"
"time" "time"
) )
@ -15,7 +16,8 @@ type Sociaty struct {
api *apiComp api *apiComp
service base.IRPCXService service base.IRPCXService
modelSociaty *ModelSociaty modelSociaty *ModelSociaty
configure *modules.MCompConfigure modelSociatyTask *ModelSociatyTask
configure *configureComp
} }
func NewModule() core.IModule { func NewModule() core.IModule {
@ -35,6 +37,8 @@ func (this *Sociaty) OnInstallComp() {
this.ModuleBase.OnInstallComp() this.ModuleBase.OnInstallComp()
this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelSociaty = this.RegisterComp(new(ModelSociaty)).(*ModelSociaty) this.modelSociaty = this.RegisterComp(new(ModelSociaty)).(*ModelSociaty)
this.modelSociatyTask = this.RegisterComp(new(ModelSociatyTask)).(*ModelSociatyTask)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
} }
func (this *Sociaty) Start() (err error) { func (this *Sociaty) Start() (err error) {
@ -68,3 +72,9 @@ func (this *Sociaty) ProcessAccuse(uid, sociatyId string) {
} }
} }
} }
// 公会成员
func (this *Sociaty) Members(uid string) (list []*pb.SociatyMemberInfo) {
sociaty := this.modelSociaty.getUserSociaty(uid)
return this.modelSociaty.members(sociaty)
}

View File

@ -30,6 +30,7 @@ type Timer struct {
season *SeasonPagoda season *SeasonPagoda
forum *ForumComp forum *ForumComp
arena *ArenaComp arena *ArenaComp
sociaty *SociatyTimer
} }
//模块名 //模块名
@ -64,6 +65,7 @@ func (this *Timer) OnInstallComp() {
this.chat = this.RegisterComp(new(ChatComp)).(*ChatComp) this.chat = this.RegisterComp(new(ChatComp)).(*ChatComp)
this.season = this.RegisterComp(new(SeasonPagoda)).(*SeasonPagoda) this.season = this.RegisterComp(new(SeasonPagoda)).(*SeasonPagoda)
this.arena = this.RegisterComp(new(ArenaComp)).(*ArenaComp) this.arena = this.RegisterComp(new(ArenaComp)).(*ArenaComp)
this.sociaty = this.RegisterComp(new(SociatyTimer)).(*SociatyTimer)
} }
//日志 //日志

47
modules/timer/sociaty.go Normal file
View File

@ -0,0 +1,47 @@
package timer
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/cron"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/bson"
)
type SociatyTimer struct {
modules.MCompModel
service core.IService
}
//组件初始化接口
func (this *SociatyTimer) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.TableName = comm.TableSociaty
this.MCompModel.Init(service, module, comp, options)
this.service = service
return
}
func (this *SociatyTimer) Start() (err error) {
err = this.MCompModel.Start()
cron.AddFunc("0 0 12 * * ?", this.updateSign)
return
}
// updateSign
func (this *SociatyTimer) updateSign() {
cur, err := this.DB.Find(core.SqlTable(this.TableName), bson.M{})
if err != nil {
return
}
for cur.Next(context.TODO()) {
sociaty := &pb.DBSociaty{}
if err = cur.Decode(sociaty); err == nil {
sociaty.LastSignCount = int32(len(sociaty.SignIds))
sociaty.SignIds = make([]string, 0)
_, err = this.DB.UpdateOne(core.SqlTable(this.TableName), bson.M{}, sociaty)
}
}
}

View File

@ -202,7 +202,7 @@ func (this *User) QueryAttributeValue(uid string, attr string) (value int64) {
err error err error
) )
if this.IsCross() { if this.IsCross() {
user, err = this.GetRmoteUser(uid) user, err = this.GetRemoteUser(uid)
if err != nil { if err != nil {
return return
} }
@ -239,13 +239,13 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
err error err error
) )
if this.IsCross() { if this.IsCross() {
user, err = this.GetRmoteUser(uid) user, err = this.GetRemoteUser(uid)
if err != nil { if err != nil {
code = pb.ErrorCode_UserSessionNobeing code = pb.ErrorCode_UserSessionNobeing
return return
} }
userEx, err = this.GetUserExpand(uid) userEx, err = this.GetRemoteUserExpand(uid)
if err != nil { if err != nil {
code = pb.ErrorCode_UserExpandNull code = pb.ErrorCode_UserExpandNull
return return

View File

@ -316,6 +316,7 @@ type SociatyMember struct {
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` //成员ID Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` //成员ID
Job SociatyJob `protobuf:"varint,2,opt,name=job,proto3,enum=SociatyJob" json:"job" bson:"job"` //职位 Job SociatyJob `protobuf:"varint,2,opt,name=job,proto3,enum=SociatyJob" json:"job" bson:"job"` //职位
Ctime int64 `protobuf:"varint,3,opt,name=ctime,proto3" json:"ctime" bson:"ctime"` //入会时间 Ctime int64 `protobuf:"varint,3,opt,name=ctime,proto3" json:"ctime" bson:"ctime"` //入会时间
Contribution int32 `protobuf:"varint,4,opt,name=contribution,proto3" json:"contribution" bson:"contribution"` //贡献值
} }
func (x *SociatyMember) Reset() { func (x *SociatyMember) Reset() {
@ -371,6 +372,13 @@ func (x *SociatyMember) GetCtime() int64 {
return 0 return 0
} }
func (x *SociatyMember) GetContribution() int32 {
if x != nil {
return x.Contribution
}
return 0
}
// 日志 // 日志
type SociatyLog struct { type SociatyLog struct {
state protoimpl.MessageState state protoimpl.MessageState
@ -427,6 +435,205 @@ func (x *SociatyLog) GetCtime() int64 {
return 0 return 0
} }
// 公会成员任务
type DBSociatyTask struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
SociatyId string `protobuf:"bytes,1,opt,name=sociatyId,proto3" json:"sociatyId"` //@go_tags(`bson:"sociatyId") 公会ID
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
List []*SociatyTask `protobuf:"bytes,3,rep,name=list,proto3" json:"list" bson:"list"` //任务列表
}
func (x *DBSociatyTask) Reset() {
*x = DBSociatyTask{}
if protoimpl.UnsafeEnabled {
mi := &file_sociaty_sociaty_db_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DBSociatyTask) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DBSociatyTask) ProtoMessage() {}
func (x *DBSociatyTask) ProtoReflect() protoreflect.Message {
mi := &file_sociaty_sociaty_db_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DBSociatyTask.ProtoReflect.Descriptor instead.
func (*DBSociatyTask) Descriptor() ([]byte, []int) {
return file_sociaty_sociaty_db_proto_rawDescGZIP(), []int{4}
}
func (x *DBSociatyTask) GetSociatyId() string {
if x != nil {
return x.SociatyId
}
return ""
}
func (x *DBSociatyTask) GetUid() string {
if x != nil {
return x.Uid
}
return ""
}
func (x *DBSociatyTask) GetList() []*SociatyTask {
if x != nil {
return x.List
}
return nil
}
type SociatyTask struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
TaskId int32 `protobuf:"varint,1,opt,name=taskId,proto3" json:"taskId" bson:"taskId"` //任务ID
Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status" bson:"status"` //领取状态:0未领取 1已领取
}
func (x *SociatyTask) Reset() {
*x = SociatyTask{}
if protoimpl.UnsafeEnabled {
mi := &file_sociaty_sociaty_db_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SociatyTask) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SociatyTask) ProtoMessage() {}
func (x *SociatyTask) ProtoReflect() protoreflect.Message {
mi := &file_sociaty_sociaty_db_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SociatyTask.ProtoReflect.Descriptor instead.
func (*SociatyTask) Descriptor() ([]byte, []int) {
return file_sociaty_sociaty_db_proto_rawDescGZIP(), []int{5}
}
func (x *SociatyTask) GetTaskId() int32 {
if x != nil {
return x.TaskId
}
return 0
}
func (x *SociatyTask) GetStatus() int32 {
if x != nil {
return x.Status
}
return 0
}
//排行榜
type DBSociatyRank struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
SociatyId string `protobuf:"bytes,1,opt,name=sociatyId,proto3" json:"sociatyId" bson:"sociatyId"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name" bson:"name"` //公会名称
Lv int32 `protobuf:"varint,3,opt,name=lv,proto3" json:"lv" bson:"lv"` //等级
Activity int32 `protobuf:"varint,4,opt,name=activity,proto3" json:"activity" bson:"activity"` //活跃度
Ctime int64 `protobuf:"varint,5,opt,name=ctime,proto3" json:"ctime" bson:"ctime"` //公会创建时间
}
func (x *DBSociatyRank) Reset() {
*x = DBSociatyRank{}
if protoimpl.UnsafeEnabled {
mi := &file_sociaty_sociaty_db_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DBSociatyRank) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DBSociatyRank) ProtoMessage() {}
func (x *DBSociatyRank) ProtoReflect() protoreflect.Message {
mi := &file_sociaty_sociaty_db_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DBSociatyRank.ProtoReflect.Descriptor instead.
func (*DBSociatyRank) Descriptor() ([]byte, []int) {
return file_sociaty_sociaty_db_proto_rawDescGZIP(), []int{6}
}
func (x *DBSociatyRank) GetSociatyId() string {
if x != nil {
return x.SociatyId
}
return ""
}
func (x *DBSociatyRank) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *DBSociatyRank) GetLv() int32 {
if x != nil {
return x.Lv
}
return 0
}
func (x *DBSociatyRank) GetActivity() int32 {
if x != nil {
return x.Activity
}
return 0
}
func (x *DBSociatyRank) GetCtime() int64 {
if x != nil {
return x.Ctime
}
return 0
}
var File_sociaty_sociaty_db_proto protoreflect.FileDescriptor var File_sociaty_sociaty_db_proto protoreflect.FileDescriptor
var file_sociaty_sociaty_db_proto_rawDesc = []byte{ var file_sociaty_sociaty_db_proto_rawDesc = []byte{
@ -465,22 +672,43 @@ var file_sociaty_sociaty_db_proto_rawDesc = []byte{
0x35, 0x0a, 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x35, 0x0a, 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10,
0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64,
0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x56, 0x0a, 0x0d, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x7a, 0x0a, 0x0d, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74,
0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x03, 0x6a, 0x6f, 0x62, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x03, 0x6a, 0x6f, 0x62,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79,
0x4a, 0x6f, 0x62, 0x52, 0x03, 0x6a, 0x6f, 0x62, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x4a, 0x6f, 0x62, 0x52, 0x03, 0x6a, 0x6f, 0x62, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d,
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x3c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x22,
0x0a, 0x0a, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4c, 0x6f, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04,
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69,
0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x6f, 0x6e, 0x22, 0x3c, 0x0a, 0x0a, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4c, 0x6f, 0x67,
0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x2a, 0x50, 0x0a, 0x0a, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4a, 0x6f, 0x62, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x4f, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74,
0x4a, 0x4f, 0x42, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65,
0x01, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x22, 0x61, 0x0a, 0x0d, 0x44, 0x42, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x54, 0x61, 0x73,
0x56, 0x49, 0x43, 0x45, 0x50, 0x52, 0x45, 0x53, 0x49, 0x44, 0x45, 0x4e, 0x54, 0x10, 0x03, 0x12, 0x6b, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x18, 0x01,
0x0d, 0x0a, 0x09, 0x50, 0x52, 0x45, 0x53, 0x49, 0x44, 0x45, 0x4e, 0x54, 0x10, 0x04, 0x42, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x12,
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69,
0x64, 0x12, 0x20, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x0c, 0x2e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x04, 0x6c,
0x69, 0x73, 0x74, 0x22, 0x3d, 0x0a, 0x0b, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x54, 0x61,
0x73, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74,
0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74,
0x75, 0x73, 0x22, 0x83, 0x01, 0x0a, 0x0d, 0x44, 0x42, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79,
0x52, 0x61, 0x6e, 0x6b, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79,
0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x03, 0x20, 0x01,
0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69,
0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69,
0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28,
0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x2a, 0x50, 0x0a, 0x0a, 0x53, 0x6f, 0x63, 0x69,
0x61, 0x74, 0x79, 0x4a, 0x6f, 0x62, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x4f, 0x4a, 0x4f, 0x42, 0x10,
0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x01, 0x12, 0x09, 0x0a,
0x05, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x56, 0x49, 0x43, 0x45,
0x50, 0x52, 0x45, 0x53, 0x49, 0x44, 0x45, 0x4e, 0x54, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x50,
0x52, 0x45, 0x53, 0x49, 0x44, 0x45, 0x4e, 0x54, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -496,24 +724,28 @@ func file_sociaty_sociaty_db_proto_rawDescGZIP() []byte {
} }
var file_sociaty_sociaty_db_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_sociaty_sociaty_db_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_sociaty_sociaty_db_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_sociaty_sociaty_db_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_sociaty_sociaty_db_proto_goTypes = []interface{}{ var file_sociaty_sociaty_db_proto_goTypes = []interface{}{
(SociatyJob)(0), // 0: SociatyJob (SociatyJob)(0), // 0: SociatyJob
(*DBSociaty)(nil), // 1: DBSociaty (*DBSociaty)(nil), // 1: DBSociaty
(*ApplyRecord)(nil), // 2: ApplyRecord (*ApplyRecord)(nil), // 2: ApplyRecord
(*SociatyMember)(nil), // 3: SociatyMember (*SociatyMember)(nil), // 3: SociatyMember
(*SociatyLog)(nil), // 4: SociatyLog (*SociatyLog)(nil), // 4: SociatyLog
(*DBSociatyTask)(nil), // 5: DBSociatyTask
(*SociatyTask)(nil), // 6: SociatyTask
(*DBSociatyRank)(nil), // 7: DBSociatyRank
} }
var file_sociaty_sociaty_db_proto_depIdxs = []int32{ var file_sociaty_sociaty_db_proto_depIdxs = []int32{
2, // 0: DBSociaty.applyRecord:type_name -> ApplyRecord 2, // 0: DBSociaty.applyRecord:type_name -> ApplyRecord
3, // 1: DBSociaty.members:type_name -> SociatyMember 3, // 1: DBSociaty.members:type_name -> SociatyMember
4, // 2: DBSociaty.logs:type_name -> SociatyLog 4, // 2: DBSociaty.logs:type_name -> SociatyLog
0, // 3: SociatyMember.job:type_name -> SociatyJob 0, // 3: SociatyMember.job:type_name -> SociatyJob
4, // [4:4] is the sub-list for method output_type 6, // 4: DBSociatyTask.list:type_name -> SociatyTask
4, // [4:4] is the sub-list for method input_type 5, // [5:5] is the sub-list for method output_type
4, // [4:4] is the sub-list for extension type_name 5, // [5:5] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension extendee 5, // [5:5] is the sub-list for extension type_name
0, // [0:4] is the sub-list for field type_name 5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
} }
func init() { file_sociaty_sociaty_db_proto_init() } func init() { file_sociaty_sociaty_db_proto_init() }
@ -570,6 +802,42 @@ func file_sociaty_sociaty_db_proto_init() {
return nil return nil
} }
} }
file_sociaty_sociaty_db_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DBSociatyTask); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_sociaty_sociaty_db_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SociatyTask); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_sociaty_sociaty_db_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DBSociatyRank); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -577,7 +845,7 @@ func file_sociaty_sociaty_db_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_sociaty_sociaty_db_proto_rawDesc, RawDescriptor: file_sociaty_sociaty_db_proto_rawDesc,
NumEnums: 1, NumEnums: 1,
NumMessages: 4, NumMessages: 7,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
type GameGuildActivity struct {
_dataMap map[int32]*GameGuildActivityData
_dataList []*GameGuildActivityData
}
func NewGameGuildActivity(_buf []map[string]interface{}) (*GameGuildActivity, error) {
_dataList := make([]*GameGuildActivityData, 0, len(_buf))
dataMap := make(map[int32]*GameGuildActivityData)
for _, _ele_ := range _buf {
if _v, err2 := DeserializeGameGuildActivityData(_ele_); err2 != nil {
return nil, err2
} else {
_dataList = append(_dataList, _v)
dataMap[_v.Id] = _v
}
}
return &GameGuildActivity{_dataList:_dataList, _dataMap:dataMap}, nil
}
func (table *GameGuildActivity) GetDataMap() map[int32]*GameGuildActivityData {
return table._dataMap
}
func (table *GameGuildActivity) GetDataList() []*GameGuildActivityData {
return table._dataList
}
func (table *GameGuildActivity) Get(key int32) *GameGuildActivityData {
return table._dataMap[key]
}

View File

@ -0,0 +1,52 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
import "errors"
type GameGuildActivityData struct {
Id int32
Activity int32
Reward []*Gameatn
}
const TypeId_GameGuildActivityData = 1556214768
func (*GameGuildActivityData) GetTypeId() int32 {
return 1556214768
}
func (_v *GameGuildActivityData)Deserialize(_buf map[string]interface{}) (err error) {
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["activity"].(float64); !_ok_ { err = errors.New("activity error"); return }; _v.Activity = int32(_tempNum_) }
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["reward"].([]interface{}); !_ok_ { err = errors.New("reward error"); return }
_v.Reward = make([]*Gameatn, 0, len(_arr_))
for _, _e_ := range _arr_ {
var _list_v_ *Gameatn
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } }
_v.Reward = append(_v.Reward, _list_v_)
}
}
return
}
func DeserializeGameGuildActivityData(_buf map[string]interface{}) (*GameGuildActivityData, error) {
v := &GameGuildActivityData{}
if err := v.Deserialize(_buf); err == nil {
return v, nil
} else {
return nil, err
}
}

View File

@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
type GameGuildLv struct {
_dataMap map[int32]*GameGuildLvData
_dataList []*GameGuildLvData
}
func NewGameGuildLv(_buf []map[string]interface{}) (*GameGuildLv, error) {
_dataList := make([]*GameGuildLvData, 0, len(_buf))
dataMap := make(map[int32]*GameGuildLvData)
for _, _ele_ := range _buf {
if _v, err2 := DeserializeGameGuildLvData(_ele_); err2 != nil {
return nil, err2
} else {
_dataList = append(_dataList, _v)
dataMap[_v.Lv] = _v
}
}
return &GameGuildLv{_dataList:_dataList, _dataMap:dataMap}, nil
}
func (table *GameGuildLv) GetDataMap() map[int32]*GameGuildLvData {
return table._dataMap
}
func (table *GameGuildLv) GetDataList() []*GameGuildLvData {
return table._dataList
}
func (table *GameGuildLv) Get(key int32) *GameGuildLvData {
return table._dataMap[key]
}

View File

@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
import "errors"
type GameGuildLvData struct {
Lv int32
Exp int32
MemberMax int32
}
const TypeId_GameGuildLvData = 150033963
func (*GameGuildLvData) GetTypeId() int32 {
return 150033963
}
func (_v *GameGuildLvData)Deserialize(_buf map[string]interface{}) (err error) {
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["lv"].(float64); !_ok_ { err = errors.New("lv error"); return }; _v.Lv = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["exp"].(float64); !_ok_ { err = errors.New("exp error"); return }; _v.Exp = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["member_max"].(float64); !_ok_ { err = errors.New("member_max error"); return }; _v.MemberMax = int32(_tempNum_) }
return
}
func DeserializeGameGuildLvData(_buf map[string]interface{}) (*GameGuildLvData, error) {
v := &GameGuildLvData{}
if err := v.Deserialize(_buf); err == nil {
return v, nil
} else {
return nil, err
}
}

View File

@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
type GameGuildPng struct {
_dataMap map[int32]*GameGuildPngData
_dataList []*GameGuildPngData
}
func NewGameGuildPng(_buf []map[string]interface{}) (*GameGuildPng, error) {
_dataList := make([]*GameGuildPngData, 0, len(_buf))
dataMap := make(map[int32]*GameGuildPngData)
for _, _ele_ := range _buf {
if _v, err2 := DeserializeGameGuildPngData(_ele_); err2 != nil {
return nil, err2
} else {
_dataList = append(_dataList, _v)
dataMap[_v.Id] = _v
}
}
return &GameGuildPng{_dataList:_dataList, _dataMap:dataMap}, nil
}
func (table *GameGuildPng) GetDataMap() map[int32]*GameGuildPngData {
return table._dataMap
}
func (table *GameGuildPng) GetDataList() []*GameGuildPngData {
return table._dataList
}
func (table *GameGuildPng) Get(key int32) *GameGuildPngData {
return table._dataMap[key]
}

View File

@ -0,0 +1,37 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
import "errors"
type GameGuildPngData struct {
Id int32
Png string
}
const TypeId_GameGuildPngData = -586458500
func (*GameGuildPngData) GetTypeId() int32 {
return -586458500
}
func (_v *GameGuildPngData)Deserialize(_buf map[string]interface{}) (err error) {
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) }
{ var _ok_ bool; if _v.Png, _ok_ = _buf["png"].(string); !_ok_ { err = errors.New("png error"); return } }
return
}
func DeserializeGameGuildPngData(_buf map[string]interface{}) (*GameGuildPngData, error) {
v := &GameGuildPngData{}
if err := v.Deserialize(_buf); err == nil {
return v, nil
} else {
return nil, err
}
}

View File

@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
type GameGuildSign struct {
_dataMap map[int32]*GameGuildSignData
_dataList []*GameGuildSignData
}
func NewGameGuildSign(_buf []map[string]interface{}) (*GameGuildSign, error) {
_dataList := make([]*GameGuildSignData, 0, len(_buf))
dataMap := make(map[int32]*GameGuildSignData)
for _, _ele_ := range _buf {
if _v, err2 := DeserializeGameGuildSignData(_ele_); err2 != nil {
return nil, err2
} else {
_dataList = append(_dataList, _v)
dataMap[_v.Id] = _v
}
}
return &GameGuildSign{_dataList:_dataList, _dataMap:dataMap}, nil
}
func (table *GameGuildSign) GetDataMap() map[int32]*GameGuildSignData {
return table._dataMap
}
func (table *GameGuildSign) GetDataList() []*GameGuildSignData {
return table._dataList
}
func (table *GameGuildSign) Get(key int32) *GameGuildSignData {
return table._dataMap[key]
}

View File

@ -0,0 +1,58 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
import "errors"
type GameGuildSignData struct {
Id int32
Down int32
Up int32
SignInText string
Reward []*Gameatn
Exp *Gameatn
}
const TypeId_GameGuildSignData = -171525346
func (*GameGuildSignData) GetTypeId() int32 {
return -171525346
}
func (_v *GameGuildSignData)Deserialize(_buf map[string]interface{}) (err error) {
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["down"].(float64); !_ok_ { err = errors.New("down error"); return }; _v.Down = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["up"].(float64); !_ok_ { err = errors.New("up error"); return }; _v.Up = int32(_tempNum_) }
{var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["SignIn_text"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.SignInText error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.SignInText, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["reward"].([]interface{}); !_ok_ { err = errors.New("reward error"); return }
_v.Reward = make([]*Gameatn, 0, len(_arr_))
for _, _e_ := range _arr_ {
var _list_v_ *Gameatn
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } }
_v.Reward = append(_v.Reward, _list_v_)
}
}
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["exp"].(map[string]interface{}); !_ok_ { err = errors.New("exp error"); return }; if _v.Exp, err = DeserializeGameatn(_x_); err != nil { return } }
return
}
func DeserializeGameGuildSignData(_buf map[string]interface{}) (*GameGuildSignData, error) {
v := &GameGuildSignData{}
if err := v.Deserialize(_buf); err == nil {
return v, nil
} else {
return nil, err
}
}

View File

@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
type GameGuildTask struct {
_dataMap map[int32]*GameGuildTaskData
_dataList []*GameGuildTaskData
}
func NewGameGuildTask(_buf []map[string]interface{}) (*GameGuildTask, error) {
_dataList := make([]*GameGuildTaskData, 0, len(_buf))
dataMap := make(map[int32]*GameGuildTaskData)
for _, _ele_ := range _buf {
if _v, err2 := DeserializeGameGuildTaskData(_ele_); err2 != nil {
return nil, err2
} else {
_dataList = append(_dataList, _v)
dataMap[_v.Id] = _v
}
}
return &GameGuildTask{_dataList:_dataList, _dataMap:dataMap}, nil
}
func (table *GameGuildTask) GetDataMap() map[int32]*GameGuildTaskData {
return table._dataMap
}
func (table *GameGuildTask) GetDataList() []*GameGuildTaskData {
return table._dataList
}
func (table *GameGuildTask) Get(key int32) *GameGuildTaskData {
return table._dataMap[key]
}

View File

@ -0,0 +1,69 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
import "errors"
type GameGuildTaskData struct {
Id int32
Weight int32
Reward []*Gameatn
SociatyReward []*Gameatn
Contribution int32
}
const TypeId_GameGuildTaskData = -892997914
func (*GameGuildTaskData) GetTypeId() int32 {
return -892997914
}
func (_v *GameGuildTaskData)Deserialize(_buf map[string]interface{}) (err error) {
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["weight"].(float64); !_ok_ { err = errors.New("weight error"); return }; _v.Weight = int32(_tempNum_) }
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["reward"].([]interface{}); !_ok_ { err = errors.New("reward error"); return }
_v.Reward = make([]*Gameatn, 0, len(_arr_))
for _, _e_ := range _arr_ {
var _list_v_ *Gameatn
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } }
_v.Reward = append(_v.Reward, _list_v_)
}
}
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["sociaty_reward"].([]interface{}); !_ok_ { err = errors.New("sociaty_reward error"); return }
_v.SociatyReward = make([]*Gameatn, 0, len(_arr_))
for _, _e_ := range _arr_ {
var _list_v_ *Gameatn
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } }
_v.SociatyReward = append(_v.SociatyReward, _list_v_)
}
}
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["contribution"].(float64); !_ok_ { err = errors.New("contribution error"); return }; _v.Contribution = int32(_tempNum_) }
return
}
func DeserializeGameGuildTaskData(_buf map[string]interface{}) (*GameGuildTaskData, error) {
v := &GameGuildTaskData{}
if err := v.Deserialize(_buf); err == nil {
return v, nil
} else {
return nil, err
}
}

View File

@ -44,7 +44,7 @@ func (_v *GameSociatyTaskData)Deserialize(_buf map[string]interface{}) (err erro
{ {
var _arr_ []interface{} var _arr_ []interface{}
var _ok_ bool var _ok_ bool
if _arr_, _ok_ = _buf["sociaty_reword"].([]interface{}); !_ok_ { err = errors.New("sociaty_reword error"); return } if _arr_, _ok_ = _buf["sociaty_reward"].([]interface{}); !_ok_ { err = errors.New("sociaty_reward error"); return }
_v.SociatyReword = make([]*Gameatn, 0, len(_arr_)) _v.SociatyReword = make([]*Gameatn, 0, len(_arr_))