Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rym-util
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengqiuyun
rym-util
Commits
cca51f65
Commit
cca51f65
authored
Dec 08, 2022
by
zhengqiuyun86
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nil默认
parent
b1bdf6c0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
8 deletions
+28
-8
PagePlus.go
PagePlus/PagePlus.go
+2
-2
CatchException_test.go
exception/catch/CatchException_test.go
+12
-0
main.go
main.go
+7
-0
IfUtil.go
util/IfUtil.go
+3
-6
StringUtil_test.go
util/StringUtil_test.go
+4
-0
No files found.
PagePlus/PagePlus.go
View file @
cca51f65
...
...
@@ -9,8 +9,8 @@ import (
func
Page
(
params
[]
page
.
Param
,
pageNum
int
,
pageSize
int
,
m
interface
{},
data
interface
{},
orderBy
string
,
db
*
gorm
.
DB
)
*
page
.
Data
{
var
page
=
page
.
Data
{}
page
.
PageSize
=
util
.
If
Int
(
pageSize
==
0
,
10
,
pageSize
)
page
.
PageNum
=
util
.
If
Int
(
pageNum
==
0
,
1
,
pageNum
)
page
.
PageSize
=
util
.
If
(
pageSize
==
0
,
10
,
pageSize
)
page
.
PageNum
=
util
.
If
(
pageNum
==
0
,
1
,
pageNum
)
tx
:=
db
.
Session
(
&
gorm
.
Session
{
PrepareStmt
:
true
})
countTx
:=
tx
.
Model
(
&
m
)
.
Select
(
"count(1)"
)
if
params
!=
nil
{
...
...
exception/catch/CatchException_test.go
0 → 100644
View file @
cca51f65
package
catch
import
(
"errors"
"testing"
)
func
TestExceptionCatch
(
t
*
testing
.
T
)
{
defer
ExceptionCatch
(
nil
)
panic
(
errors
.
New
(
"错误"
))
}
main.go
View file @
cca51f65
package
main
import
(
"git.168cad.top/zhengqiuyun/rym-util/concurrent/GoroutineExecutor"
"git.168cad.top/zhengqiuyun/rym-util/conf"
"git.168cad.top/zhengqiuyun/rym-util/es"
"git.168cad.top/zhengqiuyun/rym-util/log"
...
...
@@ -10,6 +11,12 @@ import (
)
func
main
()
{
orderCode
:=
"2020202021212"
log
.
Debugf
(
"订单完成通知:%s"
,
orderCode
)
GoroutineExecutor
.
SynDo
(
func
()
{
panic
(
"真的错误了"
)
})
log
.
Debug
(
"测试"
)
log
.
Info
(
"测试"
)
log
.
Warn
(
"测试"
)
...
...
util/IfUtil.go
View file @
cca51f65
package
util
func
If
Int
(
isTrue
bool
,
a
,
b
int
)
int
{
func
If
[
K
any
](
isTrue
bool
,
a
,
b
K
)
K
{
if
isTrue
{
return
a
}
return
b
}
func
IfString
(
isTrue
bool
,
a
,
b
string
)
string
{
if
isTrue
{
return
a
}
return
b
func
IfNull
[
K
any
](
a
*
K
,
defaultValue
K
)
K
{
return
If
(
a
==
nil
,
defaultValue
,
*
a
)
}
util/StringUtil_test.go
View file @
cca51f65
...
...
@@ -13,4 +13,8 @@ func TestContainsForSplitComma(t *testing.T) {
func
TestStrval
(
t
*
testing
.
T
)
{
fmt
.
Printf
(
"转换内容:%s"
,
GetInterfaceToString
(
3.10
))
var
a
int
a
=
If
(
true
,
12
,
0
)
a
=
IfNull
(
&
a
,
0
)
fmt
.
Printf
(
"结果:%d"
,
a
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment