()
| 73 | } |
| 74 | |
| 75 | func (u *MysqlService) ListDBOption() ([]dto.MysqlOption, error) { |
| 76 | mysqls, err := mysqlRepo.List() |
| 77 | if err != nil { |
| 78 | return nil, err |
| 79 | } |
| 80 | |
| 81 | databases, err := databaseRepo.GetList(databaseRepo.WithTypeList("mysql,mariadb")) |
| 82 | if err != nil { |
| 83 | return nil, err |
| 84 | } |
| 85 | var dbs []dto.MysqlOption |
| 86 | for _, mysql := range mysqls { |
| 87 | var item dto.MysqlOption |
| 88 | if err := copier.Copy(&item, &mysql); err != nil { |
| 89 | return nil, buserr.WithDetail("ErrStructTransform", err.Error(), nil) |
| 90 | } |
| 91 | item.Database = mysql.MysqlName |
| 92 | for _, database := range databases { |
| 93 | if database.Name == item.Database { |
| 94 | item.Type = database.Type |
| 95 | } |
| 96 | } |
| 97 | dbs = append(dbs, item) |
| 98 | } |
| 99 | return dbs, err |
| 100 | } |
| 101 | |
| 102 | func (u *MysqlService) Create(ctx context.Context, req dto.MysqlDBCreate) (*model.DatabaseMysql, error) { |
| 103 | if cmd.CheckIllegal(req.Name, req.Username, req.Password, req.Format, req.Collation, req.Permission) { |
nothing calls this directly
no test coverage detected