|
@@ -12,6 +12,12 @@ import (
|
|
|
"syscall"
|
|
"syscall"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+// curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' "http://localhost:10000/test/v1/class/create"
|
|
|
|
|
+// curl -X PUT -H "Content-Type: application/json" -d '{"id":"25a9d5dab2fc4a81a512e48d911b5063", "name":"test-new"}' "http://localhost:10000/test/v1/class/update"
|
|
|
|
|
+// curl -X GET "http://localhost:10000/test/v1/class/query?name=test&pageNo=1&pageSize=1"
|
|
|
|
|
+// curl -X GET "http://localhost:10000/test/v1/class/get?id=25a9d5dab2fc4a81a512e48d911b5063"
|
|
|
|
|
+// curl -X DELETE "http://localhost:10000/test/v1/class/25a9d5dab2fc4a81a512e48d911b5063/delete"
|
|
|
|
|
+
|
|
|
type CreateClassJsonBody struct {
|
|
type CreateClassJsonBody struct {
|
|
|
Name string `json:"name" binding:"required"`
|
|
Name string `json:"name" binding:"required"`
|
|
|
}
|
|
}
|
|
@@ -89,7 +95,7 @@ func main() {
|
|
|
|
|
|
|
|
// 删除班级
|
|
// 删除班级
|
|
|
binding.DeleteBind(v1Router, &binding.SimpleBindItem[any]{
|
|
binding.DeleteBind(v1Router, &binding.SimpleBindItem[any]{
|
|
|
- Path: "/class/delete",
|
|
|
|
|
|
|
+ Path: "/class/:id/delete",
|
|
|
ResponseFunc: binding.SendMsgResponse,
|
|
ResponseFunc: binding.SendMsgResponse,
|
|
|
DTO: &DeleteClassPathParams{},
|
|
DTO: &DeleteClassPathParams{},
|
|
|
FormDomainObjectsFunc: func(c *api.Context, dto binding.DTO) ([]domain.Object, error) {
|
|
FormDomainObjectsFunc: func(c *api.Context, dto binding.DTO) ([]domain.Object, error) {
|
|
@@ -201,19 +207,34 @@ func main() {
|
|
|
startCount = queryParams.PageNo*queryParams.PageSize + 1
|
|
startCount = queryParams.PageNo*queryParams.PageSize + 1
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- endCount := len(classMap)
|
|
|
|
|
|
|
+ needFindCount := len(classMap)
|
|
|
if queryParams.PageNo != 0 && queryParams.PageSize != 0 {
|
|
if queryParams.PageNo != 0 && queryParams.PageSize != 0 {
|
|
|
- endCount = queryParams.PageSize
|
|
|
|
|
|
|
+ needFindCount = queryParams.PageSize
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
count := 1
|
|
count := 1
|
|
|
|
|
+ findCount := 0
|
|
|
|
|
+
|
|
|
for _, existEntity := range classMap {
|
|
for _, existEntity := range classMap {
|
|
|
- if count >= endCount {
|
|
|
|
|
|
|
+ if count <
|
|
|
|
|
+
|
|
|
|
|
+ if findCount >= needFindCount {
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if count >= startCount {
|
|
if count >= startCount {
|
|
|
- if existEntity.Name == e.Name {
|
|
|
|
|
|
|
+ find := false
|
|
|
|
|
+ if strutils.IsStringNotEmpty(e.Name) {
|
|
|
|
|
+ if existEntity.Name == e.Name {
|
|
|
|
|
+ find = true
|
|
|
|
|
+ findCount++
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ find = true
|
|
|
|
|
+ findCount++
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if find {
|
|
|
classInfos = append(classInfos, ClassInfo{
|
|
classInfos = append(classInfos, ClassInfo{
|
|
|
ID: existEntity.ID,
|
|
ID: existEntity.ID,
|
|
|
Name: existEntity.Name,
|
|
Name: existEntity.Name,
|