123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package autocode
- import (
- "github.com/flipped-aurora/gin-vue-admin/server/global"
- "github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
- autoCodeReq "github.com/flipped-aurora/gin-vue-admin/server/model/autocode/request"
- "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
- )
- type ProblemReplyService struct {
- }
- func (problemReplyService *ProblemReplyService) CreateProblemReply(problemReply autocode.ProblemReply) (err error) {
- err = global.GVA_DB.Create(&problemReply).Error
- return err
- }
- func (problemReplyService *ProblemReplyService) DeleteProblemReply(problemReply autocode.ProblemReply) (err error) {
- err = global.GVA_DB.Delete(&problemReply).Error
- return err
- }
- func (problemReplyService *ProblemReplyService) DeleteProblemReplyByIds(ids request.IdsReq) (err error) {
- err = global.GVA_DB.Delete(&[]autocode.ProblemReply{}, "id in ?", ids.Ids).Error
- return err
- }
- func (problemReplyService *ProblemReplyService) UpdateProblemReply(problemReply autocode.ProblemReply) (err error) {
- err = global.GVA_DB.Save(&problemReply).Error
- return err
- }
- func (problemReplyService *ProblemReplyService) GetProblemReply(id uint) (err error, problemReply autocode.ProblemReply) {
- err = global.GVA_DB.Where("id = ?", id).First(&problemReply).Error
- return
- }
- func (problemReplyService *ProblemReplyService) GetProblemReplyInfoList(info autoCodeReq.ProblemReplySearch) (err error, list interface{}, total int64) {
- limit := info.PageSize
- offset := info.PageSize * (info.Page - 1)
-
- db := global.GVA_DB.Model(&autocode.ProblemReply{})
- var problemReplys []autocode.ProblemReply
- if info.ProblemId != nil && *info.ProblemId != 0 {
- db.Where("problem_id=?", info.ProblemId)
- }
-
- err = db.Count(&total).Error
- err = db.Limit(limit).Offset(offset).Find(&problemReplys).Error
- return err, problemReplys, total
- }
|