功能需求
点击市场活动名称链接,跳转到明细页面,查看市场活动明细
-市场活动的基本信息
-市场活动下所有的备注信息
功能分析
流程图
代码实现
一、ActivityRemarkMapper
1.ActivityRemarkMapper接口
/**
* 根据市场活动id查询备注
*/
List<ActivityRemark> selectActivityRemarkByActId(String activityId);
2.ActivityRemarkMapper映射文件,根据市场活动id查询备注集合
<!--selectActivityRemarkByActId-->
<select id="selectActivityRemarkByActId" resultMap="BaseResultMap">
select ar.id,
ar.note_content,
ar.create_time,
u1.name as create_by,
ar.edit_time,
u2.name as edit_by,
ar.edit_flag
from tbl_activity_remark ar
join tbl_user u1 on ar.create_by = u1.id
left join tbl_user u2 on ar.edit_by = u2.id
where ar.activity_id = #{activityId}
</select>
二、ActivityRemarkService
/**
* 查看市场活动备注
*/
List<ActivityRemark> queryActivityRemarkByActId(String activityId);
@Autowired
private ActivityRemarkMapper activityRemarkMapper;
@Override
public List<ActivityRemark> queryActivityRemarkByActId(String activityId) {
return activityRemarkMapper.selectActivityRemarkByActId(activityId);
}
三、ActivityRemarkController
@Autowired
private ActivityRemarkService activityRemarkService;
@RequestMapping("/workbench/activity/ActivityDetail.do")
public String ActivityDetail(String id,HttpServletRequest request){
// 调用activityService获取市场活动详细
Activity activity = activityService.queryActivityForDetail(id);
// 调用activityRemarkService,获取评论信息
List<ActivityRemark> activityRemarksList = activityRemarkService.queryActivityRemarkByActId(id);
// 保存在请求域
request.setAttribute("activity",activity);
request.setAttribute("activityRemarksList",activityRemarksList);
return "workbench/activity/detail";
}
四、前端detail.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
通过<c:forEach items="${域存放的集合}" var="remark">
<c:forEach items="${activityRemarksList}" var="remark">
<div id="div_${remark.id}" class="remarkDiv" style="height: 60px;">
<img title="${remark.createBy}" src="image/user-thumbnail.png" style="width: 35px; height:35px;">
<div style="position: relative; top: -40px; left: 40px;width: 870px; ">
<small style="color: gray;">@${remark.editFlag=='1'?remark.editBy:remark.createBy}:${remark.editFlag=='1'?remark.editTime:remark.createTime}${remark.editFlag=='1'?'修改':'创建'}</small>
<p>${remark.noteContent}</p>
<div style="position: relative; left: 500px; top: -30px; height: 30px; width: 100px; display: none;">
<a class="myHref" name="editA" remarkId="${remark.id}" href="javascript:void(0);"><span
class="glyphicon glyphicon-edit" style="font-size: 20px; color: #E6E6E6;"></span></a>
<a class="myHref" name="deleteA" remarkId="${remark.id}" href="javascript:void(0);"><span
class="glyphicon glyphicon-remove" style="font-size: 20px; color: #E6E6E6;"></span></a>
</div>
</div>
</div>
</c:forEach>