last_signined_ip is modified

This commit is contained in:
병준 박 2022-08-11 06:43:56 +00:00
parent dd88c522e8
commit 57dc1fed92
6 changed files with 5 additions and 22 deletions

View File

@ -2,4 +2,3 @@ DROP EXTENSION "uuid-ossp";
DROP FUNCTION update_updated_at_column; DROP FUNCTION update_updated_at_column;
DROP FUNCTION update_state_changed_at_column; DROP FUNCTION update_state_changed_at_column;
DROP FUNCTION update_active_changed_at_column; DROP FUNCTION update_active_changed_at_column;
DROP FUNCTION update_last_signined_at_column;

View File

@ -33,16 +33,3 @@ BEGIN
RETURN NEW; RETURN NEW;
END; END;
$$ language 'plpgsql'; $$ language 'plpgsql';
CREATE OR REPLACE FUNCTION update_last_signined_at_column()
RETURNS TRIGGER AS $$
BEGIN
IF OLD.last_signined_ip != NEW.last_signined_ip THEN
NEW.last_signined_at = (extract(epoch from now()) * 1000);
ELSE
NEW.last_signined_at = NEW.last_signined_at;
END IF;
RETURN NEW;
END;
$$ language 'plpgsql';

View File

@ -1,5 +1,4 @@
DROP INDEX idx_members_username; DROP INDEX idx_members_username;
DROP TRIGGER tg_members_last_signined_at;
DROP TRIGGER tg_members_state_changed_at; DROP TRIGGER tg_members_state_changed_at;
DROP TRIGGER tg_members_updated_at; DROP TRIGGER tg_members_updated_at;
DROP TABLE members; DROP TABLE members;

View File

@ -51,10 +51,3 @@ CREATE TRIGGER tg_members_state_changed_at
ON members ON members
FOR EACH ROW FOR EACH ROW
EXECUTE PROCEDURE update_state_changed_at_column(); EXECUTE PROCEDURE update_state_changed_at_column();
-- trigger (state_changed_at)
CREATE TRIGGER tg_members_last_signined_at
BEFORE UPDATE
ON members
FOR EACH ROW
EXECUTE PROCEDURE update_last_signined_at_column();

View File

@ -85,6 +85,8 @@ pub struct ModifyMember {
pub struct ModifyMember4LastSignined { pub struct ModifyMember4LastSignined {
/// ///
pub last_signined_ip: String, pub last_signined_ip: String,
//
pub last_signined_at: i64,
} }
/// ///

View File

@ -496,6 +496,8 @@ impl Service {
}) })
})?; })?;
let last_signined_at = chrono::Utc::now().timestamp();
self self
.member_repository .member_repository
.update_last_signined_ip( .update_last_signined_ip(
@ -503,6 +505,7 @@ impl Service {
id, id,
&repositories::member::models::ModifyMember4LastSignined { &repositories::member::models::ModifyMember4LastSignined {
last_signined_ip: client.client_ip, last_signined_ip: client.client_ip,
last_signined_at,
}, },
) )
.map_err(|e| { .map_err(|e| {