add astro api
parent
f8f203851a
commit
49037549cf
File diff suppressed because it is too large
Load Diff
@ -1,51 +0,0 @@
|
||||
server:
|
||||
id: 1
|
||||
mode: "release"
|
||||
|
||||
frontend:
|
||||
addr: "ws://testapi.gzjy-game.xyz/ws"
|
||||
|
||||
log:
|
||||
dir: "logs"
|
||||
caller: true
|
||||
request: true
|
||||
stat: false
|
||||
|
||||
http:
|
||||
ip: "0.0.0.0"
|
||||
port: 8001
|
||||
|
||||
rpc:
|
||||
ip: "127.0.0.1"
|
||||
port: 8081
|
||||
|
||||
mysql:
|
||||
addr: "127.0.0.1:3306"
|
||||
user: "root"
|
||||
password: "QianYin@66"
|
||||
database: "hawox"
|
||||
|
||||
mongo:
|
||||
addr: "127.0.0.1:27017"
|
||||
database: "attribute"
|
||||
# user: "mongo-user"
|
||||
# password: "mongo-password"
|
||||
|
||||
etcd:
|
||||
addrs: "127.0.0.1:2379"
|
||||
# user: "etcd-user"
|
||||
# password: "etcd-password"
|
||||
|
||||
redis:
|
||||
addrs: "127.0.0.1:7001;127.0.0.1:7002;127.0.0.1:7003;127.0.0.1:7004;127.0.0.1:7005;127.0.0.1:7006;127.0.0.1:7007"
|
||||
db: 0
|
||||
# user: "redis-user"
|
||||
# password: "redis-passwd"
|
||||
|
||||
queue:
|
||||
type: "kafka"
|
||||
addrs: "127.0.0.1:9092"
|
||||
|
||||
#queue:
|
||||
# type: "nsq"
|
||||
# addrs: "127.0.0.1:4161"
|
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @Author: jager
|
||||
* @Email: lhj168os@gmail.com
|
||||
* @File: consts
|
||||
* @Date: 2021/12/31 5:20 下午
|
||||
* @package: consts
|
||||
* @Version: v1.0.0
|
||||
*
|
||||
* @Description:
|
||||
*
|
||||
*/
|
||||
|
||||
package apity
|
||||
|
||||
import "strconv"
|
||||
|
||||
type ApiType int64
|
||||
|
||||
const (
|
||||
Soup ApiType = 1 << iota
|
||||
Weather
|
||||
Obscenity
|
||||
Astro
|
||||
)
|
||||
|
||||
func Type(ty string) ApiType {
|
||||
tyN, err := strconv.Atoi(ty)
|
||||
if err == nil {
|
||||
return ApiType(1 << (tyN - 1))
|
||||
}
|
||||
switch ty {
|
||||
case "soup":
|
||||
return Soup
|
||||
case "weather":
|
||||
return Weather
|
||||
case "obscenity":
|
||||
return Obscenity
|
||||
case "astro":
|
||||
return Astro
|
||||
}
|
||||
return ApiType(0)
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @Author: jager
|
||||
* @Email: lhj168os@gmail.com
|
||||
* @File: consts_test
|
||||
* @Date: 2022/1/6 2:36 下午
|
||||
* @package: consts
|
||||
* @Version: v1.0.0
|
||||
*
|
||||
* @Description:
|
||||
*
|
||||
*/
|
||||
|
||||
package apity
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestApiType(t *testing.T) {
|
||||
var opened int64 = 7
|
||||
opened = opened & int64(Astro)
|
||||
//opened = opened | int64(Obscenity)
|
||||
//opened = opened | int64(Weather)
|
||||
fmt.Printf("opened = %b\n", opened)
|
||||
//fmt.Printf("soup type = %d\n", int64(Soup)&opened)
|
||||
//fmt.Printf("weather type = %b\n", Weather)
|
||||
//fmt.Printf("obscenity type = %b\n", Obscenity)
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @Author: jager
|
||||
* @Email: lhj168os@gmail.com
|
||||
* @File: almanac
|
||||
* @Date: 2022/1/6 6:13 下午
|
||||
* @package: almanac
|
||||
* @Version: v1.0.0
|
||||
*
|
||||
* @Description:
|
||||
*
|
||||
*/
|
||||
|
||||
package almanac
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jageros/hawox/astro"
|
||||
"github.com/jageros/hawox/errcode"
|
||||
"github.com/jageros/hawox/httpx"
|
||||
"idata/internal/apity"
|
||||
"idata/internal/consts"
|
||||
"idata/internal/service/user"
|
||||
"idata/internal/types"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Almanac(ctx *gin.Context) {
|
||||
uid, ok := httpx.DecodeUrlVal(ctx, "uid")
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var opened bool
|
||||
err := user.OperateSync(uid, func(u types.RWUser) {
|
||||
opened = u.ApiCanReq(apity.Astro)
|
||||
if opened && !u.IsVip() {
|
||||
u.SetScore(u.Score() - 1)
|
||||
}
|
||||
|
||||
})
|
||||
if err != nil {
|
||||
httpx.ErrInterrupt(ctx, errcode.WithErrcode(1, err))
|
||||
return
|
||||
}
|
||||
if !opened {
|
||||
httpx.ErrInterrupt(ctx, errcode.New(1, "未获得此Api权限"))
|
||||
return
|
||||
}
|
||||
date, ok := httpx.DecodeUrlVal(ctx, "date")
|
||||
if !ok || date == "" {
|
||||
date = time.Now().Format(consts.DateFormat)
|
||||
}
|
||||
strs := strings.Split(date, "_")
|
||||
var hour = -1
|
||||
if len(strs) >= 2 {
|
||||
h, err := strconv.Atoi(strs[1])
|
||||
if err == nil {
|
||||
hour = h
|
||||
}
|
||||
}
|
||||
dd := astro.GetDate(strs[0])
|
||||
data, err := dd.Map(hour)
|
||||
if err != nil {
|
||||
httpx.ErrInterrupt(ctx, errcode.WithErrcode(2, err))
|
||||
return
|
||||
}
|
||||
httpx.PkgMsgWrite(ctx, data)
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @Author: jager
|
||||
* @Email: lhj168os@gmail.com
|
||||
* @File: utils_test
|
||||
* @Date: 2022/1/6 5:00 下午
|
||||
* @package: utils
|
||||
* @Version: v1.0.0
|
||||
*
|
||||
* @Description:
|
||||
*
|
||||
*/
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGenSecret(t *testing.T) {
|
||||
fmt.Println("Sha1: " + GenSecret("1000"))
|
||||
fmt.Println("MD5: " + GenSecretMd5("1000"))
|
||||
}
|
Loading…
Reference in New Issue