对Entity的未用字段进行借鸡下蛋
.
1.实体
public class Image extends BaseEntity {/** * serialVersionUID. */private static final long serialVersionUID = -9072699651769160951L;private String userId;private String title;// 标题private String sourcePath;// 图片原图路径private String smallPath;// 缩略图路径private String description;// 图片描述private int likes;// 得票数private String lgt;// 经度private String lat;// 维度private boolean isJoinTheme = false;// 不参加主题精选:0 参加s为1private Date createDate;private Date modifyDate;private Comment comment;// 最新留言private String photoAlbumId;// 相册编号idprivate String advertisementId = "1";// 广告活动表 id,默认值为1表示不参加活动private boolean isAlive = true;// 照片是否被禁止,0或false、禁止;1或true、不禁止}
2.页面使用
<tr><th width="30"><input type="checkbox" id="checkAll"/></th><th>序</th><th>照片名</th><th>照片描述</th><th>是否已加活</th><th>票</th><th>上用</th><th>上</th><th>照片是否有效</th><th>操作</th></tr>
3.由于需要用户名,但是对于一个image来说userId是一个数字,所以采用借鸡下蛋,借用未使用的 sourcePath来当做userName
<!-- 根据条件返回照片列表 --><select id="selectImageByOffsetAndSizeWithKeyword"parameterType="map" resultType="image">SELECTp.id,p.userId,p.smallPath,u.userName ASsourcePath,p.likes,p.isJoinTheme,p.modifyDate,p.photoAlbumId,p.title,p.sourcePath,p.createDate,p.descriptionFROM image pLEFT JOIN user u ON u.id=p.userIdWHERE p.title LIKE"%"#{imageName}"%"<if test="userName !=null">AND u.userName LIKE "%"#{userName}"%" </if><if test="imageUpDate !=null">AND p.createDate LIKE "%"#{imageUpDate}"%" </if>LIMIT #{offset},#{pageSize};</select>
.