修改成绩单会创建新志愿单
This commit is contained in:
parent
fff2833d29
commit
c1a0b60218
|
|
@ -21,6 +21,7 @@ import (
|
||||||
|
|
||||||
type UserScoreService struct {
|
type UserScoreService struct {
|
||||||
yxUserScoreService *service.YxUserScoreService
|
yxUserScoreService *service.YxUserScoreService
|
||||||
|
yxVolunteerService *service.YxVolunteerService
|
||||||
yxCalculationMajorService *service.YxCalculationMajorService
|
yxCalculationMajorService *service.YxCalculationMajorService
|
||||||
mapper *mapper.YxUserScoreMapper
|
mapper *mapper.YxUserScoreMapper
|
||||||
}
|
}
|
||||||
|
|
@ -193,6 +194,8 @@ func (s *UserScoreService) SaveUserScore(req *dto.SaveScoreRequest) (vo.UserScor
|
||||||
return vo.UserScoreVO{}, fmt.Errorf("缓存成绩记录失败: %w", err)
|
return vo.UserScoreVO{}, fmt.Errorf("缓存成绩记录失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 创建志愿表
|
||||||
|
s.yxVolunteerService.CreateByScoreId(entityItem.ID, req.CreateBy)
|
||||||
return userScoreVO, nil
|
return userScoreVO, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import "time"
|
||||||
type YxVolunteer struct {
|
type YxVolunteer struct {
|
||||||
ID string `gorm:"column:id;primaryKey" json:"id"`
|
ID string `gorm:"column:id;primaryKey" json:"id"`
|
||||||
VolunteerName string `gorm:"column:volunteer_name" json:"volunteerName"` // 志愿单名称
|
VolunteerName string `gorm:"column:volunteer_name" json:"volunteerName"` // 志愿单名称
|
||||||
ScoreID string `gorm:"column:score_id" json:"scoreId"` // 使用成绩id
|
ScoreId string `gorm:"column:score_id" json:"scoreId"` // 使用成绩id
|
||||||
CreateType string `gorm:"column:create_type;default:1" json:"createType"` // 生成类型(1.手动生成,2.智能生成)
|
CreateType string `gorm:"column:create_type;default:1" json:"createType"` // 生成类型(1.手动生成,2.智能生成)
|
||||||
State string `gorm:"column:state;default:0" json:"state"` // 志愿单状态(0-否,1.正在使用,2-历史)
|
State string `gorm:"column:state;default:0" json:"state"` // 志愿单状态(0-否,1.正在使用,2-历史)
|
||||||
CreateBy string `gorm:"column:create_by" json:"createBy"` // 创建人
|
CreateBy string `gorm:"column:create_by" json:"createBy"` // 创建人
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,10 @@ import (
|
||||||
|
|
||||||
type YxVolunteerMapper struct{}
|
type YxVolunteerMapper struct{}
|
||||||
|
|
||||||
|
func (m *YxVolunteerMapper) CloseOtherVolunteer(userId string) {
|
||||||
|
config.DB.Model(&entity.YxVolunteer{}).Where("create_by = ? ", userId).Updates(map[string]interface{}{"state": "0"})
|
||||||
|
}
|
||||||
|
|
||||||
func NewYxVolunteerMapper() *YxVolunteerMapper {
|
func NewYxVolunteerMapper() *YxVolunteerMapper {
|
||||||
return &YxVolunteerMapper{}
|
return &YxVolunteerMapper{}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ package service
|
||||||
import (
|
import (
|
||||||
"server/modules/yx/entity"
|
"server/modules/yx/entity"
|
||||||
"server/modules/yx/mapper"
|
"server/modules/yx/mapper"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
@ -64,3 +65,24 @@ func (s *YxVolunteerService) BatchUpsert(items []entity.YxVolunteer, updateColum
|
||||||
func (s *YxVolunteerService) BatchDelete(ids []string) error {
|
func (s *YxVolunteerService) BatchDelete(ids []string) error {
|
||||||
return s.mapper.BatchDelete(ids)
|
return s.mapper.BatchDelete(ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据ScoreId创建新志愿表
|
||||||
|
func (s *YxVolunteerService) CreateByScoreId(scoreId string, userId string) error {
|
||||||
|
volunteer := entity.YxVolunteer{}
|
||||||
|
volunteer.ID = uuid.New().String()
|
||||||
|
|
||||||
|
// 志愿表名称格式 时间戳 20260101134501志愿表
|
||||||
|
volunteer.VolunteerName = time.Now().Format("20060102150405") + "志愿表"
|
||||||
|
|
||||||
|
volunteer.ScoreId = scoreId
|
||||||
|
volunteer.CreateType = "1"
|
||||||
|
volunteer.State = "1"
|
||||||
|
volunteer.CreateBy = userId
|
||||||
|
volunteer.CreateTime = time.Now()
|
||||||
|
volunteer.UpdateTime = time.Now()
|
||||||
|
|
||||||
|
// 先关闭当前用户其他志愿单
|
||||||
|
s.mapper.CloseOtherVolunteer(userId)
|
||||||
|
// 创建志愿表
|
||||||
|
return s.mapper.Create(&volunteer)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue