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.
71 lines
2.0 KiB
71 lines
2.0 KiB
2 years ago
|
package com.eco.plugin.xxx.bjgjdata.db.dao;
|
||
|
|
||
|
import com.eco.plugin.xxx.bjgjdata.db.bean.DBEntity;
|
||
|
import com.eco.plugin.xxx.bjgjdata.db.bean.RecordEntity;
|
||
|
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 xxx
|
||
|
* @version 10.0
|
||
|
* Created by xxx on 2021-12-03
|
||
|
**/
|
||
|
public class RecordDao extends BaseDAO<RecordEntity> {
|
||
|
|
||
|
public RecordDao(DAOSession session) {
|
||
|
super(session);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected Class<RecordEntity> getEntityClass() {
|
||
|
return RecordEntity.class;
|
||
|
}
|
||
|
|
||
|
public final static DAOProvider DAO = new DAOProvider() {
|
||
|
@Override
|
||
|
public Class getEntityClass() {
|
||
|
return RecordEntity.class;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public Class<? extends BaseDAO> getDAOClass() {
|
||
|
return RecordDao.class;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
public void add(RecordEntity 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(RecordEntity entity) throws Exception {
|
||
|
getSession().merge(entity);
|
||
|
}
|
||
|
|
||
|
|
||
|
public RecordEntity getByUsername(String username) throws Exception {
|
||
|
QueryCondition condition = QueryFactory.create()
|
||
|
.addRestriction(RestrictionFactory.eq("username", username));
|
||
|
|
||
|
return findOne(condition);
|
||
|
}
|
||
|
|
||
|
|
||
|
public List<RecordEntity> 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);
|
||
|
}
|
||
|
}
|