首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

对Entity的未用字段进行借鸡上蛋

2012-08-31 
对Entity的未用字段进行借鸡下蛋.1.实体public class Image extends BaseEntity {/** * serialVersionUID.

对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>





.




热点排行