-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f17f94d
commit 4eb9073
Showing
16 changed files
with
337 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/main/java/hust/baseweb/baseweb/controller/SalesRouteController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package hust.baseweb.baseweb.controller; | ||
|
||
import hust.baseweb.baseweb.entity.salesroute.SalesRouteConfig; | ||
import hust.baseweb.baseweb.entity.salesroute.SalesRoutePlanningPeriod; | ||
import hust.baseweb.baseweb.model.GetUserLogin; | ||
import hust.baseweb.baseweb.repository.SalesRoutePlanningPeriodRepository; | ||
import hust.baseweb.baseweb.repository.UserLoginRepository; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.security.Principal; | ||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
class CreatePlanningPeriodRequest { | ||
private LocalDate fromDate; | ||
private LocalDate thruDate; | ||
private String description; | ||
} | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
class CreatePlanningPeriodResponse { | ||
private final List<SalesRoutePlanningPeriod> planningPeriods; | ||
} | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
class CreateConfigRequest { | ||
private boolean isEnabled; | ||
private short repeatWeek; | ||
} | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
class CreateConfigResponse { | ||
private final List<SalesRouteConfig> configs; | ||
} | ||
//@Getter | ||
//@RequiredArgsConstructor | ||
//class CreateConfigRequest { | ||
// private final boolean isEnabled; | ||
// private final short repeatWeek; | ||
//} | ||
|
||
@RestController | ||
@AllArgsConstructor(onConstructor = @__(@Autowired)) | ||
public class SalesRouteController { | ||
private UserLoginRepository userLoginRepository; | ||
private SalesRoutePlanningPeriodRepository salesRoutePlanningPeriodRepository; | ||
|
||
@GetMapping("/api/sales-route/planning-period") | ||
public List<SalesRoutePlanningPeriod> getPlanningPeriod(){ | ||
return salesRoutePlanningPeriodRepository.findAll(); | ||
} | ||
|
||
@PostMapping("/api/sales-route/create-planning-period") | ||
public CreatePlanningPeriodResponse createPlanningPeriod(@RequestBody CreatePlanningPeriodRequest request, Principal principal) { | ||
GetUserLogin getUserLogin = userLoginRepository.getUserLoginByUsername(principal.getName()); | ||
SalesRoutePlanningPeriod planningPeriod = new SalesRoutePlanningPeriod(request.getFromDate(), request.getThruDate(), | ||
getUserLogin.getId(), request.getDescription()); | ||
salesRoutePlanningPeriodRepository.save(planningPeriod); | ||
|
||
List<SalesRoutePlanningPeriod> planningPeriods = salesRoutePlanningPeriodRepository.findAll(); | ||
return new CreatePlanningPeriodResponse(planningPeriods); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package hust.baseweb.baseweb.entity; | ||
|
||
import lombok.Getter; | ||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@RequiredArgsConstructor | ||
public class DayOfWeek { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@NonNull | ||
private short day; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/hust/baseweb/baseweb/entity/salesroute/SalesRouteConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package hust.baseweb.baseweb.entity.salesroute; | ||
|
||
import lombok.*; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import java.util.Date; | ||
import java.util.UUID; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@RequiredArgsConstructor | ||
@NoArgsConstructor | ||
public class SalesRouteConfig { | ||
@Id | ||
private UUID id; | ||
|
||
@NonNull | ||
private boolean isEnabled; | ||
|
||
@NonNull | ||
private short repeatWeek; | ||
|
||
@NonNull | ||
private UUID createdByUserLoginId; | ||
|
||
private Date createdAt; | ||
private Date updatedAt; | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/hust/baseweb/baseweb/entity/salesroute/SalesRouteConfigDay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package hust.baseweb.baseweb.entity.salesroute; | ||
|
||
import lombok.*; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.EmbeddedId; | ||
import javax.persistence.Entity; | ||
import java.util.Date; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@RequiredArgsConstructor | ||
@NoArgsConstructor | ||
public class SalesRouteConfigDay { | ||
@EmbeddedId | ||
@NonNull | ||
private SalesRouteConfigDayId id; | ||
|
||
@Column(insertable = false) | ||
private Date createdAt; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/hust/baseweb/baseweb/entity/salesroute/SalesRouteConfigDayId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package hust.baseweb.baseweb.entity.salesroute; | ||
|
||
import lombok.*; | ||
|
||
import javax.persistence.Embeddable; | ||
import java.io.Serializable; | ||
import java.util.UUID; | ||
|
||
@Getter | ||
@Setter | ||
@Embeddable | ||
@EqualsAndHashCode | ||
@RequiredArgsConstructor | ||
@NoArgsConstructor | ||
public class SalesRouteConfigDayId implements Serializable { | ||
@NonNull | ||
private UUID configId; | ||
|
||
@NonNull | ||
private short day; | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/hust/baseweb/baseweb/entity/salesroute/SalesRouteDetail.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package hust.baseweb.baseweb.entity.salesroute; | ||
|
||
import lombok.*; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import java.util.Date; | ||
import java.util.UUID; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@RequiredArgsConstructor | ||
@NoArgsConstructor | ||
public class SalesRouteDetail { | ||
@Id | ||
private UUID id; | ||
|
||
@NonNull | ||
private UUID configId; | ||
|
||
@NonNull | ||
private UUID planningPeriodId; | ||
|
||
@NonNull | ||
private UUID customerId; | ||
|
||
@NonNull | ||
private UUID salesmanId; | ||
|
||
private Date createdAt; | ||
private Date updatedAt; | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/hust/baseweb/baseweb/entity/salesroute/SalesRoutePlanningPeriod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package hust.baseweb.baseweb.entity.salesroute; | ||
|
||
import lombok.*; | ||
import org.hibernate.annotations.CreationTimestamp; | ||
import org.hibernate.annotations.UpdateTimestamp; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import java.time.LocalDate; | ||
import java.util.Date; | ||
import java.util.UUID; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@RequiredArgsConstructor | ||
@NoArgsConstructor | ||
public class SalesRoutePlanningPeriod { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private UUID id; | ||
|
||
@NonNull | ||
private LocalDate fromDate; | ||
|
||
@NonNull | ||
private LocalDate thruDate; | ||
|
||
@NonNull | ||
private UUID createdByUserLoginId; | ||
|
||
@NonNull | ||
private String description; | ||
|
||
@CreationTimestamp | ||
private Date createdAt; | ||
|
||
@UpdateTimestamp | ||
private Date updatedAt; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/hust/baseweb/baseweb/entity/salesroute/SalesmanCheckinHistory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package hust.baseweb.baseweb.entity.salesroute; | ||
|
||
import lombok.*; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import java.util.Date; | ||
import java.util.UUID; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@RequiredArgsConstructor | ||
@NoArgsConstructor | ||
public class SalesmanCheckinHistory { | ||
@Id | ||
@NonNull | ||
private UUID salesRouteDetailId; | ||
|
||
private Date checkinTime; | ||
private Date createdAt; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/hust/baseweb/baseweb/repository/SalesRouteConfigDayRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package hust.baseweb.baseweb.repository; | ||
|
||
import hust.baseweb.baseweb.entity.salesroute.SalesRouteConfigDay; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public interface SalesRouteConfigDayRepository extends JpaRepository<SalesRouteConfigDay, UUID> { | ||
List<SalesRouteConfigDay> findAll(); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/hust/baseweb/baseweb/repository/SalesRouteConfigRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package hust.baseweb.baseweb.repository; | ||
|
||
import hust.baseweb.baseweb.entity.salesroute.SalesRouteConfig; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public interface SalesRouteConfigRepository extends JpaRepository<SalesRouteConfig, UUID> { | ||
List<SalesRouteConfig> findAll(); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/hust/baseweb/baseweb/repository/SalesRouteDetailRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package hust.baseweb.baseweb.repository; | ||
|
||
import hust.baseweb.baseweb.entity.salesroute.SalesRouteDetail; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public interface SalesRouteDetailRepository extends JpaRepository<SalesRouteDetail, UUID> { | ||
List<SalesRouteDetail> findAll(); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/hust/baseweb/baseweb/repository/SalesRoutePlanningPeriodRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package hust.baseweb.baseweb.repository; | ||
|
||
import hust.baseweb.baseweb.entity.salesroute.SalesRoutePlanningPeriod; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public interface SalesRoutePlanningPeriodRepository extends JpaRepository<SalesRoutePlanningPeriod, UUID> { | ||
List<SalesRoutePlanningPeriod> findAll(); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/hust/baseweb/baseweb/repository/SalesmanCheckinHistoryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package hust.baseweb.baseweb.repository; | ||
|
||
import hust.baseweb.baseweb.entity.salesroute.SalesmanCheckinHistory; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public interface SalesmanCheckinHistoryRepository extends JpaRepository<SalesmanCheckinHistory, UUID> { | ||
List<SalesmanCheckinHistory> findAll(); | ||
} |