parent
e8314277fb
commit
4bdfc16d26
@ -1,9 +0,0 @@
|
|||||||
package Test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestGetSysDict(t *testing.T) {
|
|
||||||
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package Test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"flag"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
addr = flag.String("addr", "localhost:8972", "server address")
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestBaseRpcGateWay(t *testing.T) {
|
|
||||||
//cc := &codec.MsgpackCodec{}
|
|
||||||
////提交的参数
|
|
||||||
////准备计算的参数
|
|
||||||
//args := &RpcService.DmStageArgs{
|
|
||||||
// Limit: 1000,
|
|
||||||
// Offset: 0,
|
|
||||||
//}
|
|
||||||
////定义返回的变量
|
|
||||||
//reply := &RpcService.Reply{}
|
|
||||||
//data, _ := cc.Encode(args)
|
|
||||||
//// request
|
|
||||||
//req, err := http.NewRequest("POST", "http://10.10.6.200:8001/", bytes.NewReader(data))
|
|
||||||
//if err != nil {
|
|
||||||
// fmt.Println("failed to create request: ", err)
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//// 设置header
|
|
||||||
//h := req.Header
|
|
||||||
//h.Set(gateway.XMessageID, "10000")
|
|
||||||
//h.Set(gateway.XMessageType, "0")
|
|
||||||
//h.Set(gateway.XSerializeType, "3")
|
|
||||||
//h.Set(gateway.XServicePath, "Base")
|
|
||||||
//h.Set(gateway.XServiceMethod, "GetStageList")
|
|
||||||
//
|
|
||||||
//// 发送http请求
|
|
||||||
//// http请求===>rpcx请求===>rpcx服务===>返回rpcx结果===>转换为http的response===>输出到client
|
|
||||||
//res, err := http.DefaultClient.Do(req)
|
|
||||||
//if err != nil {
|
|
||||||
// fmt.Println("failed to call: ", err)
|
|
||||||
//}
|
|
||||||
//defer res.Body.Close()
|
|
||||||
//// 获取结果
|
|
||||||
//replyData, err := ioutil.ReadAll(res.Body)
|
|
||||||
//if err != nil {
|
|
||||||
// fmt.Println("failed to read response: ", err)
|
|
||||||
//}
|
|
||||||
//// 解码
|
|
||||||
//err = cc.Decode(replyData, reply)
|
|
||||||
//if err != nil {
|
|
||||||
// fmt.Println("failed to decode reply: ", err)
|
|
||||||
//}
|
|
||||||
//fmt.Println(reply.List)
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
package Test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"dsBaseRpc/Utils/IdCardUtil"
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestIdCard(t *testing.T) {
|
|
||||||
//待验证的身份证号
|
|
||||||
idCard:="222301197710110018"
|
|
||||||
//开始检查
|
|
||||||
isValid, birthday, xb := IdCardUtil.GetIdCardNoInfo(idCard)
|
|
||||||
if !isValid{
|
|
||||||
fmt.Println("身份证号不合法!")
|
|
||||||
} else {
|
|
||||||
// isMale:true---->男
|
|
||||||
fmt.Printf("birthday=%s, xb=%s \n", birthday, xb)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package Test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"dsBaseRpc/Utils/CommonUtil"
|
|
||||||
"dsBaseRpc/Utils/DbUtil"
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSqlIn(t *testing.T) {
|
|
||||||
//方式1:传入字符串数组
|
|
||||||
idAry := []string{"1", "2", "3"}
|
|
||||||
ids := strings.Join(idAry, "','")
|
|
||||||
sqlRaw := fmt.Sprintf(`SELECT * FROM table WHERE id IN ('%s')`, ids)
|
|
||||||
fmt.Println(sqlRaw)
|
|
||||||
|
|
||||||
//方式2:传入整数数组
|
|
||||||
nums := []int{11, 12, 13}
|
|
||||||
ids = strings.Join(CommonUtil.ConvertIntegerArrayToStringArray(nums), "','")
|
|
||||||
sqlRaw = fmt.Sprintf(`select * from t_dm_subject where subject_id in ('%s')`, ids)
|
|
||||||
fmt.Println(sqlRaw)
|
|
||||||
|
|
||||||
var db = DbUtil.Engine
|
|
||||||
list, err := db.SQL(sqlRaw).Query().List()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
fmt.Println(list)
|
|
||||||
}
|
|
Loading…
Reference in new issue