-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
610c39f
commit 56da7b7
Showing
5 changed files
with
205 additions
and
19 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/java/com/swpu/uchain/blog/dao/UserLikesMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.swpu.uchain.blog.dao; | ||
|
||
import com.swpu.uchain.blog.entity.UserLikes; | ||
import java.util.List; | ||
import org.apache.ibatis.annotations.Param; | ||
|
||
public interface UserLikesMapper { | ||
int deleteByPrimaryKey(@Param("userId") Long userId, @Param("blogId") Long blogId); | ||
|
||
int insert(UserLikes record); | ||
|
||
UserLikes selectByPrimaryKey(@Param("userId") Long userId, @Param("blogId") Long blogId); | ||
|
||
List<UserLikes> selectAll(); | ||
|
||
int updateByPrimaryKey(UserLikes record); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.swpu.uchain.blog.entity; | ||
|
||
import java.io.Serializable; | ||
|
||
public class UserLikes implements Serializable { | ||
private Long userId; | ||
|
||
private Long blogId; | ||
|
||
private Boolean isLike; | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public Long getUserId() { | ||
return userId; | ||
} | ||
|
||
public void setUserId(Long userId) { | ||
this.userId = userId; | ||
} | ||
|
||
public Long getBlogId() { | ||
return blogId; | ||
} | ||
|
||
public void setBlogId(Long blogId) { | ||
this.blogId = blogId; | ||
} | ||
|
||
public Boolean getIsLike() { | ||
return isLike; | ||
} | ||
|
||
public void setIsLike(Boolean isLike) { | ||
this.isLike = isLike; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(getClass().getSimpleName()); | ||
sb.append(" ["); | ||
sb.append("Hash = ").append(hashCode()); | ||
sb.append(", userId=").append(userId); | ||
sb.append(", blogId=").append(blogId); | ||
sb.append(", isLike=").append(isLike); | ||
sb.append(", serialVersionUID=").append(serialVersionUID); | ||
sb.append("]"); | ||
return sb.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
<mapper namespace="com.swpu.uchain.blog.dao.UserLikesMapper" > | ||
<resultMap id="BaseResultMap" type="com.swpu.uchain.blog.entity.UserLikes" > | ||
<id column="user_id" property="userId" jdbcType="BIGINT" /> | ||
<id column="blog_id" property="blogId" jdbcType="BIGINT" /> | ||
<result column="is_like" property="isLike" jdbcType="BIT" /> | ||
</resultMap> | ||
<delete id="deleteByPrimaryKey" parameterType="map" > | ||
delete from user_likes | ||
where user_id = #{userId,jdbcType=BIGINT} | ||
and blog_id = #{blogId,jdbcType=BIGINT} | ||
</delete> | ||
<insert id="insert" parameterType="com.swpu.uchain.blog.entity.UserLikes" > | ||
insert into user_likes (user_id, blog_id, is_like | ||
) | ||
values (#{userId,jdbcType=BIGINT}, #{blogId,jdbcType=BIGINT}, #{isLike,jdbcType=BIT} | ||
) | ||
</insert> | ||
<update id="updateByPrimaryKey" parameterType="com.swpu.uchain.blog.entity.UserLikes" > | ||
update user_likes | ||
set is_like = #{isLike,jdbcType=BIT} | ||
where user_id = #{userId,jdbcType=BIGINT} | ||
and blog_id = #{blogId,jdbcType=BIGINT} | ||
</update> | ||
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="map" > | ||
select user_id, blog_id, is_like | ||
from user_likes | ||
where user_id = #{userId,jdbcType=BIGINT} | ||
and blog_id = #{blogId,jdbcType=BIGINT} | ||
</select> | ||
<select id="selectAll" resultMap="BaseResultMap" > | ||
select user_id, blog_id, is_like | ||
from user_likes | ||
</select> | ||
</mapper> |