更新了写真预约特殊产品处理

This commit is contained in:
chen-xin-zhi 2025-03-12 19:01:58 +08:00
parent ca5d4849b2
commit c6d5d2f92c
5 changed files with 57 additions and 2 deletions

View File

@ -22,6 +22,7 @@ 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.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -142,7 +143,7 @@ public class BookingDateController {
@Transactional(rollbackFor = Exception.class) @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) { if (bookingTimeSingleAddRequest == null || StringUtils.isBlank(bookingTimeSingleAddRequest.getTimePoint())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR); throw new BusinessException(ErrorCode.PARAMS_ERROR);
} }
BookingTime bookingTime = new BookingTime(); BookingTime bookingTime = new BookingTime();

View File

@ -367,7 +367,7 @@ public class OrderController {
* @return 是否取消成功 * @return 是否取消成功
*/ */
@PostMapping ("/cancel/id") @PostMapping ("/cancel/id")
@Operation(summary = "小程序端用户取消常规类商品订单", description = "参数订单id权限所有人方法名cancelOrderById") @Operation(summary = "小程序端用户取消服务类商品订单", description = "参数订单id权限所有人方法名cancelOrderById")
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);
@ -429,6 +429,31 @@ public class OrderController {
/**
* 小程序端用户删除商品订单
* @param commonRequest 订单id
* @return 是否取消成功
*/
@PostMapping ("/delete/id")
@Operation(summary = "小程序端用户删除商品订单", description = "参数订单id权限所有人方法名deleteOrderById")
public BaseResponse<Boolean> deleteOrderById(@RequestBody CommonRequest commonRequest, HttpServletRequest request) {
if (commonRequest == null || commonRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
Long id = commonRequest.getId();
userService.getLoginUser(request);
Order order = orderService.getById(id);
ThrowUtils.throwIf(order == null, ErrorCode.OPERATION_ERROR, "订单不存在");
ThrowUtils.throwIf(!order.getOrderStatus().equals(OrderStatusConstant.TRANSACTION_CLOSED), ErrorCode.SYSTEM_ERROR, "订单状态错误");
boolean remove = orderService.removeById(id);
ThrowUtils.throwIf(!remove, ErrorCode.OPERATION_ERROR, "订单删除失败");
return ResultUtils.success(true);
}
/** /**
* 小程序端用户取消服务类商品订单 * 小程序端用户取消服务类商品订单

View File

@ -185,6 +185,7 @@ public class UserController {
BeanUtils.copyProperties(userAddRequest, user); BeanUtils.copyProperties(userAddRequest, user);
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);
boolean save = userService.save(user); boolean save = userService.save(user);
if (!save) { if (!save) {
throw new BusinessException(ErrorCode.SYSTEM_ERROR); throw new BusinessException(ErrorCode.SYSTEM_ERROR);
@ -225,6 +226,9 @@ public class UserController {
} }
User user = new User(); User user = new User();
BeanUtils.copyProperties(userUpdateRequest, user); BeanUtils.copyProperties(userUpdateRequest, user);
String encryptPassword = DigestUtils.md5DigestAsHex((SALT + user.getUserPassword()).getBytes());
user.setUserPassword(encryptPassword);
userService.validUser(user, true);
boolean result = userService.updateById(user); boolean result = userService.updateById(user);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR); ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
return ResultUtils.success(true); return ResultUtils.success(true);

View File

@ -25,6 +25,13 @@ public interface UserService extends IService<User> {
*/ */
UserVO getUserVO(User user); UserVO getUserVO(User user);
/**
* 校验用户信息
*/
void validUser(User user, boolean update);
/** /**
* 用户退出 * 用户退出
* @return 是否退出成功 * @return 是否退出成功

View File

@ -15,6 +15,7 @@ import com.cultural.heritage.model.entity.User;
import com.cultural.heritage.model.enums.UserRoleEnum; import com.cultural.heritage.model.enums.UserRoleEnum;
import com.cultural.heritage.model.vo.user.UserVO; import com.cultural.heritage.model.vo.user.UserVO;
import com.cultural.heritage.service.user.UserService; import com.cultural.heritage.service.user.UserService;
import com.cultural.heritage.utils.RegexUtils;
import com.cultural.heritage.utils.SqlUtils; import com.cultural.heritage.utils.SqlUtils;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSession;
@ -80,6 +81,23 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
} }
@Override
public void validUser(User user, boolean update) {
String userAccount = user.getUserAccount();
String userPassword = user.getUserPassword();
String userName = user.getUserName();
String userAvatar = user.getUserAvatar();
String phone = user.getPhone();
String userRole = user.getUserRole();
Long id = user.getId();
ThrowUtils.throwIf(update && id == null, ErrorCode.OPERATION_ERROR, "id字段为null");
if (StringUtils.isAnyBlank(userAccount, userPassword, userName, userAvatar, phone, userRole)) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "存在参数为空");
}
ThrowUtils.throwIf(!RegexUtils.isPhoneInvalid(phone), ErrorCode.OPERATION_ERROR, "手机号格式错误");
}
@Override @Override
public boolean userLogout(HttpServletRequest request) { public boolean userLogout(HttpServletRequest request) {
HttpSession session = request.getSession(); HttpSession session = request.getSession();