release- 新增修改门店状态接口

release-2024-04-25
huangyawei 3 months ago
parent 13603d06c6
commit 699f25323c

@ -10,13 +10,12 @@ import com.luoo.user.pojo.Store;
import com.luoo.user.service.StoreService; import com.luoo.user.service.StoreService;
import com.luoo.user.vo.store.StoreAppVO; import com.luoo.user.vo.store.StoreAppVO;
import com.luoo.user.vo.store.StorePCVO; import com.luoo.user.vo.store.StorePCVO;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
/** /**
@ -80,4 +79,18 @@ public class StoreController {
return Result.success(); 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<Void> changeStatus(@NotNull String id, @NotNull Integer status) {
storeService.changeStatus(id, status);
return Result.success();
}
} }

@ -41,4 +41,8 @@ public class StoreSearchDto implements Serializable {
@ApiModelProperty(value = "纬度") @ApiModelProperty(value = "纬度")
String lat; String lat;
@ApiModelProperty(value = "门店状态 1-合作中 2-停止合作")
Integer status;
} }

@ -59,7 +59,6 @@ public class StoreService {
this.userInfoService = userInfoService; this.userInfoService = userInfoService;
} }
// 增删改查
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void add(Store store) { public void add(Store store) {
store.setStatus(StoreEnums.STORE_STATUS_COOPERATION.getCode()); store.setStatus(StoreEnums.STORE_STATUS_COOPERATION.getCode());
@ -84,6 +83,13 @@ public class StoreService {
storeDao.save(oldStore); 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) { public Store getOne(String id) {
return storeDao.findById(id).orElse(null); return storeDao.findById(id).orElse(null);
} }
@ -108,7 +114,9 @@ public class StoreService {
qStore.tel, qStore.tel,
qStore.openingHours, qStore.openingHours,
qStore.background, qStore.background,
qStore.description qStore.description,
qStore.createTime,
qStore.status
)).from(qStore) )).from(qStore)
.where(booleanBuilder) .where(booleanBuilder)
.orderBy(qStore.createTime.desc()) .orderBy(qStore.createTime.desc())
@ -132,6 +140,8 @@ public class StoreService {
public List<StoreAppVO> getListForApp(StoreSearchDto storeSearchDto) { public List<StoreAppVO> getListForApp(StoreSearchDto storeSearchDto) {
BooleanBuilder booleanBuilder = new BooleanBuilder(); BooleanBuilder booleanBuilder = new BooleanBuilder();
QStore qStore = QStore.store; QStore qStore = QStore.store;
// APP只查询合作中的门店
storeSearchDto.setStatus(StoreEnums.STORE_STATUS_COOPERATION.getCode());
checkCondition(booleanBuilder, qStore, storeSearchDto); checkCondition(booleanBuilder, qStore, storeSearchDto);
List<StoreAppVO> storeList = jpaQueryFactory.select(Projections.constructor(StoreAppVO.class, List<StoreAppVO> storeList = jpaQueryFactory.select(Projections.constructor(StoreAppVO.class,
@ -217,6 +227,9 @@ public class StoreService {
if (searchDto.getContentType() != null) { if (searchDto.getContentType() != null) {
} }
if (searchDto.getStatus() != null) {
booleanBuilder.and(qStore.status.eq(searchDto.getStatus()));
}
} }
} }

@ -1,13 +1,16 @@
package com.luoo.user.vo.store; package com.luoo.user.vo.store;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.luoo.user.pojo.Region; import com.luoo.user.pojo.Region;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.Value; import lombok.Value;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Transient; import javax.persistence.Transient;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime;
/** /**
* DTO for {@link com.luoo.user.pojo.Store} * DTO for {@link com.luoo.user.pojo.Store}
@ -57,13 +60,22 @@ public class StorePCVO implements Serializable {
@ApiModelProperty(value = "门店介绍") @ApiModelProperty(value = "门店介绍")
String description; 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 @Transient
Region region; Region region;
public StorePCVO() { 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.id = id;
this.name = name; this.name = name;
this.regionId = regionId; this.regionId = regionId;
@ -76,5 +88,7 @@ public class StorePCVO implements Serializable {
this.openingHours = openingHours; this.openingHours = openingHours;
this.background = background; this.background = background;
this.description = description; this.description = description;
this.createTime = createTime;
this.status = status;
} }
} }
Loading…
Cancel
Save