2022-06-08 10:19:45 +00:00
|
|
|
/*
|
|
|
|
* @Author: LinkLeong link@icewhale.com
|
|
|
|
* @Date: 2021-09-30 18:18:14
|
|
|
|
* @LastEditors: LinkLeong
|
|
|
|
* @LastEditTime: 2022-06-02 18:00:57
|
|
|
|
* @FilePath: /CasaOS/service/rely.go
|
|
|
|
* @Description:
|
|
|
|
* @Website: https://www.casaos.io
|
|
|
|
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
|
|
|
*/
|
2021-09-26 02:35:02 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
2021-09-27 06:17:36 +00:00
|
|
|
model2 "github.com/IceWhaleTech/CasaOS/service/model"
|
2021-09-26 02:35:02 +00:00
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
type RelyService interface {
|
|
|
|
Create(rely model2.RelyDBModel)
|
|
|
|
Delete(id string)
|
|
|
|
GetInfo(id string) model2.RelyDBModel
|
|
|
|
}
|
|
|
|
|
|
|
|
type relyService struct {
|
2022-06-08 10:19:45 +00:00
|
|
|
db *gorm.DB
|
2021-09-26 02:35:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *relyService) Create(rely model2.RelyDBModel) {
|
|
|
|
|
|
|
|
r.db.Create(&rely)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取我的应用列表
|
|
|
|
func (r *relyService) GetInfo(id string) model2.RelyDBModel {
|
|
|
|
var m model2.RelyDBModel
|
|
|
|
r.db.Where("custom_id = ?", id).First(&m)
|
2022-07-22 03:02:11 +00:00
|
|
|
|
|
|
|
// @tiger - 作为出参不应该直接返回数据库内的格式(见类似问题的注释)
|
2021-09-26 02:35:02 +00:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *relyService) Delete(id string) {
|
|
|
|
var c model2.RelyDBModel
|
|
|
|
r.db.Where("custom_id = ?", id).Delete(&c)
|
|
|
|
}
|
|
|
|
|
2022-06-08 10:19:45 +00:00
|
|
|
func NewRelyService(db *gorm.DB) RelyService {
|
|
|
|
return &relyService{db: db}
|
2021-09-26 02:35:02 +00:00
|
|
|
}
|