mapper.xml
<select id="selectPointGiveList" resultMap="BaseResultMap2"
parameterType="com.integral.po.TUserPo">
SELECT
a.uid,
a. NAME,
a.orgcode,
a.imgaccesspath,
b.uiddonate,
b.uiddonated,
b.jifen,
b.createtime, o.orgname
FROM
t_jifen_user a
LEFT JOIN t_jifen_jifen_donate b ON a.uid = b.uiddonated
LEFT JOIN t_jifen_org o ON a.orgcode = o.orgcode
GROUP BY
a.uid
ORDER BY
b.createtime
DESC
</select>
<resultMap id="BaseResultMap2" type="com.integral.po.TUserPo"
extends="BaseResultMap">
<result column="orgname" property="orgname" jdbcType="VARCHAR" />
<result column="uiddonate" property="uiddonate" jdbcType="VARCHAR" />
<result column="uiddonated" property="uiddonated" jdbcType="VARCHAR" />
</resultMap>
mapper:
Page<TUserPo> selectPointGiveList(TUserPo po);
service:
PageInfo<TUserPo> selectPointGiveList(TUserPo po);
serviceImpl:
public PageInfo<TUserPo> selectPointGiveList(TUserPo po) {
PageInfo<TUserPo> pageInfo = null;
int pageNum = 1;
int pageSize = 0;
if (LBUtil.isNotEmpty(po)) {
pageNum = po.getPageNum();
}
if (LBUtil.isNotEmpty(po)) {
pageSize = po.getPageSize();
}
PageHelper.startPage(pageNum, pageSize, true);
Page<TUserPo> pages = tUserMapper.selectPointGiveList(po);
String uiddonateString = null;
String uiddonatedString = null;
uiddonateString =po.getUid();
if (pages.size() > 0) {
for (TUserPo pgPo:pages) {
if (LBUtil.isNotEmpty(pgPo)) {
//遍历id
uiddonatedString = pgPo.getUiddonated();
}
//根据遍历的id查处不同的数据
List<JifenDonate> pgList = pointGiveService.selectSelfAndOther1(uiddonateString,uiddonatedString);
pgPo.setPgList(pgList);
//根据遍历的id查处不同的数据
}
}
if (null != pages) {
pageInfo = new PageInfo<TUserPo>(pages);
}
return pageInfo;
}
controller:
@RequestMapping("selectPointGiveList")
@ResponseBody
public LBResult selectPointGiveList(HttpServletRequest request,
HttpServletResponse response, TUserPo po) {
PageInfo<TUserPo> list = tuserService.selectPointGiveList(po);
try {
if (LBUtil.isNotEmpty(list)) {
return LBResult.build(400, "成功", list);
} else {
return LBResult.build(400, "失败");
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
return LBResult.build(401, "没有数据");
}
}
po:
public class TUserPo extends UserJifen {
//用于接收是否点赞的字段
private String clickLike;
public String getClickLike() {
return clickLike;
}
public void setClickLike(String clickLike) {
this.clickLike = clickLike;
}
//关联表clicklike的cid
private String cid;
public String getCid() {
return cid;
}
public void setCid(String cid) {
this.cid = cid;
}
private String pointGive;
public String getPointGive() {
return pointGive;
}
public void setPointGive(String pointGive) {
this.pointGive = pointGive;
}
private String uiddonate;
public String getUiddonate() {
return uiddonate;
}
public void setUiddonate(String uiddonate) {
this.uiddonate = uiddonate;
}
private String uiddonated;
public String getUiddonated() {
return uiddonated;
}
public void setUiddonated(String uiddonated) {
this.uiddonated = uiddonated;
}
private String orgname;// 机构名称
public String getOrgname() {
return orgname;
}
public void setOrgname(String orgname) {
this.orgname = orgname;
}
private List<JifenDonate> pgList;
public List<JifenDonate> getPgList() {
return pgList;
}
public void setPgList(List<JifenDonate> pgList) {
this.pgList = pgList;
}
}
user:
public class UserJifen extends BasePo{
private String uid;
private String username;
private String password;
private String name;
private String userstatus;
private String usergender;
private String imgname;
private String imgpath;
private String imgaccesspath;
private String orgcode;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")// 存储日期时使用
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")// 查询日期时使用
private Date createtime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")// 存储日期时使用
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")// 查询日期时使用
private Date updatetime;
}