Commit 08851fb1 authored by yanzg's avatar yanzg

修改实体位置

parent 8216dfb5
package com.yanzuoguang.mq.dao.impl; package com.yanzuoguang.mq.dao.impl;
import com.yanzuoguang.dao.impl.BaseDaoImpl; import com.yanzuoguang.dao.impl.BaseDaoImpl;
import com.yanzuoguang.db.DbExecute;
import com.yanzuoguang.mq.dao.QueueServerTokenDao; import com.yanzuoguang.mq.dao.QueueServerTokenDao;
import com.yanzuoguang.mq.vo.QueueServerTokenVo; import com.yanzuoguang.mq.vo.QueueServerTokenVo;
import com.yanzuoguang.util.vo.MapRow; import com.yanzuoguang.util.vo.MapRow;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
...@@ -15,7 +15,7 @@ import java.util.List; ...@@ -15,7 +15,7 @@ import java.util.List;
* @author 颜佐光 * @author 颜佐光
*/ */
@Component @Component
public class QueueServerTokenDaoImpl extends BaseDaoImpl implements QueueServerTokenDao { public class QueueServerTokenDaoImpl extends BaseDaoImpl implements QueueServerTokenDao, InitializingBean {
private static final String QUERY_TABLE_SQL = "SHOW TABLES LIKE 'queue_servertoken'"; private static final String QUERY_TABLE_SQL = "SHOW TABLES LIKE 'queue_servertoken'";
private static final String CREATE_TABLE_SQL = "CREATE TABLE `queue_servertoken` (" + private static final String CREATE_TABLE_SQL = "CREATE TABLE `queue_servertoken` (" +
" `serverTokenId` varchar(32) NOT NULL COMMENT '编号'," + " `serverTokenId` varchar(32) NOT NULL COMMENT '编号'," +
...@@ -36,11 +36,21 @@ public class QueueServerTokenDaoImpl extends BaseDaoImpl implements QueueServerT ...@@ -36,11 +36,21 @@ public class QueueServerTokenDaoImpl extends BaseDaoImpl implements QueueServerT
register(QueueServerTokenVo.class); register(QueueServerTokenVo.class);
} }
/**
* Invoked by a BeanFactory after it has set all bean properties supplied
* (and satisfied BeanFactoryAware and ApplicationContextAware).
* <p>This method allows the bean instance to perform initialization only
* possible when all bean properties have been set and to throw an
* exception in the event of misconfiguration.
*
* @throws Exception in the event of misconfiguration (such
* as failure to set an essential property) or if initialization fails.
*/
@Override @Override
protected void initExecute(DbExecute db) { public void afterPropertiesSet() throws Exception {
List<MapRow> tables = db.query(QueueServerTokenDaoImpl.class, "QUERY_TABLE_SQL", QUERY_TABLE_SQL); List<MapRow> tables = this.getDb().query(QueueServerTokenDaoImpl.class, "QUERY_TABLE_SQL", QUERY_TABLE_SQL);
if (tables.isEmpty()) { if (tables.isEmpty()) {
db.update(QueueServerTokenDaoImpl.class, "CREATE_TABLE_SQL", CREATE_TABLE_SQL); this.getDb().update(QueueServerTokenDaoImpl.class, "CREATE_TABLE_SQL", CREATE_TABLE_SQL);
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment