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