this is 4.2 update

This commit is contained in:
chen-xin-zhi 2025-04-02 10:12:44 +08:00
parent 3caad83a67
commit cbdb0bd965
43 changed files with 786 additions and 911 deletions

View File

@ -1,28 +1,30 @@
package com.cultural.heritage.controller.address; package com.cultural.heritage.controller.address;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.BaseResponse;
import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.common.ResultUtils; import com.cultural.heritage.common.ResultUtils;
import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonRequest; import com.cultural.heritage.model.dto.CommonRequest;
import com.cultural.heritage.model.dto.address.AddressAddRequest; import com.cultural.heritage.model.dto.address.AddressAddRequest;
import com.cultural.heritage.model.dto.address.AddressUpdateRequest; import com.cultural.heritage.model.dto.address.AddressUpdateRequest;
import com.cultural.heritage.model.entity.Address; import com.cultural.heritage.model.entity.Address;
import com.cultural.heritage.model.entity.User; import com.cultural.heritage.model.entity.User;
import com.cultural.heritage.service.address.AddressService; import com.cultural.heritage.service.address.AddressService;
import com.cultural.heritage.service.common.CommonService;
import com.cultural.heritage.service.user.UserService; import com.cultural.heritage.service.user.UserService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.List; import java.util.List;
@RestController @RestController
@ -41,6 +43,10 @@ public class AddressController {
private UserService userService; private UserService userService;
@Resource
private CommonService commonService;
/** /**
* 添加地址信息 * 添加地址信息
* @param addressAddRequest 地址添加请求体 * @param addressAddRequest 地址添加请求体
@ -48,20 +54,23 @@ public class AddressController {
*/ */
@PostMapping("/add") @PostMapping("/add")
@Operation(summary = "小程序端用户添加地址信息", description = "参数地址添加请求体权限所有人方法名addAddress") @Operation(summary = "小程序端用户添加地址信息", description = "参数地址添加请求体权限所有人方法名addAddress")
public BaseResponse<Boolean> addAddress(@RequestBody AddressAddRequest addressAddRequest, HttpServletRequest request) { public BaseResponse<Long> addAddress(@RequestBody AddressAddRequest addressAddRequest, HttpServletRequest request) {
if (addressAddRequest == null) { if (addressAddRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
User loginUser = userService.getLoginUser(request); User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId(); Long userId = loginUser.getId();
Address address = new Address(); Address address = commonService.copyProperties(addressAddRequest, Address.class);
BeanUtils.copyProperties(addressAddRequest, address);
address.setUserId(userId); address.setUserId(userId);
// 处理之前的默认地址
if (address.getIsDefault() == 1) {
LambdaUpdateWrapper<Address> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(Address::getUserId, userId).eq(Address::getIsDefault, 1).set(Address::getIsDefault, 0);
addressService.update(lambdaUpdateWrapper);
}
addressService.validAddress(address, false); addressService.validAddress(address, false);
addressService.verifyIsDefault(address); addressService.save(address);
boolean result = addressService.save(address); return ResultUtils.success(address.getId());
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true);
} }
@ -79,8 +88,7 @@ public class AddressController {
} }
userService.getLoginUser(request); userService.getLoginUser(request);
Long id = deleteRequest.getId(); Long id = deleteRequest.getId();
boolean result = addressService.removeById(id); addressService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -100,13 +108,16 @@ public class AddressController {
} }
User loginUser = userService.getLoginUser(request); User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId(); Long userId = loginUser.getId();
Address address = new Address(); Address address = commonService.copyProperties(addressUpdateRequest, Address.class);
BeanUtils.copyProperties(addressUpdateRequest, address);
address.setUserId(userId); address.setUserId(userId);
// 处理之前的默认地址
if (address.getIsDefault() == 1) {
LambdaUpdateWrapper<Address> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(Address::getUserId, userId).eq(Address::getIsDefault, 1).set(Address::getIsDefault, 0);
addressService.update(lambdaUpdateWrapper);
}
addressService.validAddress(address, true); addressService.validAddress(address, true);
addressService.verifyIsDefault(address); addressService.updateById(address);
boolean result = addressService.updateById(address);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -122,8 +133,11 @@ public class AddressController {
public BaseResponse<List<Address>> listAddress(HttpServletRequest request) { public BaseResponse<List<Address>> listAddress(HttpServletRequest request) {
User loginUser = userService.getLoginUser(request); User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId(); Long userId = loginUser.getId();
List<Address> list = addressService.getUserAddressById(userId); LambdaQueryWrapper<Address> queryWrapper = new LambdaQueryWrapper<>();
return ResultUtils.success(list); queryWrapper.eq(Address::getUserId, userId);
List<Address> addressList = addressService.list(queryWrapper);
Collections.reverse(addressList);
return ResultUtils.success(addressList);
} }

View File

@ -1,28 +1,30 @@
package com.cultural.heritage.controller.address; package com.cultural.heritage.controller.address;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.BaseResponse;
import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.common.ResultUtils; import com.cultural.heritage.common.ResultUtils;
import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonRequest; import com.cultural.heritage.model.dto.CommonRequest;
import com.cultural.heritage.model.dto.contacts.ContactsAddRequest; import com.cultural.heritage.model.dto.contacts.ContactsAddRequest;
import com.cultural.heritage.model.dto.contacts.ContactsUpdateRequest; import com.cultural.heritage.model.dto.contacts.ContactsUpdateRequest;
import com.cultural.heritage.model.entity.Contacts; import com.cultural.heritage.model.entity.Contacts;
import com.cultural.heritage.model.entity.User; import com.cultural.heritage.model.entity.User;
import com.cultural.heritage.service.address.ContactsService; import com.cultural.heritage.service.address.ContactsService;
import com.cultural.heritage.service.common.CommonService;
import com.cultural.heritage.service.user.UserService; import com.cultural.heritage.service.user.UserService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.List; import java.util.List;
@RestController @RestController
@ -40,6 +42,10 @@ public class ContactsController {
private UserService userService; private UserService userService;
@Resource
private CommonService commonService;
/** /**
* 添加联系人 * 添加联系人
* @param contactsAddRequest 联系人添加请求体 * @param contactsAddRequest 联系人添加请求体
@ -47,20 +53,23 @@ public class ContactsController {
*/ */
@PostMapping("/add") @PostMapping("/add")
@Operation(summary = "小程序端用户添加联系人信息", description = "参数联系人添加请求体权限所有人方法名addContacts") @Operation(summary = "小程序端用户添加联系人信息", description = "参数联系人添加请求体权限所有人方法名addContacts")
public BaseResponse<Boolean> addContacts(@RequestBody ContactsAddRequest contactsAddRequest, HttpServletRequest request) { public BaseResponse<Long> addContacts(@RequestBody ContactsAddRequest contactsAddRequest, HttpServletRequest request) {
if (contactsAddRequest == null) { if (contactsAddRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
User loginUser = userService.getLoginUser(request); User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId(); Long userId = loginUser.getId();
Contacts contacts = new Contacts(); Contacts contacts = commonService.copyProperties(contactsAddRequest, Contacts.class);
BeanUtils.copyProperties(contactsAddRequest, contacts);
contacts.setUserId(userId); contacts.setUserId(userId);
// 处理之前的默认联系人
if (contacts.getIsDefault() == 1) {
LambdaUpdateWrapper<Contacts> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(Contacts::getUserId, userId).eq(Contacts::getIsDefault, 1).set(Contacts::getIsDefault, 0);
contactsService.update(lambdaUpdateWrapper);
}
contactsService.validContacts(contacts, false); contactsService.validContacts(contacts, false);
contactsService.verifyIsDefault(contacts); contactsService.save(contacts);
boolean result = contactsService.save(contacts); return ResultUtils.success(contacts.getId());
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true);
} }
@ -78,13 +87,16 @@ public class ContactsController {
} }
User loginUser = userService.getLoginUser(request); User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId(); Long userId = loginUser.getId();
Contacts contacts = new Contacts(); Contacts contacts = commonService.copyProperties(contactsUpdateRequest, Contacts.class);
BeanUtils.copyProperties(contactsUpdateRequest, contacts);
contacts.setUserId(userId); contacts.setUserId(userId);
// 处理之前的默认联系人
if (contacts.getIsDefault() == 1) {
LambdaUpdateWrapper<Contacts> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(Contacts::getUserId, userId).eq(Contacts::getIsDefault, 1).set(Contacts::getIsDefault, 0);
contactsService.update(lambdaUpdateWrapper);
}
contactsService.validContacts(contacts, true); contactsService.validContacts(contacts, true);
contactsService.verifyIsDefault(contacts); contactsService.updateById(contacts);
boolean result = contactsService.updateById(contacts);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -104,8 +116,7 @@ public class ContactsController {
} }
userService.getLoginUser(request); userService.getLoginUser(request);
Long id = contactsDeleteRequest.getId(); Long id = contactsDeleteRequest.getId();
boolean result = contactsService.removeById(id); contactsService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -120,8 +131,11 @@ public class ContactsController {
public BaseResponse<List<Contacts>> listUserContacts(HttpServletRequest request) { public BaseResponse<List<Contacts>> listUserContacts(HttpServletRequest request) {
User loginUser = userService.getLoginUser(request); User loginUser = userService.getLoginUser(request);
Long userId = loginUser.getId(); Long userId = loginUser.getId();
List<Contacts> list = contactsService.getUserContactsById(userId); LambdaQueryWrapper<Contacts> queryWrapper = new LambdaQueryWrapper<>();
return ResultUtils.success(list); queryWrapper.eq(Contacts::getId, userId);
List<Contacts> contactsList = contactsService.list(queryWrapper);
Collections.reverse(contactsList);
return ResultUtils.success(contactsList);
} }

View File

@ -71,11 +71,9 @@ public class BookingDateController {
QueryWrapper<BookingTime> queryWrapper = new QueryWrapper<>(); QueryWrapper<BookingTime> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("bookingDateId", id); queryWrapper.eq("bookingDateId", id);
bookingTimeService.remove(queryWrapper); bookingTimeService.remove(queryWrapper);
// ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "预约时间点删除失败");
// 删除这个预约日期 // 删除这个预约日期
boolean success = bookingDateService.removeById(id); bookingDateService.removeById(id);
ThrowUtils.throwIf(!success, ErrorCode.OPERATION_ERROR, "预约日期删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -96,9 +94,7 @@ public class BookingDateController {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
Long id = commonRequest.getId(); Long id = commonRequest.getId();
boolean remove = bookingTimeService.removeById(id); bookingTimeService.removeById(id);
ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "预约时间删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -123,9 +119,7 @@ public class BookingDateController {
UpdateWrapper<BookingDate> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<BookingDate> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id); updateWrapper.eq("id", id);
updateWrapper.set("isAvailable", status); updateWrapper.set("isAvailable", status);
boolean update = bookingDateService.update(updateWrapper); bookingDateService.update(updateWrapper);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "预约日期状态修改失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -140,7 +134,6 @@ public class BookingDateController {
*/ */
@PostMapping("/add/time") @PostMapping("/add/time")
@Operation(summary = "Web端管理员添加预约时间段", description = "参数:预约时间段添加请求体,权限:管理员(admin, boss)方法名addAppointmentDate") @Operation(summary = "Web端管理员添加预约时间段", description = "参数:预约时间段添加请求体,权限:管理员(admin, boss)方法名addAppointmentDate")
@Transactional(rollbackFor = Exception.class)
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Long> addTimePeriod(@RequestBody BookingTimeSingleAddRequest bookingTimeSingleAddRequest) { public BaseResponse<Long> addTimePeriod(@RequestBody BookingTimeSingleAddRequest bookingTimeSingleAddRequest) {
if (bookingTimeSingleAddRequest == null || StringUtils.isBlank(bookingTimeSingleAddRequest.getTimePoint())) { if (bookingTimeSingleAddRequest == null || StringUtils.isBlank(bookingTimeSingleAddRequest.getTimePoint())) {
@ -148,9 +141,7 @@ public class BookingDateController {
} }
BookingTime bookingTime = new BookingTime(); BookingTime bookingTime = new BookingTime();
BeanUtils.copyProperties(bookingTimeSingleAddRequest, bookingTime); BeanUtils.copyProperties(bookingTimeSingleAddRequest, bookingTime);
boolean save = bookingTimeService.save(bookingTime); bookingTimeService.save(bookingTime);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "预约时间段添加失败");
return ResultUtils.success(bookingTime.getId()); return ResultUtils.success(bookingTime.getId());
} }
@ -174,8 +165,7 @@ public class BookingDateController {
// 添加当前商品的预约日期 // 添加当前商品的预约日期
BookingDate bookingDate = new BookingDate(); BookingDate bookingDate = new BookingDate();
BeanUtils.copyProperties(bookingDateSingleAddRequest, bookingDate); BeanUtils.copyProperties(bookingDateSingleAddRequest, bookingDate);
boolean save = bookingDateService.save(bookingDate); bookingDateService.save(bookingDate);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "预约日期添加失败");
// 添加当前预约日期的预约时间段 // 添加当前预约日期的预约时间段
Long bookingDateId = bookingDate.getId(); Long bookingDateId = bookingDate.getId();
@ -186,9 +176,7 @@ public class BookingDateController {
bookingTime.setBookingDateId(bookingDateId); bookingTime.setBookingDateId(bookingDateId);
return bookingTime; return bookingTime;
}).toList(); }).toList();
boolean result = bookingTimeService.saveBatch(bookingTimes); bookingTimeService.saveBatch(bookingTimes);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "批量添加预约时间失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -226,8 +214,7 @@ public class BookingDateController {
bookingTimes.addAll(bookingTimeList); bookingTimes.addAll(bookingTimeList);
} }
boolean result = bookingTimeService.saveBatch(bookingTimes); bookingTimeService.saveBatch(bookingTimes);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "预约时间批量添加失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }

View File

@ -8,7 +8,6 @@ import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.common.ResultUtils; import com.cultural.heritage.common.ResultUtils;
import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.constant.UserConstant;
import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonRequest; import com.cultural.heritage.model.dto.CommonRequest;
import com.cultural.heritage.model.dto.CommonStringRequest; import com.cultural.heritage.model.dto.CommonStringRequest;
import com.cultural.heritage.model.dto.photoCategory.PhotoCategoryAddRequest; import com.cultural.heritage.model.dto.photoCategory.PhotoCategoryAddRequest;
@ -30,6 +29,7 @@ import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -83,8 +83,7 @@ public class PhotoCategoryController {
BeanUtils.copyProperties(photoCategoryAddRequest, photoCategory); BeanUtils.copyProperties(photoCategoryAddRequest, photoCategory);
// 校验 // 校验
photoCategoryService.validPhotoCategory(photoCategory, false); photoCategoryService.validPhotoCategory(photoCategory, false);
boolean save = photoCategoryService.save(photoCategory); photoCategoryService.save(photoCategory);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "写真类别添加失败");
return ResultUtils.success(photoCategory.getId()); return ResultUtils.success(photoCategory.getId());
} }
@ -97,6 +96,7 @@ public class PhotoCategoryController {
*/ */
@PostMapping("/update") @PostMapping("/update")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
@Transactional(rollbackFor = Exception.class)
@Operation(summary = "Web端管理员更新写真类别", description = "参数:写真类别更新请求体,权限:管理员(admin, boss)方法名updatePhotoCategory") @Operation(summary = "Web端管理员更新写真类别", description = "参数:写真类别更新请求体,权限:管理员(admin, boss)方法名updatePhotoCategory")
public BaseResponse<Boolean> updatePhotoCategory(@RequestBody PhotoCategoryUpdateRequest photoCategoryUpdateRequest) { public BaseResponse<Boolean> updatePhotoCategory(@RequestBody PhotoCategoryUpdateRequest photoCategoryUpdateRequest) {
if (photoCategoryUpdateRequest == null || photoCategoryUpdateRequest.getId() <= 0) { if (photoCategoryUpdateRequest == null || photoCategoryUpdateRequest.getId() <= 0) {
@ -118,10 +118,7 @@ public class PhotoCategoryController {
BeanUtils.copyProperties(photoCategoryUpdateRequest, photoCategory); BeanUtils.copyProperties(photoCategoryUpdateRequest, photoCategory);
// 校验 // 校验
photoCategoryService.validPhotoCategory(photoCategory, true); photoCategoryService.validPhotoCategory(photoCategory, true);
photoCategoryService.updateById(photoCategory);
boolean result = photoCategoryService.updateById(photoCategory);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "写真类别名称更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -133,6 +130,7 @@ public class PhotoCategoryController {
*/ */
@PostMapping("/delete") @PostMapping("/delete")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
@Transactional(rollbackFor = Exception.class)
@Operation(summary = "Web端管理员删除写真类别", description = "参数写真类别id权限管理员(admin, boss)方法名deletePhotoCategory") @Operation(summary = "Web端管理员删除写真类别", description = "参数写真类别id权限管理员(admin, boss)方法名deletePhotoCategory")
public BaseResponse<Boolean> deletePhotoCategory(@RequestBody CommonRequest commonRequest) { public BaseResponse<Boolean> deletePhotoCategory(@RequestBody CommonRequest commonRequest) {
if (commonRequest == null || commonRequest.getId() <= 0) { if (commonRequest == null || commonRequest.getId() <= 0) {
@ -148,19 +146,12 @@ public class PhotoCategoryController {
List<BookingTime> bookingTimeList = commonService.findByFieldInTargetField(bookingDateList, bookingTimeService, BookingDate::getId, "bookingDateId"); List<BookingTime> bookingTimeList = commonService.findByFieldInTargetField(bookingDateList, bookingTimeService, BookingDate::getId, "bookingDateId");
// 批量删除预约时间 // 批量删除预约时间
bookingTimeService.removeBatchByIds(bookingTimeList); bookingTimeService.removeBatchByIds(bookingTimeList);
// ThrowUtils.throwIf(!removeTime, ErrorCode.OPERATION_ERROR, "预约时间删除失败");
// 批量删除预约日期 // 批量删除预约日期
bookingDateService.removeBatchByIds(bookingDateList); bookingDateService.removeBatchByIds(bookingDateList);
// ThrowUtils.throwIf(!removeDate, ErrorCode.OPERATION_ERROR, "预约日期批量删除失败");
// 删除该类别下所有写真产品 // 删除该类别下所有写真产品
photoProductsService.removeBatchByIds(photoProductsList); photoProductsService.removeBatchByIds(photoProductsList);
// ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "写真产品批量删除失败");
// 删除写真类别 // 删除写真类别
boolean result = photoCategoryService.removeById(id); photoCategoryService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "写真类别删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -196,7 +187,6 @@ public class PhotoCategoryController {
List<PhotoCategory> photoCategoryList = commonService.findByFieldInTargetField(photoProductsList, photoCategoryService, PhotoProducts::getCategoryName, "name"); List<PhotoCategory> photoCategoryList = commonService.findByFieldInTargetField(photoProductsList, photoCategoryService, PhotoProducts::getCategoryName, "name");
// 获取写真产品类别VO列表 // 获取写真产品类别VO列表
List<PhotoCategoryVO> photoCategoryVOList = commonService.convertList(photoCategoryList, PhotoCategoryVO.class); List<PhotoCategoryVO> photoCategoryVOList = commonService.convertList(photoCategoryList, PhotoCategoryVO.class);
return ResultUtils.success(photoCategoryVOList); return ResultUtils.success(photoCategoryVOList);
} }

View File

@ -41,7 +41,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -49,7 +49,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@RestController @RestController
@RequestMapping("/photoProducts") @RequestMapping("/photoProducts")
@ -83,10 +82,6 @@ public class PhotoProductsController {
@Resource
private RedisTemplate redisTemplate;
/** /**
* Web端管理员添加写真产品 * Web端管理员添加写真产品
* @param photoProductsAddRequest 写真产品添加请求体 * @param photoProductsAddRequest 写真产品添加请求体
@ -94,6 +89,7 @@ public class PhotoProductsController {
*/ */
@PostMapping("/add") @PostMapping("/add")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
@Transactional(rollbackFor = Exception.class)
@Operation(summary = "Web端管理员添加写真产品", description = "参数:写真产品添加请求体,权限:管理员(admin, boss)方法名addPhotoProducts") @Operation(summary = "Web端管理员添加写真产品", description = "参数:写真产品添加请求体,权限:管理员(admin, boss)方法名addPhotoProducts")
public BaseResponse<Long> addPhotoProducts(@RequestBody PhotoProductsAddRequest photoProductsAddRequest) { public BaseResponse<Long> addPhotoProducts(@RequestBody PhotoProductsAddRequest photoProductsAddRequest) {
if (photoProductsAddRequest == null) { if (photoProductsAddRequest == null) {
@ -135,9 +131,7 @@ public class PhotoProductsController {
}).toList(); }).toList();
bookingTimes.addAll(bookingTimeList); bookingTimes.addAll(bookingTimeList);
} }
boolean save = bookingTimeService.saveBatch(bookingTimes); bookingTimeService.saveBatch(bookingTimes);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "写真产品预约时间添加失败");
return ResultUtils.success(photoProducts.getId()); return ResultUtils.success(photoProducts.getId());
} }
@ -160,8 +154,7 @@ public class PhotoProductsController {
BeanUtils.copyProperties(photoProductsUpdateRequest, photoProducts); BeanUtils.copyProperties(photoProductsUpdateRequest, photoProducts);
// 校验 // 校验
photoProductsService.validPhotoProducts(photoProducts, true); photoProductsService.validPhotoProducts(photoProducts, true);
boolean result = photoProductsService.updateById(photoProducts); photoProductsService.updateById(photoProducts);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "写真产品更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -175,6 +168,7 @@ public class PhotoProductsController {
*/ */
@PostMapping("/delete") @PostMapping("/delete")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
@Transactional(rollbackFor = Exception.class)
@Operation(summary = "Web管理员删除写真产品", description = "参数写真产品id权限管理员(admin, boss)方法名deletePhotoProducts") @Operation(summary = "Web管理员删除写真产品", description = "参数写真产品id权限管理员(admin, boss)方法名deletePhotoProducts")
public BaseResponse<Boolean> deletePhotoProducts(@RequestBody CommonRequest commonRequest) { public BaseResponse<Boolean> deletePhotoProducts(@RequestBody CommonRequest commonRequest) {
if (commonRequest == null || commonRequest.getId() <= 0) { if (commonRequest == null || commonRequest.getId() <= 0) {
@ -187,13 +181,10 @@ public class PhotoProductsController {
List<BookingTime> bookingTimeList = commonService.findByFieldInTargetField(bookingDateList, bookingTimeService, BookingDate::getId, "bookingDateId"); List<BookingTime> bookingTimeList = commonService.findByFieldInTargetField(bookingDateList, bookingTimeService, BookingDate::getId, "bookingDateId");
// 删除写真产品下的预约时间 // 删除写真产品下的预约时间
bookingTimeService.removeBatchByIds(bookingTimeList); bookingTimeService.removeBatchByIds(bookingTimeList);
// ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "预约时间批量删除失败");
// 删除写真产品下的预约日期 // 删除写真产品下的预约日期
bookingDateService.removeBatchByIds(bookingDateList); bookingDateService.removeBatchByIds(bookingDateList);
// ThrowUtils.throwIf(!success, ErrorCode.OPERATION_ERROR, "预约日期批量删除失败");
// 删除写真产品 // 删除写真产品
boolean result = photoProductsService.removeById(id); photoProductsService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "写真产品删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -207,6 +198,7 @@ public class PhotoProductsController {
*/ */
@PostMapping("/delBatch") @PostMapping("/delBatch")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
@Transactional(rollbackFor = Exception.class)
@Operation(summary = "Web管理员批量删除写真产品", description = "参数写真产品id列表权限管理员(admin, boss)方法名deletePhotoProducts") @Operation(summary = "Web管理员批量删除写真产品", description = "参数写真产品id列表权限管理员(admin, boss)方法名deletePhotoProducts")
public BaseResponse<Boolean> delBatchPhotoProducts(@RequestBody CommonBatchRequest commonBatchRequest) { public BaseResponse<Boolean> delBatchPhotoProducts(@RequestBody CommonBatchRequest commonBatchRequest) {
if (commonBatchRequest == null || CollectionUtils.isEmpty(commonBatchRequest.getIdList())) { if (commonBatchRequest == null || CollectionUtils.isEmpty(commonBatchRequest.getIdList())) {
@ -219,13 +211,10 @@ public class PhotoProductsController {
List<BookingTime> bookingTimeList = commonService.findByFieldInTargetField(bookingDateList, bookingTimeService, BookingDate::getId, "bookingDateId"); List<BookingTime> bookingTimeList = commonService.findByFieldInTargetField(bookingDateList, bookingTimeService, BookingDate::getId, "bookingDateId");
// 删除写真产品下的预约时间 // 删除写真产品下的预约时间
bookingTimeService.removeBatchByIds(bookingTimeList); bookingTimeService.removeBatchByIds(bookingTimeList);
// ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "预约时间批量删除失败");
// 删除写真产品下的预约日期 // 删除写真产品下的预约日期
bookingDateService.removeBatchByIds(bookingDateList); bookingDateService.removeBatchByIds(bookingDateList);
// ThrowUtils.throwIf(!success, ErrorCode.OPERATION_ERROR, "预约日期批量删除失败");
// 批量删除写真产品 // 批量删除写真产品
boolean result = photoProductsService.removeBatchByIds(idList); photoProductsService.removeBatchByIds(idList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "写真产品批量删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -468,8 +457,7 @@ public class PhotoProductsController {
UpdateWrapper<PhotoProducts> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<PhotoProducts> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id); updateWrapper.eq("id", id);
updateWrapper.set("isShelves", status); updateWrapper.set("isShelves", status);
boolean update = photoProductsService.update(updateWrapper); photoProductsService.update(updateWrapper);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "上架状态更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -501,53 +489,53 @@ public class PhotoProductsController {
//
/** // /**
* Web端管理员保存特殊写真产品指向的id // * Web端管理员保存特殊写真产品指向的id
* @return 是否保存成功 // * @return 是否保存成功
*/ // */
@PostMapping("/special/save") // @PostMapping("/special/save")
@Operation(summary = "Web端管理员保存特殊写真产品指向的id", description = "参数:无,权限:管理员(admin, boss)方法名saveSpecialPhotoProductById") // @Operation(summary = "Web端管理员保存特殊写真产品指向的id", description = "参数:无,权限:管理员(admin, boss)方法名saveSpecialPhotoProductById")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) // @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> saveSpecialPhotoProductById(@RequestBody CommonBatchRequest commonBatchRequest) { // public BaseResponse<Boolean> saveSpecialPhotoProductById(@RequestBody CommonBatchRequest commonBatchRequest) {
if (commonBatchRequest == null) { // if (commonBatchRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR); // throw new BusinessException(ErrorCode.PARAMS_ERROR);
} // }
List<Long> idList = commonBatchRequest.getIdList(); // List<Long> idList = commonBatchRequest.getIdList();
redisTemplate.opsForValue().set("photoProductIds", idList); // redisTemplate.opsForValue().set("photoProductIds", idList);
return ResultUtils.success(true); // return ResultUtils.success(true);
} // }
//
//
//
/** // /**
* Web端小程序端管理员查询特殊写真产品指向的id // * Web端小程序端管理员查询特殊写真产品指向的id
* @return 写真产品id列表 // * @return 写真产品id列表
*/ // */
@PostMapping("/special/get") // @PostMapping("/special/get")
@Operation(summary = "Web端管理员小程序端查询特殊写真产品指向的id", description = "参数写真产品id列表权限管理员(admin, boss)方法名getSpecialPhotoProductIds") // @Operation(summary = "Web端管理员小程序端查询特殊写真产品指向的id", description = "参数写真产品id列表权限管理员(admin, boss)方法名getSpecialPhotoProductIds")
public BaseResponse<List<Long>> getSpecialPhotoProductIds () { // public BaseResponse<List<Long>> getSpecialPhotoProductIds () {
//
Object valueObj = redisTemplate.opsForValue().get("photoProductIds"); // Object valueObj = redisTemplate.opsForValue().get("photoProductIds");
List<Long> newIds = new ArrayList<>(); // List<Long> newIds = new ArrayList<>();
if (valueObj != null) { // if (valueObj != null) {
List<Long> ids = ((List<?>) valueObj).stream() // List<Long> ids = ((List<?>) valueObj).stream()
.map(obj -> ((Number) obj).longValue()) // .map(obj -> ((Number) obj).longValue())
.collect(Collectors.toList()); // .collect(Collectors.toList());
for (Long id: ids) { // for (Long id: ids) {
PhotoProducts photoProducts = photoProductsService.getById(id); // PhotoProducts photoProducts = photoProductsService.getById(id);
if (photoProducts == null || photoProducts.getIsShelves() == 0) { // if (photoProducts == null || photoProducts.getIsShelves() == 0) {
newIds.add(0L); // newIds.add(0L);
} else { // } else {
newIds.add(id); // newIds.add(id);
} // }
} // }
} else { // } else {
newIds = Arrays.asList(0L, 0L); // newIds = Arrays.asList(0L, 0L);
} // }
redisTemplate.opsForValue().set("photoProductIds", newIds); // redisTemplate.opsForValue().set("photoProductIds", newIds);
return ResultUtils.success(newIds); // return ResultUtils.success(newIds);
} // }

View File

@ -8,7 +8,6 @@ import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.common.ResultUtils; import com.cultural.heritage.common.ResultUtils;
import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.constant.UserConstant;
import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonRequest; import com.cultural.heritage.model.dto.CommonRequest;
import com.cultural.heritage.model.dto.clotheCategory.ClothesCategoryAddRequest; import com.cultural.heritage.model.dto.clotheCategory.ClothesCategoryAddRequest;
import com.cultural.heritage.model.dto.clotheCategory.ClothesCategoryUpdateRequest; import com.cultural.heritage.model.dto.clotheCategory.ClothesCategoryUpdateRequest;
@ -69,8 +68,7 @@ public class ClothesCategoryController {
ClothesCategory clothesCategory = commonService.copyProperties(clothesCategoryAddRequest, ClothesCategory.class); ClothesCategory clothesCategory = commonService.copyProperties(clothesCategoryAddRequest, ClothesCategory.class);
// 校验 // 校验
clothesCategoryService.validClothesCategory(clothesCategory, false); clothesCategoryService.validClothesCategory(clothesCategory, false);
boolean save = clothesCategoryService.save(clothesCategory); clothesCategoryService.save(clothesCategory);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "服装类别添加失败");
return ResultUtils.success(clothesCategory.getId()); return ResultUtils.success(clothesCategory.getId());
} }
@ -91,10 +89,7 @@ public class ClothesCategoryController {
ClothesCategory clothesCategory = commonService.copyProperties(clothesCategoryUpdateRequest, ClothesCategory.class); ClothesCategory clothesCategory = commonService.copyProperties(clothesCategoryUpdateRequest, ClothesCategory.class);
// 校验 // 校验
clothesCategoryService.validClothesCategory(clothesCategory, true); clothesCategoryService.validClothesCategory(clothesCategory, true);
clothesCategoryService.updateById(clothesCategory);
boolean result = clothesCategoryService.updateById(clothesCategory);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服装类别名称更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -119,11 +114,8 @@ public class ClothesCategoryController {
// 删除该类别下的所有服装 // 删除该类别下的所有服装
clothesService.remove(queryWrapper); clothesService.remove(queryWrapper);
// 删除服装类别 // 删除服装类别
boolean result = clothesCategoryService.removeById(id); clothesCategoryService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服装类别删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }

View File

@ -74,8 +74,7 @@ public class ClothesController {
Clothes clothes = commonService.copyProperties(clothesAddRequest, Clothes.class); Clothes clothes = commonService.copyProperties(clothesAddRequest, Clothes.class);
// 校验 // 校验
clothesService.validClothes(clothes, false); clothesService.validClothes(clothes, false);
boolean save = clothesService.save(clothes); clothesService.save(clothes);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "服装租赁产品添加失败");
// 缓存商品详情到 Redis // 缓存商品详情到 Redis
String clothesCacheKey = CLOTHES_KEY + clothes.getId(); String clothesCacheKey = CLOTHES_KEY + clothes.getId();
@ -100,9 +99,7 @@ public class ClothesController {
// 更新服装租赁产品 // 更新服装租赁产品
Clothes clothes = commonService.copyProperties(clothesUpdateRequest, Clothes.class); Clothes clothes = commonService.copyProperties(clothesUpdateRequest, Clothes.class);
clothesService.validClothes(clothes, true); clothesService.validClothes(clothes, true);
clothesService.updateById(clothes);
boolean result = clothesService.updateById(clothes);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服装租赁产品更新失败");
// 清除 Redis 缓存 // 清除 Redis 缓存
String cacheKey = CLOTHES_KEY + clothes.getId(); String cacheKey = CLOTHES_KEY + clothes.getId();
@ -124,8 +121,7 @@ public class ClothesController {
if (commonRequest == null || commonRequest.getId() <= 0) { if (commonRequest == null || commonRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
boolean result = clothesService.removeById(commonRequest.getId()); clothesService.removeById(commonRequest.getId());
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服装租赁产品删除失败");
// 删除缓存中的相应数据 // 删除缓存中的相应数据
String cacheKey = CLOTHES_KEY + commonRequest.getId(); String cacheKey = CLOTHES_KEY + commonRequest.getId();
@ -168,7 +164,6 @@ public class ClothesController {
// 如果缓存命中直接返回 // 如果缓存命中直接返回
if (clothes != null) { if (clothes != null) {
clothesVO = commonService.copyProperties(clothes, ClothesVO.class); clothesVO = commonService.copyProperties(clothes, ClothesVO.class);
System.out.println("走缓存");
return ResultUtils.success(clothesVO); return ResultUtils.success(clothesVO);
} }
Clothes clothesInfo = clothesService.getClothesInfoById(id); Clothes clothesInfo = clothesService.getClothesInfoById(id);
@ -195,7 +190,6 @@ public class ClothesController {
// 如果缓存命中直接返回 // 如果缓存命中直接返回
if (clothes != null) { if (clothes != null) {
clothesLabelVO = commonService.copyProperties(clothes, ClothesLabelVO.class); clothesLabelVO = commonService.copyProperties(clothes, ClothesLabelVO.class);
System.out.println("走缓存");
return ResultUtils.success(clothesLabelVO); return ResultUtils.success(clothesLabelVO);
} }
Clothes clothesInfo = clothesService.getClothesInfoById(id); Clothes clothesInfo = clothesService.getClothesInfoById(id);
@ -290,9 +284,7 @@ public class ClothesController {
UpdateWrapper<Clothes> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<Clothes> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id); updateWrapper.eq("id", id);
updateWrapper.set("isShelves", status); updateWrapper.set("isShelves", status);
boolean update = clothesService.update(updateWrapper); clothesService.update(updateWrapper);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "上架状态更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }

View File

@ -94,12 +94,8 @@ public class AppointmentDateController {
QueryWrapper<TimePeriod> queryWrapper = new QueryWrapper<>(); QueryWrapper<TimePeriod> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("appointmentDateId", id); queryWrapper.eq("appointmentDateId", id);
timePeriodService.remove(queryWrapper); timePeriodService.remove(queryWrapper);
// ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "预约时间段删除失败");
// 删除这个预约日期 // 删除这个预约日期
boolean success = appointmentDateService.removeById(id); appointmentDateService.removeById(id);
ThrowUtils.throwIf(!success, ErrorCode.OPERATION_ERROR, "预约日期删除失败");
// 删除服务类商品待处理记录 // 删除服务类商品待处理记录
QueryWrapper<PendingServiceGood> goodQueryWrapper = new QueryWrapper<>(); QueryWrapper<PendingServiceGood> goodQueryWrapper = new QueryWrapper<>();
goodQueryWrapper.eq("appointmentDateId", id); goodQueryWrapper.eq("appointmentDateId", id);
@ -110,8 +106,7 @@ public class AppointmentDateController {
map.put(pendingServiceOrder.getPendingId(), 1); map.put(pendingServiceOrder.getPendingId(), 1);
} }
pendingServiceGoodList = pendingServiceGoodList.stream().filter(pendingServiceGood -> map.get(pendingServiceGood.getId()) == null).toList(); pendingServiceGoodList = pendingServiceGoodList.stream().filter(pendingServiceGood -> map.get(pendingServiceGood.getId()) == null).toList();
boolean result = pendingServiceGoodService.removeBatchByIds(pendingServiceGoodList); pendingServiceGoodService.removeBatchByIds(pendingServiceGoodList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
@ -134,9 +129,7 @@ public class AppointmentDateController {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
Long id = commonRequest.getId(); Long id = commonRequest.getId();
boolean remove = timePeriodService.removeById(id); timePeriodService.removeById(id);
ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "预约时间段删除失败");
// 删除服务类商品待处理记录 // 删除服务类商品待处理记录
QueryWrapper<PendingServiceGood> goodQueryWrapper = new QueryWrapper<>(); QueryWrapper<PendingServiceGood> goodQueryWrapper = new QueryWrapper<>();
goodQueryWrapper.eq("timePeriodId", id); goodQueryWrapper.eq("timePeriodId", id);
@ -148,10 +141,7 @@ public class AppointmentDateController {
QueryWrapper<PendingServiceOrder> queryWrapper = new QueryWrapper<>(); QueryWrapper<PendingServiceOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("pendingId", pendingId); queryWrapper.eq("pendingId", pendingId);
long count = pendingServiceOrderService.count(queryWrapper); long count = pendingServiceOrderService.count(queryWrapper);
if (count == 0) { if (count == 0) pendingServiceGoodService.remove(goodQueryWrapper);
boolean result = pendingServiceGoodService.remove(goodQueryWrapper);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录删除失败");
}
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -164,6 +154,7 @@ public class AppointmentDateController {
*/ */
@PostMapping("/update/status") @PostMapping("/update/status")
@Operation(summary = "Web端管理员根据id修改预约日期的状态", description = "参数预约日期id权限管理员(admin, boss)方法名updateTimePeriodStatusById") @Operation(summary = "Web端管理员根据id修改预约日期的状态", description = "参数预约日期id权限管理员(admin, boss)方法名updateTimePeriodStatusById")
@Transactional(rollbackFor = Exception.class)
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> updateTimePeriodStatusById(@RequestBody CommonRequest commonRequest) { public BaseResponse<Boolean> updateTimePeriodStatusById(@RequestBody CommonRequest commonRequest) {
if (commonRequest == null || commonRequest.getId() <= 0) { if (commonRequest == null || commonRequest.getId() <= 0) {
@ -176,14 +167,11 @@ public class AppointmentDateController {
UpdateWrapper<AppointmentDate> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<AppointmentDate> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id); updateWrapper.eq("id", id);
updateWrapper.set("isAvailable", status); updateWrapper.set("isAvailable", status);
boolean update = appointmentDateService.update(updateWrapper); appointmentDateService.update(updateWrapper);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "预约日期状态修改失败");
// 批量更新服务类商品待处理记录 // 批量更新服务类商品待处理记录
UpdateWrapper<PendingServiceGood> goodUpdateWrapper = new UpdateWrapper<>(); UpdateWrapper<PendingServiceGood> goodUpdateWrapper = new UpdateWrapper<>();
goodUpdateWrapper.eq("appointmentDateId", id).set("isAvailable", status); goodUpdateWrapper.eq("appointmentDateId", id).set("isAvailable", status);
boolean result = pendingServiceGoodService.update(goodUpdateWrapper); pendingServiceGoodService.update(goodUpdateWrapper);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录批量更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -197,6 +185,7 @@ public class AppointmentDateController {
*/ */
@PostMapping("/update/time") @PostMapping("/update/time")
@Operation(summary = "Web端管理员根据id修改预约时间段的人数", description = "参数预约日期id权限管理员(admin, boss)方法名updateTimePeriodPersonNumberById") @Operation(summary = "Web端管理员根据id修改预约时间段的人数", description = "参数预约日期id权限管理员(admin, boss)方法名updateTimePeriodPersonNumberById")
@Transactional(rollbackFor = Exception.class)
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> updateTimePeriodPersonNumberById(@RequestBody TimePeriodSingleUpdateRequest timePeriodSingleUpdateRequest) { public BaseResponse<Boolean> updateTimePeriodPersonNumberById(@RequestBody TimePeriodSingleUpdateRequest timePeriodSingleUpdateRequest) {
if (timePeriodSingleUpdateRequest == null || timePeriodSingleUpdateRequest.getId() <= 0) { if (timePeriodSingleUpdateRequest == null || timePeriodSingleUpdateRequest.getId() <= 0) {
@ -210,18 +199,13 @@ public class AppointmentDateController {
BeanUtils.copyProperties(timePeriodSingleUpdateRequest, timePeriod); BeanUtils.copyProperties(timePeriodSingleUpdateRequest, timePeriod);
timePeriod.setId(time.getId()); timePeriod.setId(time.getId());
timePeriod.setTimeSlot(time.getTimeSlot()); timePeriod.setTimeSlot(time.getTimeSlot());
timePeriodService.updateById(timePeriod);
boolean update = timePeriodService.updateById(timePeriod);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "预约时间段人数修改失败");
// 更新服务类商品待处理记录 // 更新服务类商品待处理记录
UpdateWrapper<PendingServiceGood> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<PendingServiceGood> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("timePeriodId", id); updateWrapper.eq("timePeriodId", id);
updateWrapper.set("minNumber", timePeriodSingleUpdateRequest.getMinNumber()); updateWrapper.set("minNumber", timePeriodSingleUpdateRequest.getMinNumber());
updateWrapper.set("maxNumber", timePeriodSingleUpdateRequest.getMaxNumber()); updateWrapper.set("maxNumber", timePeriodSingleUpdateRequest.getMaxNumber());
boolean result = pendingServiceGoodService.update(updateWrapper); pendingServiceGoodService.update(updateWrapper);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -241,9 +225,7 @@ public class AppointmentDateController {
} }
TimePeriod timePeriod = new TimePeriod(); TimePeriod timePeriod = new TimePeriod();
BeanUtils.copyProperties(timePeriodSingleAddRequest, timePeriod); BeanUtils.copyProperties(timePeriodSingleAddRequest, timePeriod);
boolean save = timePeriodService.save(timePeriod); timePeriodService.save(timePeriod);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "预约时间段添加失败");
// 添加服务类商品待处理记录 // 添加服务类商品待处理记录
PendingServiceGood pendingServiceGood = new PendingServiceGood(); PendingServiceGood pendingServiceGood = new PendingServiceGood();
BeanUtils.copyProperties(timePeriodSingleAddRequest, pendingServiceGood); BeanUtils.copyProperties(timePeriodSingleAddRequest, pendingServiceGood);
@ -262,10 +244,7 @@ public class AppointmentDateController {
pendingServiceGood.setTimePeriodId(timePeriod.getId()); pendingServiceGood.setTimePeriodId(timePeriod.getId());
pendingServiceGood.setReservationDate(appointmentDate.getSpecificDate()); pendingServiceGood.setReservationDate(appointmentDate.getSpecificDate());
pendingServiceGood.setIsAvailable(appointmentDate.getIsAvailable()); pendingServiceGood.setIsAvailable(appointmentDate.getIsAvailable());
pendingServiceGoodService.save(pendingServiceGood);
boolean result = pendingServiceGoodService.save(pendingServiceGood);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录添加失败");
return ResultUtils.success(timePeriod.getId()); return ResultUtils.success(timePeriod.getId());
} }
@ -287,9 +266,7 @@ public class AppointmentDateController {
// 添加当前商品的预约日期 // 添加当前商品的预约日期
AppointmentDate appointmentDate = new AppointmentDate(); AppointmentDate appointmentDate = new AppointmentDate();
BeanUtils.copyProperties(appointmentDateSingleAddRequest, appointmentDate); BeanUtils.copyProperties(appointmentDateSingleAddRequest, appointmentDate);
boolean save = appointmentDateService.save(appointmentDate); appointmentDateService.save(appointmentDate);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "预约日期添加失败");
// 添加当前预约日期的预约时间段 // 添加当前预约日期的预约时间段
Long appointmentDateId = appointmentDate.getId(); Long appointmentDateId = appointmentDate.getId();
List<TimePeriodAddRequest> timePeriodAddRequestList = appointmentDateSingleAddRequest.getTimePeriodAddRequestList(); List<TimePeriodAddRequest> timePeriodAddRequestList = appointmentDateSingleAddRequest.getTimePeriodAddRequestList();
@ -299,8 +276,7 @@ public class AppointmentDateController {
timePeriod.setAppointmentDateId(appointmentDateId); timePeriod.setAppointmentDateId(appointmentDateId);
return timePeriod; return timePeriod;
}).toList(); }).toList();
boolean result = timePeriodService.saveBatch(timePeriodList); timePeriodService.saveBatch(timePeriodList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "批量添加预约时间段失败");
// 批量添加服务类商品待处理记录 // 批量添加服务类商品待处理记录
Long goodId = appointmentDate.getGoodId(); Long goodId = appointmentDate.getGoodId();
@ -333,9 +309,7 @@ public class AppointmentDateController {
pendingServiceGoodList.add(pendingServiceGood); pendingServiceGoodList.add(pendingServiceGood);
} }
boolean saveBatch = pendingServiceGoodService.saveBatch(pendingServiceGoodList); pendingServiceGoodService.saveBatch(pendingServiceGoodList);
ThrowUtils.throwIf(!saveBatch, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录批量添加失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -361,8 +335,7 @@ public class AppointmentDateController {
// 批量添加当前商品的预约日期 // 批量添加当前商品的预约日期
List<AppointmentDate> appointmentDateList = commonService.convertList(appointmentDateSingleAddRequestList, AppointmentDate.class); List<AppointmentDate> appointmentDateList = commonService.convertList(appointmentDateSingleAddRequestList, AppointmentDate.class);
boolean save = appointmentDateService.saveBatch(appointmentDateList); appointmentDateService.saveBatch(appointmentDateList);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "预约日期批量添加失败");
// 批量添加当前预约日期的预约时间段 // 批量添加当前预约日期的预约时间段
List<TimePeriod> timePeriods = new ArrayList<>(); List<TimePeriod> timePeriods = new ArrayList<>();
@ -377,8 +350,7 @@ public class AppointmentDateController {
}).toList(); }).toList();
timePeriods.addAll(timePeriodList); timePeriods.addAll(timePeriodList);
} }
boolean result = timePeriodService.saveBatch(timePeriods); timePeriodService.saveBatch(timePeriods);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "批量添加预约时间段失败");
// 批量插入服务类商品待处理记录 // 批量插入服务类商品待处理记录
List<AppointmentDateTimePeriodVO> appointmentDateTimePeriodVOList = appointmentDateService.queryAppointmentDateDetailById(good.getId()); List<AppointmentDateTimePeriodVO> appointmentDateTimePeriodVOList = appointmentDateService.queryAppointmentDateDetailById(good.getId());
@ -393,10 +365,7 @@ public class AppointmentDateController {
pendingServiceGood.setAppointmentDateId(appointmentDateTimePeriodVO.getId()); pendingServiceGood.setAppointmentDateId(appointmentDateTimePeriodVO.getId());
pendingServiceGoodList.add(pendingServiceGood); pendingServiceGoodList.add(pendingServiceGood);
} }
boolean batch = pendingServiceGoodService.saveBatch(pendingServiceGoodList); pendingServiceGoodService.saveBatch(pendingServiceGoodList);
ThrowUtils.throwIf(!batch, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录批量插入失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }

View File

@ -6,7 +6,6 @@ import com.cultural.heritage.common.BaseResponse;
import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.common.ResultUtils; import com.cultural.heritage.common.ResultUtils;
import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonBatchRequest; import com.cultural.heritage.model.dto.CommonBatchRequest;
import com.cultural.heritage.model.dto.cartService.CartExperienceAddRequest; import com.cultural.heritage.model.dto.cartService.CartExperienceAddRequest;
import com.cultural.heritage.model.dto.cartService.CartExperienceUpdateRequest; import com.cultural.heritage.model.dto.cartService.CartExperienceUpdateRequest;
@ -145,8 +144,7 @@ public class CartExperienceController {
cartExperience.setTimeSlot(timeSlot); cartExperience.setTimeSlot(timeSlot);
} }
boolean result = cartExperienceService.updateBatchById(cartExperienceList); cartExperienceService.updateBatchById(cartExperienceList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "购物车信息更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -165,8 +163,7 @@ public class CartExperienceController {
} }
userService.getLoginUser(request); userService.getLoginUser(request);
List<Long> idList = commonBatchRequest.getIdList(); List<Long> idList = commonBatchRequest.getIdList();
boolean result = cartExperienceService.removeBatchByIds(idList); cartExperienceService.removeBatchByIds(idList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true); return ResultUtils.success(true);
} }

View File

@ -5,7 +5,6 @@ import com.cultural.heritage.common.BaseResponse;
import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.common.ResultUtils; import com.cultural.heritage.common.ResultUtils;
import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonBatchRequest; import com.cultural.heritage.model.dto.CommonBatchRequest;
import com.cultural.heritage.model.dto.cart.CartRecordAddRequest; import com.cultural.heritage.model.dto.cart.CartRecordAddRequest;
import com.cultural.heritage.model.dto.cart.CartRecordUpdateRequest; import com.cultural.heritage.model.dto.cart.CartRecordUpdateRequest;
@ -115,9 +114,7 @@ public class CartRecordController {
BigDecimal price = priceMap.get(goodId); BigDecimal price = priceMap.get(goodId);
cartRecord.setSubtotal(price.multiply(BigDecimal.valueOf(quantity))); cartRecord.setSubtotal(price.multiply(BigDecimal.valueOf(quantity)));
} }
cartRecordService.updateBatchById(cartRecordList);
boolean result = cartRecordService.updateBatchById(cartRecordList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -136,8 +133,7 @@ public class CartRecordController {
} }
userService.getLoginUser(request); userService.getLoginUser(request);
List<Long> idList = commonBatchRequest.getIdList(); List<Long> idList = commonBatchRequest.getIdList();
boolean result = cartRecordService.removeBatchByIds(idList); cartRecordService.removeBatchByIds(idList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true); return ResultUtils.success(true);
} }

View File

@ -9,7 +9,6 @@ import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.common.ResultUtils; import com.cultural.heritage.common.ResultUtils;
import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.constant.UserConstant;
import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonBatchRequest; import com.cultural.heritage.model.dto.CommonBatchRequest;
import com.cultural.heritage.model.dto.CommonRequest; import com.cultural.heritage.model.dto.CommonRequest;
import com.cultural.heritage.model.dto.category.CategoryAddRequest; import com.cultural.heritage.model.dto.category.CategoryAddRequest;
@ -27,6 +26,7 @@ import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -75,8 +75,7 @@ public class CategoryController {
Category category = new Category(); Category category = new Category();
BeanUtils.copyProperties(categoryAddRequest, category); BeanUtils.copyProperties(categoryAddRequest, category);
categoryService.validCategory(category, true); categoryService.validCategory(category, true);
boolean save = categoryService.save(category); categoryService.save(category);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true, "类别插入成功"); return ResultUtils.success(true, "类别插入成功");
} }
@ -88,6 +87,7 @@ public class CategoryController {
*/ */
@PostMapping("/delete") @PostMapping("/delete")
@Operation(summary = "Web端管理员删除商品类别", description = "参数:类别删除请求体,权限:管理员(admin, boss)方法名deleteCategory") @Operation(summary = "Web端管理员删除商品类别", description = "参数:类别删除请求体,权限:管理员(admin, boss)方法名deleteCategory")
@Transactional(rollbackFor = Exception.class)
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> deleteCategory(@RequestBody CommonRequest deleteCategoryRequest) { public BaseResponse<Boolean> deleteCategory(@RequestBody CommonRequest deleteCategoryRequest) {
if (deleteCategoryRequest == null || deleteCategoryRequest.getId() <= 0) { if (deleteCategoryRequest == null || deleteCategoryRequest.getId() <= 0) {
@ -99,14 +99,9 @@ public class CategoryController {
String typeName = category.getTypeName(); String typeName = category.getTypeName();
List<Good> goodList = commonService.findByFieldEqTargetField("type", typeName, goodService); List<Good> goodList = commonService.findByFieldEqTargetField("type", typeName, goodService);
goodService.removeBatchByIds(goodList); goodService.removeBatchByIds(goodList);
// ThrowUtils.throwIf(!isSuccess, ErrorCode.OPERATION_ERROR, "商品批量删除失败");
// 删除当前类别 // 删除当前类别
boolean result = categoryService.removeById(id); categoryService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "类别删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -118,6 +113,7 @@ public class CategoryController {
*/ */
@PostMapping("/delBatch") @PostMapping("/delBatch")
@Operation(summary = "Web端管理员批量删除商品类别", description = "参数:类别删除请求体,权限:管理员(admin, boss)方法名deleteCategory") @Operation(summary = "Web端管理员批量删除商品类别", description = "参数:类别删除请求体,权限:管理员(admin, boss)方法名deleteCategory")
@Transactional(rollbackFor = Exception.class)
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> delBatchCategory(@RequestBody CommonBatchRequest commonDelBatchRequest) { public BaseResponse<Boolean> delBatchCategory(@RequestBody CommonBatchRequest commonDelBatchRequest) {
if (commonDelBatchRequest == null || CollectionUtils.isEmpty(commonDelBatchRequest.getIdList())) { if (commonDelBatchRequest == null || CollectionUtils.isEmpty(commonDelBatchRequest.getIdList())) {
@ -130,12 +126,8 @@ public class CategoryController {
// 批量删除商品 // 批量删除商品
goodService.removeBatchByIds(goodList); goodService.removeBatchByIds(goodList);
// ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "商品批量删除失败");
// 批量删除当前类别 // 批量删除当前类别
boolean remove = categoryService.removeBatchByIds(categoryList); categoryService.removeBatchByIds(categoryList);
ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "类别批量删除失败");
return ResultUtils.success(true, "批量删除类别成功"); return ResultUtils.success(true, "批量删除类别成功");
} }
@ -149,6 +141,7 @@ public class CategoryController {
*/ */
@PostMapping("/update") @PostMapping("/update")
@Operation(summary = "Web端管理员更新商品类别", description = "参数:类别更新请求体,权限:管理员(admin, boss)方法名updateCategory") @Operation(summary = "Web端管理员更新商品类别", description = "参数:类别更新请求体,权限:管理员(admin, boss)方法名updateCategory")
@Transactional(rollbackFor = Exception.class)
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> updateCategory(@RequestBody CategoryUpdateRequest categoryUpdateRequest) { public BaseResponse<Boolean> updateCategory(@RequestBody CategoryUpdateRequest categoryUpdateRequest) {
if (categoryUpdateRequest == null || categoryUpdateRequest.getId() <= 0) { if (categoryUpdateRequest == null || categoryUpdateRequest.getId() <= 0) {
@ -168,14 +161,11 @@ public class CategoryController {
Category category = new Category(); Category category = new Category();
BeanUtils.copyProperties(categoryUpdateRequest, category); BeanUtils.copyProperties(categoryUpdateRequest, category);
categoryService.validCategory(category, false); categoryService.validCategory(category, false);
boolean result = categoryService.updateById(category); categoryService.updateById(category);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "商品类别更新失败");
// 修改原有类别下所有商品的类名 // 修改原有类别下所有商品的类名
UpdateWrapper<Good> goodUpdateWrapper = new UpdateWrapper<>(); UpdateWrapper<Good> goodUpdateWrapper = new UpdateWrapper<>();
goodUpdateWrapper.eq("type", originTypeName).set("type", targetTypeName); goodUpdateWrapper.eq("type", originTypeName).set("type", targetTypeName);
goodService.update(goodUpdateWrapper); goodService.update(goodUpdateWrapper);
// ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "商品类名更新失败");
return ResultUtils.success(true, "类别更新成功"); return ResultUtils.success(true, "类别更新成功");
} }

View File

@ -95,9 +95,7 @@ public class CouponController {
} }
// 校验 // 校验
couponService.validCoupon(coupon, false); couponService.validCoupon(coupon, false);
boolean result = couponService.save(coupon); couponService.save(coupon);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "优惠券添加失败");
// 向消息队列中发送优惠券创建的消息 // 向消息队列中发送优惠券创建的消息
couponService.sendCouponCreateMessage(coupon); couponService.sendCouponCreateMessage(coupon);
@ -131,15 +129,11 @@ public class CouponController {
} else { } else {
coupon.setStatus("可用"); coupon.setStatus("可用");
} }
// 校验 // 校验
couponService.validCoupon(coupon, true); couponService.validCoupon(coupon, true);
boolean result = couponService.saveOrUpdate(coupon); couponService.saveOrUpdate(coupon);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "优惠券更新失败");
// 向消息队列中发送优惠券创建的消息 // 向消息队列中发送优惠券创建的消息
couponService.sendCouponCreateMessage(coupon); couponService.sendCouponCreateMessage(coupon);
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -158,8 +152,7 @@ public class CouponController {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
Long id = couponDeleteRequest.getId(); Long id = couponDeleteRequest.getId();
boolean result = couponService.removeById(id); couponService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "优惠券删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -178,8 +171,7 @@ public class CouponController {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "参数为null或数组为空"); throw new BusinessException(ErrorCode.PARAMS_ERROR, "参数为null或数组为空");
} }
List<Long> idList = commonBatchRequest.getIdList(); List<Long> idList = commonBatchRequest.getIdList();
boolean result = couponService.removeBatchByIds(idList); couponService.removeBatchByIds(idList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "优惠券批量删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -208,15 +200,14 @@ public class CouponController {
/** /**
* 小程序端用户积分兑换优惠券 * 小程序端用户积分兑换优惠券
* @param commonRequest 兑换记录添加请求体 * @param commonRequest 兑换记录添加请求体
* @return * @return
*/ */
@PostMapping("/exchange") @PostMapping("/exchange")
@Operation(summary = "小程序端用户积分兑换优惠券", description = "参数兑换记录添加请求体权限所有人方法名pointsExchangeCoupon")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Operation(summary = "小程序端用户积分兑换优惠券", description = "参数兑换记录添加请求体权限所有人方法名pointsExchangeCoupon")
public BaseResponse<Boolean> pointsExchangeCoupon(@RequestBody CommonRequest commonRequest, HttpServletRequest request) { public BaseResponse<Boolean> pointsExchangeCoupon(@RequestBody CommonRequest commonRequest, HttpServletRequest request) {
// 获取当前用户信息 // 获取当前用户信息
User loginUser = userService.getLoginUser(request); User loginUser = userService.getLoginUser(request);
@ -238,17 +229,12 @@ public class CouponController {
UserCoupon userCoupon = new UserCoupon(); UserCoupon userCoupon = new UserCoupon();
userCoupon.setUserId(userId); userCoupon.setUserId(userId);
userCoupon.setCouponVO(couponVO); userCoupon.setCouponVO(couponVO);
boolean save = userCouponService.save(userCoupon); userCouponService.save(userCoupon);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "兑换记录插入失败");
// 向消息队列中发送用户优惠券创建的消息 // 向消息队列中发送用户优惠券创建的消息
couponService.sendUserCouponCreateMessage(userCoupon, coupon); couponService.sendUserCouponCreateMessage(userCoupon, coupon);
// 更新用户积分 // 更新用户积分
loginUser.setPoints(loginUser.getPoints() - requirePoints); loginUser.setPoints(loginUser.getPoints() - requirePoints);
boolean isSuccess = userService.updateById(loginUser); userService.updateById(loginUser);
ThrowUtils.throwIf(!isSuccess, ErrorCode.OPERATION_ERROR, "更新用户积分信息失败");
return ResultUtils.success(true, "兑换成功"); return ResultUtils.success(true, "兑换成功");
} }
@ -256,6 +242,7 @@ public class CouponController {
/** /**
* 小程序端用户根据状态查看优惠券 * 小程序端用户根据状态查看优惠券
* @param commonStringRequest 优惠券状态 * @param commonStringRequest 优惠券状态
@ -340,8 +327,7 @@ public class CouponController {
UpdateWrapper<Coupon> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<Coupon> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id); updateWrapper.eq("id", id);
updateWrapper.set("isShelves", status); updateWrapper.set("isShelves", status);
boolean update = couponService.update(updateWrapper); couponService.update(updateWrapper);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "上架状态更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }

View File

@ -175,8 +175,7 @@ public class GoodController {
good.setFestivalName(good.getFestivalName() + ";" + url); good.setFestivalName(good.getFestivalName() + ";" + url);
// 校验 // 校验
goodService.validGood(good, false); goodService.validGood(good, false);
boolean save = goodService.save(good); goodService.save(good);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true, "商品插入成功"); return ResultUtils.success(true, "商品插入成功");
} }
@ -189,8 +188,8 @@ public class GoodController {
* @return 是否添加成功 * @return 是否添加成功
*/ */
@PostMapping("/add/service") @PostMapping("/add/service")
@Transactional(rollbackFor = Exception.class)
@Operation(summary = "Web端管理员添加服务类商品", description = "参数:服务类商品添加请求体,权限:管理员(admin, boss)方法名addServiceGood") @Operation(summary = "Web端管理员添加服务类商品", description = "参数:服务类商品添加请求体,权限:管理员(admin, boss)方法名addServiceGood")
@Transactional(rollbackFor = Exception.class)
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> addServiceGood(@RequestBody ServiceGoodAddRequest serviceGoodAddRequest) { public BaseResponse<Boolean> addServiceGood(@RequestBody ServiceGoodAddRequest serviceGoodAddRequest) {
if (serviceGoodAddRequest == null) { if (serviceGoodAddRequest == null) {
@ -205,8 +204,7 @@ public class GoodController {
good.setFestivalName(""); good.setFestivalName("");
// 校验 // 校验
goodService.validGood(good, false); goodService.validGood(good, false);
boolean save = goodService.save(good); goodService.save(good);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR);
// 添加当前商品的预约日期 // 添加当前商品的预约日期
List<AppointmentDateAddRequest> appointmentDateAddRequestList = serviceGoodAddRequest.getAppointmentDateAddRequestList(); List<AppointmentDateAddRequest> appointmentDateAddRequestList = serviceGoodAddRequest.getAppointmentDateAddRequestList();
@ -218,8 +216,7 @@ public class GoodController {
appointmentDateService.validAppointmentDate(appointmentDate, false); appointmentDateService.validAppointmentDate(appointmentDate, false);
return appointmentDate; return appointmentDate;
}).toList(); }).toList();
boolean isSaveBatch = appointmentDateService.saveBatch(appointmentDateList); appointmentDateService.saveBatch(appointmentDateList);
ThrowUtils.throwIf(!isSaveBatch, ErrorCode.OPERATION_ERROR);
// 添加当前商品的预约时间段 // 添加当前商品的预约时间段
List<TimePeriod> timePeriods = new ArrayList<>(); List<TimePeriod> timePeriods = new ArrayList<>();
@ -238,8 +235,7 @@ public class GoodController {
}).toList(); }).toList();
timePeriods.addAll(timePeriodList); timePeriods.addAll(timePeriodList);
} }
boolean result = timePeriodService.saveBatch(timePeriods); timePeriodService.saveBatch(timePeriods);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
// 批量插入服务类商品待处理记录 // 批量插入服务类商品待处理记录
List<AppointmentDateTimePeriodVO> appointmentDateTimePeriodVOList = appointmentDateService.queryAppointmentDateDetailById(good.getId()); List<AppointmentDateTimePeriodVO> appointmentDateTimePeriodVOList = appointmentDateService.queryAppointmentDateDetailById(good.getId());
@ -254,9 +250,7 @@ public class GoodController {
pendingServiceGood.setAppointmentDateId(appointmentDateTimePeriodVO.getId()); pendingServiceGood.setAppointmentDateId(appointmentDateTimePeriodVO.getId());
pendingServiceGoodList.add(pendingServiceGood); pendingServiceGoodList.add(pendingServiceGood);
} }
boolean batch = pendingServiceGoodService.saveBatch(pendingServiceGoodList); pendingServiceGoodService.saveBatch(pendingServiceGoodList);
ThrowUtils.throwIf(!batch, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录批量插入失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -275,8 +269,7 @@ public class GoodController {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
Long id = deleteRequest.getId(); Long id = deleteRequest.getId();
boolean result = goodService.removeById(id); goodService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -289,8 +282,8 @@ public class GoodController {
*/ */
@PostMapping("/delete/service") @PostMapping("/delete/service")
@Operation(summary = "Web端管理员删除服务类商品", description = "参数: 商品删除请求体,权限:管理员(admin, boss)方法名deleteServiceGood") @Operation(summary = "Web端管理员删除服务类商品", description = "参数: 商品删除请求体,权限:管理员(admin, boss)方法名deleteServiceGood")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> deleteServiceGood(@RequestBody CommonRequest deleteRequest) { public BaseResponse<Boolean> deleteServiceGood(@RequestBody CommonRequest deleteRequest) {
if (deleteRequest == null || deleteRequest.getId() <= 0) { if (deleteRequest == null || deleteRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
@ -298,17 +291,14 @@ public class GoodController {
Long id = deleteRequest.getId(); Long id = deleteRequest.getId();
// 获取预约日期列表 // 获取预约日期列表
List<AppointmentDate> appointmentDateList = commonService.findByFieldEqTargetField("goodId", id, appointmentDateService); List<AppointmentDate> appointmentDateList = commonService.findByFieldEqTargetField("goodId", id, appointmentDateService);
// 获取预约时间段列表 // 获取预约时间段列表
List<TimePeriod> timePeriodList = commonService.findByFieldInTargetField(appointmentDateList, timePeriodService, AppointmentDate::getId, "appointmentDateId"); List<TimePeriod> timePeriodList = commonService.findByFieldInTargetField(appointmentDateList, timePeriodService, AppointmentDate::getId, "appointmentDateId");
// 删除预约时间段表中与该商品关联的记录 // 删除预约时间段表中与该商品关联的记录
timePeriodService.removeBatchByIds(timePeriodList); timePeriodService.removeBatchByIds(timePeriodList);
// 删除预约日期表中与该商品关联的记录 // 删除预约日期表中与该商品关联的记录
appointmentDateService.removeBatchByIds(appointmentDateList); appointmentDateService.removeBatchByIds(appointmentDateList);
// 删除商品表中的服务类商品 // 删除商品表中的服务类商品
boolean result = goodService.removeById(id); goodService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品删除失败");
// 删除服务类商品待处理记录 // 删除服务类商品待处理记录
QueryWrapper<PendingServiceGood> queryWrapper = new QueryWrapper<>(); QueryWrapper<PendingServiceGood> queryWrapper = new QueryWrapper<>();
@ -321,8 +311,7 @@ public class GoodController {
map.put(pendingServiceOrder.getPendingId(), 1); map.put(pendingServiceOrder.getPendingId(), 1);
} }
pendingServiceGoodList = pendingServiceGoodList.stream().filter(pendingServiceGood -> map.get(pendingServiceGood.getId()) == null).toList(); pendingServiceGoodList = pendingServiceGoodList.stream().filter(pendingServiceGood -> map.get(pendingServiceGood.getId()) == null).toList();
boolean removeBatch = pendingServiceGoodService.removeBatchByIds(pendingServiceGoodList); pendingServiceGoodService.removeBatchByIds(pendingServiceGoodList);
ThrowUtils.throwIf(!removeBatch, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
@ -337,8 +326,8 @@ public class GoodController {
*/ */
@PostMapping("/delBatch/service") @PostMapping("/delBatch/service")
@Operation(summary = "Web端用户批量删除服务类商品", description = "服务类商品id列表权限管理员(admin, boss)方法名delBatchServiceGoods") @Operation(summary = "Web端用户批量删除服务类商品", description = "服务类商品id列表权限管理员(admin, boss)方法名delBatchServiceGoods")
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> delBatchServiceGoods(@RequestBody CommonBatchRequest commonBatchRequest) { public BaseResponse<Boolean> delBatchServiceGoods(@RequestBody CommonBatchRequest commonBatchRequest) {
if (commonBatchRequest == null || CollectionUtils.isEmpty(commonBatchRequest.getIdList())) { if (commonBatchRequest == null || CollectionUtils.isEmpty(commonBatchRequest.getIdList())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
@ -353,8 +342,7 @@ public class GoodController {
// 删除预约日期表中与该商品关联的记录 // 删除预约日期表中与该商品关联的记录
appointmentDateService.removeBatchByIds(appointmentDateList); appointmentDateService.removeBatchByIds(appointmentDateList);
// 删除商品表中的服务类商品 // 删除商品表中的服务类商品
boolean result = goodService.removeBatchByIds(ids); goodService.removeBatchByIds(ids);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品删除失败");
// 批量删除服务类商品待处理记录 // 批量删除服务类商品待处理记录
QueryWrapper<PendingServiceGood> goodQueryWrapper = new QueryWrapper<>(); QueryWrapper<PendingServiceGood> goodQueryWrapper = new QueryWrapper<>();
@ -366,9 +354,7 @@ public class GoodController {
map.put(pendingServiceOrder.getPendingId(), 1); map.put(pendingServiceOrder.getPendingId(), 1);
} }
pendingServiceGoodList = pendingServiceGoodList.stream().filter(pendingServiceGood -> map.get(pendingServiceGood.getId()) == null).toList(); pendingServiceGoodList = pendingServiceGoodList.stream().filter(pendingServiceGood -> map.get(pendingServiceGood.getId()) == null).toList();
boolean removeBatch = pendingServiceGoodService.removeBatchByIds(pendingServiceGoodList); pendingServiceGoodService.removeBatchByIds(pendingServiceGoodList);
ThrowUtils.throwIf(!removeBatch, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -382,6 +368,7 @@ public class GoodController {
*/ */
@PostMapping("/update") @PostMapping("/update")
@Operation(summary = "Web端管理员更新常规类商品", description = "参数:商品更新请求体,权限:管理员(admin, boss)方法名updateGoods") @Operation(summary = "Web端管理员更新常规类商品", description = "参数:商品更新请求体,权限:管理员(admin, boss)方法名updateGoods")
@Transactional(rollbackFor = Exception.class)
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE) @AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<Boolean> updateGoods(@RequestBody GoodUpdateRequest goodUpdateRequest) { public BaseResponse<Boolean> updateGoods(@RequestBody GoodUpdateRequest goodUpdateRequest) {
if (goodUpdateRequest == null || goodUpdateRequest.getId() <= 0) { if (goodUpdateRequest == null || goodUpdateRequest.getId() <= 0) {
@ -400,8 +387,7 @@ public class GoodController {
} }
// 校验 // 校验
goodService.validGood(good, true); goodService.validGood(good, true);
boolean result = goodService.updateById(good); goodService.updateById(good);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "实体类商品更新失败");
// 如果更新了商品的价格就需要更新购物车中的小计 // 如果更新了商品的价格就需要更新购物车中的小计
Long id = good.getId(); Long id = good.getId();
BigDecimal targetPrice = good.getPrice(); BigDecimal targetPrice = good.getPrice();
@ -411,8 +397,7 @@ public class GoodController {
List<CartRecord> cartRecords = commonService.findByFieldEqTargetField("goodId", id, cartRecordService); List<CartRecord> cartRecords = commonService.findByFieldEqTargetField("goodId", id, cartRecordService);
if (!cartRecords.isEmpty()) { if (!cartRecords.isEmpty()) {
List<CartRecord> cartRecordList = goodService.updateCartGoodPrice(id, targetPrice); List<CartRecord> cartRecordList = goodService.updateCartGoodPrice(id, targetPrice);
boolean update = cartRecordService.updateBatchById(cartRecordList); cartRecordService.updateBatchById(cartRecordList);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "购物车商品价格更新失败");
} }
} }
return ResultUtils.success(true); return ResultUtils.success(true);
@ -462,8 +447,7 @@ public class GoodController {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
List<Long> idList = commonDelBatchRequest.getIdList(); List<Long> idList = commonDelBatchRequest.getIdList();
boolean result = goodService.removeBatchByIds(idList); goodService.removeBatchByIds(idList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -810,9 +794,7 @@ public class GoodController {
good.setFestivalName(""); good.setFestivalName("");
// 校验 // 校验
goodService.validGood(good, true); goodService.validGood(good, true);
boolean result = goodService.updateById(good); goodService.updateById(good);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品信息更新失败");
// 删除当前商品关联的所有日期和时间段 // 删除当前商品关联的所有日期和时间段
CommonRequest commonRequest = new CommonRequest(); CommonRequest commonRequest = new CommonRequest();
commonRequest.setId(good.getId()); commonRequest.setId(good.getId());
@ -836,16 +818,13 @@ public class GoodController {
// 获取预约时间段列表 // 获取预约时间段列表
List<TimePeriod> timePeriodList = commonService.findByFieldInTargetField(appointmentDateList, timePeriodService, AppointmentDate::getId, "appointmentDateId"); List<TimePeriod> timePeriodList = commonService.findByFieldInTargetField(appointmentDateList, timePeriodService, AppointmentDate::getId, "appointmentDateId");
// 删除预约时间段表中与该商品关联的记录 // 删除预约时间段表中与该商品关联的记录
boolean remove = timePeriodService.removeBatchByIds(timePeriodList); timePeriodService.removeBatchByIds(timePeriodList);
// ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "服务类商品预约时间段删除失败");
// 删除预约日期表中与该商品关联的记录 // 删除预约日期表中与该商品关联的记录
boolean isSuccess = appointmentDateService.removeBatchByIds(appointmentDateList); appointmentDateService.removeBatchByIds(appointmentDateList);
// ThrowUtils.throwIf(!isSuccess, ErrorCode.OPERATION_ERROR, "服务类商品预约日期删除失败");
// 删除服务类商品待处理记录 // 删除服务类商品待处理记录
QueryWrapper<PendingServiceGood> queryWrapper = new QueryWrapper<>(); QueryWrapper<PendingServiceGood> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("goodId", id); queryWrapper.eq("goodId", id);
boolean removeBatch = pendingServiceGoodService.remove(queryWrapper); pendingServiceGoodService.remove(queryWrapper);
ThrowUtils.throwIf(!removeBatch, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录删除失败");
} }
@ -861,8 +840,7 @@ public class GoodController {
appointmentDateService.validAppointmentDate(appointmentDate, false); appointmentDateService.validAppointmentDate(appointmentDate, false);
return appointmentDate; return appointmentDate;
}).toList(); }).toList();
boolean isSaveBatch = appointmentDateService.saveBatch(appointmentDateList); appointmentDateService.saveBatch(appointmentDateList);
ThrowUtils.throwIf(!isSaveBatch, ErrorCode.OPERATION_ERROR);
// 添加当前商品的预约时间段 // 添加当前商品的预约时间段
List<TimePeriod> timePeriods = new ArrayList<>(); List<TimePeriod> timePeriods = new ArrayList<>();
@ -881,8 +859,7 @@ public class GoodController {
}).toList(); }).toList();
timePeriods.addAll(timePeriodList); timePeriods.addAll(timePeriodList);
} }
boolean result = timePeriodService.saveBatch(timePeriods); timePeriodService.saveBatch(timePeriods);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
// 批量插入服务类商品待处理记录 // 批量插入服务类商品待处理记录
List<AppointmentDateTimePeriodVO> appointmentDateTimePeriodVOList = appointmentDateService.queryAppointmentDateDetailById(good.getId()); List<AppointmentDateTimePeriodVO> appointmentDateTimePeriodVOList = appointmentDateService.queryAppointmentDateDetailById(good.getId());
@ -897,8 +874,7 @@ public class GoodController {
pendingServiceGood.setAppointmentDateId(appointmentDateTimePeriodVO.getId()); pendingServiceGood.setAppointmentDateId(appointmentDateTimePeriodVO.getId());
pendingServiceGoodList.add(pendingServiceGood); pendingServiceGoodList.add(pendingServiceGood);
} }
boolean batch = pendingServiceGoodService.saveBatch(pendingServiceGoodList); pendingServiceGoodService.saveBatch(pendingServiceGoodList);
ThrowUtils.throwIf(!batch, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录批量插入失败");
} }
@ -923,8 +899,7 @@ public class GoodController {
UpdateWrapper<Good> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<Good> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id); updateWrapper.eq("id", id);
updateWrapper.set("isShelves", status); updateWrapper.set("isShelves", status);
boolean update = goodService.update(updateWrapper); goodService.update(updateWrapper);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "上架状态更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -957,8 +932,7 @@ public class GoodController {
good.setFestivalName(""); good.setFestivalName("");
// 校验 // 校验
goodService.validGood(good, true); goodService.validGood(good, true);
boolean result = goodService.updateById(good); goodService.updateById(good);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品信息更新失败");
// 如果更新了商品的价格就需要更新购物车中的小计 // 如果更新了商品的价格就需要更新购物车中的小计
Long id = good.getId(); Long id = good.getId();
@ -969,8 +943,7 @@ public class GoodController {
if (!cartExperiences.isEmpty()) { if (!cartExperiences.isEmpty()) {
// 更新购物车中的小计 // 更新购物车中的小计
List<CartExperience> cartExperienceList = goodService.updateCartExperienceGoodPrice(id, targetPrice); List<CartExperience> cartExperienceList = goodService.updateCartExperienceGoodPrice(id, targetPrice);
boolean update = cartExperienceService.updateBatchById(cartExperienceList); cartExperienceService.updateBatchById(cartExperienceList);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "购物车商品价格更新失败");
} }
} }
return ResultUtils.success(true); return ResultUtils.success(true);
@ -995,7 +968,6 @@ public class GoodController {
ThrowUtils.throwIf(good == null, ErrorCode.NOT_FOUND_ERROR, "商品不存在"); ThrowUtils.throwIf(good == null, ErrorCode.NOT_FOUND_ERROR, "商品不存在");
ServiceGoodCardVO serviceGoodVO = new ServiceGoodCardVO(); ServiceGoodCardVO serviceGoodVO = new ServiceGoodCardVO();
BeanUtils.copyProperties(good, serviceGoodVO); BeanUtils.copyProperties(good, serviceGoodVO);
return ResultUtils.success(serviceGoodVO); return ResultUtils.success(serviceGoodVO);
} }

View File

@ -147,8 +147,7 @@ public class AdvanceOrderController {
advanceOrder.setOrderStatus(OrderStatusConstant.PENDING_PAYMENT); advanceOrder.setOrderStatus(OrderStatusConstant.PENDING_PAYMENT);
// 校验 // 校验
advanceOrderService.validAdvanceOrder(advanceOrder); advanceOrderService.validAdvanceOrder(advanceOrder);
boolean result = advanceOrderService.save(advanceOrder); advanceOrderService.save(advanceOrder);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "订单创建失败");
// 向消息队列中发送订单创建的消息 // 向消息队列中发送订单创建的消息
advanceOrderService.sendAdvanceOrderMessage(advanceOrder.getId()); advanceOrderService.sendAdvanceOrderMessage(advanceOrder.getId());
return ResultUtils.success(advanceOrder.getId()); return ResultUtils.success(advanceOrder.getId());
@ -175,9 +174,7 @@ public class AdvanceOrderController {
ThrowUtils.throwIf(advanceOrder == null, ErrorCode.OPERATION_ERROR, "订单不存在"); ThrowUtils.throwIf(advanceOrder == null, ErrorCode.OPERATION_ERROR, "订单不存在");
ThrowUtils.throwIf(!advanceOrder.getOrderStatus().equals(OrderStatusConstant.PENDING_PAYMENT), ErrorCode.SYSTEM_ERROR, "订单状态错误"); ThrowUtils.throwIf(!advanceOrder.getOrderStatus().equals(OrderStatusConstant.PENDING_PAYMENT), ErrorCode.SYSTEM_ERROR, "订单状态错误");
advanceOrder.setOrderStatus(OrderStatusConstant.TRANSACTION_CLOSED); advanceOrder.setOrderStatus(OrderStatusConstant.TRANSACTION_CLOSED);
boolean update = advanceOrderService.updateById(advanceOrder); advanceOrderService.updateById(advanceOrder);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "订单状态更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -201,7 +198,6 @@ public class AdvanceOrderController {
AdvanceOrder advanceOrder = advanceOrderService.getById(id); AdvanceOrder advanceOrder = advanceOrderService.getById(id);
ThrowUtils.throwIf(advanceOrder == null, ErrorCode.OPERATION_ERROR, "订单不存在"); ThrowUtils.throwIf(advanceOrder == null, ErrorCode.OPERATION_ERROR, "订单不存在");
AdvanceOrderVO advanceOrderVO = commonService.copyProperties(advanceOrder, AdvanceOrderVO.class); AdvanceOrderVO advanceOrderVO = commonService.copyProperties(advanceOrder, AdvanceOrderVO.class);
return ResultUtils.success(advanceOrderVO); return ResultUtils.success(advanceOrderVO);
} }
@ -276,8 +272,7 @@ public class AdvanceOrderController {
Long id = commonRequest.getId(); Long id = commonRequest.getId();
AdvanceOrder advanceOrder = advanceOrderService.getById(id); AdvanceOrder advanceOrder = advanceOrderService.getById(id);
ThrowUtils.throwIf(advanceOrder == null || !advanceOrder.getOrderStatus().equals(OrderStatusConstant.TRANSACTION_CLOSED), ErrorCode.OPERATION_ERROR, "订单不存在或状态错误"); ThrowUtils.throwIf(advanceOrder == null || !advanceOrder.getOrderStatus().equals(OrderStatusConstant.TRANSACTION_CLOSED), ErrorCode.OPERATION_ERROR, "订单不存在或状态错误");
boolean result = advanceOrderService.removeById(id); advanceOrderService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "订单删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -372,8 +367,7 @@ public class AdvanceOrderController {
UpdateWrapper<AdvanceOrder> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<AdvanceOrder> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id); updateWrapper.eq("id", id);
updateWrapper.set("orderStatus", orderStatus); updateWrapper.set("orderStatus", orderStatus);
boolean result = advanceOrderService.update(updateWrapper); advanceOrderService.update(updateWrapper);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "订单状态不存在或订单状态更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }

View File

@ -90,6 +90,8 @@ public class ClothesRentOrderController {
clothesRentOrderService.validClothesRentOrder(clothesRentOrderAddRequest); clothesRentOrderService.validClothesRentOrder(clothesRentOrderAddRequest);
// 获取服装信息 // 获取服装信息
Long clothesId = clothesRentOrderAddRequest.getClothesId(); Long clothesId = clothesRentOrderAddRequest.getClothesId();
// 校验当前服装是否已被租赁
clothesRentOrderService.validIsBeenRented(clothesId);
Clothes clothes = clothesService.getById(clothesId); Clothes clothes = clothesService.getById(clothesId);
ThrowUtils.throwIf(clothes == null || clothes.getIsShelves() == 0, ErrorCode.OPERATION_ERROR, "服装已被下架或者不存在"); ThrowUtils.throwIf(clothes == null || clothes.getIsShelves() == 0, ErrorCode.OPERATION_ERROR, "服装已被下架或者不存在");
ClothesSnapshot clothesSnapshot = commonService.copyProperties(clothes, ClothesSnapshot.class); ClothesSnapshot clothesSnapshot = commonService.copyProperties(clothes, ClothesSnapshot.class);
@ -116,8 +118,7 @@ public class ClothesRentOrderController {
clothesRentOrder.setRentDays(rentDays); clothesRentOrder.setRentDays(rentDays);
clothesRentOrder.setTotalAmount(totalAmount); clothesRentOrder.setTotalAmount(totalAmount);
boolean save = clothesRentOrderService.save(clothesRentOrder); clothesRentOrderService.save(clothesRentOrder);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "订单创建失败");
clothesRentOrderService.sendClothesRentOrderMessage(clothesRentOrder.getId()); clothesRentOrderService.sendClothesRentOrderMessage(clothesRentOrder.getId());
return ResultUtils.success(clothesRentOrder.getId()); return ResultUtils.success(clothesRentOrder.getId());
@ -146,8 +147,7 @@ public class ClothesRentOrderController {
ThrowUtils.throwIf(!clothesRentOrder.getOrderStatus().equals(OrderStatusConstant.PENDING_PAYMENT), ErrorCode.SYSTEM_ERROR, "订单状态错误"); ThrowUtils.throwIf(!clothesRentOrder.getOrderStatus().equals(OrderStatusConstant.PENDING_PAYMENT), ErrorCode.SYSTEM_ERROR, "订单状态错误");
UpdateWrapper<ClothesRentOrder> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<ClothesRentOrder> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id).set("orderStatus", OrderStatusConstant.TRANSACTION_CLOSED); updateWrapper.eq("id", id).set("orderStatus", OrderStatusConstant.TRANSACTION_CLOSED);
boolean update = clothesRentOrderService.update(updateWrapper); clothesRentOrderService.update(updateWrapper);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "订单状态更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -238,8 +238,7 @@ public class ClothesRentOrderController {
Long id = commonRequest.getId(); Long id = commonRequest.getId();
ClothesRentOrder clothesRentOrder = clothesRentOrderService.getById(id); ClothesRentOrder clothesRentOrder = clothesRentOrderService.getById(id);
ThrowUtils.throwIf(clothesRentOrder == null || !clothesRentOrder.getOrderStatus().equals(OrderStatusConstant.TRANSACTION_CLOSED), ErrorCode.OPERATION_ERROR, "订单不存在或状态错误"); ThrowUtils.throwIf(clothesRentOrder == null || !clothesRentOrder.getOrderStatus().equals(OrderStatusConstant.TRANSACTION_CLOSED), ErrorCode.OPERATION_ERROR, "订单不存在或状态错误");
boolean result = clothesRentOrderService.removeById(id); clothesRentOrderService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "订单删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }

View File

@ -57,7 +57,6 @@ import java.util.Map;
@RequestMapping("/order") @RequestMapping("/order")
@Slf4j @Slf4j
@Tag(name = "订单管理模块") @Tag(name = "订单管理模块")
@Transactional(rollbackFor = Exception.class)
public class OrderController { public class OrderController {
@Resource @Resource
@ -332,8 +331,7 @@ public class OrderController {
updateWrapper.eq("id", id); updateWrapper.eq("id", id);
updateWrapper.set("trackingNumber", trackingNumber); updateWrapper.set("trackingNumber", trackingNumber);
updateWrapper.set("orderStatus", OrderStatusConstant.PENDING_DELIVERY); updateWrapper.set("orderStatus", OrderStatusConstant.PENDING_DELIVERY);
boolean result = orderService.update(updateWrapper); orderService.update(updateWrapper);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "订单状态不存在或订单状态更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -370,6 +368,7 @@ public class OrderController {
*/ */
@PostMapping ("/cancel/id") @PostMapping ("/cancel/id")
@Operation(summary = "小程序端用户取消服务类商品订单", description = "参数订单id权限所有人方法名cancelOrderById") @Operation(summary = "小程序端用户取消服务类商品订单", description = "参数订单id权限所有人方法名cancelOrderById")
@Transactional(rollbackFor = Exception.class)
public BaseResponse<Boolean> cancelOrderById(@RequestBody CommonRequest commonRequest, HttpServletRequest request) { public BaseResponse<Boolean> cancelOrderById(@RequestBody CommonRequest commonRequest, HttpServletRequest request) {
if (commonRequest == null || commonRequest.getId() <= 0) { if (commonRequest == null || commonRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
@ -380,8 +379,7 @@ public class OrderController {
ThrowUtils.throwIf(order == null, ErrorCode.OPERATION_ERROR, "订单不存在"); ThrowUtils.throwIf(order == null, ErrorCode.OPERATION_ERROR, "订单不存在");
ThrowUtils.throwIf(!order.getOrderStatus().equals(OrderStatusConstant.PENDING_PAYMENT), ErrorCode.SYSTEM_ERROR, "订单状态错误"); ThrowUtils.throwIf(!order.getOrderStatus().equals(OrderStatusConstant.PENDING_PAYMENT), ErrorCode.SYSTEM_ERROR, "订单状态错误");
order.setOrderStatus(OrderStatusConstant.TRANSACTION_CLOSED); order.setOrderStatus(OrderStatusConstant.TRANSACTION_CLOSED);
boolean update = orderService.updateById(order); orderService.updateById(order);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "订单状态更新失败");
// 恢复商品库存 // 恢复商品库存
List<OrderItems> orderItemsList = commonService.findByFieldEqTargetField("orderId", id, orderItemService); List<OrderItems> orderItemsList = commonService.findByFieldEqTargetField("orderId", id, orderItemService);
@ -410,9 +408,7 @@ public class OrderController {
Integer inventory = good.getInventory(); Integer inventory = good.getInventory();
good.setInventory(quantity + inventory); good.setInventory(quantity + inventory);
} }
boolean updateBatch = goodService.updateBatchById(goodList); goodService.updateBatchById(goodList);
ThrowUtils.throwIf(!updateBatch, ErrorCode.SYSTEM_ERROR, "商品库存恢复失败");
// 如果使用了优惠券则退还优惠券 // 如果使用了优惠券则退还优惠券
CouponSnapshot couponSnapshot = order.getCouponSnapshot(); CouponSnapshot couponSnapshot = order.getCouponSnapshot();
if (couponSnapshot != null) { if (couponSnapshot != null) {
@ -421,8 +417,7 @@ public class OrderController {
ThrowUtils.throwIf(userCoupon == null, ErrorCode.OPERATION_ERROR, "优惠券不存在"); ThrowUtils.throwIf(userCoupon == null, ErrorCode.OPERATION_ERROR, "优惠券不存在");
// 更新优惠券状态 // 更新优惠券状态
userCoupon.setIsUsed(0); userCoupon.setIsUsed(0);
boolean result = userCouponService.updateById(userCoupon); userCouponService.updateById(userCoupon);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "优惠券状态更新失败");
} }
return ResultUtils.success(true); return ResultUtils.success(true);
@ -448,8 +443,7 @@ public class OrderController {
ThrowUtils.throwIf(order == null, ErrorCode.OPERATION_ERROR, "订单不存在"); ThrowUtils.throwIf(order == null, ErrorCode.OPERATION_ERROR, "订单不存在");
ThrowUtils.throwIf(!order.getOrderStatus().equals(OrderStatusConstant.TRANSACTION_CLOSED), ErrorCode.SYSTEM_ERROR, "订单状态错误"); ThrowUtils.throwIf(!order.getOrderStatus().equals(OrderStatusConstant.TRANSACTION_CLOSED), ErrorCode.SYSTEM_ERROR, "订单状态错误");
boolean remove = orderService.removeById(id); orderService.removeById(id);
ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "订单删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -464,6 +458,7 @@ public class OrderController {
*/ */
@PostMapping ("/cancel/service/id") @PostMapping ("/cancel/service/id")
@Operation(summary = "小程序端用户取消服务类商品订单", description = "参数订单id权限所有人方法名cancelOrderById") @Operation(summary = "小程序端用户取消服务类商品订单", description = "参数订单id权限所有人方法名cancelOrderById")
@Transactional(rollbackFor = Exception.class)
public BaseResponse<Boolean> cancelServiceOrderById(@RequestBody CommonRequest commonRequest, HttpServletRequest request) { public BaseResponse<Boolean> cancelServiceOrderById(@RequestBody CommonRequest commonRequest, HttpServletRequest request) {
if (commonRequest == null || commonRequest.getId() <= 0) { if (commonRequest == null || commonRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
@ -474,17 +469,14 @@ public class OrderController {
ThrowUtils.throwIf(order == null, ErrorCode.OPERATION_ERROR, "订单不存在"); ThrowUtils.throwIf(order == null, ErrorCode.OPERATION_ERROR, "订单不存在");
ThrowUtils.throwIf(!order.getOrderStatus().equals(OrderStatusConstant.PENDING_PAYMENT), ErrorCode.SYSTEM_ERROR, "订单状态错误"); ThrowUtils.throwIf(!order.getOrderStatus().equals(OrderStatusConstant.PENDING_PAYMENT), ErrorCode.SYSTEM_ERROR, "订单状态错误");
order.setOrderStatus(OrderStatusConstant.TRANSACTION_CLOSED); order.setOrderStatus(OrderStatusConstant.TRANSACTION_CLOSED);
boolean update = orderService.updateById(order); orderService.updateById(order);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "订单状态更新失败");
// 更新服务类商品待处理订单记录 // 更新服务类商品待处理订单记录
List<PendingServiceOrder> pendingServiceOrderList = commonService.findByFieldEqTargetField("orderNumber", order.getOrderNumber(), pendingServiceOrderService); List<PendingServiceOrder> pendingServiceOrderList = commonService.findByFieldEqTargetField("orderNumber", order.getOrderNumber(), pendingServiceOrderService);
for (PendingServiceOrder pendingServiceOrder : pendingServiceOrderList) { for (PendingServiceOrder pendingServiceOrder : pendingServiceOrderList) {
pendingServiceOrder.setOrderItemStatus(order.getOrderStatus()); pendingServiceOrder.setOrderItemStatus(order.getOrderStatus());
} }
boolean updateResult = pendingServiceOrderService.updateBatchById(pendingServiceOrderList); pendingServiceOrderService.updateBatchById(pendingServiceOrderList);
ThrowUtils.throwIf(!updateResult, ErrorCode.OPERATION_ERROR, "服务类商品待处理订单记录更新失败");
// 如果使用了优惠券则退还优惠券 // 如果使用了优惠券则退还优惠券
CouponSnapshot couponSnapshot = order.getCouponSnapshot(); CouponSnapshot couponSnapshot = order.getCouponSnapshot();
@ -494,8 +486,7 @@ public class OrderController {
ThrowUtils.throwIf(userCoupon == null, ErrorCode.OPERATION_ERROR, "优惠券不存在"); ThrowUtils.throwIf(userCoupon == null, ErrorCode.OPERATION_ERROR, "优惠券不存在");
// 更新优惠券状态 // 更新优惠券状态
userCoupon.setIsUsed(0); userCoupon.setIsUsed(0);
boolean result = userCouponService.updateById(userCoupon); userCouponService.updateById(userCoupon);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "优惠券状态更新失败");
} }
return ResultUtils.success(true); return ResultUtils.success(true);
@ -522,8 +513,7 @@ public class OrderController {
UpdateWrapper<Order> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<Order> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id); updateWrapper.eq("id", id);
updateWrapper.set("orderStatus", orderStatus); updateWrapper.set("orderStatus", orderStatus);
boolean result = orderService.update(updateWrapper); orderService.update(updateWrapper);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "订单状态不存在或订单状态更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }

View File

@ -28,7 +28,6 @@ import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -44,7 +43,6 @@ import java.util.stream.Collectors;
@RequestMapping("/pending") @RequestMapping("/pending")
@Slf4j @Slf4j
@Tag(name = "待处理商品管理模块") @Tag(name = "待处理商品管理模块")
@Transactional(rollbackFor = Exception.class)
public class PendingServiceGoodController { public class PendingServiceGoodController {

View File

@ -16,7 +16,6 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -26,7 +25,6 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/refund") @RequestMapping("/refund")
@Slf4j @Slf4j
@Tag(name = "退款管理模块") @Tag(name = "退款管理模块")
@Transactional(rollbackFor = Exception.class)
public class RefundRecordController { public class RefundRecordController {

View File

@ -9,7 +9,6 @@ import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.common.ResultUtils; import com.cultural.heritage.common.ResultUtils;
import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.constant.UserConstant;
import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonRequest; import com.cultural.heritage.model.dto.CommonRequest;
import com.cultural.heritage.model.dto.CommonStringRequest; import com.cultural.heritage.model.dto.CommonStringRequest;
import com.cultural.heritage.model.dto.banner.BannerAddRequest; import com.cultural.heritage.model.dto.banner.BannerAddRequest;
@ -62,8 +61,7 @@ public class BannerController {
Banner banner = new Banner(); Banner banner = new Banner();
BeanUtils.copyProperties(bannerAddRequest, banner); BeanUtils.copyProperties(bannerAddRequest, banner);
bannerService.validBanner(banner, false); bannerService.validBanner(banner, false);
boolean result = bannerService.save(banner); bannerService.save(banner);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "轮播图添加失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -82,8 +80,7 @@ public class BannerController {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
Long id = commonRequest.getId(); Long id = commonRequest.getId();
boolean result = bannerService.removeById(id); bannerService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "轮播图删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -105,8 +102,7 @@ public class BannerController {
Banner banner = new Banner(); Banner banner = new Banner();
BeanUtils.copyProperties(bannerUpdateRequest, banner); BeanUtils.copyProperties(bannerUpdateRequest, banner);
bannerService.validBanner(banner, true); bannerService.validBanner(banner, true);
boolean result = bannerService.updateById(banner); bannerService.updateById(banner);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "轮播图更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }

View File

@ -12,7 +12,6 @@ import com.cultural.heritage.common.ResultUtils;
import com.cultural.heritage.config.WxOpenConfig; import com.cultural.heritage.config.WxOpenConfig;
import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.constant.UserConstant;
import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonRequest; import com.cultural.heritage.model.dto.CommonRequest;
import com.cultural.heritage.model.dto.user.*; import com.cultural.heritage.model.dto.user.*;
import com.cultural.heritage.model.entity.User; import com.cultural.heritage.model.entity.User;
@ -181,8 +180,7 @@ public class UserController {
User user = new User(); User user = new User();
BeanUtils.copyProperties(userUpdateMyRequest, user); BeanUtils.copyProperties(userUpdateMyRequest, user);
user.setId(loginUser.getId()); user.setId(loginUser.getId());
boolean result = userService.updateById(user); userService.updateById(user);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "用户信息更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -228,8 +226,7 @@ public class UserController {
String encryptPassword = DigestUtils.md5DigestAsHex((SALT + user.getUserPassword()).getBytes()); String encryptPassword = DigestUtils.md5DigestAsHex((SALT + user.getUserPassword()).getBytes());
user.setUserPassword(encryptPassword); user.setUserPassword(encryptPassword);
userService.validUser(user, false); userService.validUser(user, false);
boolean save = userService.save(user); userService.save(user);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "用户添加失败");
return ResultUtils.success(user, "添加用户成功"); return ResultUtils.success(user, "添加用户成功");
} }
@ -246,8 +243,7 @@ public class UserController {
if (deleteRequest == null || deleteRequest.getId() <= 0) { if (deleteRequest == null || deleteRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
boolean result = userService.removeById(deleteRequest.getId()); userService.removeById(deleteRequest.getId());
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -282,8 +278,7 @@ public class UserController {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "无法修改为boss权限"); throw new BusinessException(ErrorCode.PARAMS_ERROR, "无法修改为boss权限");
} }
userService.validUser(user, true); userService.validUser(user, true);
boolean result = userService.updateById(user); userService.updateById(user);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true); return ResultUtils.success(true);
} }

View File

@ -11,7 +11,6 @@ import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.common.ResultUtils; import com.cultural.heritage.common.ResultUtils;
import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.constant.UserConstant;
import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.model.dto.CommonRequest; import com.cultural.heritage.model.dto.CommonRequest;
import com.cultural.heritage.model.dto.article.OfficialAccountArticleAddRequest; import com.cultural.heritage.model.dto.article.OfficialAccountArticleAddRequest;
import com.cultural.heritage.model.dto.article.OfficialAccountArticleQueryRequest; import com.cultural.heritage.model.dto.article.OfficialAccountArticleQueryRequest;
@ -70,8 +69,7 @@ public class WeChatController {
OfficialAccountArticle officialAccountArticle = new OfficialAccountArticle(); OfficialAccountArticle officialAccountArticle = new OfficialAccountArticle();
BeanUtils.copyProperties(officialAccountArticleAddRequest, officialAccountArticle); BeanUtils.copyProperties(officialAccountArticleAddRequest, officialAccountArticle);
weChatOfficialAccountService.validArticle(officialAccountArticle, false); weChatOfficialAccountService.validArticle(officialAccountArticle, false);
boolean result = weChatOfficialAccountService.save(officialAccountArticle); weChatOfficialAccountService.save(officialAccountArticle);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "文章添加失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -90,8 +88,7 @@ public class WeChatController {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
Long id = deleteRequest.getId(); Long id = deleteRequest.getId();
boolean result = weChatOfficialAccountService.removeById(id); weChatOfficialAccountService.removeById(id);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "文章删除失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }
@ -113,8 +110,7 @@ public class WeChatController {
OfficialAccountArticle officialAccountArticle = new OfficialAccountArticle(); OfficialAccountArticle officialAccountArticle = new OfficialAccountArticle();
BeanUtils.copyProperties(officialAccountArticleUpdateRequest, officialAccountArticle); BeanUtils.copyProperties(officialAccountArticleUpdateRequest, officialAccountArticle);
weChatOfficialAccountService.validArticle(officialAccountArticle, true); weChatOfficialAccountService.validArticle(officialAccountArticle, true);
boolean result = weChatOfficialAccountService.updateById(officialAccountArticle); weChatOfficialAccountService.updateById(officialAccountArticle);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "文章更新失败");
return ResultUtils.success(true); return ResultUtils.success(true);
} }

View File

@ -112,7 +112,7 @@ public class WeChatLogisticsController {
public BaseResponse<WxAccessToken> getAccessToken() { public BaseResponse<WxAccessToken> getAccessToken() {
String accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY); String accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY);
if (accessToken == null) { if (accessToken == null) {
weChatLogisticsService.getAccessToken(); weChatLogisticsService.getStableAccessToken();
accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY); accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY);
} }
WxAccessToken wxAccessToken = WxAccessToken.builder() WxAccessToken wxAccessToken = WxAccessToken.builder()

View File

@ -99,7 +99,6 @@ public class WeChatPayController {
*/ */
@Hidden @Hidden
@PostMapping("/payment/callback") @PostMapping("/payment/callback")
@Transactional(rollbackFor = Exception.class)
@Operation(summary = "JSAPI 下单回调(商品类)", description = "参数订单id, 权限:所有人, 方法名callbackPayment") @Operation(summary = "JSAPI 下单回调(商品类)", description = "参数订单id, 权限:所有人, 方法名callbackPayment")
public synchronized BaseResponse<Boolean> callbackPayment(HttpServletRequest request) throws IOException { public synchronized BaseResponse<Boolean> callbackPayment(HttpServletRequest request) throws IOException {
// 获取下单信息 // 获取下单信息
@ -142,7 +141,6 @@ public class WeChatPayController {
*/ */
@Hidden @Hidden
@PostMapping("/payment/photo/callback") @PostMapping("/payment/photo/callback")
@Transactional(rollbackFor = Exception.class)
@Operation(summary = "JSAPI 下单回调(写真预约类)", description = "参数订单id, 权限:所有人, 方法名callbackPhotoProductsPayment") @Operation(summary = "JSAPI 下单回调(写真预约类)", description = "参数订单id, 权限:所有人, 方法名callbackPhotoProductsPayment")
public synchronized BaseResponse<Boolean> callbackPhotoProductsPayment(HttpServletRequest request) throws IOException { public synchronized BaseResponse<Boolean> callbackPhotoProductsPayment(HttpServletRequest request) throws IOException {
// 获取下单信息 // 获取下单信息
@ -340,7 +338,6 @@ public class WeChatPayController {
*/ */
@Hidden @Hidden
@PostMapping("/payment/clothesRent/callback") @PostMapping("/payment/clothesRent/callback")
@Transactional(rollbackFor = Exception.class)
@Operation(summary = "JSAPI 下单回调(服装租赁)", description = "参数订单id, 权限:所有人, 方法名callbackClothesRentPayment") @Operation(summary = "JSAPI 下单回调(服装租赁)", description = "参数订单id, 权限:所有人, 方法名callbackClothesRentPayment")
public synchronized BaseResponse<Boolean> callbackClothesRentPayment(HttpServletRequest request) throws IOException { public synchronized BaseResponse<Boolean> callbackClothesRentPayment(HttpServletRequest request) throws IOException {
// 获取下单信息 // 获取下单信息
@ -395,8 +392,6 @@ public class WeChatPayController {
// /** // /**
// * 发送订阅消息 // * 发送订阅消息
// */ // */

View File

@ -3,20 +3,7 @@ package com.cultural.heritage.service.address;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.cultural.heritage.model.entity.Address; import com.cultural.heritage.model.entity.Address;
import java.util.List;
public interface AddressService extends IService<Address> { public interface AddressService extends IService<Address> {
/**
* 校验是否添加或更新了默认地址
*/
void verifyIsDefault(Address address);
/**
* 根据userId获取用户地址
*/
List<Address> getUserAddressById(Long id);
/** /**
* 校验用户提交的地址信息 * 校验用户提交的地址信息

View File

@ -3,20 +3,7 @@ package com.cultural.heritage.service.address;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.cultural.heritage.model.entity.Contacts; import com.cultural.heritage.model.entity.Contacts;
import java.util.List;
public interface ContactsService extends IService<Contacts> { public interface ContactsService extends IService<Contacts> {
/**
* 校验是否添加或更新了默认联系人
*/
void verifyIsDefault(Contacts contacts);
/**
* 根据userId获取用户联系人
*/
List<Contacts> getUserContactsById(Long id);
/** /**
* 校验用户提交的地址信息 * 校验用户提交的地址信息

View File

@ -1,10 +1,8 @@
package com.cultural.heritage.service.address.impl; package com.cultural.heritage.service.address.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.mapper.AddressMapper; import com.cultural.heritage.mapper.AddressMapper;
import com.cultural.heritage.model.entity.Address; import com.cultural.heritage.model.entity.Address;
import com.cultural.heritage.service.address.AddressService; import com.cultural.heritage.service.address.AddressService;
@ -12,37 +10,10 @@ import com.cultural.heritage.utils.RegexUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
@Service @Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements AddressService { public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements AddressService {
@Override
public void verifyIsDefault(Address address) {
Integer isDefault = address.getIsDefault();
Long userId = address.getUserId();
List<Address> list = this.getUserAddressById(userId);
if (CollectionUtils.isEmpty(list)) {
return ;
}
if (isDefault == 1) {
list.forEach(item -> item.setIsDefault(0));
}
boolean result = this.updateBatchById(list);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
}
@Override
public List<Address> getUserAddressById(Long userId) {
QueryWrapper<Address> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("userId", userId);
List<Address> list = this.list(queryWrapper);
return list;
}
/** /**
* 校验用户提交的地址信息 * 校验用户提交的地址信息
*/ */

View File

@ -1,10 +1,8 @@
package com.cultural.heritage.service.address.impl; package com.cultural.heritage.service.address.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.mapper.ContactsMapper; import com.cultural.heritage.mapper.ContactsMapper;
import com.cultural.heritage.model.entity.Contacts; import com.cultural.heritage.model.entity.Contacts;
import com.cultural.heritage.service.address.ContactsService; import com.cultural.heritage.service.address.ContactsService;
@ -12,38 +10,11 @@ import com.cultural.heritage.utils.RegexUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
@Service @Service
public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> implements ContactsService { public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> implements ContactsService {
@Override
public void verifyIsDefault(Contacts contacts) {
Integer isDefault = contacts.getIsDefault();
Long userId = contacts.getUserId();
List<Contacts> list = this.getUserContactsById(userId);
if (CollectionUtils.isEmpty(list)) {
return ;
}
if (isDefault == 1) {
list.forEach(item -> item.setIsDefault(0));
}
boolean result = this.updateBatchById(list);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
}
@Override
public List<Contacts> getUserContactsById(Long userId) {
QueryWrapper<Contacts> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("userId", userId);
List<Contacts> list = this.list(queryWrapper);
return list;
}
/** /**
* 校验用户提交的地址信息 * 校验用户提交的地址信息
*/ */

View File

@ -9,51 +9,6 @@ import java.util.function.Function;
public interface CommonService { public interface CommonService {
//
// /**
// * 从源集合中提取 ID 列表并根据这些 ID 查询目标集合的数据
// * @param sourceList 源集合List<T>包含需要提取 ID 的元素
// * @param genericService 执行查询的 ServiceIService<R>
// * @param getId 提取源集合中每个元素的 ID 的函数
// * @param <T> 源集合中元素的类型
// * @param <R> 目标集合中元素的类型
// * @return 查询结果集合
// */
// <T, R> List<R> findByMyIdInOtherIds(List<T> sourceList, IService<R> genericService, Function<T, Long> getId);
//
//
//
//
//
// /**
// * 该方法接收一个 List<Long> 类型的 ID 列表利用传入的服务接口和目标字段名构造查询条件并执行查询
// * @param idList ID 列表List<Long>
// * @param service 执行查询的 Service
// * @param targetField 目标字段名
// * @param <T> 查询结果实体类型
// * @return 查询结果集合
// */
// <T> List<T> findByMyFieldValueInOtherIds(List<Long> idList, IService<T> service, String targetField);
//
//
//
//
//
// /**
// * 从第一个集合中提取某个属性值并用这些值作为查询条件去查询第二个集合的数据
// * @param sourceList 原始集合源数据
// * @param service 要执行查询的 Service
// * @param sourceField 在原始集合中提取的字段名
// * @param targetField 在目标集合中的查询字段名
// * @param <T> 目标查询实体类型
// * @return 查询结果集合
// */
// <T> List<T> findByMyFieldValueInOtherFieldValues(List<?> sourceList, IService<T> service, String sourceField, String targetField);
//
//
/** /**

View File

@ -15,116 +15,6 @@ import java.util.stream.Collectors;
public class CommonServiceImpl implements CommonService { public class CommonServiceImpl implements CommonService {
//
//
// /**
// * 从源集合中提取 ID 列表并根据这些 ID 查询目标集合的数据
// * @param sourceList 源集合List<T>包含需要提取 ID 的元素
// * @param genericService 执行查询的 ServiceIService<R>
// * @param getId 提取源集合中每个元素的 ID 的函数
// * @param <T> 源集合中元素的类型
// * @param <R> 目标集合中元素的类型
// * @return 查询结果集合
// */
// @Override
// public <T, R> List<R> findByMyIdInOtherIds(List<T> sourceList, IService<R> genericService, Function<T, Long> getId) {
// // 提取ID
// List<Long> ids = sourceList.stream()
// .map(getId) // 提取每个元素的ID
// .collect(Collectors.toList());
//
// if (ids.isEmpty()) {
// return List.of(); // 返回空集合
// }
// // 构造查询条件
// QueryWrapper<R> queryWrapper = new QueryWrapper<>();
// queryWrapper.in("id", ids);
//
// // 返回查询结果
// return genericService.list(queryWrapper);
// }
//
//
//
//
// /**
// * 该方法接收一个 List<Long> 类型的 ID 列表利用传入的服务接口和目标字段名构造查询条件并执行查询
// * @param idList ID 列表List<Long>
// * @param service 执行查询的 Service
// * @param targetField 目标字段名
// * @param <T> 查询结果实体类型
// * @return 查询结果集合
// */
// public <T> List<T> findByMyFieldValueInOtherIds(List<Long> idList, IService<T> service, String targetField) {
// // 如果 idList 为空或为 null直接返回空集合
// if (idList.isEmpty()) {
// return List.of(); // 返回空集合
// }
//
// // 创建 QueryWrapper 对象用于构建查询条件
// QueryWrapper<T> queryWrapper = new QueryWrapper<>();
//
// // 使用 in 方法构造根据 targetField 字段值查询的条件
// queryWrapper.in(targetField, idList); // 将传入的 ID 列表作为查询条件
//
// // 调用 service list 方法执行查询并返回结果
// return service.list(queryWrapper); // 返回查询结果
// }
//
//
//
//
//
// /**
// * 从第一个集合中提取某个属性值并用这些值作为查询条件去查询第二个集合的数据
// * @param sourceList 原始集合源数据
// * @param service 要执行查询的 Service
// * @param sourceField 在原始集合中提取的字段名
// * @param targetField 在目标集合中的查询字段名
// * @param <T> 目标查询实体类型
// * @return 查询结果集合
// */
// @Override
// public <T> List<T> findByMyFieldValueInOtherFieldValues(List<?> sourceList, IService<T> service, String sourceField, String targetField) {
// // 使用反射获取源集合中对应字段的值
// List<Object> fieldValues = sourceList.stream()
// .map(item -> getFieldValue(item, sourceField)) // 获取字段值
// .collect(Collectors.toList());
//
// // 如果 fieldValues 为空直接返回空集合
// if (fieldValues.isEmpty()) {
// return List.of(); // 返回空集合
// }
// // 创建查询条件
// QueryWrapper<T> queryWrapper = new QueryWrapper<>();
// queryWrapper.in(targetField, fieldValues); // 根据字段值进行查询
//
// return service.list(queryWrapper); // 执行查询并返回结果
// }
//
//
//
// /**
// * 使用反射获取对象的字段值
// * @param object 对象
// * @param fieldName 字段名
// * @return 字段的值
// */
// private Object getFieldValue(Object object, String fieldName) {
// try {
// Field field = object.getClass().getDeclaredField(fieldName);
// field.setAccessible(true);
// return field.get(object);
// } catch (NoSuchFieldException | IllegalAccessException e) {
// throw new RuntimeException("字段获取失败", e);
// }
// }
/** /**
* 从源集合中提取指定属性并作为查询条件查询目标集合 * 从源集合中提取指定属性并作为查询条件查询目标集合
* @param sourceList 源集合List<T>包含需要提取属性的元素 * @param sourceList 源集合List<T>包含需要提取属性的元素

View File

@ -1,21 +1,11 @@
package com.cultural.heritage.service.good; package com.cultural.heritage.service.good;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.cultural.heritage.model.entity.Category; import com.cultural.heritage.model.entity.Category;
import com.cultural.heritage.model.entity.Good;
import java.util.List;
public interface CategoryService extends IService<Category> { public interface CategoryService extends IService<Category> {
/**
* 获取类别名列表
*/
List<String> getTypeNameList();
/** /**
* 根据id获取类别 * 根据id获取类别
*/ */
@ -26,10 +16,4 @@ public interface CategoryService extends IService<Category> {
*/ */
void validCategory(Category category, boolean add); void validCategory(Category category, boolean add);
/**
* 根据类别id获取商品删除的条件
*/
QueryWrapper<Good> getDeleteQueryWrapper(Long id);
} }

View File

@ -85,8 +85,7 @@ public class CartExperienceServiceImpl extends ServiceImpl<CartExperienceMapper,
// 如果购物车中已存在该商品, 就叠加数量 // 如果购物车中已存在该商品, 就叠加数量
cartExperience.setQuantity(originQuantity + addQuantity); cartExperience.setQuantity(originQuantity + addQuantity);
cartExperience.setSubtotal(good.getPrice().multiply(BigDecimal.valueOf(cartExperience.getQuantity()))); cartExperience.setSubtotal(good.getPrice().multiply(BigDecimal.valueOf(cartExperience.getQuantity())));
boolean result = this.updateById(cartExperience); this.updateById(cartExperience);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "更新购物车商品数量失败");
} else { } else {
// 校验当前服务类商品的预约情况 // 校验当前服务类商品的预约情况
goodService.checkServiceGoodBookingDetailIsProperly(goodId, reservationDate, timeSlot, addQuantity); goodService.checkServiceGoodBookingDetailIsProperly(goodId, reservationDate, timeSlot, addQuantity);
@ -98,8 +97,7 @@ public class CartExperienceServiceImpl extends ServiceImpl<CartExperienceMapper,
cartExperienceRecord.setSubtotal(good.getPrice().multiply(BigDecimal.valueOf(cartExperienceRecord.getQuantity()))); cartExperienceRecord.setSubtotal(good.getPrice().multiply(BigDecimal.valueOf(cartExperienceRecord.getQuantity())));
// 校验 // 校验
this.validCart(cartExperienceRecord, false); this.validCart(cartExperienceRecord, false);
boolean result = this.save(cartExperienceRecord); this.save(cartExperienceRecord);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
} }
} }

View File

@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.mapper.CartRecordMapper; import com.cultural.heritage.mapper.CartRecordMapper;
import com.cultural.heritage.model.dto.cart.CartOrderItemAddRequest; import com.cultural.heritage.model.dto.cart.CartOrderItemAddRequest;
import com.cultural.heritage.model.dto.cart.CartRecordAddRequest; import com.cultural.heritage.model.dto.cart.CartRecordAddRequest;
@ -68,8 +67,7 @@ public class CartRecordServiceImpl extends ServiceImpl<CartRecordMapper, CartRec
// 如果购物车中已存在该商品, 就叠加数量 // 如果购物车中已存在该商品, 就叠加数量
cartRecord.setQuantity(currentQuantity); cartRecord.setQuantity(currentQuantity);
cartRecord.setSubtotal(good.getPrice().multiply(BigDecimal.valueOf(currentQuantity))); cartRecord.setSubtotal(good.getPrice().multiply(BigDecimal.valueOf(currentQuantity)));
boolean result = this.updateById(cartRecord); this.updateById(cartRecord);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "更新购物车商品数量失败");
} else { } else {
// 判断数量是否超出库存 // 判断数量是否超出库存
Integer currentQuantity = cartRecordAddRequest.getQuantity(); Integer currentQuantity = cartRecordAddRequest.getQuantity();
@ -81,8 +79,7 @@ public class CartRecordServiceImpl extends ServiceImpl<CartRecordMapper, CartRec
cartGood.setSubtotal(good.getPrice().multiply(BigDecimal.valueOf(cartGood.getQuantity()))); cartGood.setSubtotal(good.getPrice().multiply(BigDecimal.valueOf(cartGood.getQuantity())));
// 校验 // 校验
this.validCart(cartGood, false); this.validCart(cartGood, false);
boolean result = this.save(cartGood); this.save(cartGood);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
} }
} }

View File

@ -7,32 +7,13 @@ import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.mapper.CategoryMapper; import com.cultural.heritage.mapper.CategoryMapper;
import com.cultural.heritage.model.entity.Category; import com.cultural.heritage.model.entity.Category;
import com.cultural.heritage.model.entity.Good;
import com.cultural.heritage.service.good.CategoryService; import com.cultural.heritage.service.good.CategoryService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService { public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {
/**
* 获取类别名列表
*/
@Override
public List<String> getTypeNameList() {
List<Category> list = this.list();
List<String> collect = list.stream().map(Category::getTypeName).collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect)) {
return new ArrayList<>();
}
return collect;
}
@Override @Override
public Category getCategoryById(Long id) { public Category getCategoryById(Long id) {
QueryWrapper<Category> queryWrapper = new QueryWrapper<>(); QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
@ -70,16 +51,4 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
} }
/**
* 根据类别id获取商品删除的条件
*/
@Override
public QueryWrapper<Good> getDeleteQueryWrapper(Long id) {
Category category = this.getById(id);
String typeName = category.getTypeName();
QueryWrapper<Good> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", typeName);
return queryWrapper;
}
} }

View File

@ -33,4 +33,10 @@ public interface ClothesRentOrderService extends IService<ClothesRentOrder> {
* 向消息队列中发送服装租赁倒计时的消息 * 向消息队列中发送服装租赁倒计时的消息
*/ */
void sendClothesRentPeriodMessage(Long id, Integer days); void sendClothesRentPeriodMessage(Long id, Integer days);
/**
* 校验当前服装是否被租赁
*/
void validIsBeenRented(Long clothesId);
} }

View File

@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.constant.CommonConstant; import com.cultural.heritage.constant.CommonConstant;
import com.cultural.heritage.constant.MqConstant; import com.cultural.heritage.constant.MqConstant;
import com.cultural.heritage.constant.OrderStatusConstant;
import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.exception.ThrowUtils;
import com.cultural.heritage.mapper.ClothesRentOrderMapper; import com.cultural.heritage.mapper.ClothesRentOrderMapper;
import com.cultural.heritage.model.dto.clothesRentOrder.ClothesRentOrderAddRequest; import com.cultural.heritage.model.dto.clothesRentOrder.ClothesRentOrderAddRequest;
@ -106,4 +108,21 @@ public class ClothesRentOrderServiceImpl extends ServiceImpl<ClothesRentOrderMap
} }
/**
* 校验当前服装是否被租赁
*/
@Override
public void validIsBeenRented(Long clothesId) {
QueryWrapper<ClothesRentOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.in(OrderStatusConstant.PENDING_SHIPMENT, OrderStatusConstant.PENDING_DELIVERY);
List<ClothesRentOrder> clothesRentOrderList = this.list(queryWrapper);
for (ClothesRentOrder clothesRentOrder : clothesRentOrderList) {
Long clothesSnapshotId = clothesRentOrder.getClothesSnapshot().getId();
if (clothesSnapshotId.equals(clothesId)) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "该服装已被租赁");
}
}
}
} }

View File

@ -257,8 +257,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
order.setOrderStatus(OrderStatusConstant.PENDING_PAYMENT); order.setOrderStatus(OrderStatusConstant.PENDING_PAYMENT);
// 校验订单 // 校验订单
this.validOrder(order); this.validOrder(order);
boolean result = this.save(order); this.save(order);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "订单生成失败");
// 创建订单明细 // 创建订单明细
Long id = order.getId(); Long id = order.getId();
List<OrderItemAddRequest> orderItemList = orderAddRequest.getOrderItemList(); List<OrderItemAddRequest> orderItemList = orderAddRequest.getOrderItemList();
@ -268,9 +267,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
orderItems.setOrderId(id); orderItems.setOrderId(id);
return orderItems; return orderItems;
}).toList(); }).toList();
boolean save = orderItemService.saveBatch(newOrderItemsList); orderItemService.saveBatch(newOrderItemsList);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "订单明细生成失败");
if (isGeneral) { if (isGeneral) {
// 扣减商品库存 // 扣减商品库存
List<OrderItemMainInfoAddRequest> orderItemMainInfoAddRequestList = orderMainInfoAddRequest.getOrderItemMainInfoAddRequestList(); List<OrderItemMainInfoAddRequest> orderItemMainInfoAddRequestList = orderMainInfoAddRequest.getOrderItemMainInfoAddRequestList();
@ -282,14 +279,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
// 清空购物车 // 清空购物车
if (isCartOrder) { if (isCartOrder) {
if (isGeneral) { if (isGeneral) cartRecordService.removeBatchByIds(cartIds);
boolean removeGeneral = cartRecordService.removeBatchByIds(cartIds); else cartExperienceService.removeBatchByIds(cartIds);
ThrowUtils.throwIf(!removeGeneral, ErrorCode.OPERATION_ERROR, "清空常规类购物车失败");
} else {
boolean removeService = cartExperienceService.removeBatchByIds(cartIds);
ThrowUtils.throwIf(!removeService, ErrorCode.OPERATION_ERROR, "清空服务类购物车失败");
}
} }
return id; return id;
} }
@ -328,8 +319,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
pendingServiceOrderList.add(pendingServiceOrder); pendingServiceOrderList.add(pendingServiceOrder);
} }
boolean saveBatch = pendingServiceOrderService.saveBatch(pendingServiceOrderList); pendingServiceOrderService.saveBatch(pendingServiceOrderList);
ThrowUtils.throwIf(!saveBatch, ErrorCode.OPERATION_ERROR, "服务类订单待处理记录批量生成失败");
} }
@ -359,8 +349,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
Integer inventory = map.get(good.getId()); Integer inventory = map.get(good.getId());
good.setInventory(good.getInventory() - inventory); good.setInventory(good.getInventory() - inventory);
} }
boolean update = goodService.updateBatchById(goodList); goodService.updateBatchById(goodList);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "商品库存更新失败");
} }
@ -410,8 +399,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
conditionAmount = userCoupon.getCouponVO().getConditionAmount(); conditionAmount = userCoupon.getCouponVO().getConditionAmount();
// 更新优惠券状态 // 更新优惠券状态
userCoupon.setIsUsed(1); userCoupon.setIsUsed(1);
boolean update = userCouponService.updateById(userCoupon); userCouponService.updateById(userCoupon);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "优惠券状态更新失败");
} }
Integer quantity = orderItemMainInfoAddRequest.getQuantity(); Integer quantity = orderItemMainInfoAddRequest.getQuantity();
Long goodId = orderItemMainInfoAddRequest.getGoodId(); Long goodId = orderItemMainInfoAddRequest.getGoodId();
@ -502,8 +490,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
totalAmount = totalAmount.subtract(conditionAmount); totalAmount = totalAmount.subtract(conditionAmount);
// 更新优惠券状态 // 更新优惠券状态
userCoupon.setIsUsed(1); userCoupon.setIsUsed(1);
boolean update = userCouponService.updateById(userCoupon); userCouponService.updateById(userCoupon);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "优惠券状态更新失败");
} }
// 填充订单主要信息请求体金额 // 填充订单主要信息请求体金额
orderMainInfoAddRequest.setTotalAmount(totalAmount); orderMainInfoAddRequest.setTotalAmount(totalAmount);
@ -576,8 +563,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
totalAmount = totalAmount.subtract(conditionAmount); totalAmount = totalAmount.subtract(conditionAmount);
// 更新优惠券状态 // 更新优惠券状态
userCoupon.setIsUsed(1); userCoupon.setIsUsed(1);
boolean update = userCouponService.updateById(userCoupon); userCouponService.updateById(userCoupon);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "优惠券状态更新失败");
} }
// 填充订单主要信息请求体金额 // 填充订单主要信息请求体金额
orderMainInfoAddRequest.setTotalAmount(totalAmount); orderMainInfoAddRequest.setTotalAmount(totalAmount);

View File

@ -189,8 +189,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
user.setUserRole("user"); user.setUserRole("user");
user.setPoints(10000); user.setPoints(10000);
user.setUserAvatar(UserConstant.USER_DEFAULT_AVATAR); user.setUserAvatar(UserConstant.USER_DEFAULT_AVATAR);
boolean result = this.save(user); this.save(user);
ThrowUtils.throwIf(!result, ErrorCode.SYSTEM_ERROR, "登录失败");
// 记住用户的登录态 // 记住用户的登录态
} }
request.getSession().setAttribute(USER_LOGIN_STATE, user); request.getSession().setAttribute(USER_LOGIN_STATE, user);
@ -210,8 +209,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
} else { } else {
user.setPoints(Math.max(user.getPoints() - points, 0)); user.setPoints(Math.max(user.getPoints() - points, 0));
} }
boolean update = this.updateById(user); this.updateById(user);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "积分更新失败");
} }
} }

View File

@ -45,7 +45,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* @author 玄德 * @author 陈新知
*/ */
@Slf4j @Slf4j
@Service @Service
@ -536,8 +536,7 @@ public class WeChatServiceImpl implements WeChatService {
// 更新服务类订单待处理记录 // 更新服务类订单待处理记录
UpdateWrapper<PendingServiceOrder> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<PendingServiceOrder> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("orderItemId", orderItemId).set("orderItemStatus", OrderStatusConstant.PAYMENT_REFUNDED); updateWrapper.eq("orderItemId", orderItemId).set("orderItemStatus", OrderStatusConstant.PAYMENT_REFUNDED);
boolean update = pendingServiceOrderService.update(updateWrapper); pendingServiceOrderService.update(updateWrapper);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "服务类订单待处理记录状态更新失败");
// 如果退款的是订单中最后一个订单明细则修改订单状态 // 如果退款的是订单中最后一个订单明细则修改订单状态
QueryWrapper<RefundRecord> queryWrapper = new QueryWrapper<>(); QueryWrapper<RefundRecord> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("outTradeNo", orderNumber); queryWrapper.eq("outTradeNo", orderNumber);
@ -550,8 +549,7 @@ public class WeChatServiceImpl implements WeChatService {
UpdateWrapper<Order> orderUpdateWrapper = new UpdateWrapper<>(); UpdateWrapper<Order> orderUpdateWrapper = new UpdateWrapper<>();
if (refundCount == orderItemCount) { if (refundCount == orderItemCount) {
orderUpdateWrapper.eq("id", order.getId()).set("orderStatus", OrderStatusConstant.PAYMENT_REFUNDED); orderUpdateWrapper.eq("id", order.getId()).set("orderStatus", OrderStatusConstant.PAYMENT_REFUNDED);
boolean result = orderService.update(orderUpdateWrapper); orderService.update(orderUpdateWrapper);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "订单状态更新失败");
} }
} else { } else {
// 恢复商品库存 // 恢复商品库存
@ -561,7 +559,6 @@ public class WeChatServiceImpl implements WeChatService {
ThrowUtils.throwIf(good == null, ErrorCode.OPERATION_ERROR, "当前商品不存在"); ThrowUtils.throwIf(good == null, ErrorCode.OPERATION_ERROR, "当前商品不存在");
good.setInventory(good.getInventory() + orderItems.getQuantity()); good.setInventory(good.getInventory() + orderItems.getQuantity());
goodService.updateById(good); goodService.updateById(good);
// ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "商品库存恢复失败");
} }
System.out.println("---------------------------微信退款回调(结束)-------------------------------"); System.out.println("---------------------------微信退款回调(结束)-------------------------------");
return true; return true;
@ -790,8 +787,7 @@ public class WeChatServiceImpl implements WeChatService {
for (PendingServiceOrder pendingServiceOrder : pendingServiceOrderList) { for (PendingServiceOrder pendingServiceOrder : pendingServiceOrderList) {
pendingServiceOrder.setOrderItemStatus(orderStatus); pendingServiceOrder.setOrderItemStatus(orderStatus);
} }
boolean result = pendingServiceOrderService.updateBatchById(pendingServiceOrderList); pendingServiceOrderService.updateBatchById(pendingServiceOrderList);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类订单待处理记录批量更新失败");
} }
@ -845,9 +841,7 @@ public class WeChatServiceImpl implements WeChatService {
refundRecord.setOutTradeNo(refundNotification.getOutTradeNo()); refundRecord.setOutTradeNo(refundNotification.getOutTradeNo());
refundRecord.setOutRefundNo(refundNotification.getOutRefundNo()); refundRecord.setOutRefundNo(refundNotification.getOutRefundNo());
refundRecord.setRefundAmount(BigDecimal.valueOf(refundNotification.getAmount().getRefund()).movePointLeft(2)); refundRecord.setRefundAmount(BigDecimal.valueOf(refundNotification.getAmount().getRefund()).movePointLeft(2));
refundRecordService.save(refundRecord);
boolean save = refundRecordService.save(refundRecord);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "退款记录生成失败");
} }
@ -860,9 +854,7 @@ public class WeChatServiceImpl implements WeChatService {
refundRecord.setOutTradeNo(outTradeNo); refundRecord.setOutTradeNo(outTradeNo);
refundRecord.setOutRefundNo(outRefundNo); refundRecord.setOutRefundNo(outRefundNo);
refundRecord.setRefundAmount(refundAmount.movePointLeft(2)); refundRecord.setRefundAmount(refundAmount.movePointLeft(2));
refundRecordService.save(refundRecord);
boolean save = refundRecordService.save(refundRecord);
ThrowUtils.throwIf(!save, ErrorCode.OPERATION_ERROR, "退款记录生成失败");
} }
@ -875,8 +867,7 @@ public class WeChatServiceImpl implements WeChatService {
private void modifyOrderStatus(Order order, String orderStatus) { private void modifyOrderStatus(Order order, String orderStatus) {
order.setOrderStatus(orderStatus); order.setOrderStatus(orderStatus);
order.setUpdateTime(DateUtil.date()); order.setUpdateTime(DateUtil.date());
boolean update = orderService.updateById(order); orderService.updateById(order);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "订单状态修改失败");
} }
@ -886,8 +877,7 @@ public class WeChatServiceImpl implements WeChatService {
private void modifyAdvanceOrderStatus(AdvanceOrder advanceOrder, String orderStatus) { private void modifyAdvanceOrderStatus(AdvanceOrder advanceOrder, String orderStatus) {
advanceOrder.setOrderStatus(orderStatus); advanceOrder.setOrderStatus(orderStatus);
advanceOrder.setUpdateTime(DateUtil.date()); advanceOrder.setUpdateTime(DateUtil.date());
boolean update = advanceOrderService.updateById(advanceOrder); advanceOrderService.updateById(advanceOrder);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "订单状态修改失败");
} }
@ -898,8 +888,7 @@ public class WeChatServiceImpl implements WeChatService {
private void modifyClothesRentStatus(ClothesRentOrder clothesRentOrder, String orderStatus) { private void modifyClothesRentStatus(ClothesRentOrder clothesRentOrder, String orderStatus) {
clothesRentOrder.setOrderStatus(orderStatus); clothesRentOrder.setOrderStatus(orderStatus);
clothesRentOrder.setUpdateTime(DateUtil.date()); clothesRentOrder.setUpdateTime(DateUtil.date());
boolean update = clothesRentOrderService.updateById(clothesRentOrder); clothesRentOrderService.updateById(clothesRentOrder);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "订单状态修改失败");
} }
@ -951,7 +940,6 @@ public class WeChatServiceImpl implements WeChatService {
good.setUpdateTime(DateUtil.date()); good.setUpdateTime(DateUtil.date());
} }
goodService.updateBatchById(goodList); goodService.updateBatchById(goodList);
// ThrowUtils.throwIf(!updateBatch, ErrorCode.SYSTEM_ERROR, "商品库存恢复失败");
} }

View File

@ -0,0 +1,101 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://123.249.108.160:3306/feiyi-sc?serverTimezone=Asia/Shanghai
username: feiyi-sc
password: 123456asd
hikari:
maximum-pool-size: 20
max-lifetime: 120000
rabbitmq:
host: 123.249.108.160
port: 5672
username: chenxinzhi
password: yuanteng
virtual-host: vhost
listener:
simple:
prefetch: 1
data:
redis:
port: 6379
host: 123.249.108.160
database: 0
password: yuanteng
servlet:
multipart:
max-file-size: 20MB
max-request-size: 20MB
springdoc:
default-flat-param-object: true
server:
port: 9092
servlet:
context-path: /api
# cookie 30 天过期
session:
cookie:
max-age: 2592000
timeout: 720h
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
configuration:
map-underscore-to-camel-case: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
logic-delete-field: isDelete #全局逻辑删除的实体字段名
logic-delete-value: 1 #逻辑已删除值(默认为1)
logic-not-delete-value: 0 #逻辑未删除值(默认为0)
type-handlers-package: com.cultural.heritage.handler
hwyun:
obs:
accessKey: TEA5FAYCZDUSCEJP8NKX
securityKey: djX3WNrYjRDmp5v7rOXfa25e9CHj8OXKRzQJp6Ec
endPoint: obs.cn-north-4.myhuaweicloud.com
bucketName: carbon2
wx:
mini:
appId: wx61b63e27bddf4ea2
appSecret: 5ef9e1f17acd8180afe2d80199fd466e
official:
appId: wx5d04ca2de0e628a8
appSecret: 495af5bc4df1b86ffcfc21bb12daea76
pay:
#应用id小程序id
appId: wx61b63e27bddf4ea2
#商户号
merchantId: 1700326544
#商户API私钥
privateKeyPath: apiclient_key.pem
#商户证书序列号
merchantSerialNumber: 6DC8953AB741D309920DA650B92F837BE38A2757
#商户APIv3密钥
apiV3Key: fbemuj4Xql7CYlQJAoTEPYxvPSNgYT2t
#通知地址
notifyUrl: https://winning-mouse-internally.ngrok-free.app
#微信服务器地址
domain: https://api.mch.weixin.qq.com
knife4j:
enable: true

View File

@ -0,0 +1,105 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://123.249.108.160:3306/feiyi-sc?serverTimezone=Asia/Shanghai
username: feiyi-sc
password: 123456asd
hikari:
maximum-pool-size: 20
max-lifetime: 120000
rabbitmq:
host: 123.249.108.160
port: 5672
username: chenxinzhi
password: yuanteng
virtual-host: vhost
listener:
simple:
prefetch: 1
data:
redis:
port: 6379
host: 123.249.108.160
database: 0
password: yuanteng
servlet:
multipart:
max-file-size: 20MB
max-request-size: 20MB
springdoc:
default-flat-param-object: true
server:
port: 8888
ssl:
key-store: classpath:carboner.cn.jks
key-store-password: 6gsn1hke4m4f7
key-store-type: JKS
servlet:
context-path: /api
# cookie 30 天过期
session:
cookie:
max-age: 2592000
timeout: 720h
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
configuration:
map-underscore-to-camel-case: false
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
global-config:
db-config:
logic-delete-field: isDelete #全局逻辑删除的实体字段名
logic-delete-value: 1 #逻辑已删除值(默认为1)
logic-not-delete-value: 0 #逻辑未删除值(默认为0)
type-handlers-package: com.cultural.heritage.handler
hwyun:
obs:
accessKey: TEA5FAYCZDUSCEJP8NKX
securityKey: djX3WNrYjRDmp5v7rOXfa25e9CHj8OXKRzQJp6Ec
endPoint: obs.cn-north-4.myhuaweicloud.com
bucketName: carbon2
wx:
mini:
appId: wx61b63e27bddf4ea2
appSecret: 5ef9e1f17acd8180afe2d80199fd466e
official:
appId: wx5d04ca2de0e628a8
appSecret: 495af5bc4df1b86ffcfc21bb12daea76
pay:
#应用id小程序id
appId: wx61b63e27bddf4ea2
#商户号
merchantId: 1700326544
#商户API私钥
privateKeyPath: apiclient_key.pem
#商户证书序列号
merchantSerialNumber: 6DC8953AB741D309920DA650B92F837BE38A2757
#商户APIv3密钥
apiV3Key: fbemuj4Xql7CYlQJAoTEPYxvPSNgYT2t
#通知地址
notifyUrl: https://www.carboner.cn:8888
#微信服务器地址
domain: https://api.mch.weixin.qq.com
knife4j:
enable: false

View File

@ -0,0 +1,109 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://123.249.108.160:3306/feiyi?serverTimezone=Asia/Shanghai
username: feiyi
password: 123456asd
hikari:
maximum-pool-size: 20
max-lifetime: 120000
rabbitmq:
host: 154.8.193.216
port: 5672
username: admin
password: cksys6509
virtual-host: vhost
listener:
simple:
prefetch: 1
servlet:
multipart:
max-file-size: 20MB
max-request-size: 20MB
data:
redis:
port: 6379
host: 123.249.108.160
database: 0
password: yuanteng
springdoc:
default-flat-param-object: true
server:
port: 9093
servlet:
context-path: /api
# cookie 30 天过期
session:
cookie:
max-age: 2592000
timeout: 720h
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
configuration:
map-underscore-to-camel-case: false
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
global-config:
db-config:
logic-delete-field: isDelete #全局逻辑删除的实体字段名
logic-delete-value: 1 #逻辑已删除值(默认为1)
logic-not-delete-value: 0 #逻辑未删除值(默认为0)
type-handlers-package: com.cultural.heritage.handler
hwyun:
obs:
accessKey: TEA5FAYCZDUSCEJP8NKX
securityKey: djX3WNrYjRDmp5v7rOXfa25e9CHj8OXKRzQJp6Ec
endPoint: obs.cn-north-4.myhuaweicloud.com
bucketName: carbon2
wx:
mini:
appId: wx61b63e27bddf4ea2
appSecret: 5ef9e1f17acd8180afe2d80199fd466e
official:
appId: wx5d04ca2de0e628a8
appSecret: 495af5bc4df1b86ffcfc21bb12daea76
pay:
#应用id小程序id
appId: wx61b63e27bddf4ea2
#商户号
merchantId: 1700326544
#商户API私钥
privateKeyPath: apiclient_key.pem
#商户证书序列号
merchantSerialNumber: 6DC8953AB741D309920DA650B92F837BE38A2757
#商户APIv3密钥
apiV3Key: fbemuj4Xql7CYlQJAoTEPYxvPSNgYT2t
#通知地址
notifyUrl: http://154.8.193.216:9093
#微信服务器地址
domain: https://api.mch.weixin.qq.com
knife4j:
enable: true

View File

@ -1,183 +1,6 @@
spring: spring:
datasource: profiles:
# 生产环境 active: test
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://154.8.193.216:3306/feiyi?serverTimezone=Asia/Shanghai
# username: feiyi
# password: 123456asd
# hikari:
# maximum-pool-size: 20
# max-lifetime: 120000
# 开发环境
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://123.249.108.160:3306/feiyi-sc?serverTimezone=Asia/Shanghai
username: feiyi-sc
password: 123456asd
hikari:
maximum-pool-size: 20
max-lifetime: 120000
# 测试环境
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://123.249.108.160:3306/feiyi?serverTimezone=Asia/Shanghai
# username: feiyi
# password: 123456asd
# hikari:
# maximum-pool-size: 20
# max-lifetime: 120000
# 新环境
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://1.94.237.210:3306/feiyi?serverTimezone=Asia/Shanghai
# username: root
# password: Cxzyt331
# hikari:
# maximum-pool-size: 20
# max-lifetime: 120000
# 生产环境
rabbitmq:
host: 123.249.108.160
port: 5672
username: chenxinzhi
password: yuanteng
virtual-host: vhost
listener:
simple:
prefetch: 1
# 测试环境
# rabbitmq:
# host: 154.8.193.216
# port: 5672
# username: admin
# password: cksys6509
# virtual-host: vhost
# listener:
# simple:
# prefetch: 1
# 新环境
# rabbitmq:
# host: 1.94.237.210
# port: 5672
# username: admin
# password: Cxzyt331
# virtual-host: vhost
# listener:
# simple:
# prefetch: 1
servlet:
multipart:
max-file-size: 20MB
max-request-size: 20MB
# 开发环境
data:
redis:
port: 6379
host: 123.249.108.160
database: 0
password: yuanteng
# 开发环境
# data:
# redis:
# port: 6379
# host: 1.94.237.210
# database: 0
# password: Cxzyt331
springdoc:
default-flat-param-object: true
server:
# port: 9093
port: 8888
ssl:
key-store: classpath:carboner.cn.jks
key-store-password: 6gsn1hke4m4f7
key-store-type: JKS
servlet:
context-path: /api
# cookie 30 天过期
session:
cookie:
max-age: 2592000
timeout: 720h
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
configuration:
map-underscore-to-camel-case: false
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
logic-delete-field: isDelete #全局逻辑删除的实体字段名
logic-delete-value: 1 #逻辑已删除值(默认为1)
logic-not-delete-value: 0 #逻辑未删除值(默认为0)
type-handlers-package: com.cultural.heritage.handler
hwyun:
obs:
accessKey: TEA5FAYCZDUSCEJP8NKX
securityKey: djX3WNrYjRDmp5v7rOXfa25e9CHj8OXKRzQJp6Ec
endPoint: obs.cn-north-4.myhuaweicloud.com
bucketName: carbon2
wx:
mini:
appId: wx61b63e27bddf4ea2
appSecret: 5ef9e1f17acd8180afe2d80199fd466e
official:
appId: wx5d04ca2de0e628a8
appSecret: 495af5bc4df1b86ffcfc21bb12daea76
pay:
#应用id小程序id
appId: wx61b63e27bddf4ea2
#商户号
merchantId: 1700326544
#商户API私钥
privateKeyPath: apiclient_key.pem
#商户证书序列号
merchantSerialNumber: 6DC8953AB741D309920DA650B92F837BE38A2757
#商户APIv3密钥
apiV3Key: fbemuj4Xql7CYlQJAoTEPYxvPSNgYT2t
#通知地址
# notifyUrl: https://winning-mouse-internally.ngrok-free.app
# notifyUrl: http://123.249.108.160:8888
# notifyUrl: http://154.8.193.216:9092
# notifyUrl: http://154.8.193.216:9093
notifyUrl: https://www.carboner.cn:8888
#微信服务器地址
domain: https://api.mch.weixin.qq.com
knife4j:
enable: true

183
src/main/resources/temp.yml Normal file
View File

@ -0,0 +1,183 @@
#spring:
# datasource:
# # 生产环境
# # driver-class-name: com.mysql.cj.jdbc.Driver
# # url: jdbc:mysql://154.8.193.216:3306/feiyi?serverTimezone=Asia/Shanghai
# # username: feiyi
# # password: 123456asd
# # hikari:
# # maximum-pool-size: 20
# # max-lifetime: 120000
#
#
# # 开发环境
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://123.249.108.160:3306/feiyi-sc?serverTimezone=Asia/Shanghai
# username: feiyi-sc
# password: 123456asd
# hikari:
# maximum-pool-size: 20
# max-lifetime: 120000
#
#
# # 测试环境
# # driver-class-name: com.mysql.cj.jdbc.Driver
# # url: jdbc:mysql://123.249.108.160:3306/feiyi?serverTimezone=Asia/Shanghai
# # username: feiyi
# # password: 123456asd
# # hikari:
# # maximum-pool-size: 20
# # max-lifetime: 120000
#
#
#
# # 新环境
# # driver-class-name: com.mysql.cj.jdbc.Driver
# # url: jdbc:mysql://1.94.237.210:3306/feiyi?serverTimezone=Asia/Shanghai
# # username: root
# # password: Cxzyt331
# # hikari:
# # maximum-pool-size: 20
# # max-lifetime: 120000
#
#
#
#
# # 生产环境
# rabbitmq:
# host: 123.249.108.160
# port: 5672
# username: chenxinzhi
# password: yuanteng
# virtual-host: vhost
# listener:
# simple:
# prefetch: 1
#
#
# # 测试环境
# # rabbitmq:
# # host: 154.8.193.216
# # port: 5672
# # username: admin
# # password: cksys6509
# # virtual-host: vhost
# # listener:
# # simple:
# # prefetch: 1
#
#
# # 新环境
# # rabbitmq:
# # host: 1.94.237.210
# # port: 5672
# # username: admin
# # password: Cxzyt331
# # virtual-host: vhost
# # listener:
# # simple:
# # prefetch: 1
#
#
#
# servlet:
# multipart:
# max-file-size: 20MB
# max-request-size: 20MB
#
#
# # 开发环境
# data:
# redis:
# port: 6379
# host: 123.249.108.160
# database: 0
# password: yuanteng
#
#
#
## 开发环境
## data:
## redis:
## port: 6379
## host: 1.94.237.210
## database: 0
## password: Cxzyt331
#
#
#
#springdoc:
# default-flat-param-object: true
#
#
#server:
# # port: 9093
# port: 8888
# ssl:
# key-store: classpath:carboner.cn.jks
# key-store-password: 6gsn1hke4m4f7
# key-store-type: JKS
#
# servlet:
# context-path: /api
# # cookie 30 天过期
# session:
# cookie:
# max-age: 2592000
# timeout: 720h
#
#mybatis-plus:
# mapper-locations: classpath:mapper/*.xml
# configuration:
# map-underscore-to-camel-case: false
# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
# # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# global-config:
# db-config:
# logic-delete-field: isDelete #全局逻辑删除的实体字段名
# logic-delete-value: 1 #逻辑已删除值(默认为1)
# logic-not-delete-value: 0 #逻辑未删除值(默认为0)
# type-handlers-package: com.cultural.heritage.handler
#
#
#hwyun:
# obs:
# accessKey: TEA5FAYCZDUSCEJP8NKX
# securityKey: djX3WNrYjRDmp5v7rOXfa25e9CHj8OXKRzQJp6Ec
# endPoint: obs.cn-north-4.myhuaweicloud.com
# bucketName: carbon2
#
#
#
#
#wx:
# mini:
# appId: wx61b63e27bddf4ea2
# appSecret: 5ef9e1f17acd8180afe2d80199fd466e
# official:
# appId: wx5d04ca2de0e628a8
# appSecret: 495af5bc4df1b86ffcfc21bb12daea76
# pay:
# #应用id小程序id
# appId: wx61b63e27bddf4ea2
# #商户号
# merchantId: 1700326544
# #商户API私钥
# privateKeyPath: apiclient_key.pem
# #商户证书序列号
# merchantSerialNumber: 6DC8953AB741D309920DA650B92F837BE38A2757
# #商户APIv3密钥
# apiV3Key: fbemuj4Xql7CYlQJAoTEPYxvPSNgYT2t
# #通知地址
# # notifyUrl: https://winning-mouse-internally.ngrok-free.app
# # notifyUrl: http://123.249.108.160:8888
# # notifyUrl: http://154.8.193.216:9092
# # notifyUrl: http://154.8.193.216:9093
# notifyUrl: https://www.carboner.cn:8888
#
# #微信服务器地址
# domain: https://api.mch.weixin.qq.com
#
#
#knife4j:
# enable: true