remove interfaces
This commit is contained in:
@@ -7,11 +7,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type CaptchaController interface {
|
||||
Show(*gin.Context) (*captcha.CaptchaResponse, error)
|
||||
}
|
||||
|
||||
type captchaControllerImpl struct {
|
||||
type CaptchaController struct {
|
||||
conf *config.Config
|
||||
captcha *captcha.Captcha
|
||||
}
|
||||
@@ -19,13 +15,13 @@ type captchaControllerImpl struct {
|
||||
func NewCaptchaController(
|
||||
conf *config.Config,
|
||||
captcha *captcha.Captcha,
|
||||
) CaptchaController {
|
||||
return &captchaControllerImpl{
|
||||
) *CaptchaController {
|
||||
return &CaptchaController{
|
||||
conf: conf,
|
||||
captcha: captcha,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *captchaControllerImpl) Show(ctx *gin.Context) (*captcha.CaptchaResponse, error) {
|
||||
func (c *CaptchaController) Show(ctx *gin.Context) (*captcha.CaptchaResponse, error) {
|
||||
return c.captcha.Generate()
|
||||
}
|
||||
|
||||
@@ -8,20 +8,16 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Dao interface {
|
||||
Release(context.Context, int, string) error
|
||||
}
|
||||
|
||||
type DaoImpl struct {
|
||||
type Dao struct {
|
||||
Conf *config.Config
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
func NewDao(DB *gorm.DB) Dao {
|
||||
return &DaoImpl{DB: DB}
|
||||
func NewDao(DB *gorm.DB) *Dao {
|
||||
return &Dao{DB: DB}
|
||||
}
|
||||
|
||||
func (c *DaoImpl) Release(ctx context.Context, a int, b string) error {
|
||||
func (c *Dao) Release(ctx context.Context, a int, b string) error {
|
||||
if a == 20 {
|
||||
return errors.New("A cant't be 20 ")
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestDaoImpl_Release(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
c := &DaoImpl{
|
||||
c := &Dao{
|
||||
Conf: tt.fields.Conf,
|
||||
DB: tt.fields.DB,
|
||||
}
|
||||
|
||||
@@ -4,13 +4,10 @@ import (
|
||||
"atom/modules/system/dao"
|
||||
)
|
||||
|
||||
type SystemService interface {
|
||||
}
|
||||
|
||||
type systemService struct {
|
||||
type SystemService struct {
|
||||
dao dao.Dao
|
||||
}
|
||||
|
||||
func NewSystemService(dao dao.Dao) SystemService {
|
||||
return &systemService{dao: dao}
|
||||
func NewSystemService(dao dao.Dao) *SystemService {
|
||||
return &SystemService{dao: dao}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user