1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-09-01 22:53:29 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

添加用户收藏书籍、取消收藏书籍、获取书籍收藏状态功能(后端+数据库);更新Api文档

This commit is contained in:
2022-04-05 18:21:49 +08:00
parent 8598edc0f7
commit cf26e925d9
11 changed files with 852 additions and 10 deletions

View File

@@ -114,14 +114,14 @@ router.get('/dashboard/:group/:page', function (req, res) {
title: "仪表盘",
baseTemplate: "index",
},
"myBookshelf": {
title: "我的书架",
baseTemplate: "form",
pageTemplate: "myBookshelf",
},
// "myBookshelf": {
// title: "我的书架",
// baseTemplate: "form",
// pageTemplate: "myBookshelf",
// },
"myCollection": {
title: "我的收藏",
baseTemplate: "form",
baseTemplate: "blank",
pageTemplate: "myCollection",
},
"myAccount": {

View File

@@ -11,7 +11,7 @@
Target Server Version : 50726
File Encoding : 65001
Date: 04/04/2022 17:06:31
Date: 05/04/2022 17:54:17
*/
SET NAMES utf8mb4;
@@ -205,6 +205,23 @@ CREATE TABLE `third_party_user_info` (
-- Records of third_party_user_info
-- ----------------------------
-- ----------------------------
-- Table structure for user_book_favorites_relation
-- ----------------------------
DROP TABLE IF EXISTS `user_book_favorites_relation`;
CREATE TABLE `user_book_favorites_relation` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`book_id` int(11) NOT NULL,
`create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `user_id`(`user_id`, `book_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of user_book_favorites_relation
-- ----------------------------
-- ----------------------------
-- Table structure for user_info
-- ----------------------------

View File

@@ -170,6 +170,79 @@ __必填__|id|integer (int32)
----
[[_addfavoritesusingpost_1]]
==== 【用户】收藏/取消收藏书籍
....
POST /api/book/getFavoritesStatus
....
===== 说明
用户收藏书籍
===== 参数
[options="header", cols=".^2a,.^3a,.^4a"]
|===
|类型|名称|类型
|**FormData**|**bookId** +
__可选__|integer (int32)
|**FormData**|**token** +
__可选__|string
|===
===== 响应
[options="header", cols=".^2a,.^14a,.^4a"]
|===
|HTTP代码|说明|类型
|**200**|OK|<<_commonreturntype,CommonReturnType>>
|**201**|Created|无内容
|**401**|Unauthorized|无内容
|**403**|Forbidden|无内容
|**404**|Not Found|无内容
|===
===== 消耗
* `application/x-www-form-urlencoded`
===== 生成
* `\*/*`
===== HTTP请求示例
====== 请求 path
----
/api/book/getFavoritesStatus
----
====== 请求 formData
[source,json]
----
"string"
----
===== HTTP响应示例
====== 响应 200
[source,json]
----
{
"data" : "object",
"status" : "string"
}
----
[[_searchusingget]]
==== 查询书籍列表
....
@@ -238,6 +311,81 @@ __可选__|publishingHouse|string
----
[[_addfavoritesusingpost]]
==== 【用户】收藏/取消收藏书籍
....
POST /api/book/toggleFavorites
....
===== 说明
用户收藏书籍
===== 参数
[options="header", cols=".^2a,.^3a,.^4a"]
|===
|类型|名称|类型
|**FormData**|**bookId** +
__可选__|integer (int32)
|**FormData**|**status** +
__可选__|boolean
|**FormData**|**token** +
__可选__|string
|===
===== 响应
[options="header", cols=".^2a,.^14a,.^4a"]
|===
|HTTP代码|说明|类型
|**200**|OK|<<_commonreturntype,CommonReturnType>>
|**201**|Created|无内容
|**401**|Unauthorized|无内容
|**403**|Forbidden|无内容
|**404**|Not Found|无内容
|===
===== 消耗
* `application/x-www-form-urlencoded`
===== 生成
* `\*/*`
===== HTTP请求示例
====== 请求 path
----
/api/book/toggleFavorites
----
====== 请求 formData
[source,json]
----
"string"
----
===== HTTP响应示例
====== 响应 200
[source,json]
----
{
"data" : "object",
"status" : "string"
}
----
[[_82c2171949c312f17a084ab9b31e7d55]]
=== 书籍分类信息
Category Controller
@@ -354,6 +502,79 @@ GET /api/category/list
User Controller
[[_cancelaccountusingpost]]
==== 账号注销
....
POST /api/user/cancelAccount
....
===== 说明
传入用户 token 以及密码明文后台计算密码SHA1值进行注销
===== 参数
[options="header", cols=".^2a,.^3a,.^4a"]
|===
|类型|名称|类型
|**FormData**|**password** +
__可选__|string
|**FormData**|**token** +
__可选__|string
|===
===== 响应
[options="header", cols=".^2a,.^14a,.^4a"]
|===
|HTTP代码|说明|类型
|**200**|OK|<<_commonreturntype,CommonReturnType>>
|**201**|Created|无内容
|**401**|Unauthorized|无内容
|**403**|Forbidden|无内容
|**404**|Not Found|无内容
|===
===== 消耗
* `application/x-www-form-urlencoded`
===== 生成
* `\*/*`
===== HTTP请求示例
====== 请求 path
----
/api/user/cancelAccount
----
====== 请求 formData
[source,json]
----
"string"
----
===== HTTP响应示例
====== 响应 200
[source,json]
----
{
"data" : "object",
"status" : "string"
}
----
[[_getuserstatususingpost]]
==== 获取用户登录状态
....
@@ -719,6 +940,64 @@ __可选__|token|string
----
[[_getbindingstatususingget]]
==== 获取用户已绑定的第三方平台
....
GET /api/third-party/getBindingStatus
....
===== 说明
传入当前登录用户 token ,返回已绑定的第三方平台
===== 参数
[options="header", cols=".^2a,.^3a,.^9a,.^4a"]
|===
|类型|名称|说明|类型
|**Query**|**token** +
__可选__|token|string
|===
===== 响应
[options="header", cols=".^2a,.^14a,.^4a"]
|===
|HTTP代码|说明|类型
|**200**|OK|<<_commonreturntype,CommonReturnType>>
|**401**|Unauthorized|无内容
|**403**|Forbidden|无内容
|**404**|Not Found|无内容
|===
===== 生成
* `\*/*`
===== HTTP请求示例
====== 请求 path
----
/api/third-party/getBindingStatus
----
===== HTTP响应示例
====== 响应 200
[source,json]
----
{
"data" : "object",
"status" : "string"
}
----
[[_loginusingget]]
==== 第三方用户登录跳转地址
....
@@ -777,6 +1056,79 @@ __必填__|platform|string
----
[[_unbindthirdpartaccountusingpost]]
==== 取消第三方平台绑定
....
POST /api/third-party/withdrawThirdPartyBings
....
===== 说明
传入当前登录用户 token 和平台 platform (不区分大小写),返回 bool 值true 为取消绑定成功
===== 参数
[options="header", cols=".^2a,.^3a,.^4a"]
|===
|类型|名称|类型
|**FormData**|**platform** +
__可选__|string
|**FormData**|**token** +
__可选__|string
|===
===== 响应
[options="header", cols=".^2a,.^14a,.^4a"]
|===
|HTTP代码|说明|类型
|**200**|OK|<<_commonreturntype,CommonReturnType>>
|**201**|Created|无内容
|**401**|Unauthorized|无内容
|**403**|Forbidden|无内容
|**404**|Not Found|无内容
|===
===== 消耗
* `application/x-www-form-urlencoded`
===== 生成
* `\*/*`
===== HTTP请求示例
====== 请求 path
----
/api/third-party/withdrawThirdPartyBings
----
====== 请求 formData
[source,json]
----
"string"
----
===== HTTP响应示例
====== 响应 200
[source,json]
----
{
"data" : "object",
"status" : "string"
}
----
[[_aca0f16a4237edba915fe70c9b07871c]]
=== 系统调试接口
Debug Controller

View File

@@ -18,8 +18,15 @@ public enum BusinessErrorCode implements CommonError {
// 40000开头为第三方登录相关错误定义
THIRD_PARTY_LOGIN_FAIL(40001, "第三方登录失败"),
THIRD_PARTY_ACCOUNT_ALREADY_BOUND(40002, "该账号已被其他账号绑定"),
THIRD_PARTY_UNBIND_FAIL(40003, "第三方账号解绑失败");
THIRD_PARTY_UNBIND_FAIL(40003, "第三方账号解绑失败"),
// 50000开头为书籍相关错误定义
BOOK_NOT_EXIST(50001, "书籍不存在"),
BOOK_FAVORITES_ALREADY_EXIST(50002, "书籍已经在收藏夹中"),
BOOK_FAVORITES_NOT_EXIST(50003, "书籍不在收藏夹中"),
// 占位
PLACE_HOLDER(99999, "这是一个占位符错误");
private BusinessErrorCode(int errCode, String errMsg) {
this.errCode = errCode;

View File

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import plus.bookshelf.Common.Error.BusinessErrorCode;
import plus.bookshelf.Common.Error.BusinessException;
import plus.bookshelf.Common.Response.CommonReturnType;
import plus.bookshelf.Controller.VO.BookVO;
@@ -19,6 +20,7 @@ import plus.bookshelf.Service.Model.UserModel;
import plus.bookshelf.Service.Service.BookService;
import java.util.List;
import java.util.Map;
@Api(tags = "书籍信息")
@Controller("book")
@@ -71,6 +73,49 @@ public class BookController extends BaseController {
return CommonReturnType.create(bookModels);
}
@ApiOperation(value = "【用户】收藏/取消收藏书籍", notes = "用户收藏书籍")
@RequestMapping(value = "toggleFavorites", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
@ResponseBody
public CommonReturnType addFavorites(@RequestParam(value = "token", required = false) String token,
@RequestParam(value = "bookId", required = false) Integer bookId,
@RequestParam(value = "status", required = true) Boolean isFavoritesNow) throws BusinessException {
// 已经在 getUserByToken 方法中判断了 token 为空、不合法;用户不存在情况,此处无需再判断
UserModel userModel = userService.getUserByToken(redisTemplate, token);
if (isFavoritesNow) {
// 这里查询一次书籍的用处是为了防止用户收藏的书籍不存在
BookModel bookModel = bookService.getBookById(bookId);
if (bookModel == null) {
throw new BusinessException(BusinessErrorCode.BOOK_NOT_EXIST, "书籍不存在");
}
Boolean isSuccess = bookService.addFavorites(userModel.getId(), bookModel.getId());
if (!isSuccess) {
throw new BusinessException(BusinessErrorCode.BOOK_FAVORITES_ALREADY_EXIST, "书籍已经收藏");
}
} else {
// 不用担心书籍不存在的情况,因为书籍不存在数据库中不会删除成功
Boolean isSuccess = bookService.removeFavorites(userModel.getId(), bookId);
if (!isSuccess) {
throw new BusinessException(BusinessErrorCode.BOOK_FAVORITES_NOT_EXIST, "书籍尚未收藏");
}
}
return CommonReturnType.create("success");
}
@ApiOperation(value = "【用户】收藏/取消收藏书籍", notes = "用户收藏书籍")
@RequestMapping(value = "getFavoritesStatus", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
@ResponseBody
public CommonReturnType addFavorites(@RequestParam(value = "token", required = false) String token,
@RequestParam(value = "bookId", required = false) Integer bookId) throws BusinessException {
// 已经在 getUserByToken 方法中判断了 token 为空、不合法;用户不存在情况,此处无需再判断
UserModel userModel = userService.getUserByToken(redisTemplate, token);
Map favoritesStatus = bookService.getFavoritesStatus(userModel.getId(), bookId);
return CommonReturnType.create(favoritesStatus);
}
@ApiOperation(value = "【管理员】添加书籍", notes = "管理员在后台添加书籍")
@RequestMapping(value = "add", method = {RequestMethod.GET})

View File

@@ -0,0 +1,137 @@
package plus.bookshelf.Dao.DO;
import java.util.Date;
public class UserFavoritesDO {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column user_book_favorites_relation.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column user_book_favorites_relation.user_id
*
* @mbg.generated
*/
private Integer userId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column user_book_favorites_relation.book_id
*
* @mbg.generated
*/
private Integer bookId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column user_book_favorites_relation.create_time
*
* @mbg.generated
*/
private Date createTime;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column user_book_favorites_relation.id
*
* @return the value of user_book_favorites_relation.id
*
* @mbg.generated
*/
public Integer getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column user_book_favorites_relation.id
*
* @param id the value for user_book_favorites_relation.id
*
* @mbg.generated
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column user_book_favorites_relation.user_id
*
* @return the value of user_book_favorites_relation.user_id
*
* @mbg.generated
*/
public Integer getUserId() {
return userId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column user_book_favorites_relation.user_id
*
* @param userId the value for user_book_favorites_relation.user_id
*
* @mbg.generated
*/
public void setUserId(Integer userId) {
this.userId = userId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column user_book_favorites_relation.book_id
*
* @return the value of user_book_favorites_relation.book_id
*
* @mbg.generated
*/
public Integer getBookId() {
return bookId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column user_book_favorites_relation.book_id
*
* @param bookId the value for user_book_favorites_relation.book_id
*
* @mbg.generated
*/
public void setBookId(Integer bookId) {
this.bookId = bookId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column user_book_favorites_relation.create_time
*
* @return the value of user_book_favorites_relation.create_time
*
* @mbg.generated
*/
public Date getCreateTime() {
return createTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column user_book_favorites_relation.create_time
*
* @param createTime the value for user_book_favorites_relation.create_time
*
* @mbg.generated
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

View File

@@ -0,0 +1,69 @@
package plus.bookshelf.Dao.Mapper;
import plus.bookshelf.Dao.DO.UserFavoritesDO;
public interface UserFavoritesDOMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_book_favorites_relation
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_book_favorites_relation
*
* @mbg.generated
*/
int insert(UserFavoritesDO record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_book_favorites_relation
*
* @mbg.generated
*/
int insertSelective(UserFavoritesDO record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_book_favorites_relation
*
* @mbg.generated
*/
UserFavoritesDO selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_book_favorites_relation
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(UserFavoritesDO record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_book_favorites_relation
*
* @mbg.generated
*/
int updateByPrimaryKey(UserFavoritesDO record);
/**
* 通过用户id和书籍id删除用户收藏状态
* @param userId
* @param bookId
* @return
*/
int deleteByUserIdAndBookId(Integer userId, Integer bookId);
/**
* 通过用户id和书籍id获取用户收藏状态
* @param userId
* @param bookId
* @return
*/
UserFavoritesDO selectCountByUserIdAndBookId(Integer userId, Integer bookId);
}

View File

@@ -1,8 +1,6 @@
package plus.bookshelf.Service.Impl;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -12,14 +10,18 @@ import plus.bookshelf.Common.Validator.ValidationResult;
import plus.bookshelf.Common.Validator.ValidatorImpl;
import plus.bookshelf.Dao.DO.BookDO;
import plus.bookshelf.Dao.DO.BookDOExample;
import plus.bookshelf.Dao.DO.UserFavoritesDO;
import plus.bookshelf.Dao.Mapper.BookDOMapper;
import plus.bookshelf.Dao.Mapper.UserFavoritesDOMapper;
import plus.bookshelf.Service.Model.BookModel;
import plus.bookshelf.Service.Model.CategoryModel;
import plus.bookshelf.Service.Service.BookService;
import plus.bookshelf.Service.Service.CategoryService;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class BookServiceImpl implements BookService {
@@ -30,6 +32,9 @@ public class BookServiceImpl implements BookService {
@Autowired
private CategoryService categoryService;
@Autowired
private UserFavoritesDOMapper userFavoritesDOMapper;
@Autowired
ValidatorImpl validator;
@@ -83,6 +88,62 @@ public class BookServiceImpl implements BookService {
return bookDOMapper.insertSelective(bookDO);
}
/**
* 用户收藏书籍
*
* @param userId 用户id
* @param bookId 书籍id
* @return
* @throws BusinessException
*/
@Override
public Boolean addFavorites(Integer userId, Integer bookId) throws BusinessException {
UserFavoritesDO userFavoritesDO = new UserFavoritesDO();
userFavoritesDO.setBookId(bookId);
userFavoritesDO.setUserId(userId);
int affectRows = userFavoritesDOMapper.insert(userFavoritesDO);
return affectRows > 0;
}
/**
* 用户取消收藏书籍
*
* @param userId 用户id
* @param bookId 书籍id
* @return
* @throws BusinessException
*/
@Override
public Boolean removeFavorites(Integer userId, Integer bookId) throws BusinessException {
int affectRows = userFavoritesDOMapper.deleteByUserIdAndBookId(userId, bookId);
return affectRows > 0;
}
/**
* 获取用户收藏状态
*
* @param userId 用户id
* @param bookId 书籍id
* @return
* @throws BusinessException
*/
@Override
public Map getFavoritesStatus(Integer userId, Integer bookId) throws BusinessException {
UserFavoritesDO userFavoritesDO = userFavoritesDOMapper.selectCountByUserIdAndBookId(userId, bookId);
Map<String, String> result = new HashMap<>();
if (userFavoritesDO == null) {
// 用户未收藏
result.put("status", "0");
result.put("time", null);
} else {
// 用户已收藏,返回收藏时间
result.put("status", "1");
result.put("time", userFavoritesDO.getCreateTime().toString());
}
return result;
}
private BookModel convertFromDataObjecct(BookDO bookDO) {
if (bookDO == null) {
return null;

View File

@@ -5,6 +5,7 @@ import plus.bookshelf.Dao.DO.BookDO;
import plus.bookshelf.Service.Model.BookModel;
import java.util.List;
import java.util.Map;
public interface BookService {
/**
@@ -29,4 +30,30 @@ public interface BookService {
* @return
*/
Integer addBook(BookModel bookModel) throws BusinessException;
/**
* 用户收藏书籍
*
* @param bookId 书籍id
* @return
*/
Boolean addFavorites(Integer userId, Integer bookId) throws BusinessException;
/**
* 用户取消收藏书籍
* @param userId
* @param bookId
* @return
* @throws BusinessException
*/
Boolean removeFavorites(Integer userId, Integer bookId) throws BusinessException;
/**
* 获取用户收藏状态
* @param userId 用户id
* @param bookId 书籍id
* @return
* @throws BusinessException
*/
Map getFavoritesStatus(Integer userId, Integer bookId) throws BusinessException;
}

View File

@@ -0,0 +1,124 @@
<?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="plus.bookshelf.Dao.Mapper.UserFavoritesDOMapper">
<resultMap id="BaseResultMap" type="plus.bookshelf.Dao.DO.UserFavoritesDO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="book_id" jdbcType="INTEGER" property="bookId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, user_id, book_id, create_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from user_book_favorites_relation
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from user_book_favorites_relation
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="plus.bookshelf.Dao.DO.UserFavoritesDO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into user_book_favorites_relation (id, user_id, book_id,
create_time)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{bookId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="plus.bookshelf.Dao.DO.UserFavoritesDO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into user_book_favorites_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="bookId != null">
book_id,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="bookId != null">
#{bookId,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="plus.bookshelf.Dao.DO.UserFavoritesDO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update user_book_favorites_relation
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="bookId != null">
book_id = #{bookId,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="plus.bookshelf.Dao.DO.UserFavoritesDO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update user_book_favorites_relation
set user_id = #{userId,jdbcType=INTEGER},
book_id = #{bookId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteByUserIdAndBookId" parameterType="java.lang.Integer">
delete from user_book_favorites_relation
where user_id = #{userId,jdbcType=INTEGER} and book_id = #{bookId,jdbcType=INTEGER} limit 1
</delete>
<select id="selectCountByUserIdAndBookId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from user_book_favorites_relation
where user_id = #{userId,jdbcType=INTEGER} and book_id = #{bookId,jdbcType=INTEGER}
</select>
</mapper>

View File

@@ -94,5 +94,8 @@
<!--<table tableName="third_party_user_auth_relation" domainObjectName="ThirdPartyUserAuthDO" enableCountByExample="false"-->
<!-- enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"-->
<!-- selectByExampleQueryId="false"></table>-->
<!--<table tableName="user_book_favorites_relation" domainObjectName="UserFavoritesDO" enableCountByExample="false"-->
<!-- enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"-->
<!-- selectByExampleQueryId="false"></table>-->
</context>
</generatorConfiguration>