first commit
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package lingtao.net.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lingtao.net.bean.Article;
|
||||
import lingtao.net.bean.Msg;
|
||||
import lingtao.net.dao.ArticleMapper;
|
||||
|
||||
@Service
|
||||
public class ArticleService {
|
||||
|
||||
@Autowired
|
||||
ArticleMapper articlesMapper;
|
||||
|
||||
public List<Article> getArticle(Article article) {
|
||||
return articlesMapper.getArticle(article);
|
||||
|
||||
}
|
||||
|
||||
public Msg addArticle(Article article) {
|
||||
try {
|
||||
article.setCreateDate(new Date());
|
||||
articlesMapper.insertSelective(article);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Msg.fail("新增失败");
|
||||
}
|
||||
}
|
||||
|
||||
public Msg updateArticleById(Article article) {
|
||||
try {
|
||||
article.setUpdateDate(new Date());
|
||||
articlesMapper.updateByPrimaryKeySelective(article);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Msg.fail("修改失败");
|
||||
}
|
||||
}
|
||||
|
||||
public Msg delArticleById(Integer id) {
|
||||
try {
|
||||
articlesMapper.deleteByPrimaryKey(id);
|
||||
return Msg.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Msg.fail("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
public Article articleInfo(Integer id) {
|
||||
try {
|
||||
return articlesMapper.selectByPrimaryKey(id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user