front 로그인 작업 중 (2)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package app.module.core.config.adapters.persistence.component;
|
||||
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class AuditCommand {
|
||||
private LocalDateTime createdAt;
|
||||
private String createdBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private String updatedBy;
|
||||
private LocalDateTime deletedAt;
|
||||
private String deletedBy;
|
||||
|
||||
public void create() {
|
||||
this.createdAt = LocalDateTime.now();
|
||||
this.createdBy = CommonUtil.getLoginUsername();
|
||||
this.updatedAt = LocalDateTime.now();
|
||||
this.updatedBy = CommonUtil.getLoginUsername();
|
||||
}
|
||||
|
||||
public void update() {
|
||||
this.updatedAt = LocalDateTime.now();
|
||||
this.updatedBy = CommonUtil.getLoginUsername();
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
this.updatedAt = LocalDateTime.now();
|
||||
this.updatedBy = CommonUtil.getLoginUsername();
|
||||
this.deletedAt = LocalDateTime.now();
|
||||
this.deletedBy = CommonUtil.getLoginUsername();
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,11 @@ public class Household extends AuditEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String household_num;
|
||||
private String householdNum;
|
||||
|
||||
private String owner_name;
|
||||
private String ownerName;
|
||||
|
||||
private Integer owner_age;
|
||||
private Integer ownerAge;
|
||||
|
||||
private String tel;
|
||||
|
||||
@@ -27,27 +27,25 @@ public class Household extends AuditEntity {
|
||||
|
||||
private String password;
|
||||
|
||||
private String zipcode;
|
||||
|
||||
private String region;
|
||||
|
||||
private String city;
|
||||
|
||||
private String address_detail;
|
||||
private String addressDetail;
|
||||
|
||||
private Integer industry_large_code;
|
||||
private Integer industryLargeCode;
|
||||
|
||||
private Integer industry_middle_code;
|
||||
private Integer industryMiddleCode;
|
||||
|
||||
private Integer industry_small_code;
|
||||
private Integer industrySmallCode;
|
||||
|
||||
private Integer scale_code;
|
||||
private Integer scaleCode;
|
||||
|
||||
private Integer employment_code;
|
||||
private Integer employmentCode;
|
||||
|
||||
private Boolean is_panel;
|
||||
private Boolean isPanel;
|
||||
|
||||
private String memo;
|
||||
|
||||
private String drop_reason;
|
||||
private String dropReason;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.module.core.config.application.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CreateCommand {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.core.config.application.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface DeleteCommand {}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.core.config.application.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface UpdateCommand {}
|
||||
@@ -0,0 +1,38 @@
|
||||
package app.module.core.config.application.aop;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
public class AuditCommandAspect {
|
||||
@Before("@annotation(app.module.core.config.application.annotation.CreateCommand)")
|
||||
public void applyCreateAudit(JoinPoint joinPoint) {
|
||||
inject(joinPoint, "create");
|
||||
}
|
||||
|
||||
@Before("@annotation(app.module.core.config.application.annotation.UpdateCommand)")
|
||||
public void applyUpdateAudit(JoinPoint joinPoint) {
|
||||
inject(joinPoint, "update");
|
||||
}
|
||||
|
||||
@Before("@annotation(app.module.core.config.application.annotation.DeleteCommand)")
|
||||
public void applyDeleteAudit(JoinPoint joinPoint) {
|
||||
inject(joinPoint, "delete");
|
||||
}
|
||||
|
||||
private void inject(JoinPoint joinPoint, String type) {
|
||||
for (Object arg : joinPoint.getArgs()) {
|
||||
if (arg instanceof AuditCommand audit) {
|
||||
switch (type) {
|
||||
case "create" -> audit.create();
|
||||
case "update" -> audit.update();
|
||||
case "delete" -> audit.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package app.module.core.usecase.household.getHousehold.adapters.persistence;
|
||||
|
||||
import app.module.core.config.adapters.web.security.domain.CoreRole;
|
||||
import app.module.core.usecase.household.getHousehold.ports.application.domain.GetHousehold;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@@ -22,7 +22,6 @@ public class GetHousehold {
|
||||
private String tel;
|
||||
private String phone;
|
||||
private String password;
|
||||
private String zipcode;
|
||||
private String region;
|
||||
private String city;
|
||||
private String addressDetail;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.module.core.usecase.household.updateFrontHousehold.adapters.persistence;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import app.module.core.usecase.household.updateFrontHousehold.ports.application.domain.UpdateFrontHouseholdCmd;
|
||||
import app.module.core.usecase.household.updateFrontHousehold.ports.UpdateFrontHouseholdPortOut;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class UpdateFrontHouseholdDao implements UpdateFrontHouseholdPortOut {
|
||||
private final UpdateFrontHouseholdMapper mapper;
|
||||
|
||||
@Override
|
||||
public void operate(UpdateFrontHouseholdCmd cmd) {
|
||||
mapper.update(cmd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.module.core.usecase.household.updateFrontHousehold.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.household.updateFrontHousehold.ports.application.domain.UpdateFrontHouseholdCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UpdateFrontHouseholdMapper {
|
||||
void update(UpdateFrontHouseholdCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package app.module.core.usecase.household.updateFrontHousehold.ports;
|
||||
|
||||
import app.module.core.usecase.household.updateFrontHousehold.ports.application.domain.UpdateFrontHouseholdCmd;
|
||||
|
||||
public interface UpdateFrontHouseholdPortIn {
|
||||
void operate(UpdateFrontHouseholdCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package app.module.core.usecase.household.updateFrontHousehold.ports;
|
||||
|
||||
import app.module.core.usecase.household.updateFrontHousehold.ports.application.domain.UpdateFrontHouseholdCmd;
|
||||
|
||||
public interface UpdateFrontHouseholdPortOut {
|
||||
void operate(UpdateFrontHouseholdCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.module.core.usecase.household.updateFrontHousehold.ports.application;
|
||||
|
||||
import app.module.core.config.application.annotation.UpdateCommand;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import app.module.core.usecase.household.updateFrontHousehold.ports.application.domain.UpdateFrontHouseholdCmd;
|
||||
import app.module.core.usecase.household.updateFrontHousehold.ports.UpdateFrontHouseholdPortIn;
|
||||
import app.module.core.usecase.household.updateFrontHousehold.ports.UpdateFrontHouseholdPortOut;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class UpdateFrontHouseholdService implements UpdateFrontHouseholdPortIn {
|
||||
private final UpdateFrontHouseholdPortOut portOut;
|
||||
|
||||
@Override
|
||||
@UpdateCommand
|
||||
public void operate(UpdateFrontHouseholdCmd cmd) { portOut.operate(cmd); }
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package app.module.core.usecase.household.updateFrontHousehold.ports.application.domain;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class UpdateFrontHouseholdCmd extends AuditCommand {
|
||||
private Long id;
|
||||
private String householdNum;
|
||||
private String ownerName;
|
||||
private Integer ownerAge;
|
||||
private String tel;
|
||||
private String phone;
|
||||
private String region;
|
||||
private String city;
|
||||
private String addressDetail;
|
||||
}
|
||||
@@ -14,7 +14,6 @@
|
||||
tel,
|
||||
phone,
|
||||
password,
|
||||
zipcode,
|
||||
region,
|
||||
city,
|
||||
address_detail,
|
||||
@@ -54,7 +53,7 @@
|
||||
JOIN role r ON hhr.role_id = r.id AND r.is_deleted = false
|
||||
LEFT JOIN role_has_privilege rhp ON r.id = rhp.role_id AND rhp.is_deleted = false
|
||||
LEFT JOIN privilege p ON rhp.privilege_id = p.id AND p.is_deleted = false
|
||||
WHERE hhr.id = #{id}
|
||||
WHERE hhr.household_id = #{id}
|
||||
AND hhr.is_deleted = false
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper
|
||||
namespace="app.module.core.usecase.household.updateFrontHousehold.adapters.persistence.UpdateFrontHouseholdMapper">
|
||||
|
||||
<update id="update">
|
||||
UPDATE household
|
||||
SET
|
||||
owner_name = #{ownerName},
|
||||
owner_age = #{ownerAge},
|
||||
tel = #{tel},
|
||||
phone = #{phone},
|
||||
region = #{region},
|
||||
city = #{city},
|
||||
address_detail = #{addressDetail},
|
||||
<include refid="common.fields.UpdateBaseSet" />
|
||||
WHERE id = ${id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user