mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-21 01:10:39 +08:00
用户反馈书籍失效,下载书籍,以及登录注册时记录用户浏览器指纹(获取不到浏览器指纹的使用浏览器UA代替)
This commit is contained in:
@@ -13,7 +13,11 @@
|
||||
|
||||
前项目为书栖网官网开源项目,你也可以通过这个项目搭建一个属于自己的电子书分享与管理平台。
|
||||
|
||||
> 如需获取计算机类电子书,请访问https://bookshelf.plus/ ,或前往Git仓库👉([GitHub](https://github.com/only-4/computer-related-books)、[Gitee](https://gitee.com/only4/computer-related-books))
|
||||
> 目前项目已上线,网址:https://bookshelf.plus/
|
||||
>
|
||||
> 也可前往Git仓库👉[GitHub](https://github.com/only-4/computer-related-books)、[Gitee](https://gitee.com/only4/computer-related-books)
|
||||
|
||||
> 项目部分功能仍在开发中,另外文档部分内容尚未更新,部署使用需要掌握一定的技术,如果项目后期看好的人多,将会花精力完善文档以及适当增添新功能。
|
||||
|
||||
|
||||
|
||||
@@ -408,6 +412,6 @@ chmod -R 755 bookshelf.plus/
|
||||
|
||||
目前该项目由 程序员小墨 独立开发,你可以在 [GitHub](https://github.com/coder-xiaomo)、[Gitee](https://gitee.com/coder-xiaomo)、[B站](https://space.bilibili.com/457109942)或微信公众号等平台找到我(所有平台都是“程序员小墨”这个名字)。
|
||||
|
||||
如您希望合作,或者共同维护本项目,可以通过 `admin@only4.work` 与我取得联系。邮件主题中请注明 `[书栖网开源项目]` 方便我们快速了解您的来意,谢谢。
|
||||
如您希望合作,或者共同维护本项目,可以通过 `admin@only4.work` 与我取得联系。邮件主题中请注明 `[书栖网丨开源项目]` 方便我们快速了解您的来意,谢谢。
|
||||
|
||||
精力有限,暂不提供免费客服服务,如您遇到问题,请自行搜索解决。这类相关邮件我们将不予回复,望理解!
|
||||
|
2610
bookshelfplus-frontend/public/assets/lib/fingerprintjs/3.3.3/esm.js
Normal file
2610
bookshelfplus-frontend/public/assets/lib/fingerprintjs/3.3.3/esm.js
Normal file
File diff suppressed because it is too large
Load Diff
8
bookshelfplus-frontend/public/assets/lib/fingerprintjs/3.3.3/esm.min.js
vendored
Normal file
8
bookshelfplus-frontend/public/assets/lib/fingerprintjs/3.3.3/esm.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -477,7 +477,7 @@
|
||||
case "腾讯云对象存储":
|
||||
title = "直链下载";
|
||||
if (!localStorageUtils.getLoginStatus()) {
|
||||
downloadLink = "登录后方可使用";
|
||||
downloadLink = "<span><a href='{}'>登录</a>后方可使用</span>".replace("{}", "/login?redirect=" + encodeURIComponent(location.pathname + location.search));
|
||||
} else {
|
||||
content = `<span style="font-size: 12px;"><nobr>每次点击都会扣减下载次数</nobr></span>`;
|
||||
downloadLink = `<a style="cursor: pointer;" onclick="getDirectLink(${fileObjectInfo.id});">下载</a>`;
|
||||
@@ -590,7 +590,7 @@
|
||||
</script>
|
||||
<script>
|
||||
// 获取直链下载链接,并下载该文件
|
||||
function getDirectLink(fileObjectId) {
|
||||
async function getDirectLink(fileObjectId) {
|
||||
var fileObject = direckLinkInfo[fileObjectId];
|
||||
console.log("fileObject", fileObject);
|
||||
|
||||
@@ -601,7 +601,9 @@
|
||||
|
||||
var fileNameForUser = `${fileObject.fileName}.${fileObject.fileType}`;
|
||||
var fileKeyForCos = fileObject.filePath;
|
||||
postRequest("/file/cos/get", { fileSha1: fileObject.fileSha1, fileNameAndExt: fileNameForUser, token: localStorageUtils.getToken(), expireMinute: 30 })
|
||||
|
||||
var visitorId = await getVisitorId();
|
||||
postRequest("/file/cos/get", { fileSha1: fileObject.fileSha1, fileNameAndExt: fileNameForUser, token: localStorageUtils.getToken(), visitorId: visitorId, expireMinute: 30 })
|
||||
.then(function (response) {
|
||||
var axiosData = response.data;
|
||||
var status = axiosData.status;
|
||||
@@ -625,7 +627,7 @@
|
||||
</script>
|
||||
<script>
|
||||
// 链接失效反馈
|
||||
function linkFeedback(fileId, fileObjectId) {
|
||||
async function linkFeedback(fileId, fileObjectId) {
|
||||
if (!confirm("确定这个下载链接失效了吗?(没失效的链接不可以乱点着玩儿哦)"))
|
||||
return;
|
||||
|
||||
@@ -636,7 +638,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
postRequest("/file/object/FailureFeedback", { bookId: bookId, fileId: fileId, fileObjectId: fileObjectId, token: localStorageUtils.getToken() })
|
||||
var visitorId = await getVisitorId();
|
||||
postRequest("/file/object/FailureFeedback", { bookId: bookId, fileId: fileId, fileObjectId: fileObjectId, token: localStorageUtils.getToken(), visitorId: visitorId })
|
||||
.then(function (response) {
|
||||
var axiosData = response.data;
|
||||
var status = axiosData.status;
|
||||
|
@@ -18,4 +18,36 @@
|
||||
<style>
|
||||
/* 字体加载前先隐藏,不然文字会闪一下 */
|
||||
html, body { opacity: 0; }
|
||||
</style>
|
||||
</style>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* 获取用户浏览器指纹
|
||||
*
|
||||
* refer:
|
||||
* - https://fingerprintjs.com/
|
||||
* - https://github.com/fingerprintjs/fingerprintjs
|
||||
*
|
||||
*/
|
||||
// Initialize the agent at application startup.
|
||||
const fpPromise = import('/assets/lib/fingerprintjs/3.3.3/esm.min.js')
|
||||
// const fpPromise = import('https://openfpcdn.io/fingerprintjs/v3')
|
||||
.then(FingerprintJS => FingerprintJS.load())
|
||||
|
||||
// // Get the visitor identifier when you need it.
|
||||
// fpPromise
|
||||
// .then(fp => fp.get())
|
||||
// .then(result => {
|
||||
// // This is the visitor identifier:
|
||||
// const visitorId = result.visitorId
|
||||
// console.log(visitorId)
|
||||
// });
|
||||
|
||||
async function getVisitorId() {
|
||||
try {
|
||||
return (await fpPromise.then(fp => fp.get())).visitorId;
|
||||
} catch (error) {
|
||||
return JSON.stringify(navigator.userAgent);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@@ -105,7 +105,7 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
$(".btn-submit").click(function () {
|
||||
$(".btn-submit").click(async function () {
|
||||
if ($("#username").val() === "" || $("#password").val() === "") {
|
||||
alert("用户名或密码不能为空!");
|
||||
if ($("#username").val() === "") {
|
||||
@@ -126,7 +126,8 @@
|
||||
// var encryptpwd = hex_md5(password);
|
||||
|
||||
localStorageUtils.userLogout();
|
||||
postRequest("/user/login", { username: username, password: password })
|
||||
var visitorId = await getVisitorId();
|
||||
postRequest("/user/login", { username: username, password: password, visitorId: visitorId })
|
||||
.then(function (response) {
|
||||
var axiosData = response.data;
|
||||
var status = axiosData.status;
|
||||
|
@@ -64,11 +64,12 @@
|
||||
|
||||
$("#username").val("xiaomo");
|
||||
$("#password").val("123456");
|
||||
$(".btn-register").click(function() {
|
||||
$(".btn-register").click(async function() {
|
||||
var username = $("#username").val();
|
||||
var password = $("#password").val();
|
||||
|
||||
postRequest("/user/register", { username: username, password: password })
|
||||
var visitorId = await getVisitorId();
|
||||
postRequest("/user/register", { username: username, password: password, visitorId: visitorId })
|
||||
.then(function (response) {
|
||||
var axiosData = response.data;
|
||||
var status = axiosData.status;
|
||||
|
@@ -11,7 +11,7 @@
|
||||
Target Server Version : 50726
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 18/04/2022 17:54:01
|
||||
Date: 19/04/2022 22:46:17
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
@@ -310,6 +310,22 @@ CREATE TABLE `user_info` (
|
||||
-- Records of user_info
|
||||
-- ----------------------------
|
||||
INSERT INTO `user_info` VALUES (1, 'admin', '7c4a8d09ca3762af61e59520943dc26494f8941b', '小小墨', 'ADMIN', '/密码/123456/', '', '', '', '');
|
||||
INSERT INTO `user_info` VALUES (2, 'xiaomo', '7c4a8d09ca3762af61e59520943dc26494f8941b', '小小墨', 'USER', '/密码/123456/', '', '', '', '');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for visitor_fingerprint_log
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `visitor_fingerprint_log`;
|
||||
CREATE TABLE `visitor_fingerprint_log` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`visitor_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`user_id` int(11) NULL DEFAULT NULL COMMENT '未登录用户 userId 为 0',
|
||||
`create_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`action` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '注意,用户浏览器指纹有概率重复,所以仅供参考,不能作为判断的依据\r\n\r\n获取不到浏览器指纹的将使用浏览器UA代替' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of visitor_fingerprint_log
|
||||
-- ----------------------------
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
@@ -19,10 +19,7 @@ import plus.bookshelf.Common.Response.CommonReturnType;
|
||||
import plus.bookshelf.Config.QCloudCosConfig;
|
||||
import plus.bookshelf.Controller.VO.FileObjectVO;
|
||||
import plus.bookshelf.Controller.VO.FileVO;
|
||||
import plus.bookshelf.Service.Impl.FailureFeedbackServiceImpl;
|
||||
import plus.bookshelf.Service.Impl.FileObjectServiceImpl;
|
||||
import plus.bookshelf.Service.Impl.FileServiceImpl;
|
||||
import plus.bookshelf.Service.Impl.UserServiceImpl;
|
||||
import plus.bookshelf.Service.Impl.*;
|
||||
import plus.bookshelf.Service.Model.FailureFeedbackModel;
|
||||
import plus.bookshelf.Service.Model.FileModel;
|
||||
import plus.bookshelf.Service.Model.FileObjectModel;
|
||||
@@ -55,6 +52,9 @@ public class FileController extends BaseController {
|
||||
@Autowired
|
||||
FailureFeedbackServiceImpl failureFeedbackService;
|
||||
|
||||
@Autowired
|
||||
VisitorFingerprintLogServiceImpl visitorFingerprintLogService;
|
||||
|
||||
@ApiOperation(value = "书籍下载页面获取文件提供的下载方式", notes = "")
|
||||
@RequestMapping(value = "getFile", method = {RequestMethod.GET})
|
||||
@ResponseBody
|
||||
@@ -106,7 +106,9 @@ public class FileController extends BaseController {
|
||||
public CommonReturnType failureFeedback(@RequestParam(value = "token", required = false) String token,
|
||||
@RequestParam(value = "bookId", required = false) Integer bookId,
|
||||
@RequestParam(value = "fileId", required = false) Integer fileId,
|
||||
@RequestParam(value = "fileObjectId", required = false) Integer fileObjectId) throws BusinessException {
|
||||
@RequestParam(value = "fileObjectId", required = false) Integer fileObjectId,
|
||||
@RequestParam(value = "visitorId", required = true) String visitorFingerprint) throws BusinessException {
|
||||
|
||||
Integer userId = null;
|
||||
if (token != null) {
|
||||
try {
|
||||
@@ -117,6 +119,10 @@ public class FileController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
if (!visitorFingerprintLogService.saveFingerprint("Failure Feedback", userId, visitorFingerprint)) {
|
||||
throw new BusinessException(BusinessErrorCode.OPERATION_NOT_ALLOWED, "参数错误,请联系管理员处理");
|
||||
}
|
||||
|
||||
FailureFeedbackModel failureFeedbackModel = new FailureFeedbackModel();
|
||||
failureFeedbackModel.setBookId(bookId);
|
||||
failureFeedbackModel.setFileId(fileId);
|
||||
@@ -229,7 +235,8 @@ public class FileController extends BaseController {
|
||||
@RequestParam(value = "fileId", required = false) Integer fileId, // 关联的文件ID,创建新文件则为0
|
||||
|
||||
// 以下为 GET 请求必传参数
|
||||
@RequestParam(value = "fileNameAndExt", required = false) String fileNameAndExt
|
||||
@RequestParam(value = "fileNameAndExt", required = false) String fileNameAndExt,
|
||||
@RequestParam(value = "visitorId", required = false) String visitorFingerprint
|
||||
) throws BusinessException, InvocationTargetException, IllegalAccessException {
|
||||
if (expireMinute == null) {
|
||||
expireMinute = 30;
|
||||
@@ -270,6 +277,9 @@ public class FileController extends BaseController {
|
||||
break;
|
||||
case GET:
|
||||
if (!isExist) throw new BusinessException(BusinessErrorCode.PARAMETER_VALIDATION_ERROR, "文件不存在");
|
||||
if (visitorFingerprint == null || !visitorFingerprintLogService.saveFingerprint("FailureFeedback", userModel.getId(), visitorFingerprint)) {
|
||||
throw new BusinessException(BusinessErrorCode.OPERATION_NOT_ALLOWED, "参数错误,请联系管理员处理");
|
||||
}
|
||||
url = qCloudCosUtils.generatePresignedUrlForGET(userModel.getId(), bookSaveFolder, fileSha1, expireMinute, urlGUID, fileNameAndExt);
|
||||
break;
|
||||
case DELETE:
|
||||
|
@@ -15,6 +15,7 @@ import plus.bookshelf.Common.Error.BusinessException;
|
||||
import plus.bookshelf.Common.Response.CommonReturnType;
|
||||
import plus.bookshelf.Controller.VO.UserVO;
|
||||
import plus.bookshelf.Service.Impl.UserServiceImpl;
|
||||
import plus.bookshelf.Service.Impl.VisitorFingerprintLogServiceImpl;
|
||||
import plus.bookshelf.Service.Model.UserModel;
|
||||
|
||||
@Api(tags = "用户操作")
|
||||
@@ -25,6 +26,9 @@ public class UserController extends BaseController {
|
||||
@Autowired
|
||||
UserServiceImpl userService;
|
||||
|
||||
@Autowired
|
||||
VisitorFingerprintLogServiceImpl visitorFingerprintService;
|
||||
|
||||
@ApiOperation(value = "用户登录", notes = "传入用户名,以及密码明文,后台计算密码SHA1值,进行登录")
|
||||
// @ApiImplicitParams(value = {
|
||||
// @ApiImplicitParam(name = "username", value = "用户名", example = "username1", paramType = "form", dataType = "String", required = true, dataTypeClass = String.class),
|
||||
@@ -33,8 +37,9 @@ public class UserController extends BaseController {
|
||||
@RequestMapping(value = "login", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
|
||||
@ResponseBody
|
||||
public CommonReturnType login(@RequestParam(value = "username") String username,
|
||||
@RequestParam(value = "password") String password) throws BusinessException {
|
||||
if (username == null || password == null) {
|
||||
@RequestParam(value = "password") String password,
|
||||
@RequestParam(value = "visitorId") String visitorFingerprint) throws BusinessException {
|
||||
if (username == null || password == null || visitorFingerprint == null) {
|
||||
throw new BusinessException(BusinessErrorCode.PARAMETER_VALIDATION_ERROR);
|
||||
}
|
||||
String encryptPwd = DigestUtils.sha1Hex(password);
|
||||
@@ -43,8 +48,15 @@ public class UserController extends BaseController {
|
||||
UserVO userVO = convertFromService(userModel);
|
||||
|
||||
if (userModel != null) {
|
||||
if (!visitorFingerprintService.saveFingerprint("Login Success", userModel.getId(), visitorFingerprint)) {
|
||||
throw new BusinessException(BusinessErrorCode.OPERATION_NOT_ALLOWED, "参数错误,请联系管理员处理");
|
||||
}
|
||||
String token = onLogin(userModel);
|
||||
userVO.setToken(token); // token 仅在用户登录时传一次,后面获取用户状态接口中不重复返回 token 信息
|
||||
} else {
|
||||
if (!visitorFingerprintService.saveFingerprint("Login Failed", null, visitorFingerprint)) {
|
||||
throw new BusinessException(BusinessErrorCode.OPERATION_NOT_ALLOWED, "参数错误,请联系管理员处理");
|
||||
}
|
||||
}
|
||||
return CommonReturnType.create(userVO);
|
||||
}
|
||||
@@ -53,7 +65,8 @@ public class UserController extends BaseController {
|
||||
@RequestMapping(value = "register", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
|
||||
@ResponseBody
|
||||
public CommonReturnType register(@RequestParam(value = "username") String username,
|
||||
@RequestParam(value = "password") String password) throws BusinessException {
|
||||
@RequestParam(value = "password") String password,
|
||||
@RequestParam(value = "visitorId") String visitorFingerprint) throws BusinessException {
|
||||
if (username == null || password == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -62,8 +75,9 @@ public class UserController extends BaseController {
|
||||
if (!userService.userRegister(username, encryptPwd)) {
|
||||
throw new BusinessException(BusinessErrorCode.UNKNOWN_ERROR, "未知错误,注册失败");
|
||||
}
|
||||
|
||||
// 注册成功后,进行登录
|
||||
return login(username, password);
|
||||
return login(username, password, visitorFingerprint);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "【用户|管理员】用户登出", notes = "用户退出登录")
|
||||
@@ -102,7 +116,7 @@ public class UserController extends BaseController {
|
||||
// 已经在 getUserByToken 方法中判断了 token 为空、不合法;用户不存在情况,此处无需再判断
|
||||
UserModel userModel = userService.getUserByToken(redisTemplate, token);
|
||||
|
||||
if(password == null || "".equals(password)){
|
||||
if (password == null || "".equals(password)) {
|
||||
throw new BusinessException(BusinessErrorCode.PARAMETER_VALIDATION_ERROR, "参数不合法,缺少密码");
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,170 @@
|
||||
package plus.bookshelf.Dao.DO;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class VisitorFingerprintLogDO {
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column visitor_fingerprint_log.id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column visitor_fingerprint_log.visitor_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
private String visitorId;
|
||||
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column visitor_fingerprint_log.user_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
private Integer userId;
|
||||
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column visitor_fingerprint_log.create_at
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
private Date createAt;
|
||||
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column visitor_fingerprint_log.action
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
private String action;
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column visitor_fingerprint_log.id
|
||||
*
|
||||
* @return the value of visitor_fingerprint_log.id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column visitor_fingerprint_log.id
|
||||
*
|
||||
* @param id the value for visitor_fingerprint_log.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 visitor_fingerprint_log.visitor_id
|
||||
*
|
||||
* @return the value of visitor_fingerprint_log.visitor_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public String getVisitorId() {
|
||||
return visitorId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column visitor_fingerprint_log.visitor_id
|
||||
*
|
||||
* @param visitorId the value for visitor_fingerprint_log.visitor_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setVisitorId(String visitorId) {
|
||||
this.visitorId = visitorId == null ? null : visitorId.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column visitor_fingerprint_log.user_id
|
||||
*
|
||||
* @return the value of visitor_fingerprint_log.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 visitor_fingerprint_log.user_id
|
||||
*
|
||||
* @param userId the value for visitor_fingerprint_log.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 visitor_fingerprint_log.create_at
|
||||
*
|
||||
* @return the value of visitor_fingerprint_log.create_at
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Date getCreateAt() {
|
||||
return createAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column visitor_fingerprint_log.create_at
|
||||
*
|
||||
* @param createAt the value for visitor_fingerprint_log.create_at
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setCreateAt(Date createAt) {
|
||||
this.createAt = createAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column visitor_fingerprint_log.action
|
||||
*
|
||||
* @return the value of visitor_fingerprint_log.action
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column visitor_fingerprint_log.action
|
||||
*
|
||||
* @param action the value for visitor_fingerprint_log.action
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setAction(String action) {
|
||||
this.action = action == null ? null : action.trim();
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
package plus.bookshelf.Dao.Mapper;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import plus.bookshelf.Dao.DO.VisitorFingerprintLogDO;
|
||||
|
||||
@Repository // 添加这个注解,Autowired的时候idea就不会报错了
|
||||
public interface VisitorFingerprintLogDOMapper {
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table visitor_fingerprint_log
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table visitor_fingerprint_log
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int insert(VisitorFingerprintLogDO row);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table visitor_fingerprint_log
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int insertSelective(VisitorFingerprintLogDO row);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table visitor_fingerprint_log
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
VisitorFingerprintLogDO selectByPrimaryKey(Integer id);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table visitor_fingerprint_log
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int updateByPrimaryKeySelective(VisitorFingerprintLogDO row);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table visitor_fingerprint_log
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int updateByPrimaryKey(VisitorFingerprintLogDO row);
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
package plus.bookshelf.Service.Impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import plus.bookshelf.Dao.DO.VisitorFingerprintLogDO;
|
||||
import plus.bookshelf.Dao.Mapper.VisitorFingerprintLogDOMapper;
|
||||
import plus.bookshelf.Service.Service.VisitorFingerprintLogService;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
@Service
|
||||
public class VisitorFingerprintLogServiceImpl implements VisitorFingerprintLogService {
|
||||
|
||||
@Autowired
|
||||
VisitorFingerprintLogDOMapper visitorFingerprintLogDOMapper;
|
||||
|
||||
/**
|
||||
* 将用户指纹信息存入数据库
|
||||
*
|
||||
* @param action
|
||||
* @param userId
|
||||
* @param fingerprint
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean saveFingerprint(String action, Integer userId, String fingerprint) {
|
||||
|
||||
VisitorFingerprintLogDO visitorFingerprintLogDO = new VisitorFingerprintLogDO();
|
||||
visitorFingerprintLogDO.setCreateAt(Calendar.getInstance().getTime());
|
||||
visitorFingerprintLogDO.setAction(action);
|
||||
visitorFingerprintLogDO.setUserId(userId);
|
||||
visitorFingerprintLogDO.setVisitorId(fingerprint);
|
||||
|
||||
if (visitorFingerprintLogDO == null) {
|
||||
return false;
|
||||
} else {
|
||||
int affectRows = visitorFingerprintLogDOMapper.insertSelective(visitorFingerprintLogDO);
|
||||
return affectRows > 0;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package plus.bookshelf.Service.Service;
|
||||
|
||||
public interface VisitorFingerprintLogService {
|
||||
/**
|
||||
* 将用户指纹信息存入数据库
|
||||
*
|
||||
* @param action
|
||||
* @param userId
|
||||
* @param fingerprint
|
||||
* @return
|
||||
*/
|
||||
Boolean saveFingerprint(String action, Integer userId, String fingerprint);
|
||||
}
|
@@ -0,0 +1,125 @@
|
||||
<?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.VisitorFingerprintLogDOMapper">
|
||||
<resultMap id="BaseResultMap" type="plus.bookshelf.Dao.DO.VisitorFingerprintLogDO">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
-->
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="visitor_id" jdbcType="VARCHAR" property="visitorId" />
|
||||
<result column="user_id" jdbcType="INTEGER" property="userId" />
|
||||
<result column="create_at" jdbcType="TIMESTAMP" property="createAt" />
|
||||
<result column="action" jdbcType="VARCHAR" property="action" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
-->
|
||||
id, visitor_id, user_id, create_at, `action`
|
||||
</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 visitor_fingerprint_log
|
||||
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 visitor_fingerprint_log
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="plus.bookshelf.Dao.DO.VisitorFingerprintLogDO">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
-->
|
||||
insert into visitor_fingerprint_log (id, visitor_id, user_id,
|
||||
create_at, `action`)
|
||||
values (#{id,jdbcType=INTEGER}, #{visitorId,jdbcType=VARCHAR}, #{userId,jdbcType=INTEGER},
|
||||
#{createAt,jdbcType=TIMESTAMP}, #{action,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="plus.bookshelf.Dao.DO.VisitorFingerprintLogDO">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
-->
|
||||
insert into visitor_fingerprint_log
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="visitorId != null">
|
||||
visitor_id,
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="createAt != null">
|
||||
create_at,
|
||||
</if>
|
||||
<if test="action != null">
|
||||
`action`,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="visitorId != null">
|
||||
#{visitorId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
#{userId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="createAt != null">
|
||||
#{createAt,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="action != null">
|
||||
#{action,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="plus.bookshelf.Dao.DO.VisitorFingerprintLogDO">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
-->
|
||||
update visitor_fingerprint_log
|
||||
<set>
|
||||
<if test="visitorId != null">
|
||||
visitor_id = #{visitorId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
user_id = #{userId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="createAt != null">
|
||||
create_at = #{createAt,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="action != null">
|
||||
`action` = #{action,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="plus.bookshelf.Dao.DO.VisitorFingerprintLogDO">
|
||||
<!--
|
||||
WARNING - @mbg.generated
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
-->
|
||||
update visitor_fingerprint_log
|
||||
set visitor_id = #{visitorId,jdbcType=VARCHAR},
|
||||
user_id = #{userId,jdbcType=INTEGER},
|
||||
create_at = #{createAt,jdbcType=TIMESTAMP},
|
||||
`action` = #{action,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
@@ -106,5 +106,8 @@
|
||||
<!--<table tableName="failure_feedback" domainObjectName="FailureFeedbackDO" enableCountByExample="false"-->
|
||||
<!-- enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"-->
|
||||
<!-- selectByExampleQueryId="false"></table>-->
|
||||
<!--<table tableName="visitor_fingerprint_log" domainObjectName="VisitorFingerprintLogDO" enableCountByExample="false"-->
|
||||
<!-- enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"-->
|
||||
<!-- selectByExampleQueryId="false"></table>-->
|
||||
</context>
|
||||
</generatorConfiguration>
|
Reference in New Issue
Block a user