mirror of
https://github.com/ZSCNetSupportDept/WechatTicketSystem.git
synced 2025-10-29 08:05:04 +08:00
new operator entity
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package love.sola.netsupport.api;
|
package love.sola.netsupport.api;
|
||||||
|
|
||||||
import love.sola.netsupport.enums.Block;
|
|
||||||
import love.sola.netsupport.enums.ISP;
|
import love.sola.netsupport.enums.ISP;
|
||||||
import love.sola.netsupport.pojo.User;
|
import love.sola.netsupport.pojo.User;
|
||||||
import love.sola.netsupport.sql.TableUser;
|
import love.sola.netsupport.sql.TableUser;
|
||||||
@@ -38,7 +37,7 @@ public class Register extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ISP isp = checkISP(request.getParameter("isp"));
|
ISP isp = checkISP(request.getParameter("isp"));
|
||||||
Block block = checkBlock(request.getParameter("block"));
|
int block = checkBlock(request.getParameter("block"));
|
||||||
String result = register(
|
String result = register(
|
||||||
checkStudentId(request.getParameter("sid")),
|
checkStudentId(request.getParameter("sid")),
|
||||||
request.getParameter("name"),
|
request.getParameter("name"),
|
||||||
@@ -60,13 +59,13 @@ public class Register extends HttpServlet {
|
|||||||
Redirect.message(response, -1, "Illegal_Request");
|
Redirect.message(response, -1, "Illegal_Request");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String register(long sid, String name, ISP isp, String netAccount, Block block, int room, long phone, String wechat) {
|
private String register(long sid, String name, ISP isp, String netAccount, int block, int room, long phone, String wechat) {
|
||||||
if (wechat == null) return "Illegal_Request";
|
if (wechat == null) return "Illegal_Request";
|
||||||
if (sid == -1) return "Invalid_Student_Id";
|
if (sid == -1) return "Invalid_Student_Id";
|
||||||
if (name == null) return "Invalid_Name";
|
if (name == null) return "Invalid_Name";
|
||||||
if (isp == null) return "Invalid_ISP";
|
if (isp == null) return "Invalid_ISP";
|
||||||
if (netAccount == null) return "Invalid_Account";
|
if (netAccount == null) return "Invalid_Account";
|
||||||
if (block == null) return "Invalid_Block";
|
if (block == -1) return "Invalid_Block";
|
||||||
if (room == -1) return "Invalid_Room";
|
if (room == -1) return "Invalid_Room";
|
||||||
if (phone == -1) return "Invalid_Phone_Number";
|
if (phone == -1) return "Invalid_Phone_Number";
|
||||||
User user = TableUser.getUserById(sid);
|
User user = TableUser.getUserById(sid);
|
||||||
@@ -122,17 +121,17 @@ public class Register extends HttpServlet {
|
|||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Block checkBlock(String block) {
|
private int checkBlock(String block) {
|
||||||
if (block == null) return null;
|
if (block == null) return -1;
|
||||||
try {
|
try {
|
||||||
return Block.fromId(Integer.parseInt(block));
|
return Integer.parseInt(block);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
return null;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int checkRoom(String room, Block block) {
|
private int checkRoom(String room, int block) {
|
||||||
if (block == null) return -1;
|
if (block == -1) return -1;
|
||||||
if (room == null) return -1;
|
if (room == null) return -1;
|
||||||
try {
|
try {
|
||||||
Integer i = Integer.parseInt(room);
|
Integer i = Integer.parseInt(room);
|
||||||
|
|||||||
10
src/main/java/love/sola/netsupport/api/TicketCancel.java
Normal file
10
src/main/java/love/sola/netsupport/api/TicketCancel.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package love.sola.netsupport.api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ***********************************************
|
||||||
|
* Created by Sola on 2015/12/6.
|
||||||
|
* Don't modify this source without my agreement
|
||||||
|
* ***********************************************
|
||||||
|
*/
|
||||||
|
public class TicketCancel {
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import love.sola.netsupport.wechat.Command;
|
|||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.criterion.Order;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
@@ -64,6 +65,7 @@ public class TicketQuery extends HttpServlet {
|
|||||||
int limit = request.getParameter("limit") == null ? 5 : Integer.parseInt(request.getParameter("limit"));
|
int limit = request.getParameter("limit") == null ? 5 : Integer.parseInt(request.getParameter("limit"));
|
||||||
c.setFirstResult(first);
|
c.setFirstResult(first);
|
||||||
c.setMaxResults(limit);
|
c.setMaxResults(limit);
|
||||||
|
c.addOrder(Order.desc(Ticket.PROPERTY_SUBMIT_TIME));
|
||||||
c.add(Restrictions.eq(Ticket.PROPERTY_USER, u));
|
c.add(Restrictions.eq(Ticket.PROPERTY_USER, u));
|
||||||
if (request.getParameter("status") != null) {
|
if (request.getParameter("status") != null) {
|
||||||
c.add(Restrictions.eq(Ticket.PROPERTY_STATUS, Integer.parseInt(request.getParameter("status"))));
|
c.add(Restrictions.eq(Ticket.PROPERTY_STATUS, Integer.parseInt(request.getParameter("status"))));
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package love.sola.netsupport.api;
|
package love.sola.netsupport.api.admin;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import love.sola.netsupport.api.Response;
|
||||||
import love.sola.netsupport.pojo.User;
|
import love.sola.netsupport.pojo.User;
|
||||||
import love.sola.netsupport.sql.SQLCore;
|
import love.sola.netsupport.sql.SQLCore;
|
||||||
import love.sola.netsupport.sql.TableUser;
|
import love.sola.netsupport.sql.TableUser;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package love.sola.netsupport.api;
|
package love.sola.netsupport.api.test;
|
||||||
|
|
||||||
import javax.servlet.ServletConfig;
|
import javax.servlet.ServletConfig;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
@@ -1,106 +1,56 @@
|
|||||||
package love.sola.netsupport.enums;
|
package love.sola.netsupport.enums;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static love.sola.netsupport.config.Lang.lang;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ***********************************************
|
* ***********************************************
|
||||||
* Created by Sola on 2015/11/30.
|
* Created by Sola on 2015/11/30.
|
||||||
* Don't modify this source without my agreement
|
* Don't modify this source without my agreement
|
||||||
* ***********************************************
|
* ***********************************************
|
||||||
*/
|
*/
|
||||||
public enum Block {
|
public class Block {
|
||||||
|
|
||||||
@SerializedName("10")
|
public static final int QT_18 = 10;
|
||||||
QT_18(10),
|
public static final int QT_19 = 11;
|
||||||
@SerializedName("11")
|
public static final int QT_16 = 12;
|
||||||
QT_19(11),
|
public static final int QT_17 = 13;
|
||||||
@SerializedName("12")
|
public static final int BM_7 = 20;
|
||||||
QT_16(12),
|
public static final int BM_8 = 21;
|
||||||
@SerializedName("13")
|
public static final int BM_9 = 22;
|
||||||
QT_17(13),
|
public static final int BM_10 = 23;
|
||||||
@SerializedName("20")
|
public static final int BM_11 = 24;
|
||||||
BM_7(20),
|
public static final int DM_12 = 30;
|
||||||
@SerializedName("21")
|
public static final int DM_13 = 31;
|
||||||
BM_8(21),
|
public static final int DM_14 = 32;
|
||||||
@SerializedName("22")
|
public static final int DM_15 = 33;
|
||||||
BM_9(22),
|
public static final int XH_A = 40;
|
||||||
@SerializedName("23")
|
public static final int XH_B = 41;
|
||||||
BM_10(23),
|
public static final int XH_C = 42;
|
||||||
@SerializedName("24")
|
public static final int XH_D = 43;
|
||||||
BM_11(24),
|
public static final int FX_1 = 50;
|
||||||
@SerializedName("30")
|
public static final int FX_2 = 51;
|
||||||
DM_12(30),
|
public static final int FX_3 = 52;
|
||||||
@SerializedName("31")
|
public static final int FX_4 = 53;
|
||||||
DM_13(31),
|
public static final int FX_5 = 54;
|
||||||
@SerializedName("32")
|
public static final int FX_6 = 55;
|
||||||
DM_14(32),
|
public static final int DM_20 = 60;
|
||||||
@SerializedName("33")
|
public static final int DM_21 = 61;
|
||||||
DM_15(33),
|
|
||||||
@SerializedName("40")
|
|
||||||
XH_A(40),
|
|
||||||
@SerializedName("41")
|
|
||||||
XH_B(41),
|
|
||||||
@SerializedName("42")
|
|
||||||
XH_C(42),
|
|
||||||
@SerializedName("43")
|
|
||||||
XH_D(43),
|
|
||||||
@SerializedName("50")
|
|
||||||
FX_1(50),
|
|
||||||
@SerializedName("51")
|
|
||||||
FX_2(51),
|
|
||||||
@SerializedName("52")
|
|
||||||
FX_3(52),
|
|
||||||
@SerializedName("53")
|
|
||||||
FX_4(53),
|
|
||||||
@SerializedName("54")
|
|
||||||
FX_5(54),
|
|
||||||
@SerializedName("55")
|
|
||||||
FX_6(55),
|
|
||||||
@SerializedName("60")
|
|
||||||
DM_20(60),
|
|
||||||
@SerializedName("61")
|
|
||||||
DM_21(61),
|
|
||||||
;
|
|
||||||
|
|
||||||
private static final Map<String, Block> NAME_MAP = new HashMap<>();
|
public static final Map<Integer, String> inverseMap = new HashMap<>();
|
||||||
private static final Map<Integer, Block> ID_MAP = new HashMap<>();
|
|
||||||
|
|
||||||
static {
|
static{
|
||||||
for (Block type : values()) {
|
System.out.println("Loading Blocks...");
|
||||||
if (type.name != null) {
|
for (Field field : Block.class.getDeclaredFields()) {
|
||||||
NAME_MAP.put(type.name.toLowerCase(), type);
|
if (field.getType().isAssignableFrom(Integer.TYPE)) {
|
||||||
}
|
try {
|
||||||
if (type.id > 0) {
|
inverseMap.put((Integer) field.get(null), field.getName());
|
||||||
ID_MAP.put(type.id, type);
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String name;
|
|
||||||
public final int id;
|
|
||||||
|
|
||||||
Block(int id) {
|
|
||||||
this.name = lang("BLOCK_" + name());
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Block fromName(String name) {
|
|
||||||
if (name == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return NAME_MAP.get(name.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Block fromId(int id) {
|
|
||||||
return ID_MAP.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() { return name; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
package love.sola.netsupport.enums;
|
|
||||||
|
|
||||||
import javax.persistence.AttributeConverter;
|
|
||||||
import javax.persistence.Converter;
|
|
||||||
|
|
||||||
@Converter
|
|
||||||
public class BlockConverter implements AttributeConverter<Block, Integer> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer convertToDatabaseColumn(Block attribute) {
|
|
||||||
if (attribute == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return attribute.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Block convertToEntityAttribute(Integer dbData) {
|
|
||||||
if (dbData == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return Block.fromId(dbData);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
33
src/main/java/love/sola/netsupport/enums/Status.java
Normal file
33
src/main/java/love/sola/netsupport/enums/Status.java
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package love.sola.netsupport.enums;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ***********************************************
|
||||||
|
* Created by Sola on 2015/12/6.
|
||||||
|
* Don't modify this source without my agreement
|
||||||
|
* ***********************************************
|
||||||
|
*/
|
||||||
|
public class Status {
|
||||||
|
|
||||||
|
public static final int UNCHECKED = 0;
|
||||||
|
public static final int UNSOLVED = 9;
|
||||||
|
|
||||||
|
public static final Map<Integer, String> inverseMap = new HashMap<>();
|
||||||
|
|
||||||
|
static{
|
||||||
|
System.out.println("Loading Status...");
|
||||||
|
for (Field field : Status.class.getDeclaredFields()) {
|
||||||
|
if (field.getType().isAssignableFrom(Integer.TYPE)) {
|
||||||
|
try {
|
||||||
|
inverseMap.put((Integer) field.get(null), field.getName());
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
39
src/main/java/love/sola/netsupport/pojo/Operator.java
Normal file
39
src/main/java/love/sola/netsupport/pojo/Operator.java
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package love.sola.netsupport.pojo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ***********************************************
|
||||||
|
* Created by Sola on 2015/12/6.
|
||||||
|
* Don't modify this source without my agreement
|
||||||
|
* ***********************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Entity
|
||||||
|
@Table(name = "operators")
|
||||||
|
public class Operator {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "id", nullable = false, insertable = false, updatable = false)
|
||||||
|
private Integer id;
|
||||||
|
@Column(name = "name", nullable = false, insertable = false, updatable = false)
|
||||||
|
private String name;
|
||||||
|
@Column(name = "access", nullable = false, insertable = false, updatable = false)
|
||||||
|
private Integer access;
|
||||||
|
@Column(name = "wechat", nullable = false, insertable = false, updatable = false)
|
||||||
|
private String wechat;
|
||||||
|
private Integer block;
|
||||||
|
private Integer week;
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@ public class Ticket {
|
|||||||
|
|
||||||
public static final String PROPERTY_USER = "user";
|
public static final String PROPERTY_USER = "user";
|
||||||
public static final String PROPERTY_STATUS = "status";
|
public static final String PROPERTY_STATUS = "status";
|
||||||
|
public static final String PROPERTY_SUBMIT_TIME = "submitTime";
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@@ -31,13 +32,13 @@ public class Ticket {
|
|||||||
@JoinColumn(name = TableTicket.COLUMN_SID)
|
@JoinColumn(name = TableTicket.COLUMN_SID)
|
||||||
private User user;
|
private User user;
|
||||||
private String description;
|
private String description;
|
||||||
@Column(name = TableTicket.COLUMN_SUBMIT_TIME, insertable = false)
|
@Column(name = TableTicket.COLUMN_SUBMIT_TIME, insertable = false, updatable = false)
|
||||||
private Date submitTime;
|
private Date submitTime;
|
||||||
private String remark;
|
private String remark;
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true)
|
||||||
@JoinColumn(name = TableTicket.COLUMN_OPSID)
|
@JoinColumn(name = TableTicket.COLUMN_OPSID)
|
||||||
private User operator;
|
private Operator operator;
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package love.sola.netsupport.pojo;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import love.sola.netsupport.enums.Block;
|
|
||||||
import love.sola.netsupport.enums.BlockConverter;
|
|
||||||
import love.sola.netsupport.enums.ISP;
|
import love.sola.netsupport.enums.ISP;
|
||||||
import love.sola.netsupport.enums.ISPConverter;
|
import love.sola.netsupport.enums.ISPConverter;
|
||||||
|
|
||||||
@@ -23,6 +21,10 @@ import javax.persistence.*;
|
|||||||
@Table(name = "users")
|
@Table(name = "users")
|
||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
|
public static final String PROPERTY_NAME = "name";
|
||||||
|
public static final String PROPERTY_WECHAT = "wechatId";
|
||||||
|
public static final String PROPERTY_BLOCK = "block";
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "id", updatable = false, nullable = false)
|
@Column(name = "id", updatable = false, nullable = false)
|
||||||
private Long id;
|
private Long id;
|
||||||
@@ -34,8 +36,7 @@ public class User {
|
|||||||
private String netAccount;
|
private String netAccount;
|
||||||
@Column(name = "wechat")
|
@Column(name = "wechat")
|
||||||
private String wechatId;
|
private String wechatId;
|
||||||
@Convert(converter = BlockConverter.class)
|
private Integer block;
|
||||||
private Block block;
|
|
||||||
private Integer room;
|
private Integer room;
|
||||||
private Long phone;
|
private Long phone;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
package love.sola.netsupport.sql;
|
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.
|
* 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_OPSID = "opsid";
|
||||||
public static final String COLUMN_STATUS = "status";
|
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;
|
package love.sola.netsupport.sql;
|
||||||
|
|
||||||
import love.sola.netsupport.pojo.User;
|
import love.sola.netsupport.pojo.User;
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
|
|
||||||
@@ -26,29 +25,20 @@ public class TableUser extends SQLCore {
|
|||||||
public static User getUserById(long id) {
|
public static User getUserById(long id) {
|
||||||
try (Session s = sf.openSession()) {
|
try (Session s = sf.openSession()) {
|
||||||
return s.get(User.class, id);
|
return s.get(User.class, id);
|
||||||
} catch (HibernateException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static User getUserByWechat(String wechat) {
|
public static User getUserByWechat(String wechat) {
|
||||||
try (Session s = sf.openSession()) {
|
try (Session s = sf.openSession()) {
|
||||||
return (User) s.createCriteria(User.class).add(Restrictions.eq(COLUMN_WECHAT, wechat)).uniqueResult();
|
return (User) s.createCriteria(User.class).add(Restrictions.eq(User.PROPERTY_WECHAT, wechat)).uniqueResult();
|
||||||
} catch (HibernateException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static User getUserByName(String name) {
|
public static User getUserByName(String name) {
|
||||||
try (Session s = sf.openSession()) {
|
try (Session s = sf.openSession()) {
|
||||||
return (User) s.createCriteria(User.class).add(Restrictions.eq(COLUMN_NAME, name)).uniqueResult();
|
return (User) s.createCriteria(User.class).add(Restrictions.eq(User.PROPERTY_NAME, name)).uniqueResult();
|
||||||
} catch (HibernateException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int updateUser(User user) {
|
public static int updateUser(User user) {
|
||||||
@@ -57,10 +47,7 @@ public class TableUser extends SQLCore {
|
|||||||
s.update(user);
|
s.update(user);
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
return 1;
|
return 1;
|
||||||
} catch (HibernateException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
21
src/main/java/love/sola/netsupport/util/Crypt.java
Normal file
21
src/main/java/love/sola/netsupport/util/Crypt.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package love.sola.netsupport.util;
|
||||||
|
|
||||||
|
import org.mindrot.jbcrypt.BCrypt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ***********************************************
|
||||||
|
* Created by Sola on 2015/12/6.
|
||||||
|
* Don't modify this source without my agreement
|
||||||
|
* ***********************************************
|
||||||
|
*/
|
||||||
|
public class Crypt {
|
||||||
|
|
||||||
|
public static String hash(String pw) {
|
||||||
|
return BCrypt.hashpw(pw, BCrypt.gensalt());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean check(String plain, String hash) {
|
||||||
|
return BCrypt.checkpw(plain, hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -39,6 +39,7 @@
|
|||||||
<!-- Names the annotated entity class -->
|
<!-- Names the annotated entity class -->
|
||||||
<mapping class="love.sola.netsupport.pojo.User"/>
|
<mapping class="love.sola.netsupport.pojo.User"/>
|
||||||
<mapping class="love.sola.netsupport.pojo.Ticket"/>
|
<mapping class="love.sola.netsupport.pojo.Ticket"/>
|
||||||
|
<mapping class="love.sola.netsupport.pojo.Operator"/>
|
||||||
|
|
||||||
</session-factory>
|
</session-factory>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package love.sola.netsupport.wechat;
|
||||||
|
|
||||||
|
import love.sola.netsupport.enums.Block;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ***********************************************
|
||||||
|
* Created by Sola on 2015/12/6.
|
||||||
|
* Don't modify this source without my agreement
|
||||||
|
* ***********************************************
|
||||||
|
*/
|
||||||
|
public class TestReflection {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBlock() {
|
||||||
|
System.out.println(Block.inverseMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user