카테고리 리스트 저장 및 삭제, 순서변경 추가
This commit is contained in:
@@ -80,7 +80,7 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
let deletedList =[];
|
||||
|
||||
function init(){
|
||||
dragInit();
|
||||
@@ -95,14 +95,16 @@
|
||||
}
|
||||
function initCategoryList(){
|
||||
$("#categoryList").empty();
|
||||
deletedList = [];
|
||||
$.ajax({
|
||||
type: 'get'
|
||||
, url: '/store-service/category'
|
||||
, success: function (ajaxData, status, request) {
|
||||
console.log(ajaxData)
|
||||
|
||||
$(ajaxData.data).each(function (index,element) {
|
||||
$("#categoryList").append("<li class=\"list-group-item d-flex justify-content-between align-items-center\" role=\"button\">\n" +
|
||||
" <span class=\"list-element\" contenteditable=\"true\" data-value=\""+element.order+"\" > "+element.name+"</span>\n" +
|
||||
" <span class=\"list-element\" contenteditable=\"true\" data-id=\""+element.categoryId+"\" >"+element.name+"</span>\n" +
|
||||
" <span class=\"badge badge-danger badge-pill remove-element \" role=\"button\" >삭제</span>\n" +
|
||||
" </li>");
|
||||
|
||||
@@ -129,22 +131,44 @@
|
||||
|
||||
}
|
||||
function clickSave(){
|
||||
alert("저장되었습니다.");
|
||||
let categoryArr =[];
|
||||
let order = 1;
|
||||
$("#categoryList li .list-element").each(function (index,element) {
|
||||
let category = {
|
||||
categoryId : $(element).attr('data-value'),
|
||||
categoryName : $(element).text(),
|
||||
ordered : order++
|
||||
categoryId : $(element).attr('data-id'),
|
||||
name : $(element).text(),
|
||||
order : order++
|
||||
}
|
||||
categoryArr.push(category)
|
||||
});
|
||||
|
||||
console.log(categoryArr);
|
||||
|
||||
let data = {
|
||||
storeId : "1",
|
||||
categoryList: categoryArr,
|
||||
deletedList: deletedList
|
||||
}
|
||||
|
||||
console.log(data)
|
||||
|
||||
$.ajax({
|
||||
type: 'put'
|
||||
, async: true
|
||||
, url: '/store-service/category'
|
||||
, data: JSON.stringify(data)
|
||||
,dataType : "text"
|
||||
, beforeSend: function(xhr) {
|
||||
xhr.setRequestHeader("Content-type","application/json; charset=utf-8");
|
||||
}
|
||||
, success: function (ajaxData, status, request) {
|
||||
alert("저장 성공");
|
||||
}
|
||||
, error: function(request, status, err) {
|
||||
alert("저장 실패");
|
||||
}
|
||||
, complete: function(request, status) { }
|
||||
});
|
||||
$("#myModal").modal('toggle');
|
||||
|
||||
}
|
||||
|
||||
function dblclickCategoryList(ele) {
|
||||
@@ -159,7 +183,14 @@
|
||||
selection.addRange(newRange);
|
||||
}
|
||||
function clickRemoveElement(item){
|
||||
$(item).parent().remove()
|
||||
|
||||
let category = {
|
||||
categoryId : $(item).parent().children(".list-element").attr('data-id'),
|
||||
name : $(item).parent().children(".list-element").text(),
|
||||
order:""
|
||||
}
|
||||
deletedList.push(category)
|
||||
$(item).parent().remove();
|
||||
}
|
||||
|
||||
|
||||
|
||||
2
store-service/.gitignore
vendored
2
store-service/.gitignore
vendored
@@ -4,6 +4,7 @@ build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
**/src/main/generated/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
@@ -26,6 +27,7 @@ out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.justpickup.storeservice.domain.category.entity;
|
||||
|
||||
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import javax.annotation.processing.Generated;
|
||||
import com.querydsl.core.types.Path;
|
||||
import com.querydsl.core.types.dsl.PathInits;
|
||||
|
||||
|
||||
/**
|
||||
* QCategory is a Querydsl query type for Category
|
||||
*/
|
||||
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
|
||||
public class QCategory extends EntityPathBase<Category> {
|
||||
|
||||
private static final long serialVersionUID = -1430562590L;
|
||||
|
||||
private static final PathInits INITS = PathInits.DIRECT2;
|
||||
|
||||
public static final QCategory category = new QCategory("category");
|
||||
|
||||
public final com.justpickup.storeservice.global.entity.QBaseEntity _super = new com.justpickup.storeservice.global.entity.QBaseEntity(this);
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> createdBy = _super.createdBy;
|
||||
|
||||
public final NumberPath<Long> id = createNumber("id", Long.class);
|
||||
|
||||
public final ListPath<com.justpickup.storeservice.domain.item.entity.Item, com.justpickup.storeservice.domain.item.entity.QItem> items = this.<com.justpickup.storeservice.domain.item.entity.Item, com.justpickup.storeservice.domain.item.entity.QItem>createList("items", com.justpickup.storeservice.domain.item.entity.Item.class, com.justpickup.storeservice.domain.item.entity.QItem.class, PathInits.DIRECT2);
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> lastModifiedAt = _super.lastModifiedAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> lastModifiedBy = _super.lastModifiedBy;
|
||||
|
||||
public final StringPath name = createString("name");
|
||||
|
||||
public final NumberPath<Integer> order = createNumber("order", Integer.class);
|
||||
|
||||
public final com.justpickup.storeservice.domain.store.entity.QStore store;
|
||||
|
||||
public QCategory(String variable) {
|
||||
this(Category.class, forVariable(variable), INITS);
|
||||
}
|
||||
|
||||
public QCategory(Path<? extends Category> path) {
|
||||
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
|
||||
}
|
||||
|
||||
public QCategory(PathMetadata metadata) {
|
||||
this(metadata, PathInits.getFor(metadata, INITS));
|
||||
}
|
||||
|
||||
public QCategory(PathMetadata metadata, PathInits inits) {
|
||||
this(Category.class, metadata, inits);
|
||||
}
|
||||
|
||||
public QCategory(Class<? extends Category> type, PathMetadata metadata, PathInits inits) {
|
||||
super(type, metadata, inits);
|
||||
this.store = inits.isInitialized("store") ? new com.justpickup.storeservice.domain.store.entity.QStore(forProperty("store"), inits.get("store")) : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.justpickup.storeservice.domain.favoritestore.entity;
|
||||
|
||||
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import javax.annotation.processing.Generated;
|
||||
import com.querydsl.core.types.Path;
|
||||
import com.querydsl.core.types.dsl.PathInits;
|
||||
|
||||
|
||||
/**
|
||||
* QFavoriteStore is a Querydsl query type for FavoriteStore
|
||||
*/
|
||||
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
|
||||
public class QFavoriteStore extends EntityPathBase<FavoriteStore> {
|
||||
|
||||
private static final long serialVersionUID = -356764916L;
|
||||
|
||||
private static final PathInits INITS = PathInits.DIRECT2;
|
||||
|
||||
public static final QFavoriteStore favoriteStore = new QFavoriteStore("favoriteStore");
|
||||
|
||||
public final com.justpickup.storeservice.global.entity.QBaseEntity _super = new com.justpickup.storeservice.global.entity.QBaseEntity(this);
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> createdBy = _super.createdBy;
|
||||
|
||||
public final NumberPath<Long> id = createNumber("id", Long.class);
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> lastModifiedAt = _super.lastModifiedAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> lastModifiedBy = _super.lastModifiedBy;
|
||||
|
||||
public final com.justpickup.storeservice.domain.store.entity.QStore store;
|
||||
|
||||
public final NumberPath<Long> userId = createNumber("userId", Long.class);
|
||||
|
||||
public QFavoriteStore(String variable) {
|
||||
this(FavoriteStore.class, forVariable(variable), INITS);
|
||||
}
|
||||
|
||||
public QFavoriteStore(Path<? extends FavoriteStore> path) {
|
||||
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
|
||||
}
|
||||
|
||||
public QFavoriteStore(PathMetadata metadata) {
|
||||
this(metadata, PathInits.getFor(metadata, INITS));
|
||||
}
|
||||
|
||||
public QFavoriteStore(PathMetadata metadata, PathInits inits) {
|
||||
this(FavoriteStore.class, metadata, inits);
|
||||
}
|
||||
|
||||
public QFavoriteStore(Class<? extends FavoriteStore> type, PathMetadata metadata, PathInits inits) {
|
||||
super(type, metadata, inits);
|
||||
this.store = inits.isInitialized("store") ? new com.justpickup.storeservice.domain.store.entity.QStore(forProperty("store"), inits.get("store")) : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.justpickup.storeservice.domain.item.entity;
|
||||
|
||||
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import javax.annotation.processing.Generated;
|
||||
import com.querydsl.core.types.Path;
|
||||
import com.querydsl.core.types.dsl.PathInits;
|
||||
|
||||
|
||||
/**
|
||||
* QItem is a Querydsl query type for Item
|
||||
*/
|
||||
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
|
||||
public class QItem extends EntityPathBase<Item> {
|
||||
|
||||
private static final long serialVersionUID = -2047337460L;
|
||||
|
||||
private static final PathInits INITS = PathInits.DIRECT2;
|
||||
|
||||
public static final QItem item = new QItem("item");
|
||||
|
||||
public final com.justpickup.storeservice.global.entity.QBaseEntity _super = new com.justpickup.storeservice.global.entity.QBaseEntity(this);
|
||||
|
||||
public final com.justpickup.storeservice.domain.category.entity.QCategory category;
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> createdBy = _super.createdBy;
|
||||
|
||||
public final NumberPath<Long> id = createNumber("id", Long.class);
|
||||
|
||||
public final ListPath<com.justpickup.storeservice.domain.itemoption.entity.ItemOption, com.justpickup.storeservice.domain.itemoption.entity.QItemOption> itemOptions = this.<com.justpickup.storeservice.domain.itemoption.entity.ItemOption, com.justpickup.storeservice.domain.itemoption.entity.QItemOption>createList("itemOptions", com.justpickup.storeservice.domain.itemoption.entity.ItemOption.class, com.justpickup.storeservice.domain.itemoption.entity.QItemOption.class, PathInits.DIRECT2);
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> lastModifiedAt = _super.lastModifiedAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> lastModifiedBy = _super.lastModifiedBy;
|
||||
|
||||
public final StringPath name = createString("name");
|
||||
|
||||
public final com.justpickup.storeservice.global.entity.QPhoto photo;
|
||||
|
||||
public final NumberPath<Long> price = createNumber("price", Long.class);
|
||||
|
||||
public final EnumPath<com.justpickup.storeservice.global.entity.Yn> salesYn = createEnum("salesYn", com.justpickup.storeservice.global.entity.Yn.class);
|
||||
|
||||
public final com.justpickup.storeservice.domain.store.entity.QStore store;
|
||||
|
||||
public QItem(String variable) {
|
||||
this(Item.class, forVariable(variable), INITS);
|
||||
}
|
||||
|
||||
public QItem(Path<? extends Item> path) {
|
||||
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
|
||||
}
|
||||
|
||||
public QItem(PathMetadata metadata) {
|
||||
this(metadata, PathInits.getFor(metadata, INITS));
|
||||
}
|
||||
|
||||
public QItem(PathMetadata metadata, PathInits inits) {
|
||||
this(Item.class, metadata, inits);
|
||||
}
|
||||
|
||||
public QItem(Class<? extends Item> type, PathMetadata metadata, PathInits inits) {
|
||||
super(type, metadata, inits);
|
||||
this.category = inits.isInitialized("category") ? new com.justpickup.storeservice.domain.category.entity.QCategory(forProperty("category"), inits.get("category")) : null;
|
||||
this.photo = inits.isInitialized("photo") ? new com.justpickup.storeservice.global.entity.QPhoto(forProperty("photo")) : null;
|
||||
this.store = inits.isInitialized("store") ? new com.justpickup.storeservice.domain.store.entity.QStore(forProperty("store"), inits.get("store")) : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.justpickup.storeservice.domain.itemoption.entity;
|
||||
|
||||
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import javax.annotation.processing.Generated;
|
||||
import com.querydsl.core.types.Path;
|
||||
import com.querydsl.core.types.dsl.PathInits;
|
||||
|
||||
|
||||
/**
|
||||
* QItemOption is a Querydsl query type for ItemOption
|
||||
*/
|
||||
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
|
||||
public class QItemOption extends EntityPathBase<ItemOption> {
|
||||
|
||||
private static final long serialVersionUID = -374806570L;
|
||||
|
||||
private static final PathInits INITS = PathInits.DIRECT2;
|
||||
|
||||
public static final QItemOption itemOption = new QItemOption("itemOption");
|
||||
|
||||
public final com.justpickup.storeservice.global.entity.QBaseEntity _super = new com.justpickup.storeservice.global.entity.QBaseEntity(this);
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> createdBy = _super.createdBy;
|
||||
|
||||
public final NumberPath<Long> id = createNumber("id", Long.class);
|
||||
|
||||
public final com.justpickup.storeservice.domain.item.entity.QItem item;
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> lastModifiedAt = _super.lastModifiedAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> lastModifiedBy = _super.lastModifiedBy;
|
||||
|
||||
public final StringPath name = createString("name");
|
||||
|
||||
public final EnumPath<OptionType> optionType = createEnum("optionType", OptionType.class);
|
||||
|
||||
public final NumberPath<Long> price = createNumber("price", Long.class);
|
||||
|
||||
public QItemOption(String variable) {
|
||||
this(ItemOption.class, forVariable(variable), INITS);
|
||||
}
|
||||
|
||||
public QItemOption(Path<? extends ItemOption> path) {
|
||||
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
|
||||
}
|
||||
|
||||
public QItemOption(PathMetadata metadata) {
|
||||
this(metadata, PathInits.getFor(metadata, INITS));
|
||||
}
|
||||
|
||||
public QItemOption(PathMetadata metadata, PathInits inits) {
|
||||
this(ItemOption.class, metadata, inits);
|
||||
}
|
||||
|
||||
public QItemOption(Class<? extends ItemOption> type, PathMetadata metadata, PathInits inits) {
|
||||
super(type, metadata, inits);
|
||||
this.item = inits.isInitialized("item") ? new com.justpickup.storeservice.domain.item.entity.QItem(forProperty("item"), inits.get("item")) : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.justpickup.storeservice.domain.map.entity;
|
||||
|
||||
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import javax.annotation.processing.Generated;
|
||||
import com.querydsl.core.types.Path;
|
||||
|
||||
|
||||
/**
|
||||
* QMap is a Querydsl query type for Map
|
||||
*/
|
||||
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
|
||||
public class QMap extends EntityPathBase<Map> {
|
||||
|
||||
private static final long serialVersionUID = -1253033268L;
|
||||
|
||||
public static final QMap map = new QMap("map");
|
||||
|
||||
public final com.justpickup.storeservice.global.entity.QBaseEntity _super = new com.justpickup.storeservice.global.entity.QBaseEntity(this);
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> createdBy = _super.createdBy;
|
||||
|
||||
public final NumberPath<Long> id = createNumber("id", Long.class);
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> lastModifiedAt = _super.lastModifiedAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> lastModifiedBy = _super.lastModifiedBy;
|
||||
|
||||
public QMap(String variable) {
|
||||
super(Map.class, forVariable(variable));
|
||||
}
|
||||
|
||||
public QMap(Path<? extends Map> path) {
|
||||
super(path.getType(), path.getMetadata());
|
||||
}
|
||||
|
||||
public QMap(PathMetadata metadata) {
|
||||
super(Map.class, metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.justpickup.storeservice.domain.review.entity;
|
||||
|
||||
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import javax.annotation.processing.Generated;
|
||||
import com.querydsl.core.types.Path;
|
||||
import com.querydsl.core.types.dsl.PathInits;
|
||||
|
||||
|
||||
/**
|
||||
* QReview is a Querydsl query type for Review
|
||||
*/
|
||||
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
|
||||
public class QReview extends EntityPathBase<Review> {
|
||||
|
||||
private static final long serialVersionUID = -573894826L;
|
||||
|
||||
private static final PathInits INITS = PathInits.DIRECT2;
|
||||
|
||||
public static final QReview review = new QReview("review");
|
||||
|
||||
public final com.justpickup.storeservice.global.entity.QBaseEntity _super = new com.justpickup.storeservice.global.entity.QBaseEntity(this);
|
||||
|
||||
public final StringPath content = createString("content");
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> createdBy = _super.createdBy;
|
||||
|
||||
public final NumberPath<Long> id = createNumber("id", Long.class);
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> lastModifiedAt = _super.lastModifiedAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> lastModifiedBy = _super.lastModifiedBy;
|
||||
|
||||
public final NumberPath<Long> orderId = createNumber("orderId", Long.class);
|
||||
|
||||
public final com.justpickup.storeservice.global.entity.QPhoto photo;
|
||||
|
||||
public final com.justpickup.storeservice.domain.reviewreply.entity.QReviewReply reviewReply;
|
||||
|
||||
public final NumberPath<Integer> starRating = createNumber("starRating", Integer.class);
|
||||
|
||||
public final com.justpickup.storeservice.domain.store.entity.QStore store;
|
||||
|
||||
public final NumberPath<Long> userId = createNumber("userId", Long.class);
|
||||
|
||||
public QReview(String variable) {
|
||||
this(Review.class, forVariable(variable), INITS);
|
||||
}
|
||||
|
||||
public QReview(Path<? extends Review> path) {
|
||||
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
|
||||
}
|
||||
|
||||
public QReview(PathMetadata metadata) {
|
||||
this(metadata, PathInits.getFor(metadata, INITS));
|
||||
}
|
||||
|
||||
public QReview(PathMetadata metadata, PathInits inits) {
|
||||
this(Review.class, metadata, inits);
|
||||
}
|
||||
|
||||
public QReview(Class<? extends Review> type, PathMetadata metadata, PathInits inits) {
|
||||
super(type, metadata, inits);
|
||||
this.photo = inits.isInitialized("photo") ? new com.justpickup.storeservice.global.entity.QPhoto(forProperty("photo")) : null;
|
||||
this.reviewReply = inits.isInitialized("reviewReply") ? new com.justpickup.storeservice.domain.reviewreply.entity.QReviewReply(forProperty("reviewReply")) : null;
|
||||
this.store = inits.isInitialized("store") ? new com.justpickup.storeservice.domain.store.entity.QStore(forProperty("store"), inits.get("store")) : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.justpickup.storeservice.domain.reviewreply.entity;
|
||||
|
||||
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import javax.annotation.processing.Generated;
|
||||
import com.querydsl.core.types.Path;
|
||||
|
||||
|
||||
/**
|
||||
* QReviewReply is a Querydsl query type for ReviewReply
|
||||
*/
|
||||
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
|
||||
public class QReviewReply extends EntityPathBase<ReviewReply> {
|
||||
|
||||
private static final long serialVersionUID = -1004430868L;
|
||||
|
||||
public static final QReviewReply reviewReply = new QReviewReply("reviewReply");
|
||||
|
||||
public final com.justpickup.storeservice.global.entity.QBaseEntity _super = new com.justpickup.storeservice.global.entity.QBaseEntity(this);
|
||||
|
||||
public final StringPath content = createString("content");
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> createdBy = _super.createdBy;
|
||||
|
||||
public final NumberPath<Long> id = createNumber("id", Long.class);
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> lastModifiedAt = _super.lastModifiedAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> lastModifiedBy = _super.lastModifiedBy;
|
||||
|
||||
public QReviewReply(String variable) {
|
||||
super(ReviewReply.class, forVariable(variable));
|
||||
}
|
||||
|
||||
public QReviewReply(Path<? extends ReviewReply> path) {
|
||||
super(path.getType(), path.getMetadata());
|
||||
}
|
||||
|
||||
public QReviewReply(PathMetadata metadata) {
|
||||
super(ReviewReply.class, metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.justpickup.storeservice.domain.store.entity;
|
||||
|
||||
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import javax.annotation.processing.Generated;
|
||||
import com.querydsl.core.types.Path;
|
||||
import com.querydsl.core.types.dsl.PathInits;
|
||||
|
||||
|
||||
/**
|
||||
* QStore is a Querydsl query type for Store
|
||||
*/
|
||||
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
|
||||
public class QStore extends EntityPathBase<Store> {
|
||||
|
||||
private static final long serialVersionUID = 358375596L;
|
||||
|
||||
private static final PathInits INITS = PathInits.DIRECT2;
|
||||
|
||||
public static final QStore store = new QStore("store");
|
||||
|
||||
public final com.justpickup.storeservice.global.entity.QBaseEntity _super = new com.justpickup.storeservice.global.entity.QBaseEntity(this);
|
||||
|
||||
public final com.justpickup.storeservice.global.entity.QAddress address;
|
||||
|
||||
public final DateTimePath<java.time.LocalDateTime> businessEndTime = createDateTime("businessEndTime", java.time.LocalDateTime.class);
|
||||
|
||||
public final DateTimePath<java.time.LocalDateTime> businessStartTime = createDateTime("businessStartTime", java.time.LocalDateTime.class);
|
||||
|
||||
public final ListPath<com.justpickup.storeservice.domain.category.entity.Category, com.justpickup.storeservice.domain.category.entity.QCategory> categories = this.<com.justpickup.storeservice.domain.category.entity.Category, com.justpickup.storeservice.domain.category.entity.QCategory>createList("categories", com.justpickup.storeservice.domain.category.entity.Category.class, com.justpickup.storeservice.domain.category.entity.QCategory.class, PathInits.DIRECT2);
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> createdBy = _super.createdBy;
|
||||
|
||||
public final NumberPath<Long> id = createNumber("id", Long.class);
|
||||
|
||||
public final ListPath<com.justpickup.storeservice.domain.item.entity.Item, com.justpickup.storeservice.domain.item.entity.QItem> items = this.<com.justpickup.storeservice.domain.item.entity.Item, com.justpickup.storeservice.domain.item.entity.QItem>createList("items", com.justpickup.storeservice.domain.item.entity.Item.class, com.justpickup.storeservice.domain.item.entity.QItem.class, PathInits.DIRECT2);
|
||||
|
||||
//inherited
|
||||
public final DateTimePath<java.time.LocalDateTime> lastModifiedAt = _super.lastModifiedAt;
|
||||
|
||||
//inherited
|
||||
public final NumberPath<Long> lastModifiedBy = _super.lastModifiedBy;
|
||||
|
||||
public final com.justpickup.storeservice.domain.map.entity.QMap map;
|
||||
|
||||
public final StringPath phoneNumber = createString("phoneNumber");
|
||||
|
||||
public final com.justpickup.storeservice.global.entity.QPhoto photo;
|
||||
|
||||
public final NumberPath<Long> userId = createNumber("userId", Long.class);
|
||||
|
||||
public QStore(String variable) {
|
||||
this(Store.class, forVariable(variable), INITS);
|
||||
}
|
||||
|
||||
public QStore(Path<? extends Store> path) {
|
||||
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
|
||||
}
|
||||
|
||||
public QStore(PathMetadata metadata) {
|
||||
this(metadata, PathInits.getFor(metadata, INITS));
|
||||
}
|
||||
|
||||
public QStore(PathMetadata metadata, PathInits inits) {
|
||||
this(Store.class, metadata, inits);
|
||||
}
|
||||
|
||||
public QStore(Class<? extends Store> type, PathMetadata metadata, PathInits inits) {
|
||||
super(type, metadata, inits);
|
||||
this.address = inits.isInitialized("address") ? new com.justpickup.storeservice.global.entity.QAddress(forProperty("address")) : null;
|
||||
this.map = inits.isInitialized("map") ? new com.justpickup.storeservice.domain.map.entity.QMap(forProperty("map")) : null;
|
||||
this.photo = inits.isInitialized("photo") ? new com.justpickup.storeservice.global.entity.QPhoto(forProperty("photo")) : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.justpickup.storeservice.global.entity;
|
||||
|
||||
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import javax.annotation.processing.Generated;
|
||||
import com.querydsl.core.types.Path;
|
||||
|
||||
|
||||
/**
|
||||
* QAddress is a Querydsl query type for Address
|
||||
*/
|
||||
@Generated("com.querydsl.codegen.DefaultEmbeddableSerializer")
|
||||
public class QAddress extends BeanPath<Address> {
|
||||
|
||||
private static final long serialVersionUID = -1606742445L;
|
||||
|
||||
public static final QAddress address = new QAddress("address");
|
||||
|
||||
public final StringPath city = createString("city");
|
||||
|
||||
public final StringPath street = createString("street");
|
||||
|
||||
public final StringPath zipcode = createString("zipcode");
|
||||
|
||||
public QAddress(String variable) {
|
||||
super(Address.class, forVariable(variable));
|
||||
}
|
||||
|
||||
public QAddress(Path<? extends Address> path) {
|
||||
super(path.getType(), path.getMetadata());
|
||||
}
|
||||
|
||||
public QAddress(PathMetadata metadata) {
|
||||
super(Address.class, metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.justpickup.storeservice.global.entity;
|
||||
|
||||
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import javax.annotation.processing.Generated;
|
||||
import com.querydsl.core.types.Path;
|
||||
|
||||
|
||||
/**
|
||||
* QBaseEntity is a Querydsl query type for BaseEntity
|
||||
*/
|
||||
@Generated("com.querydsl.codegen.DefaultSupertypeSerializer")
|
||||
public class QBaseEntity extends EntityPathBase<BaseEntity> {
|
||||
|
||||
private static final long serialVersionUID = -1618660523L;
|
||||
|
||||
public static final QBaseEntity baseEntity = new QBaseEntity("baseEntity");
|
||||
|
||||
public final DateTimePath<java.time.LocalDateTime> createdAt = createDateTime("createdAt", java.time.LocalDateTime.class);
|
||||
|
||||
public final NumberPath<Long> createdBy = createNumber("createdBy", Long.class);
|
||||
|
||||
public final DateTimePath<java.time.LocalDateTime> lastModifiedAt = createDateTime("lastModifiedAt", java.time.LocalDateTime.class);
|
||||
|
||||
public final NumberPath<Long> lastModifiedBy = createNumber("lastModifiedBy", Long.class);
|
||||
|
||||
public QBaseEntity(String variable) {
|
||||
super(BaseEntity.class, forVariable(variable));
|
||||
}
|
||||
|
||||
public QBaseEntity(Path<? extends BaseEntity> path) {
|
||||
super(path.getType(), path.getMetadata());
|
||||
}
|
||||
|
||||
public QBaseEntity(PathMetadata metadata) {
|
||||
super(BaseEntity.class, metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.justpickup.storeservice.global.entity;
|
||||
|
||||
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import javax.annotation.processing.Generated;
|
||||
import com.querydsl.core.types.Path;
|
||||
|
||||
|
||||
/**
|
||||
* QPhoto is a Querydsl query type for Photo
|
||||
*/
|
||||
@Generated("com.querydsl.codegen.DefaultEmbeddableSerializer")
|
||||
public class QPhoto extends BeanPath<Photo> {
|
||||
|
||||
private static final long serialVersionUID = 329628753L;
|
||||
|
||||
public static final QPhoto photo = new QPhoto("photo");
|
||||
|
||||
public final StringPath name = createString("name");
|
||||
|
||||
public final StringPath path = createString("path");
|
||||
|
||||
public QPhoto(String variable) {
|
||||
super(Photo.class, forVariable(variable));
|
||||
}
|
||||
|
||||
public QPhoto(Path<? extends Photo> path) {
|
||||
super(path.getType(), path.getMetadata());
|
||||
}
|
||||
|
||||
public QPhoto(PathMetadata metadata) {
|
||||
super(Photo.class, metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.justpickup.storeservice.domain.category.dto;
|
||||
|
||||
import com.justpickup.storeservice.domain.category.entity.Category;
|
||||
import com.justpickup.storeservice.domain.category.web.CategoryController;
|
||||
import com.justpickup.storeservice.domain.item.entity.Item;
|
||||
import com.justpickup.storeservice.domain.store.entity.Store;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,16 +14,36 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
public class CategoryDto {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
private Integer order;
|
||||
private Store store;
|
||||
private List<Item> items;
|
||||
|
||||
public CategoryDto(Category category) {
|
||||
this.id = category.getId();
|
||||
this.name = category.getName();
|
||||
this.order = category.getOrder();
|
||||
this.store = category.getStore();
|
||||
this.items = category.getItems();
|
||||
}
|
||||
|
||||
public CategoryDto(CategoryController.PutCategoryRequest.Category category) {
|
||||
this.id = category.getCategoryId();
|
||||
this.name = category.getName();
|
||||
this.order = category.getOrder();
|
||||
}
|
||||
|
||||
public static Category createCategory(CategoryDto categoryDto){
|
||||
Category category = Category.createCategory(
|
||||
categoryDto.getId()
|
||||
,categoryDto.getName()
|
||||
, categoryDto.getOrder()
|
||||
, categoryDto.getStore());
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setStore(Store store){
|
||||
this.store=store;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,4 +43,21 @@ public class Category extends BaseEntity {
|
||||
items.add(item);
|
||||
item.setCategory(this);
|
||||
}
|
||||
|
||||
public void changeNameAndOrder(String name , Integer order){
|
||||
this.name = name;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
private Category (Long id , String name, Integer order, Store store){
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.order = order;
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
public static Category createCategory(Long id ,String name, Integer order, Store store){
|
||||
return new Category(id,name,order,store);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.justpickup.storeservice.domain.category.exception;
|
||||
|
||||
import com.justpickup.storeservice.global.exception.CustomException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
public class NotFoundStoreException extends CustomException {
|
||||
|
||||
public NotFoundStoreException(HttpStatus status, String message){
|
||||
super(status,message);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
package com.justpickup.storeservice.domain.category.service;
|
||||
|
||||
import com.justpickup.storeservice.domain.category.dto.CategoryDto;
|
||||
import com.justpickup.storeservice.domain.category.entity.Category;
|
||||
import com.justpickup.storeservice.domain.category.exception.NotFoundStoreException;
|
||||
import com.justpickup.storeservice.domain.category.repository.CategoryRepository;
|
||||
import com.justpickup.storeservice.domain.store.entity.Store;
|
||||
import com.justpickup.storeservice.domain.store.repository.StoreRepository;
|
||||
import com.justpickup.storeservice.global.exception.CustomException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -17,6 +23,7 @@ import java.util.stream.Collectors;
|
||||
public class CategoryService {
|
||||
|
||||
private final CategoryRepository categoryRepository;
|
||||
private final StoreRepository storeRepository;
|
||||
|
||||
public List<CategoryDto> getCategoryList(Long storeId){
|
||||
|
||||
@@ -25,4 +32,46 @@ public class CategoryService {
|
||||
.map(CategoryDto::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Transactional(readOnly = false)
|
||||
public void putCategoryList(Long storeId , List<CategoryDto> categoryDtoList , List<CategoryDto> deletedCategoryDtoList ){
|
||||
|
||||
Store store = storeRepository.findById(storeId)
|
||||
.orElseThrow(() -> new NotFoundStoreException(HttpStatus.BAD_REQUEST,"존재하지않는 Store"));
|
||||
|
||||
List<Category> categoryList =categoryDtoList.stream()
|
||||
.map(categoryDto -> {
|
||||
categoryDto.setStore(store);
|
||||
return CategoryDto.createCategory(categoryDto);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<Category> deletedCategoryList =deletedCategoryDtoList.stream()
|
||||
.map(categoryDto -> {
|
||||
categoryDto.setStore(store);
|
||||
return CategoryDto.createCategory(categoryDto);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
categoryList.forEach(
|
||||
category -> {
|
||||
if (category.getId() ==null)
|
||||
categoryRepository.save(category);
|
||||
else {
|
||||
categoryRepository.findById(category.getId())
|
||||
.orElseThrow(() -> new NotFoundStoreException(HttpStatus.BAD_REQUEST,"존재하지않는 Category"))
|
||||
.changeNameAndOrder(category.getName(),category.getOrder());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
deletedCategoryList.forEach(
|
||||
category -> {
|
||||
if (category.getId() !=null)
|
||||
categoryRepository.delete(categoryRepository.findById(category.getId())
|
||||
.orElseThrow(() -> new NotFoundStoreException(HttpStatus.BAD_REQUEST,"존재하지않는 Category")));
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,11 @@ package com.justpickup.storeservice.domain.category.web;
|
||||
import com.justpickup.storeservice.domain.category.dto.CategoryDto;
|
||||
import com.justpickup.storeservice.domain.category.service.CategoryService;
|
||||
import com.justpickup.storeservice.global.dto.Result;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -23,6 +21,7 @@ public class CategoryController {
|
||||
|
||||
@GetMapping("/category")
|
||||
public ResponseEntity getCategoryList( ){
|
||||
// TODO: 2022-02-09 storeId hard coding 변경해야함
|
||||
Long storeId = 1L;
|
||||
List<CategoryDto> categoryList = categoryService.getCategoryList(storeId);
|
||||
|
||||
@@ -38,13 +37,47 @@ public class CategoryController {
|
||||
|
||||
@Data
|
||||
static class CategoryResponse{
|
||||
private Long categoryId;
|
||||
private String name;
|
||||
private Integer order;
|
||||
|
||||
public CategoryResponse (CategoryDto categoryDto){
|
||||
this.categoryId = categoryDto.getId();
|
||||
this.name= categoryDto.getName();
|
||||
this.order= categoryDto.getOrder();
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/category")
|
||||
public ResponseEntity putCategoryList( @RequestBody PutCategoryRequest categoryRequest){
|
||||
|
||||
List<CategoryDto> categoryList = categoryRequest.getCategoryList().stream()
|
||||
.map(CategoryDto::new)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<CategoryDto> deletedList = categoryRequest.getDeletedList().stream()
|
||||
.map(CategoryDto::new)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
categoryService.putCategoryList(categoryRequest.getStoreId(),categoryList,deletedList);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.NO_CONTENT)
|
||||
.body(Result.createSuccessResult(null));
|
||||
}
|
||||
|
||||
@Data @NoArgsConstructor @AllArgsConstructor
|
||||
public static class PutCategoryRequest{
|
||||
private Long storeId;
|
||||
private List<Category> categoryList;
|
||||
private List<Category> deletedList;
|
||||
|
||||
@Data
|
||||
public static class Category{
|
||||
private Long categoryId;
|
||||
private String name;
|
||||
private Integer order;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.justpickup.storeservice.domain.store.repository;
|
||||
|
||||
import com.justpickup.storeservice.domain.store.entity.Store;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface StoreRepository extends JpaRepository<Store,Long> {
|
||||
}
|
||||
Reference in New Issue
Block a user