试题分类删除优化

This commit is contained in:
flower 2018-12-18 07:43:34 +08:00
parent 8392af7bda
commit ce5c7314de
2 changed files with 38 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import com.ruoyi.exam.domain.ExamPaperCategory;
import com.ruoyi.framework.web.util.ShiroUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
@ -178,4 +179,23 @@ public class ExamQuestionCategoryController extends BaseController
return res;
}
/**
* 删除
*/
@Log(title = "试题分类管理", businessType = BusinessType.DELETE)
@RequiresPermissions("system:examQuestionCategory:remove")
@PostMapping("/remove/{id}")
@ResponseBody
public AjaxResult remove(@PathVariable("id") Long id)
{
ExamQuestionCategory exam = new ExamQuestionCategory();
exam.setParentId(id);
if (examQuestionCategoryService.selectList(exam).size() > 0)
{
return error(1, "存在下级分类,不允许删除");
}
return toAjax(examQuestionCategoryService.deleteById(id));
}
}

View File

@ -113,13 +113,30 @@
}
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.treeTable.init(options);
});
function remove(id) {
$.modal.confirm("确定删除该条" + $.table._option.modalName + "信息吗?", function() {
$.ajax({
type : 'post',
url: prefix + "/remove/" + id,
success : function(result) {
if (result.code == web_status.SUCCESS) {
$.modal.msgSuccess(result.msg);
$.treeTable.refresh();
} else {
$.modal.msgError(result.msg);
}
}
});
});
}
</script>
</body>
</html>