feat: new suffix group auto-creates one workspace row
新建分组即自动带一行工作行(双击命名、上传模板/向下插入行/↑/↓/×按钮齐全), 消灭空分组死步骤;集成测试清理只清自建数据的口径下断言按行名定位
This commit is contained in:
@@ -608,14 +608,30 @@ func (a *BusinessAPI) createSuffixGroup(c *gin.Context) {
|
||||
}
|
||||
var order sql.NullInt64
|
||||
_ = a.db.QueryRowContext(c, "SELECT MAX(sort_order) FROM suffix_groups").Scan(&order)
|
||||
res, err := a.db.ExecContext(c,
|
||||
tx, err := a.db.BeginTx(c, nil)
|
||||
if err != nil {
|
||||
apiError(c, 500, "internal_error", "分组创建失败")
|
||||
return
|
||||
}
|
||||
defer tx.Rollback()
|
||||
gres, err := tx.ExecContext(c,
|
||||
"INSERT INTO suffix_groups(name,sort_order) VALUES(?,?)", name, order.Int64+1)
|
||||
if err != nil {
|
||||
apiError(c, 500, "internal_error", "分组创建失败")
|
||||
return
|
||||
}
|
||||
id, _ := res.LastInsertId()
|
||||
c.JSON(201, gin.H{"data": gin.H{"id": id, "name": name, "suffixes": []suffixOverview{}}})
|
||||
gid, _ := gres.LastInsertId()
|
||||
// 新建分组自动带一行工作行,按钮齐全,双击即可命名。
|
||||
if _, err := tx.ExecContext(c,
|
||||
"INSERT INTO suffixes(group_id,name,sort_order) VALUES(?,'',0)", gid); err != nil {
|
||||
apiError(c, 500, "internal_error", "分组创建失败")
|
||||
return
|
||||
}
|
||||
if err := tx.Commit(); err != nil {
|
||||
apiError(c, 500, "internal_error", "分组创建失败")
|
||||
return
|
||||
}
|
||||
c.JSON(201, gin.H{"data": gin.H{"id": gid, "name": name, "suffixes": []suffixOverview{}}})
|
||||
}
|
||||
|
||||
func (a *BusinessAPI) renameSuffixGroup(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user