You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.9 KiB
68 lines
1.9 KiB
package com.eco.plugin.xx.kdxfsso.db.dao; |
|
|
|
import com.eco.plugin.xx.kdxfsso.db.bean.DBEntity; |
|
import com.fr.stable.db.dao.BaseDAO; |
|
import com.fr.stable.db.dao.DAOProvider; |
|
import com.fr.stable.db.session.DAOSession; |
|
import com.fr.stable.query.QueryFactory; |
|
import com.fr.stable.query.condition.QueryCondition; |
|
import com.fr.stable.query.restriction.RestrictionFactory; |
|
import java.util.List; |
|
|
|
/** |
|
* @author xx |
|
* @version 10.0 |
|
* Created by xx on 2021-12-03 |
|
**/ |
|
public class DBDao extends BaseDAO<DBEntity> { |
|
|
|
public DBDao(DAOSession session) { |
|
super(session); |
|
} |
|
|
|
@Override |
|
protected Class<DBEntity> getEntityClass() { |
|
return DBEntity.class; |
|
} |
|
|
|
public final static DAOProvider DAO = new DAOProvider() { |
|
@Override |
|
public Class getEntityClass() { |
|
return DBEntity.class; |
|
} |
|
|
|
@Override |
|
public Class<? extends BaseDAO> getDAOClass() { |
|
return DBDao.class; |
|
} |
|
}; |
|
|
|
public void add(DBEntity entity) throws Exception { |
|
getSession().persist(entity); |
|
} |
|
|
|
public void remove(String id) throws Exception { |
|
getSession().remove(QueryFactory.create() |
|
.addRestriction(RestrictionFactory.eq("id", id)), |
|
this.getEntityClass()); |
|
} |
|
|
|
public void update(DBEntity entity) throws Exception { |
|
getSession().merge(entity); |
|
} |
|
|
|
|
|
public DBEntity getByUsername(String username) throws Exception { |
|
QueryCondition condition = QueryFactory.create() |
|
.addRestriction(RestrictionFactory.eq("token", username)); |
|
|
|
return findOne(condition); |
|
} |
|
|
|
|
|
public List<DBEntity> like(String pid, String type)throws Exception{ |
|
QueryCondition condition = QueryFactory.create() |
|
.addRestriction(RestrictionFactory.like("", pid)).addRestriction(RestrictionFactory.like(DBEntity.COLUMN_ID,type)); |
|
return find(condition); |
|
} |
|
}
|
|
|