From ae789bd7b5d808d3f074610c84bcc6e9aa4c2af1 Mon Sep 17 00:00:00 2001 From: moec42frf <3378620026@qq.com> Date: Sun, 30 Apr 2023 09:34:50 +0800 Subject: [PATCH] ADD file via upload --- .../org/sang/service/CategoryService.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 blogserver/src/main/java/org/sang/service/CategoryService.java diff --git a/blogserver/src/main/java/org/sang/service/CategoryService.java b/blogserver/src/main/java/org/sang/service/CategoryService.java new file mode 100644 index 0000000..d7ce692 --- /dev/null +++ b/blogserver/src/main/java/org/sang/service/CategoryService.java @@ -0,0 +1,37 @@ +package org.sang.service; + +import org.sang.bean.Category; +import org.sang.mapper.CategoryMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.Timestamp; +import java.util.List; + + +@Service +@Transactional +public class CategoryService { + @Autowired + CategoryMapper categoryMapper; + + public List getAllCategories() { + return categoryMapper.getAllCategories(); + } + + public boolean deleteCategoryByIds(String ids) { + String[] split = ids.split(","); + int result = categoryMapper.deleteCategoryByIds(split); + return result == split.length; + } + + public int updateCategoryById(Category category) { + return categoryMapper.updateCategoryById(category); + } + + public int addCategory(Category category) { + category.setDate(new Timestamp(System.currentTimeMillis())); + return categoryMapper.addCategory(category); + } +}