Skip to content

Commit

Permalink
update fate
Browse files Browse the repository at this point in the history
  • Loading branch information
godcong committed Nov 21, 2019
1 parent 8ab1899 commit fe2b533
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
8 changes: 4 additions & 4 deletions character.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (

//Character 字符
type Character struct {
Hash string `xorm:"pk hash"`
PinYin []string `xorm:"default() notnull pin_yin"` //拼音
Ch string `xorm:"default() notnull ch"` //字符
ScienceStroke string `xorm:"science_stroke" json:"science_stroke"`
Hash string `xorm:"pk hash"`
PinYin []string `xorm:"default() notnull pin_yin"` //拼音
Ch string `xorm:"default() notnull ch"` //字符
//ScienceStroke string `xorm:"science_stroke" json:"science_stroke"`
Radical string `xorm:"default() notnull radical"` //部首
RadicalStroke int `xorm:"default(0) notnull radical_stroke"` //部首笔画
Stroke int `xorm:"default() notnull stroke"` //总笔画数
Expand Down
2 changes: 1 addition & 1 deletion cmd/console/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func main() {
return nil
}
app.Action = func(context *cli.Context) error {
e := f.MakeName()
e := f.MakeName(context.Context)
if e != nil {
return e
}
Expand Down
11 changes: 9 additions & 2 deletions fate.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fate

import (
"context"
"strings"
"time"

Expand All @@ -16,7 +17,7 @@ var DefaultStrokeMin = 0
var HardMode = false

type Fate interface {
MakeName() (e error)
MakeName(ctx context.Context) (e error)
XiYong() *XiYong
//SetCharDB(engine *xorm.Engine)
//GetLastCharacter() error
Expand Down Expand Up @@ -122,7 +123,7 @@ func (f *fateImpl) getLastCharacter() error {
return nil
}

func (f *fateImpl) MakeName() (e error) {
func (f *fateImpl) MakeName(ctx context.Context) (e error) {
n, e := CountWuGeLucky(f.db)
if e != nil {
return Wrap(e, "count total error")
Expand Down Expand Up @@ -154,6 +155,12 @@ func (f *fateImpl) MakeName() (e error) {
var tmpChar []*Character
//supplyFilter := false
for n := range name {
select {
case <-ctx.Done():
return
default:

}
if f.debug {
log.With("name", n.String()).Info("name")
}
Expand Down

0 comments on commit fe2b533

Please sign in to comment.