|
@@ -9,7 +9,6 @@ import (
|
|
"github.com/flipped-aurora/gin-vue-admin/server/service"
|
|
"github.com/flipped-aurora/gin-vue-admin/server/service"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gin-gonic/gin"
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap"
|
|
- "time"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
type UnitApi struct {
|
|
type UnitApi struct {
|
|
@@ -29,25 +28,25 @@ var unitService = service.ServiceGroupApp.AutoCodeServiceGroup.UnitService
|
|
func (unitApi *UnitApi) CreateUnit(c *gin.Context) {
|
|
func (unitApi *UnitApi) CreateUnit(c *gin.Context) {
|
|
var unit autocode.Unit
|
|
var unit autocode.Unit
|
|
_ = c.ShouldBindJSON(&unit)
|
|
_ = c.ShouldBindJSON(&unit)
|
|
- if err, nowUnit := unitService.GetUnitTop(); err != nil {
|
|
|
|
- //新建期数
|
|
|
|
- unit.Period = time.Now().Format("20060102150405")
|
|
|
|
- integral := 1000
|
|
|
|
- unit.UnitIntegral = &integral
|
|
|
|
- unit.UnitMaxIntegral = &integral
|
|
|
|
- unitService.CreateUnit(unit)
|
|
|
|
- response.OkWithMessage("创建成功", c)
|
|
|
|
- } else {
|
|
|
|
- unit.UnitIntegral = nowUnit.UnitMaxIntegral
|
|
|
|
- unit.UnitMaxIntegral = nowUnit.UnitMaxIntegral
|
|
|
|
- unit.Period = nowUnit.Period
|
|
|
|
- if err := unitService.CreateUnit(unit); err != nil {
|
|
|
|
- global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
|
|
|
|
- response.FailWithMessage("创建失败", c)
|
|
|
|
- } else {
|
|
|
|
- response.OkWithMessage("创建成功", c)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //if err, nowUnit := unitService.GetUnitTop(); err != nil {
|
|
|
|
+ //新建期数
|
|
|
|
+ //unit.Period = time.Now().Format("20060102150405")
|
|
|
|
+ integral := 0
|
|
|
|
+ unit.UnitIntegral = &integral
|
|
|
|
+ unit.UnitMaxIntegral = &integral
|
|
|
|
+ unitService.CreateUnit(unit)
|
|
|
|
+ response.OkWithMessage("创建成功", c)
|
|
|
|
+ //} else {
|
|
|
|
+ // unit.UnitIntegral = nowUnit.UnitMaxIntegral
|
|
|
|
+ // unit.UnitMaxIntegral = nowUnit.UnitMaxIntegral
|
|
|
|
+ // unit.Period = nowUnit.Period
|
|
|
|
+ // if err := unitService.CreateUnit(unit); err != nil {
|
|
|
|
+ // global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
|
|
|
|
+ // response.FailWithMessage("创建失败", c)
|
|
|
|
+ // } else {
|
|
|
|
+ // response.OkWithMessage("创建成功", c)
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
}
|
|
}
|
|
|
|
|
|
// DeleteUnit 删除Unit
|
|
// DeleteUnit 删除Unit
|