parent
347c9e6bf3
commit
b54fcbb6f3
@ -1,14 +1,30 @@ |
||||
package com.share.help.dao; |
||||
|
||||
import com.share.help.entity.LeaveWordEntity; |
||||
import com.share.help.entity.custorm.LeaveWordRes; |
||||
import com.share.help.res.Page; |
||||
import org.apache.ibatis.annotations.Insert; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Select; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 留言信息数据接口 |
||||
*/ |
||||
public interface LeaveWordMapper { |
||||
|
||||
// 添加留言
|
||||
@Insert("insert into leave_word(type,source_user_id,target_user_id,activity_id,create_time)" + |
||||
"value(#{type},#{sourceUserId},#{targetUserId},#{activityId},#{createTime})") |
||||
boolean insert(LeaveWordEntity leaveWordEntity); |
||||
|
||||
// 查询留言列表
|
||||
@Select("select user.user_id as userId,user.name,user.head_img as headImg,user.info,leave_word.type,activity_id as activityId from leave_word,user\n" + |
||||
"where leave_word.target_user_id=#{userId} and leave_word.target_user_id=user.user_id order by create_time desc limit #{start},#{count}") |
||||
List<LeaveWordRes> select(@Param("start") long start,@Param("count") long count,@Param("userId") String userId); |
||||
|
||||
// 统计留言列表分页数
|
||||
@Select("select count(*) as count,ceil(count(*)/#{pageSize}) as totalPage from leave_word where target_user_id=#{userId}") |
||||
Page<List<LeaveWordRes>> count(@Param("pageSize") Integer pageSize,@Param("userId") String userId); |
||||
} |
||||
|
@ -0,0 +1,89 @@ |
||||
package com.share.help.entity.custorm; |
||||
|
||||
import com.share.help.form.LeaveWordType; |
||||
|
||||
/** |
||||
* 留言列表 |
||||
*/ |
||||
public class LeaveWordRes { |
||||
// 留言用户id
|
||||
private String userId; |
||||
// 留言用户姓名
|
||||
private String name; |
||||
// 留言用户头像
|
||||
private String headImg; |
||||
// 留言类型
|
||||
private LeaveWordType type; |
||||
// 活动id
|
||||
private Long activityId; |
||||
// 留言用户简介
|
||||
private String info; |
||||
//活动标题
|
||||
private String title; |
||||
//活动内容
|
||||
private String content; |
||||
|
||||
public String getTitle() { |
||||
return title; |
||||
} |
||||
|
||||
public void setTitle(String title) { |
||||
this.title = title; |
||||
} |
||||
|
||||
public String getContent() { |
||||
return content; |
||||
} |
||||
|
||||
public void setContent(String content) { |
||||
this.content = content; |
||||
} |
||||
|
||||
public String getInfo() { |
||||
return info; |
||||
} |
||||
|
||||
public void setInfo(String info) { |
||||
this.info = info; |
||||
} |
||||
|
||||
public Long getActivityId() { |
||||
return activityId; |
||||
} |
||||
|
||||
public void setActivityId(Long activityId) { |
||||
this.activityId = activityId; |
||||
} |
||||
|
||||
public String getUserId() { |
||||
return userId; |
||||
} |
||||
|
||||
public void setUserId(String userId) { |
||||
this.userId = userId; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getHeadImg() { |
||||
return headImg; |
||||
} |
||||
|
||||
public void setHeadImg(String headImg) { |
||||
this.headImg = headImg; |
||||
} |
||||
|
||||
public LeaveWordType getType() { |
||||
return type; |
||||
} |
||||
|
||||
public void setType(LeaveWordType type) { |
||||
this.type = type; |
||||
} |
||||
} |
@ -0,0 +1,26 @@ |
||||
package com.share.help.form; |
||||
|
||||
/** |
||||
* 查找留言表单 |
||||
*/ |
||||
public class FindLeaveWordForm { |
||||
private Integer currentPage; |
||||
|
||||
private String userId; |
||||
|
||||
public String getUserId() { |
||||
return userId; |
||||
} |
||||
|
||||
public void setUserId(String userId) { |
||||
this.userId = userId; |
||||
} |
||||
|
||||
public Integer getCurrentPage() { |
||||
return currentPage; |
||||
} |
||||
|
||||
public void setCurrentPage(Integer currentPage) { |
||||
this.currentPage = currentPage; |
||||
} |
||||
} |
@ -0,0 +1,37 @@ |
||||
package com.share.help.form; |
||||
|
||||
/** |
||||
* 查找用户 |
||||
*/ |
||||
public class QueryUserForm { |
||||
//用户id
|
||||
private String userId; |
||||
//用户名
|
||||
private String userName; |
||||
//简介信息
|
||||
private String info; |
||||
|
||||
public String getUserId() { |
||||
return userId; |
||||
} |
||||
|
||||
public void setUserId(String userId) { |
||||
this.userId = userId; |
||||
} |
||||
|
||||
public String getUserName() { |
||||
return userName; |
||||
} |
||||
|
||||
public void setUserName(String userName) { |
||||
this.userName = userName; |
||||
} |
||||
|
||||
public String getInfo() { |
||||
return info; |
||||
} |
||||
|
||||
public void setInfo(String info) { |
||||
this.info = info; |
||||
} |
||||
} |
@ -0,0 +1,44 @@ |
||||
package com.share.help.service; |
||||
|
||||
import com.share.help.dao.ActivityMapper; |
||||
import com.share.help.dao.LeaveWordMapper; |
||||
import com.share.help.entity.ActivityEntity; |
||||
import com.share.help.entity.custorm.LeaveWordRes; |
||||
import com.share.help.form.FindLeaveWordForm; |
||||
import com.share.help.form.LeaveWordType; |
||||
import com.share.help.res.DefaultRes; |
||||
import com.share.help.res.JSONResponse; |
||||
import com.share.help.res.Page; |
||||
import com.share.help.res.Result; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Service |
||||
public class LeaveWordService { |
||||
|
||||
@Value("${leave-word.page-size}") |
||||
private int pageSize; |
||||
|
||||
@Autowired |
||||
private LeaveWordMapper leaveWordMapper; |
||||
|
||||
@Autowired |
||||
private ActivityMapper activityMapper; |
||||
|
||||
public JSONResponse<DefaultRes, Page<List<LeaveWordRes>>> query(FindLeaveWordForm findLeaveWordForm){ |
||||
Page<List<LeaveWordRes>> listPage=leaveWordMapper.count(pageSize,findLeaveWordForm.getUserId()); |
||||
List<LeaveWordRes> leaveWordRes=leaveWordMapper.select((findLeaveWordForm.getCurrentPage()-1)*pageSize,pageSize,findLeaveWordForm.getUserId()); |
||||
for(LeaveWordRes wordRes:leaveWordRes){ |
||||
if(LeaveWordType.friend!=wordRes.getType()&&wordRes.getActivityId()!=null){ |
||||
ActivityEntity activityEntity=activityMapper.findOne(wordRes.getActivityId()); |
||||
wordRes.setTitle(activityEntity.getTitle()); |
||||
wordRes.setContent(activityEntity.getContent()); |
||||
} |
||||
} |
||||
listPage.setBody(leaveWordRes); |
||||
return new JSONResponse<DefaultRes,Page<List<LeaveWordRes>>>(DefaultRes.ok, Result.OK).setBody(listPage); |
||||
} |
||||
} |
Loading…
Reference in new issue