package v1
|
|
import (
|
"aps_crm/model/request"
|
"aps_crm/model/response"
|
"aps_crm/pkg/contextx"
|
"aps_crm/pkg/ecode"
|
"aps_crm/service"
|
"github.com/gin-gonic/gin"
|
"strconv"
|
)
|
|
type BankAccountApi struct{}
|
|
// Add
|
// @Tags 银行账户管理
|
// @Summary 添加银行账户
|
// @Produce application/json
|
// @Param object body request.AddBankAccount true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/bankAccount/add [post]
|
func (s *BankAccountApi) Add(c *gin.Context) {
|
var params request.AddBankAccount
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
errCode := service.NewBankAccountService().AddBankAccount(¶ms.BankAccount)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// Delete
|
// @Tags 银行账户管理
|
// @Summary 删除银行账户
|
// @Produce application/json
|
// @Param id path int true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/bankAccount/delete/{id} [delete]
|
func (s *BankAccountApi) Delete(c *gin.Context) {
|
ctx, ok := contextx.NewContext(c, nil)
|
if !ok {
|
return
|
}
|
|
id, _ := strconv.Atoi(c.Param("id"))
|
errCode := service.NewBankAccountService().DeleteBankAccount(id)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// Update
|
// @Tags 银行账户管理
|
// @Summary 更新银行账户
|
// @Produce application/json
|
// @Param object body request.UpdateBankAccount true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/bankAccount/update [put]
|
func (s *BankAccountApi) Update(c *gin.Context) {
|
var params request.UpdateBankAccount
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
if params.Id == 0 {
|
ctx.Fail(ecode.ParamsErr)
|
}
|
params.BankAccount.Id = params.Id
|
|
errCode := service.NewBankAccountService().UpdateBankAccount(¶ms.BankAccount)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// List
|
// @Tags 银行账户管理
|
// @Summary 获取银行账户列表
|
// @Produce application/json
|
// @Param object query request.GetBankAccountList true "参数"
|
// @Success 200 {object} response.ListResponse{data=[]model.BankAccount}
|
// @Router /api/bankAccount/list [get]
|
func (s *BankAccountApi) List(c *gin.Context) {
|
var params request.GetBankAccountList
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
bankAccount, total, errCode := service.NewBankAccountService().GetBankAccountList()
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.OkWithDetailed(response.ListResponse{
|
Data: bankAccount,
|
Count: total,
|
})
|
}
|