新增银行列表
This commit is contained in:
parent
fade9ea4a7
commit
fd749b9dbc
40
api/controller/bank.go
Normal file
40
api/controller/bank.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"hospital-admin-api/api/dao"
|
||||||
|
"hospital-admin-api/api/requests"
|
||||||
|
"hospital-admin-api/api/responses"
|
||||||
|
"hospital-admin-api/api/responses/basicBankResponse"
|
||||||
|
"hospital-admin-api/global"
|
||||||
|
"hospital-admin-api/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Bank struct{}
|
||||||
|
|
||||||
|
// GetBankList 获取银行列表
|
||||||
|
func (b *Bank) GetBankList(c *gin.Context) {
|
||||||
|
bankRequest := requests.BankRequest{}
|
||||||
|
if err := c.ShouldBind(&bankRequest.GetBankList); err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 参数验证
|
||||||
|
if err := global.Validate.Struct(bankRequest.GetBankList); err != nil {
|
||||||
|
responses.FailWithMessage(utils.Translate(err), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
basicBankDao := dao.BasicBankDao{}
|
||||||
|
|
||||||
|
basicBank, err := basicBankDao.GetBasicBankListByStruct(bankRequest.GetBankList)
|
||||||
|
if err != nil {
|
||||||
|
responses.Ok(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理返回值
|
||||||
|
getBasicBankListResponse := basicBankResponse.GetBasicBankListResponse(basicBank)
|
||||||
|
responses.OkWithData(getBasicBankListResponse, c)
|
||||||
|
}
|
||||||
@ -28,4 +28,5 @@ type basic struct {
|
|||||||
Department // 科室管理
|
Department // 科室管理
|
||||||
Hospital // 医院管理
|
Hospital // 医院管理
|
||||||
DiseaseClassExpertise // 专长管理
|
DiseaseClassExpertise // 专长管理
|
||||||
|
Bank // 银行管理
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,6 +36,6 @@ func (b *DiseaseClassExpertise) GetExpertiseList(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 处理返回值
|
// 处理返回值
|
||||||
getDepartmentListResponse := diseaseClassExpertiseResponse.GetDiseaseClassExpertiseListResponse(diseaseClassExpertises)
|
getExpertiseListResponse := diseaseClassExpertiseResponse.GetDiseaseClassExpertiseListResponse(diseaseClassExpertises)
|
||||||
responses.OkWithData(getDepartmentListResponse, c)
|
responses.OkWithData(getExpertiseListResponse, c)
|
||||||
}
|
}
|
||||||
|
|||||||
92
api/dao/basicBank.go
Normal file
92
api/dao/basicBank.go
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"hospital-admin-api/api/model"
|
||||||
|
"hospital-admin-api/api/requests"
|
||||||
|
"hospital-admin-api/global"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BasicBankDao struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBasicBankById 获取专长-专长id
|
||||||
|
func (r *BasicBankDao) GetBasicBankById(bankId int64) (m *model.BasicBank, err error) {
|
||||||
|
err = global.Db.First(&m, bankId).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteBasicBank 删除专长
|
||||||
|
func (r *BasicBankDao) DeleteBasicBank(tx *gorm.DB, maps interface{}) error {
|
||||||
|
err := tx.Where(maps).Delete(&model.BasicBank{}).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditBasicBank 修改专长
|
||||||
|
func (r *BasicBankDao) EditBasicBank(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||||
|
err := tx.Model(&model.BasicBank{}).Where(maps).Updates(data).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditBasicBankById 修改专长-医生id
|
||||||
|
func (r *BasicBankDao) EditBasicBankById(tx *gorm.DB, bankId int64, data interface{}) error {
|
||||||
|
err := tx.Model(&model.BasicBank{}).Where("bank_id = ?", bankId).Updates(data).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBasicBankList 获取专长列表
|
||||||
|
func (r *BasicBankDao) GetBasicBankList(maps interface{}) (m []*model.BasicBank, err error) {
|
||||||
|
err = global.Db.Where(maps).Find(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddBasicBank 新增专长
|
||||||
|
func (r *BasicBankDao) AddBasicBank(tx *gorm.DB, model *model.BasicBank) (*model.BasicBank, error) {
|
||||||
|
if err := tx.Create(model).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return model, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddBasicBankByMap 新增专长-map
|
||||||
|
func (r *BasicBankDao) AddBasicBankByMap(tx *gorm.DB, data map[string]interface{}) (*model.BasicBank, error) {
|
||||||
|
userDoctorInfo := &model.BasicBank{}
|
||||||
|
if err := tx.Model(&model.BasicBank{}).Create(data).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return userDoctorInfo, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBasicBankListByStruct 获取专长列表
|
||||||
|
func (r *BasicBankDao) GetBasicBankListByStruct(bankRequest requests.GetBankList) (m []*model.BasicBank, err error) {
|
||||||
|
result := global.Db
|
||||||
|
|
||||||
|
if bankRequest.BankCode != "" {
|
||||||
|
result = result.Where("bank_code = ?", bankRequest.BankCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
if bankRequest.BankName != "" {
|
||||||
|
result = result.Where("bank_name like ?", "%"+bankRequest.BankName+"%")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = result.Find(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
14
api/model/basicBank.go
Normal file
14
api/model/basicBank.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
type BasicBank struct {
|
||||||
|
BankId int64 `gorm:"column:bank_id;type:bigint(19);primary_key;comment:主键id" json:"bank_id"`
|
||||||
|
BankCode string `gorm:"column:bank_code;type:varchar(255);comment:银行编码" json:"bank_code"`
|
||||||
|
BankName string `gorm:"column:bank_name;type:varchar(50);comment:银行名称" json:"bank_name"`
|
||||||
|
BankIconPath string `gorm:"column:bank_icon_path;type:varchar(255);comment:银行图标地址" json:"bank_icon_path"`
|
||||||
|
BankImgPath string `gorm:"column:bank_img_path;type:varchar(255);comment:银行图片地址" json:"bank_img_path"`
|
||||||
|
Model
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *BasicBank) TableName() string {
|
||||||
|
return "gdxz_basic_bank"
|
||||||
|
}
|
||||||
11
api/requests/bank.go
Normal file
11
api/requests/bank.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package requests
|
||||||
|
|
||||||
|
type BankRequest struct {
|
||||||
|
GetBankList // 获取银行列表
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBankList 获取银行列表
|
||||||
|
type GetBankList struct {
|
||||||
|
BankCode string `json:"bank_code" form:"bank_code" label:"主键id"`
|
||||||
|
BankName string `json:"bank_name" form:"bank_name" label:"银行名称"`
|
||||||
|
}
|
||||||
56
api/responses/basicBankResponse/basicBank.go
Normal file
56
api/responses/basicBankResponse/basicBank.go
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package basicBankResponse
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hospital-admin-api/api/model"
|
||||||
|
"hospital-admin-api/config"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BasicBank struct {
|
||||||
|
BankId string `json:"bank_id"` // 主键
|
||||||
|
BankCode string `gorm:"column:bank_code;type:varchar(255);comment:银行编码" json:"bank_code"` // 银行编码
|
||||||
|
BankName string `gorm:"column:bank_name;type:varchar(50);comment:银行名称" json:"bank_name"` // 银行名称
|
||||||
|
BankIconPath string `gorm:"column:bank_icon_path;type:varchar(255);comment:银行图标地址" json:"bank_icon_path"` // 银行图标地址
|
||||||
|
BankImgPath string `gorm:"column:bank_img_path;type:varchar(255);comment:银行图片地址" json:"bank_img_path"` // 银行图片地址
|
||||||
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
|
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// BasicBankResponse 银行详情
|
||||||
|
func BasicBankResponse(basicBank *model.BasicBank) *BasicBank {
|
||||||
|
return &BasicBank{
|
||||||
|
BankId: strconv.FormatInt(basicBank.BankId, 10),
|
||||||
|
BankCode: basicBank.BankCode,
|
||||||
|
BankName: basicBank.BankName,
|
||||||
|
BankIconPath: config.C.Oss.OssCustomDomainName + basicBank.BankIconPath,
|
||||||
|
BankImgPath: config.C.Oss.OssCustomDomainName + basicBank.BankImgPath,
|
||||||
|
CreatedAt: basicBank.CreatedAt,
|
||||||
|
UpdatedAt: basicBank.UpdatedAt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBasicBankListResponse 获取银行列表
|
||||||
|
func GetBasicBankListResponse(basicBank []*model.BasicBank) []BasicBank {
|
||||||
|
// 处理返回值
|
||||||
|
getBasicBankListResponses := make([]BasicBank, len(basicBank))
|
||||||
|
|
||||||
|
if len(basicBank) > 0 {
|
||||||
|
for i, v := range basicBank {
|
||||||
|
// 将原始结构体转换为新结构体
|
||||||
|
getBasicBankListResponse := BasicBank{
|
||||||
|
BankId: strconv.FormatInt(v.BankId, 10),
|
||||||
|
BankCode: v.BankCode,
|
||||||
|
BankName: v.BankName,
|
||||||
|
BankIconPath: config.C.Oss.OssCustomDomainName + v.BankIconPath,
|
||||||
|
BankImgPath: config.C.Oss.OssCustomDomainName + v.BankImgPath,
|
||||||
|
CreatedAt: v.CreatedAt,
|
||||||
|
UpdatedAt: v.UpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将转换后的结构体添加到新切片中
|
||||||
|
getBasicBankListResponses[i] = getBasicBankListResponse
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getBasicBankListResponses
|
||||||
|
}
|
||||||
@ -80,6 +80,55 @@ func adminRouter(r *gin.Engine, api controller.Api) {
|
|||||||
|
|
||||||
// basicRouter 基础数据-验证权限
|
// basicRouter 基础数据-验证权限
|
||||||
func basicRouter(r *gin.Engine, api controller.Api) {
|
func basicRouter(r *gin.Engine, api controller.Api) {
|
||||||
|
basicGroup := r.Group("/basic")
|
||||||
|
|
||||||
|
// 科室管理-基础数据
|
||||||
|
departmentGroup := basicGroup.Group("/department")
|
||||||
|
{
|
||||||
|
// 自定义科室
|
||||||
|
customGroup := departmentGroup.Group("/custom")
|
||||||
|
{
|
||||||
|
// 获取自定义科室列表
|
||||||
|
customGroup.GET("/list", api.Department.GetDepartmentCustomList)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 医院管理-基础数据
|
||||||
|
hospitalGroup := basicGroup.Group("/hospital")
|
||||||
|
{
|
||||||
|
// 获取医院列表-限制条数
|
||||||
|
hospitalGroup.GET("/list", api.Hospital.GetHospitalLimit)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 专长管理-基础数据
|
||||||
|
expertiseGroup := basicGroup.Group("/expertise")
|
||||||
|
{
|
||||||
|
// 获取专长列表
|
||||||
|
expertiseGroup.GET("/list", api.DiseaseClassExpertise.GetExpertiseList)
|
||||||
|
|
||||||
|
// 获取专长列表-分页
|
||||||
|
|
||||||
|
// 专长详情
|
||||||
|
|
||||||
|
// 修改专长
|
||||||
|
|
||||||
|
// 新增专长
|
||||||
|
}
|
||||||
|
|
||||||
|
// 银行管理-基础数据
|
||||||
|
bankGroup := basicGroup.Group("/bank")
|
||||||
|
{
|
||||||
|
// 获取银行列表
|
||||||
|
bankGroup.GET("/list", api.Bank.GetBankList)
|
||||||
|
|
||||||
|
// 获取银行列表-分页
|
||||||
|
|
||||||
|
// 银行详情
|
||||||
|
|
||||||
|
// 修改银行
|
||||||
|
|
||||||
|
// 新增银行
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// privateRouter 私有路由-验证权限
|
// privateRouter 私有路由-验证权限
|
||||||
@ -266,36 +315,4 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
|||||||
// doctorGroup.PUT("/:post_id", api.Post.PutPost)
|
// doctorGroup.PUT("/:post_id", api.Post.PutPost)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 科室管理-基础数据
|
|
||||||
departmentGroup := adminGroup.Group("/department")
|
|
||||||
{
|
|
||||||
// 自定义科室
|
|
||||||
customGroup := departmentGroup.Group("/custom")
|
|
||||||
{
|
|
||||||
// 获取自定义科室列表
|
|
||||||
customGroup.GET("/list", api.Department.GetDepartmentCustomList)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 医院管理-基础数据
|
|
||||||
hospitalGroup := adminGroup.Group("/hospital")
|
|
||||||
{
|
|
||||||
// 获取医院列表-限制条数
|
|
||||||
hospitalGroup.GET("/list", api.Hospital.GetHospitalLimit)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 专长管理-基础数据
|
|
||||||
expertiseGroup := adminGroup.Group("/expertise")
|
|
||||||
{
|
|
||||||
// 获取专长列表
|
|
||||||
expertiseGroup.GET("/list", api.DiseaseClassExpertise.GetExpertiseList)
|
|
||||||
|
|
||||||
// 获取专长列表-分页
|
|
||||||
|
|
||||||
// 专长详情
|
|
||||||
|
|
||||||
// 修改专长
|
|
||||||
|
|
||||||
// 新增专长
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user