会员点赞的核心实现
imooc-reader 项目:
webapp\WEB-INF\ftl\
detail.ftl 图书详情页面
<div class="reply pl-2 pr-2">
<!-- 遍历评论集合 -->
<#list evaluationList as evaluation>
<div>
<div>
<!-- string("MM-dd") 表示对日期格式化, 只保留"月-日" -->
<span class="pt-1 small text-black-50 mr-2">${evaluation.createTime ? string("MM-dd")}</span>
<!-- 昵称 -->
<span class="mr-2 small pt-1">${evaluation.member.nickname}</span>
<!-- 评分 -->
<span class="stars mr-2" data-score="${evaluation.score}"></span>
<!-- 点赞按钮 -->
<button type="button" data-evaluation-id="${evaluation.evaluationId}"
class="btn btn-success btn-sm text-white float-right" style="margin-top: -3px;">
<img style="width: 24px;margin-top: -5px;" class="mr-1"
src="https://img3.doubanio.com/f/talion/7a0756b3b6e67b59ea88653bc0cfa14f61ff219d/pics/card/ic_like_gray.svg"/>
<!-- 点赞数量 -->
<span>${evaluation.enjoy}</span>
</button>
</div>
<!-- 短评内容 -->
<div class="row mt-2 small mb-3">
${evaluation.content}
</div>
<hr/>
</div>
</#list>
</div>
.service.
MemberService 会员服务接口
package com.tony.reader.service;
import com.tony.reader.entity.Evaluation;
import com.tony.reader.entity.Member;
import com.tony.reader.entity.MemberReadState;
/**
* 会员服务接口
*/
public interface MemberService {
//创建一个新的会员(会员注册), 参数3为昵称
public Member createMember(String username, String password, String nickname);
//会员登录
public