From 699f25323c5d9790a2cade65962ebcf1ab549257 Mon Sep 17 00:00:00 2001 From: huangyawei Date: Sun, 11 Aug 2024 15:29:24 +0800 Subject: [PATCH] =?UTF-8?q?release-=20=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=97=A8=E5=BA=97=E7=8A=B6=E6=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luoo/user/controller/StoreController.java | 19 ++++++++++++++++--- .../luoo/user/dto/store/StoreSearchDto.java | 4 ++++ .../com/luoo/user/service/StoreService.java | 17 +++++++++++++++-- .../com/luoo/user/vo/store/StorePCVO.java | 16 +++++++++++++++- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/luoo_user/src/main/java/com/luoo/user/controller/StoreController.java b/luoo_user/src/main/java/com/luoo/user/controller/StoreController.java index b3d2def..535d04b 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/StoreController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/StoreController.java @@ -10,13 +10,12 @@ import com.luoo.user.pojo.Store; import com.luoo.user.service.StoreService; import com.luoo.user.vo.store.StoreAppVO; import com.luoo.user.vo.store.StorePCVO; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; +import io.swagger.annotations.*; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.validation.constraints.NotNull; import java.util.List; /** @@ -80,4 +79,18 @@ public class StoreController { return Result.success(); } + @PostMapping("/changeStatus") + @GlobalInterceptor(checkAdminLogin = true) + @ApiOperation(value = "修改门店状态(PC)", notes = "修改门店状态") + @ApiImplicitParams( + { + @ApiImplicitParam(name = "id", value = "门店id", required = true, dataType = "String"), + @ApiImplicitParam(name = "status", value = "门店状态 1-合作中 2-停止合作", required = true, dataType = "Integer") + } + ) + public Result changeStatus(@NotNull String id, @NotNull Integer status) { + storeService.changeStatus(id, status); + return Result.success(); + } + } diff --git a/luoo_user/src/main/java/com/luoo/user/dto/store/StoreSearchDto.java b/luoo_user/src/main/java/com/luoo/user/dto/store/StoreSearchDto.java index 941d217..eb349e9 100644 --- a/luoo_user/src/main/java/com/luoo/user/dto/store/StoreSearchDto.java +++ b/luoo_user/src/main/java/com/luoo/user/dto/store/StoreSearchDto.java @@ -41,4 +41,8 @@ public class StoreSearchDto implements Serializable { @ApiModelProperty(value = "纬度") String lat; + @ApiModelProperty(value = "门店状态 1-合作中 2-停止合作") + Integer status; + + } \ No newline at end of file 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 9b20258..368b657 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 @@ -59,7 +59,6 @@ public class StoreService { this.userInfoService = userInfoService; } - // 增删改查 @Transactional(rollbackFor = Exception.class) public void add(Store store) { store.setStatus(StoreEnums.STORE_STATUS_COOPERATION.getCode()); @@ -84,6 +83,13 @@ public class StoreService { storeDao.save(oldStore); } + @Transactional(rollbackFor = Exception.class) + public void changeStatus(String id, Integer status) { + Store oldStore = storeDao.findById(id).orElseThrow(() -> new RuntimeException("Store not found")); + oldStore.setStatus(status); + storeDao.save(oldStore); + } + public Store getOne(String id) { return storeDao.findById(id).orElse(null); } @@ -108,7 +114,9 @@ public class StoreService { qStore.tel, qStore.openingHours, qStore.background, - qStore.description + qStore.description, + qStore.createTime, + qStore.status )).from(qStore) .where(booleanBuilder) .orderBy(qStore.createTime.desc()) @@ -132,6 +140,8 @@ public class StoreService { public List getListForApp(StoreSearchDto storeSearchDto) { BooleanBuilder booleanBuilder = new BooleanBuilder(); QStore qStore = QStore.store; + // APP只查询合作中的门店 + storeSearchDto.setStatus(StoreEnums.STORE_STATUS_COOPERATION.getCode()); checkCondition(booleanBuilder, qStore, storeSearchDto); List storeList = jpaQueryFactory.select(Projections.constructor(StoreAppVO.class, @@ -217,6 +227,9 @@ public class StoreService { if (searchDto.getContentType() != null) { } + if (searchDto.getStatus() != null) { + booleanBuilder.and(qStore.status.eq(searchDto.getStatus())); + } } } 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 84a87da..a4087bd 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 @@ -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.persistence.Transient; import java.io.Serializable; +import java.time.LocalDateTime; /** * DTO for {@link com.luoo.user.pojo.Store} @@ -57,13 +60,22 @@ public class StorePCVO implements Serializable { @ApiModelProperty(value = "门店介绍") String description; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("创建时间") + LocalDateTime createTime; + + @ApiModelProperty(value = "门店状态 1-合作中 2-停止合作") + private Integer status; + + @Transient Region region; public StorePCVO() { } - 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) { + 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) { this.id = id; this.name = name; this.regionId = regionId; @@ -76,5 +88,7 @@ public class StorePCVO implements Serializable { this.openingHours = openingHours; this.background = background; this.description = description; + this.createTime = createTime; + this.status = status; } } \ No newline at end of file