|
@@ -73,6 +73,36 @@ func DeleteTest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
return repo.RepoDeleteDbDoc(apictx.CreateRepoCtx(), db, repo.CollectionTest, _id)
|
|
|
}
|
|
|
|
|
|
+type BatchDeleteTestReq struct {
|
|
|
+ Ids []string `json:"ids"`
|
|
|
+}
|
|
|
+
|
|
|
+func BatchDeleteTest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
+ // 验证是否为管理员
|
|
|
+ isAdmin, err := IsAdmin(c, apictx)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if !isAdmin {
|
|
|
+ return nil, errors.New("没有权限")
|
|
|
+ }
|
|
|
+ db := c.Param("scope")
|
|
|
+ if len(db) == 0 {
|
|
|
+ return nil, errors.New("scope不能为空")
|
|
|
+ }
|
|
|
+ var form BatchDeleteTestReq
|
|
|
+ err = c.ShouldBindJSON(&form)
|
|
|
+ if err != nil {
|
|
|
+ return nil, errors.New("参数错误")
|
|
|
+ }
|
|
|
+ if len(form.Ids) > 0 {
|
|
|
+ for _, id := range form.Ids {
|
|
|
+ repo.RepoDeleteDbDoc(apictx.CreateRepoCtx(), db, repo.CollectionTest, id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true, nil
|
|
|
+}
|
|
|
+
|
|
|
// 试题列表
|
|
|
// /admin/test/list/:scope?content=xxx&type=判断&page=1&size=10
|
|
|
func TestList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|