Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-user
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
chenweijian
hilo-user
Commits
a018afb7
Commit
a018afb7
authored
Feb 24, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:去掉service
parent
16c1daec
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
68 deletions
+6
-68
headwear.go
domain/service/headwear_s/headwear.go
+2
-3
noble.go
domain/service/noble_s/noble.go
+2
-3
ride.go
domain/service/ride_s/ride.go
+2
-3
service.go
domain/service/service.go
+0
-59
No files found.
domain/service/headwear_s/headwear.go
View file @
a018afb7
...
...
@@ -6,18 +6,17 @@ import (
"git.hilo.cn/hilo-common/resource/mysql"
"hilo-user/_const/enum/headwear_e"
"hilo-user/domain/model/user_m"
"hilo-user/domain/service"
"hilo-user/myerr"
"hilo-user/myerr/bizerr"
"time"
)
type
HeadwearService
struct
{
svc
*
service
.
Service
svc
*
domain
.
Service
}
func
NewHeadwearService
(
myContext
*
mycontext
.
MyContext
)
*
HeadwearService
{
svc
:=
service
.
CreateService
(
myContext
)
svc
:=
domain
.
CreateService
(
myContext
)
return
&
HeadwearService
{
svc
}
}
...
...
domain/service/noble_s/noble.go
View file @
a018afb7
...
...
@@ -10,7 +10,6 @@ import (
"hilo-user/domain/model/msg_m"
"hilo-user/domain/model/noble_m"
"hilo-user/domain/model/user_m"
"hilo-user/domain/service"
"hilo-user/myerr"
"hilo-user/myerr/bizerr"
"strconv"
...
...
@@ -18,11 +17,11 @@ import (
)
type
NobleService
struct
{
svc
*
service
.
Service
svc
*
domain
.
Service
}
func
NewNobleService
(
myContext
*
mycontext
.
MyContext
)
*
NobleService
{
svc
:=
service
.
CreateService
(
myContext
)
svc
:=
domain
.
CreateService
(
myContext
)
return
&
NobleService
{
svc
}
}
...
...
domain/service/ride_s/ride.go
View file @
a018afb7
...
...
@@ -6,16 +6,15 @@ import (
"git.hilo.cn/hilo-common/resource/mysql"
"hilo-user/_const/enum/property_e"
"hilo-user/domain/model/user_m"
"hilo-user/domain/service"
"time"
)
type
RideService
struct
{
svc
*
service
.
Service
svc
*
domain
.
Service
}
func
NewRideService
(
myContext
*
mycontext
.
MyContext
)
*
RideService
{
svc
:=
service
.
CreateService
(
myContext
)
svc
:=
domain
.
CreateService
(
myContext
)
return
&
RideService
{
svc
}
}
...
...
domain/service/service.go
deleted
100755 → 0
View file @
16c1daec
package
service
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/resource/redisCli"
"runtime/debug"
)
type
Service
struct
{
*
domain
.
CtxAndDb
}
func
(
service
*
Service
)
getMyContext
()
*
mycontext
.
MyContext
{
return
service
.
MyContext
}
/**
* 创建服务
* @param
* @return
**/
func
CreateService
(
myContext
*
mycontext
.
MyContext
)
*
Service
{
if
myContext
==
nil
{
return
&
Service
{
CtxAndDb
:
&
domain
.
CtxAndDb
{
Db
:
mysql
.
Db
,
MyContext
:
mycontext
.
CreateMyContext
(
nil
),
Redis
:
redisCli
.
GetRedis
(),
}}
}
else
{
return
&
Service
{
CtxAndDb
:
&
domain
.
CtxAndDb
{
Db
:
mysql
.
Db
,
MyContext
:
myContext
,
Redis
:
redisCli
.
GetRedis
(),
}}
}
}
//事务钩子回调,遇到错误,异常则回调,写service都需要钩子回调
func
(
service
*
Service
)
Transactional
(
callback
func
()
error
)
error
{
//异常回调
defer
func
()
{
if
err
:=
recover
();
err
!=
nil
{
service
.
Log
.
Errorf
(
"doTransactional SYSTEM ACTION PANIC: %v, stack: %v"
,
err
,
string
(
debug
.
Stack
()))
service
.
Db
.
Rollback
()
//为了防止给controller层造成数据错误,继续抛恐慌
panic
(
err
)
}
}()
service
.
CtxAndDb
.
Db
=
mysql
.
Db
.
Begin
()
err
:=
callback
()
if
err
!=
nil
{
service
.
Db
.
Rollback
()
return
err
}
//提交
return
service
.
Db
.
Commit
()
.
Error
}
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