增加:
单条增加xml
DAO
public int insert(WycjwdjlTemp wycjwdjlTemp) {
return sessionTemplate.insert("addWycjwdjlTemp", wycjwdjlTemp);
}
XML
INSERT INTO wycjwdjl_temp (recordid, lng, lat, gpstime, speed, isabled,direction,remark)
VALUES (#{recordid},#{lng},#{lat},#{gpstime},#{speed},#{isabled},#{direction},#{remark})
*************************************************************************************************************************************
批量增加xml:
DAO:
public int insert(List wycjwdjlTemps) {
return sessionTemplate.insert("addWycjwdjlTempBatch", wycjwdjlTemps);
}
XML
INSERT INTO wycjwdjl_temp (recordid, lng, lat, gpstime, speed, isabled,direction,remark) values
(#{item.recordid},#{item.lng},#{item.lat},#{item.gpstime},#{item.speed},#{item.isabled},#{item.direction},#{item.remark})
查询:
DAO:
public UserDacheReceipt findUserDacheReceiptByrecordId(long recordId) {
UserDacheReceipt userDacheReceipt=sessionTemplate.selectOne("findUserDacheReceiptByrecordId",recordId);
return userDacheReceipt;
}
DAO list;
public List findUserDacheReceiptByrecordId(long recordId) {
List userDacheReceipts=sessionTemplate.selectList("findUserDacheReceiptByrecordId",recordId);
return userDacheReceipts;
}
XML
*************************************************************************************************************************************
更新:
DAO
public int update(UserDache userDache) {
return sessionTemplate.update("editDacheUser", userDache);
}
xml
UPDATE `user_dache_info` SET `username`=#{username}, `tel`=#{tel}, `sex`=#{sex} WHERE openid=#{openid};
删除
DAO
public void del(int id) {
sessionTemplate.delete("delDacheUser", id);
}
xml
DELETE FROM user_dache_info where id=#{id}
*****************************************************************************************************************************************************
批量查询、模糊查询和时间段查询
DAO
public List findUsers(String starttime,String endtime,String username,String tel) {
Map map=new HashMap();
map.put("startTime",starttime);
map.put("endTime",endtime);
map.put("username",username);
map.put("tel",tel);
List list = sessionTemplate.selectList("findUsers",map);
return list;
}
xml
1 = 1//一定能执行,为了关联后面的ADN,不然会报错
AND createTime >= #{startTime}
AND createTime <= #{endTime}
AND username LIKE CONCAT ('%',#{username},'%' )
AND tel LIKE CONCAT('%',#{tel},'%' )