|
@@ -20,6 +20,7 @@ type surplus struct {
|
|
|
Id int64 `xorm:"id" json:"id"`
|
|
|
PastureId int64 `xorm:"pastureId" json:"pastureId"`
|
|
|
Surplus string `xorm:"surplus" json:"surplus"`
|
|
|
+ FeedId string `xorm:"feedId" json:"feedId"`
|
|
|
}
|
|
|
|
|
|
func AddSurplus(c *gin.Context) {
|
|
@@ -35,7 +36,7 @@ func AddSurplus(c *gin.Context) {
|
|
|
tx.Begin()
|
|
|
|
|
|
if s.Id > 0 {
|
|
|
- _, err := tx.Exec(` update surplus set surplus = ? where id = ? `, s.Surplus, s.Id)
|
|
|
+ _, err := tx.Exec(` update surplus set surplus = ?,feedId = ? where id = ? `, s.Surplus, s.FeedId, s.Id)
|
|
|
if err != nil {
|
|
|
log.Println("AddSurplus-error-5: ", err)
|
|
|
tx.Rollback()
|
|
@@ -74,7 +75,8 @@ func AddSurplus(c *gin.Context) {
|
|
|
ids = time.Now().UnixNano()
|
|
|
logging.Info("create SnowIds err", err)
|
|
|
}
|
|
|
- _, err = tx.Exec(`insert into feed(id,pastureid,feedcode,fname,fclass,fclassid,backup3)values(?,?,?,?,?,(select id from feedclass where pastureid = ? and fcname = ? ),?)`,
|
|
|
+ _, err = tx.Exec(`insert into feed(id,pastureid,feedcode,fname,fclass,fclassid,backup3,is_surplus)values(?,?,?,?,?,
|
|
|
+ (select id from feedclass where pastureid = ? and fcname = ? ),?,1)`,
|
|
|
ids, s.PastureId, s.Surplus+"_剩料", s.Surplus+"_剩料", "剩料", s.PastureId, "剩料", s1.Id)
|
|
|
if err != nil {
|
|
|
log.Println("AddSurplus-error-4: ", err)
|