should favorite article
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package io.spring.infrastructure.favorite;
|
||||
|
||||
import io.spring.core.favorite.ArticleFavorite;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface ArticleFavoriteMapper {
|
||||
boolean find(@Param("articleFavorite") ArticleFavorite articleFavorite);
|
||||
|
||||
void insert(@Param("articleFavorite") ArticleFavorite articleFavorite);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package io.spring.infrastructure.favorite;
|
||||
|
||||
import io.spring.core.favorite.ArticleFavorite;
|
||||
import io.spring.core.favorite.ArticleFavoriteRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class MyBatisArticleFavoriteRepository implements ArticleFavoriteRepository {
|
||||
private ArticleFavoriteMapper mapper;
|
||||
|
||||
@Autowired
|
||||
public MyBatisArticleFavoriteRepository(ArticleFavoriteMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(ArticleFavorite articleFavorite) {
|
||||
if (!mapper.find(articleFavorite)) {
|
||||
mapper.insert(articleFavorite);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user