mirror of
				https://github.com/ZSCNetSupportDept/WechatTicketSystem.git
				synced 2025-11-01 02:46:19 +08:00 
			
		
		
		
	new operator entity
This commit is contained in:
		| @@ -1,5 +1,13 @@ | ||||
| package love.sola.netsupport.sql; | ||||
|  | ||||
| import love.sola.netsupport.enums.Status; | ||||
| import love.sola.netsupport.pojo.Ticket; | ||||
| import love.sola.netsupport.pojo.User; | ||||
| import org.hibernate.Session; | ||||
| import org.hibernate.criterion.Restrictions; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * *********************************************** | ||||
|  * Created by Sola on 2015/12/6. | ||||
| @@ -17,4 +25,24 @@ public class TableTicket extends SQLCore { | ||||
| 	public static final String COLUMN_OPSID = "opsid"; | ||||
| 	public static final String COLUMN_STATUS = "status"; | ||||
|  | ||||
|  | ||||
| 	public static Ticket queryLastOpen(User u) { | ||||
| 		try (Session s = SQLCore.sf.openSession()) { | ||||
| 			return (Ticket) s.createCriteria(Ticket.class) | ||||
| 					.add(Restrictions.eq(Ticket.PROPERTY_USER, u)) | ||||
| 					.add(Restrictions.eq(Ticket.PROPERTY_STATUS, Status.UNCHECKED)) | ||||
| 					.uniqueResult(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	@SuppressWarnings("unchecked") | ||||
| 	public static List<Ticket> queryUnsolvedByBlock(int b) { | ||||
| 		try (Session s = SQLCore.sf.openSession()) { | ||||
| 			return s.createCriteria(Ticket.class) | ||||
| 					.createCriteria(Ticket.PROPERTY_USER) | ||||
| 					.add(Restrictions.between(User.PROPERTY_BLOCK, b * 10, (b + 1) * 10 - 1)) | ||||
| 					.list(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,7 +1,6 @@ | ||||
| package love.sola.netsupport.sql; | ||||
|  | ||||
| import love.sola.netsupport.pojo.User; | ||||
| import org.hibernate.HibernateException; | ||||
| import org.hibernate.Session; | ||||
| import org.hibernate.criterion.Restrictions; | ||||
|  | ||||
| @@ -26,29 +25,20 @@ public class TableUser extends SQLCore { | ||||
| 	public static User getUserById(long id) { | ||||
| 		try (Session s = sf.openSession()) { | ||||
| 			return s.get(User.class, id); | ||||
| 		} catch (HibernateException e) { | ||||
| 			e.printStackTrace(); | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	public static User getUserByWechat(String wechat) { | ||||
| 		try (Session s = sf.openSession()) { | ||||
| 			return (User) s.createCriteria(User.class).add(Restrictions.eq(COLUMN_WECHAT, wechat)).uniqueResult(); | ||||
| 		} catch (HibernateException e) { | ||||
| 			e.printStackTrace(); | ||||
| 			return (User) s.createCriteria(User.class).add(Restrictions.eq(User.PROPERTY_WECHAT, wechat)).uniqueResult(); | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
|  | ||||
| 	public static User getUserByName(String name) { | ||||
| 		try (Session s = sf.openSession()) { | ||||
| 			return (User) s.createCriteria(User.class).add(Restrictions.eq(COLUMN_NAME, name)).uniqueResult(); | ||||
| 		} catch (HibernateException e) { | ||||
| 			e.printStackTrace(); | ||||
| 			return (User) s.createCriteria(User.class).add(Restrictions.eq(User.PROPERTY_NAME, name)).uniqueResult(); | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
|  | ||||
| 	public static int updateUser(User user) { | ||||
| @@ -57,10 +47,7 @@ public class TableUser extends SQLCore { | ||||
| 			s.update(user); | ||||
| 			s.getTransaction().commit(); | ||||
| 			return 1; | ||||
| 		} catch (HibernateException e) { | ||||
| 			e.printStackTrace(); | ||||
| 		} | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Sola
					Sola