Commit bb98b00e authored by yanzg's avatar yanzg

修改实体位置

parent 08851fb1
...@@ -5,6 +5,7 @@ import com.yanzuoguang.db.DbExecute; ...@@ -5,6 +5,7 @@ import com.yanzuoguang.db.DbExecute;
import com.yanzuoguang.mq.dao.QueueServerDao; import com.yanzuoguang.mq.dao.QueueServerDao;
import com.yanzuoguang.mq.vo.QueueServerVo; import com.yanzuoguang.mq.vo.QueueServerVo;
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 +16,7 @@ import java.util.List; ...@@ -15,7 +16,7 @@ import java.util.List;
* @author 颜佐光 * @author 颜佐光
*/ */
@Component @Component
public class QueueServerDaoImpl extends BaseDaoImpl implements QueueServerDao { public class QueueServerDaoImpl extends BaseDaoImpl implements QueueServerDao, InitializingBean {
private static final String QUERY_TABLE_SQL = "SHOW TABLES LIKE 'queue_server'"; private static final String QUERY_TABLE_SQL = "SHOW TABLES LIKE 'queue_server'";
private static final String CREATE_TABLE_SQL = "CREATE TABLE `queue_server` (" + private static final String CREATE_TABLE_SQL = "CREATE TABLE `queue_server` (" +
" `serverId` varchar(32) NOT NULL COMMENT '服务Id'," + " `serverId` varchar(32) NOT NULL COMMENT '服务Id'," +
...@@ -32,8 +33,19 @@ public class QueueServerDaoImpl extends BaseDaoImpl implements QueueServerDao { ...@@ -32,8 +33,19 @@ public class QueueServerDaoImpl extends BaseDaoImpl implements QueueServerDao {
register(QueueServerVo.class); register(QueueServerVo.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 {
DbExecute db = this.getDb();
List<MapRow> tables = db.query(QueueServerDaoImpl.class, "QUERY_TABLE_SQL", QUERY_TABLE_SQL); List<MapRow> tables = db.query(QueueServerDaoImpl.class, "QUERY_TABLE_SQL", QUERY_TABLE_SQL);
if (tables.isEmpty()) { if (tables.isEmpty()) {
db.update(QueueServerDaoImpl.class, "CREATE_TABLE_SQL", CREATE_TABLE_SQL); db.update(QueueServerDaoImpl.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