mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-12 02:54:59 +08:00
为 AccountDao.insert 也提供 PostgreSQL 的 AccountDao.insertOnPG 版。
This commit is contained in:
@@ -18,6 +18,9 @@ public class AccountDaoImpl implements AccountDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SqlSessionTemplate sqlSession;
|
private SqlSessionTemplate sqlSession;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private KafkaManagerProperties kafkaManagerProperties;
|
||||||
|
|
||||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||||
this.sqlSession = sqlSession;
|
this.sqlSession = sqlSession;
|
||||||
}
|
}
|
||||||
@@ -25,7 +28,7 @@ public class AccountDaoImpl implements AccountDao {
|
|||||||
@Override
|
@Override
|
||||||
public int addNewAccount(AccountDO accountDO) {
|
public int addNewAccount(AccountDO accountDO) {
|
||||||
accountDO.setStatus(DBStatusEnum.NORMAL.getStatus());
|
accountDO.setStatus(DBStatusEnum.NORMAL.getStatus());
|
||||||
return sqlSession.insert("AccountDao.insert", accountDO);
|
return updateAccount(accountDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -35,6 +38,9 @@ public class AccountDaoImpl implements AccountDao {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateAccount(AccountDO accountDO) {
|
public int updateAccount(AccountDO accountDO) {
|
||||||
|
if (kafkaManagerProperties.hasPG()) {
|
||||||
|
return sqlSession.insert("AccountDao.insertOnPG", accountDO);
|
||||||
|
}
|
||||||
return sqlSession.insert("AccountDao.insert", accountDO);
|
return sqlSession.insert("AccountDao.insert", accountDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,18 @@
|
|||||||
]]>
|
]]>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<insert id="insertOnPG" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.AccountDO">
|
||||||
|
<![CDATA[
|
||||||
|
insert into account
|
||||||
|
(username, password, role, status)
|
||||||
|
values
|
||||||
|
(#{username}, #{password}, #{role}, #{status})
|
||||||
|
on conflict (username) do update set password = excluded.password,
|
||||||
|
role = excluded.role,
|
||||||
|
status = excluded.status
|
||||||
|
]]>
|
||||||
|
</insert>
|
||||||
|
|
||||||
<delete id="deleteByName" parameterType="java.lang.String">
|
<delete id="deleteByName" parameterType="java.lang.String">
|
||||||
DELETE FROM account WHERE username = #{username}
|
DELETE FROM account WHERE username = #{username}
|
||||||
</delete>
|
</delete>
|
||||||
|
|||||||
@@ -22,12 +22,12 @@
|
|||||||
|
|
||||||
<insert id="replaceOnPG" parameterType="BrokerDO">
|
<insert id="replaceOnPG" parameterType="BrokerDO">
|
||||||
insert into broker
|
insert into broker
|
||||||
(cluster_id, broker_id, host, port, timestamp, status)
|
(cluster_id, broker_id, host, port, timestamp, status)
|
||||||
values
|
values (#{clusterId}, #{brokerId}, #{host}, #{port}, #{timestamp}, #{status})
|
||||||
on conflict (cluster_id, broker_id) do update set host = excluded.host,
|
on conflict (cluster_id, broker_id) do update set host = excluded.host,
|
||||||
port = excluded.port,
|
port = excluded.port,
|
||||||
timestamp = excluded.timestamp,
|
timestamp = excluded.timestamp,
|
||||||
status = excluded.status
|
status = excluded.status
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<delete id="deleteById" parameterType="java.util.Map">
|
<delete id="deleteById" parameterType="java.util.Map">
|
||||||
|
|||||||
Reference in New Issue
Block a user