Skip to content

Commit

Permalink
fix: fetch tags
Browse files Browse the repository at this point in the history
  • Loading branch information
bs32g1038 committed Mar 24, 2024
1 parent e013bc2 commit 9e52e10
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions server/src/main/java/com/jixialunbi/controllers/TagController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.jixialunbi.controllers;

import com.jixialunbi.common.R;
import com.jixialunbi.repository.TagRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/v1")
public class TagController {

@Autowired
TagRepository tagRepository;

@GetMapping("/tags")
public R fetchTags(@RequestParam(required = false, defaultValue = "1") int page, @RequestParam(required = false, defaultValue = "10") int pageSize) {
try {
return R.ok().data(tagRepository.findAll());
} catch (Exception e) {
return R.error().message("系统异常");
}
}

}
2 changes: 1 addition & 1 deletion web/components/Write/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Write = () => {
const [form] = useForm();
const router = useRouter();
const { user } = useAppStore();
const { data, isLoading } = useSWR({ url: '/api/v1/categories' });
const { data, isLoading } = useSWR({ url: '/api/v1/tags' });
const { trigger: createPost } = useSWRMutation({ url: '/api/v1/posts' });
const ref = useRef(null);
const handleUpload = (info) => {
Expand Down

0 comments on commit 9e52e10

Please sign in to comment.