1 package com.zq.www.mis.dao; 2 //import java.text.SimpleDateFormat; 3 //import java.util.Date; 4 5 import org.hibernate.Query; 6 import org.springframework.stereotype.Repository; 7 8 import com.zq.www.common.BaseDAO; 9 import com.zq.www.mis.entity.Discount; 10 @Repository 11 public class DiscountDAO extends BaseDAO<Discount> { 12 public String search(String dis,Discount discount) 13 { 14 String result = null; 15 16 /* SimpleDateFormat bartDateFormat = 17 new SimpleDateFormat("yyyy-MM-dd"); 18 String dateStringToParse = "date"; 19 try { 20 java.util.Date date1 = bartDateFormat.parse(dateStringToParse); 21 java.sql.Date sqlDate = new java.sql.Date(date1.getTime()); 22 System.out.println(sqlDate.getTime()); 23 } 24 catch (Exception ex) { 25 System.out.println(ex.getMessage()); 26 }*/ 27 28 if(dis.toString().equals("discount")) 29 { 30 /* java.sql.Date sd; 31 sd = new java.sql.Date(date.getTime());*/ 32 String sql="SELECT discount as a from discount where id=1"; 33 Query q = gs().createSQLQuery(sql); 34 result=q.toString(); 35 //price=Double.valueOf(q.toString()).doubleValue(); 36 //price=Double.valueOf(q.toString())*price; 37 } 38 else if(dis.toString().equals("children")) 39 { 40 String sql1="SELECT children as b from discount where id=1"; 41 Query q1 = gs().createSQLQuery(sql1); 42 // price=Double.valueOf(q.toString())*price; 43 44 } 45 else if(dis.toString().equals("adult")) 46 { 47 String sql2="SELECT adult as c from discount where id=1"; 48 Query q2 = gs().createSQLQuery(sql2); 49 //price=Double.valueOf(q.toString())*price; 50 } 51 else if(dis.toString().equals("golden")) 52 { 53 String sql3="SELECT golden as d from discount where id=1"; 54 Query q3 = gs().createSQLQuery(sql3); 55 // price=Double.valueOf(q.toString())*price; 56 } 57 else if(dis.toString().equals("silver")) 58 { 59 String sql4="SELECT silver from discount where id=1"; 60 Query q4 = gs().createSQLQuery(sql4); 61 //price=Double.valueOf(q.toString())*price; 62 } 63 return result; 64 } 65 }
时间: 2024-10-06 07:23:19