diff --git a/luoo_user/src/main/java/com/luoo/user/service/StoreService.java b/luoo_user/src/main/java/com/luoo/user/service/StoreService.java index cf5f9dd..9cd9945 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/StoreService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/StoreService.java @@ -6,10 +6,7 @@ import com.luoo.user.dao.StoreDao; import com.luoo.user.dto.store.StoreSearchDto; import com.luoo.user.dto.store.StoreUpdateDto; import com.luoo.user.mapper.StoreMapper; -import com.luoo.user.pojo.QStore; -import com.luoo.user.pojo.Region; -import com.luoo.user.pojo.Store; -import com.luoo.user.pojo.UserInfo; +import com.luoo.user.pojo.*; import com.luoo.user.vo.store.StoreAppVO; import com.luoo.user.vo.store.StorePCVO; import com.querydsl.core.BooleanBuilder; @@ -110,6 +107,8 @@ public class StoreService { QStore qStore = QStore.store; + QUserInfo qUserInfo = QUserInfo.userInfo; + rabbitTemplate.convertAndSend("store_visit", id); // 只显示合作中的门店 @@ -126,10 +125,14 @@ public class StoreService { qStore.openingHours, qStore.background, qStore.description, + qUserInfo.avatar.as("contactAvatar"), + qUserInfo.nickName.as("contactNickName"), qStore.visitCount, qStore.introduction, qStore.code )).from(qStore) + .leftJoin(qUserInfo) + .on(qStore.contact.eq(qUserInfo.id)) .where( (qStore.id.eq(id)) .and(qStore.status.eq(StoreEnums.STORE_STATUS_COOPERATION.getCode()))) @@ -148,6 +151,7 @@ public class StoreService { public PageResult getList(StoreSearchDto storeSearchDto, Integer page, Integer size) { BooleanBuilder booleanBuilder = new BooleanBuilder(); QStore qStore = QStore.store; + QUserInfo qUserInfo = QUserInfo.userInfo; checkCondition(booleanBuilder, qStore, storeSearchDto); // 创建分页对象 Pageable pageable = PageRequest.of(page - 1, size); @@ -168,9 +172,13 @@ public class StoreService { qStore.createTime, qStore.status, qStore.visitCount, + qUserInfo.avatar.as("contactAvatar"), + qUserInfo.nickName.as("contactNickName"), qStore.introduction, qStore.code )).from(qStore) + .leftJoin(qUserInfo) + .on(qStore.contact.eq(qUserInfo.id)) .where(booleanBuilder) .orderBy(qStore.createTime.desc()) .offset(pageable.getOffset()) @@ -182,14 +190,6 @@ public class StoreService { .fetchCount(); storeList.forEach(store -> { - - String contact = store.getContact(); - if (StringUtils.isNotBlank(contact)) { - UserInfo byId = userInfoService.findById(contact); - store.setContactNickName(byId == null ? "" : byId.getNickName()); - store.setContactAvatar(byId == null ? "" : byId.getAvatar()); - } - if (store.getRegionId() != null) { Region regionById = regionService.getRegionById(store.getRegionId()); store.setRegion(regionById); diff --git a/luoo_user/src/main/java/com/luoo/user/vo/store/StoreAppVO.java b/luoo_user/src/main/java/com/luoo/user/vo/store/StoreAppVO.java index 3dc6141..8d29e24 100644 --- a/luoo_user/src/main/java/com/luoo/user/vo/store/StoreAppVO.java +++ b/luoo_user/src/main/java/com/luoo/user/vo/store/StoreAppVO.java @@ -1,13 +1,16 @@ package com.luoo.user.vo.store; +import com.fasterxml.jackson.annotation.JsonFormat; import com.luoo.user.pojo.Region; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.Value; +import org.springframework.format.annotation.DateTimeFormat; import javax.persistence.Column; import javax.validation.constraints.Size; import java.io.Serializable; +import java.time.LocalDateTime; /** * DTO for {@link com.luoo.user.pojo.Store} @@ -81,9 +84,55 @@ public class StoreAppVO implements Serializable { @ApiModelProperty(value = "折扣") private Float discount; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("创建时间") + private LocalDateTime createTime; + public StoreAppVO() { } + public StoreAppVO(String id, String name, Integer regionId, String address, String lng, String lat, String contact, String phone, String tel, String openingHours, String background, String description, String contactAvatar, String contactNickName, Integer visitCount, String introduction, String code, Float discount) { + this.id = id; + this.name = name; + this.regionId = regionId; + this.address = address; + this.lng = lng; + this.lat = lat; + this.contact = contact; + this.phone = phone; + this.tel = tel; + this.openingHours = openingHours; + this.background = background; + this.description = description; + this.contactAvatar = contactAvatar; + this.contactNickName = contactNickName; + this.visitCount = visitCount; + this.introduction = introduction; + this.code = code; + this.discount = discount; + } + + public StoreAppVO(String id, String name, Integer regionId, String address, String lng, String lat, String contact, String phone, String tel, String openingHours, String background, String description, String contactAvatar, String contactNickName, Integer visitCount, String introduction, String code) { + this.id = id; + this.name = name; + this.regionId = regionId; + this.address = address; + this.lng = lng; + this.lat = lat; + this.contact = contact; + this.phone = phone; + this.tel = tel; + this.openingHours = openingHours; + this.background = background; + this.description = description; + this.contactAvatar = contactAvatar; + this.contactNickName = contactNickName; + this.visitCount = visitCount; + this.introduction = introduction; + this.code = code; + } + public StoreAppVO(String id, String name, Integer regionId, String address, String lng, String lat, String contact, String phone, String tel, String openingHours, String background, String description, Integer visitCount, String introduction, String code) { this.id = id; this.name = name; @@ -101,4 +150,5 @@ public class StoreAppVO implements Serializable { this.introduction = introduction; this.code = code; } + } \ No newline at end of file diff --git a/luoo_user/src/main/java/com/luoo/user/vo/store/StorePCVO.java b/luoo_user/src/main/java/com/luoo/user/vo/store/StorePCVO.java index 790d3c3..e852555 100644 --- a/luoo_user/src/main/java/com/luoo/user/vo/store/StorePCVO.java +++ b/luoo_user/src/main/java/com/luoo/user/vo/store/StorePCVO.java @@ -108,4 +108,26 @@ public class StorePCVO implements Serializable { this.introduction = introduction; this.code = code; } + + public StorePCVO(String id, String name, Integer regionId, String address, String lng, String lat, String contact, String phone, String tel, String openingHours, String background, String description, LocalDateTime createTime, Integer status, Integer visitCount, String contactAvatar, String contactNickName, String introduction, String code) { + this.id = id; + this.name = name; + this.regionId = regionId; + this.address = address; + this.lng = lng; + this.lat = lat; + this.contact = contact; + this.phone = phone; + this.tel = tel; + this.openingHours = openingHours; + this.background = background; + this.description = description; + this.createTime = createTime; + this.status = status; + this.visitCount = visitCount; + this.contactAvatar = contactAvatar; + this.contactNickName = contactNickName; + this.introduction = introduction; + this.code = code; + } } \ No newline at end of file diff --git a/luoo_user/src/main/resources/mapper/StoreMapper.xml b/luoo_user/src/main/resources/mapper/StoreMapper.xml index 2e99839..608e184 100644 --- a/luoo_user/src/main/resources/mapper/StoreMapper.xml +++ b/luoo_user/src/main/resources/mapper/StoreMapper.xml @@ -14,7 +14,7 @@ - +