Skip to content

Commit

Permalink
feat: 将CustomerCheckinRecord中的user_id改成customer_id (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
damingerdai authored Jan 19, 2024
1 parent c260433 commit dab4462
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE customer_checkin_record RENAME customer_id TO user_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE customer_checkin_record RENAME user_id TO customer_id;
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class CustomerCheckinRecordController {
@PostMapping("customer-checkin-record")
public DataResponse<Long> createCustomerCheckinRecord(@RequestBody CreateCustomerCheckinRecordRequest request) {
var ur = new CustomerCheckinRecord()
.setUserId(request.getUserId())
.setCustomerId(request.getCustomerId())
.setRoomId(request.getRoomId())
.setBeginDate(request.getBeginDate())
.setEndDate(request.getEndDate());
Expand All @@ -49,7 +49,7 @@ public DataResponse<Long> createCustomerCheckinRecord(@RequestBody CreateCustome
public CommonResponse updateCustomerCheckinRecord(@RequestBody UpdateCustomerCheckinRecordRequest request) {
var ur = new CustomerCheckinRecord()
.setId(request.getId())
.setUserId(request.getUserId())
.setCustomerId(request.getCustomerId())
.setRoomId(request.getRoomId())
.setBeginDate(request.getBeginDate())
.setEndDate(request.getEndDate());
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/daming/hoteler/pojo/CustomerCheckinRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CustomerCheckinRecord implements Serializable {
private long id;

@JsonFormat(shape = JsonFormat.Shape.STRING)
private long userId;
private long customerId;

@JsonFormat(shape = JsonFormat.Shape.STRING)
private long roomId;
Expand All @@ -38,12 +38,12 @@ public CustomerCheckinRecord setId(long id) {
return this;
}

public long getUserId() {
return userId;
public long getCustomerId() {
return customerId;
}

public CustomerCheckinRecord setUserId(long userId) {
this.userId = userId;
public CustomerCheckinRecord setCustomerId(long customerId) {
this.customerId = customerId;
return this;
}

Expand Down Expand Up @@ -78,10 +78,10 @@ public CustomerCheckinRecord() {
super();
}

public CustomerCheckinRecord(long id, long userId, long roomId, LocalDateTime beginDate, LocalDateTime endDate) {
public CustomerCheckinRecord(long id, long customerId, long roomId, LocalDateTime beginDate, LocalDateTime endDate) {
super();
this.id = id;
this.userId = userId;
this.customerId = customerId;
this.roomId = roomId;
this.beginDate = beginDate;
this.endDate = endDate;
Expand All @@ -91,7 +91,7 @@ public CustomerCheckinRecord(long id, long userId, long roomId, LocalDateTime be
public String toString() {
return new StringJoiner(", ", CustomerCheckinRecord.class.getSimpleName() + "[", "]")
.add("id=" + id)
.add("userId=" + userId)
.add("customerId=" + customerId)
.add("roomId=" + roomId)
.add("beginDate=" + beginDate)
.add("endDate=" + endDate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CreateCustomerCheckinRecordRequest implements Serializable {
private static final long serialVersionUID = 3021114417834745800L;

@JsonFormat(shape = JsonFormat.Shape.STRING)
private long userId;
private long customerId;

@JsonFormat(shape = JsonFormat.Shape.STRING)
private long roomId;
Expand All @@ -25,12 +25,12 @@ public class CreateCustomerCheckinRecordRequest implements Serializable {

private LocalDateTime endDate;

public long getUserId() {
return userId;
public long getCustomerId() {
return customerId;
}

public void setUserId(long userId) {
this.userId = userId;
public void setCustomerId(long customerId) {
this.customerId = customerId;
}

public long getRoomId() {
Expand Down Expand Up @@ -61,9 +61,9 @@ public CreateCustomerCheckinRecordRequest() {
super();
}

public CreateCustomerCheckinRecordRequest(long userId, long roomId, LocalDateTime beginDate, LocalDateTime endDate) {
public CreateCustomerCheckinRecordRequest(long customerId, long roomId, LocalDateTime beginDate, LocalDateTime endDate) {
super();
this.userId = userId;
this.customerId = customerId;
this.roomId = roomId;
this.beginDate = beginDate;
this.endDate = endDate;
Expand All @@ -72,7 +72,7 @@ public CreateCustomerCheckinRecordRequest(long userId, long roomId, LocalDateTim
@Override
public String toString() {
return new StringJoiner(", ", CreateCustomerCheckinRecordRequest.class.getSimpleName() + "[", "]")
.add("userId=" + userId)
.add("customerId=" + customerId)
.add("roomId=" + roomId)
.add("beginDate=" + beginDate)
.add("endDate=" + endDate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class UpdateCustomerCheckinRecordRequest implements Serializable {
private long id;

@JsonFormat(shape = JsonFormat.Shape.STRING)
private long userId;
private long customerId;

@JsonFormat(shape = JsonFormat.Shape.STRING)
private long roomId;
Expand All @@ -37,12 +37,12 @@ public void setId(long id) {
this.id = id;
}

public long getUserId() {
return userId;
public long getCustomerId() {
return customerId;
}

public void setUserId(long userId) {
this.userId = userId;
public void setCustomerId(long customerId) {
this.customerId = customerId;
}

public long getRoomId() {
Expand Down Expand Up @@ -73,10 +73,10 @@ public UpdateCustomerCheckinRecordRequest() {
super();
}

public UpdateCustomerCheckinRecordRequest(long id, long userId, long roomId, LocalDateTime beginDate, LocalDateTime endDate) {
public UpdateCustomerCheckinRecordRequest(long id, long customerId, long roomId, LocalDateTime beginDate, LocalDateTime endDate) {
super();
this.id = id;
this.userId = userId;
this.customerId = customerId;
this.roomId = roomId;
this.beginDate = beginDate;
this.endDate = endDate;
Expand All @@ -86,7 +86,7 @@ public UpdateCustomerCheckinRecordRequest(long id, long userId, long roomId, Loc
public String toString() {
return new StringJoiner(", ", UpdateCustomerCheckinRecordRequest.class.getSimpleName() + "[", "]")
.add("id=" + id)
.add("userId=" + userId)
.add("customerId=" + customerId)
.add("roomId=" + roomId)
.add("beginDate=" + beginDate)
.add("endDate=" + endDate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public class CustomerCheckinRecordDaoImpl implements ICustomerCheckinRecordDao {
@Override
public void create(CustomerCheckinRecord customerCheckinRecord) throws HotelerException {
var in = Instant.now();
var sql = "insert into customer_checkin_record (id, user_id, room_id, begin_date, end_date, create_dt, create_user, update_dt, update_user) values ( ?, ?, ?, ?, ?, statement_timestamp(), 'system', statement_timestamp(), 'system')";
var params = new Object[] { customerCheckinRecord.getId(), customerCheckinRecord.getUserId(), customerCheckinRecord.getRoomId(), customerCheckinRecord.getBeginDate(), customerCheckinRecord.getEndDate() };
var sql = "insert into customer_checkin_record (id, customer_id, room_id, begin_date, end_date, create_dt, create_user, update_dt, update_user) values ( ?, ?, ?, ?, ?, statement_timestamp(), 'system', statement_timestamp(), 'system')";
var params = new Object[] { customerCheckinRecord.getId(), customerCheckinRecord.getCustomerId(), customerCheckinRecord.getRoomId(), customerCheckinRecord.getBeginDate(), customerCheckinRecord.getEndDate() };
try {
jdbcTemplate.update(sql, params);
} catch (Exception ex) {
Expand All @@ -49,8 +49,8 @@ public void create(CustomerCheckinRecord customerCheckinRecord) throws HotelerEx
@Override
public void update(CustomerCheckinRecord customerCheckinRecord) throws HotelerException {
var in = Instant.now();
var sql = "update customer_checkin_record set user_id = ?, room_id = ?, begin_date = ?, end_date = ?, update_dt = statement_timestamp(), update_user = 'system' where id = ?";
var params = new Object[] { customerCheckinRecord.getUserId(), customerCheckinRecord.getRoomId(), customerCheckinRecord.getBeginDate(), customerCheckinRecord.getEndDate(), customerCheckinRecord.getId() };
var sql = "update customer_checkin_record set customer_id = ?, room_id = ?, begin_date = ?, end_date = ?, update_dt = statement_timestamp(), update_user = 'system' where id = ?";
var params = new Object[] { customerCheckinRecord.getCustomerId(), customerCheckinRecord.getRoomId(), customerCheckinRecord.getBeginDate(), customerCheckinRecord.getEndDate(), customerCheckinRecord.getId() };
try {
jdbcTemplate.update(sql, params);
} catch (Exception ex) {
Expand Down Expand Up @@ -120,7 +120,7 @@ public List<CustomerCheckinRecord> list(LocalDate date) throws HotelerException

@Override
public List<CustomerCheckinRecord> listByRoom(long roomId, LocalDate date) throws HotelerException {
var sql = "select id, user_id, room_id, begin_date, end_date from customer_checkin_record where room_id = ? and begin_date <= ? and ? <= end_date and deleted_at is null order by create_dt desc, update_dt desc";
var sql = "select id, customer_id, room_id, begin_date, end_date from customer_checkin_record where room_id = ? and begin_date <= ? and ? <= end_date and deleted_at is null order by create_dt desc, update_dt desc";
var params = new Object[] { roomId, date, date };
try {
return this.jdbcTemplate.query(sql, (rs, i) -> getCustomerCheckinRecord(rs), params);
Expand All @@ -133,7 +133,7 @@ public List<CustomerCheckinRecord> listByRoom(long roomId, LocalDate date) throw
private CustomerCheckinRecord getCustomerCheckinRecord(ResultSet rs) throws SQLException {
return new CustomerCheckinRecord()
.setId(rs.getLong("id"))
.setUserId(rs.getLong("user_id"))
.setCustomerId(rs.getLong("customer_id"))
.setRoomId(rs.getLong("room_id"))
.setBeginDate(rs.getTimestamp("begin_date").toLocalDateTime())
.setEndDate(rs.getTimestamp("end_date").toLocalDateTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var record = new CustomerCheckinRecord();
record.setBeginDate(beginDateTime);
record.setEndDate(endDateTime);
record.setRoomId(customerCheckinRecord.getRoomId());
record.setUserId(customerCheckinRecord.getUserId());
record.setCustomerId(customerCheckinRecord.getCustomerId());

if (DateUtils.isToday(begin)) {
this.doCreate(record);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var record = this.jsonMapper.readValue(content, CustomerCheckinRecord.class);;

private void processCheckInTimeEvent(HotelerEvent type, CustomerCheckinRecord record) throws SchedulerException {
var beginDate = record.getBeginDate();
var triggerName = String.valueOf( record.getUserId() + record.getRoomId() + record.hashCode());
var triggerName = String.valueOf( record.getCustomerId() + record.getRoomId() + record.hashCode());
var cron = CronBuilder.cron(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ))
.withSecond(FieldExpressionFactory.on(0))
.withMinute(FieldExpressionFactory.on(0))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE customer_checkin_record RENAME user_id TO customer_id;

0 comments on commit dab4462

Please sign in to comment.