feat: 添加用户、角色服务和验证工具类
新增用户服务实现类UsersServiceImpl,包含用户CRUD操作 新增角色服务实现类RolesServiceImpl,包含角色管理功能 新增验证工具类ValidateUtil,提供参数验证功能 更新所有实体类添加@Builder注解 更新所有Mapper接口添加selectInfo和updateInfo方法 更新application.properties添加server.port配置 修复OrdersServiceImpl中Logger使用问题 添加updateInfo方法使用文档
This commit is contained in:
145
doc/updateInfo方法使用模板.md
Normal file
145
doc/updateInfo方法使用模板.md
Normal file
@@ -0,0 +1,145 @@
|
||||
# UsersMapper.updateInfo 方法使用模板
|
||||
|
||||
本文档提供了如何使用 `UsersMapper` 接口中的 `updateInfo` 方法的示例模板,该方法支持使用 `UpdateWrapper` 构建灵活的更新条件。
|
||||
|
||||
## 方法签名
|
||||
|
||||
```java
|
||||
/**
|
||||
* 更新用户信息
|
||||
* @param users 用户信息
|
||||
* @param updateWrapper 更新条件包装器
|
||||
* @return 是否成功
|
||||
*/
|
||||
int updateInfo(Users users, UpdateWrapper<Users> updateWrapper);
|
||||
```
|
||||
|
||||
## 示例代码
|
||||
|
||||
以下是在 Service 层中使用该方法的完整示例:
|
||||
|
||||
```java
|
||||
package com.qf.backend.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.qf.backend.entity.Users;
|
||||
import com.qf.backend.mapper.UsersMapper;
|
||||
import com.qf.backend.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
@Autowired
|
||||
private UsersMapper usersMapper;
|
||||
|
||||
/**
|
||||
* 更新用户信息示例
|
||||
* @param userId 用户ID
|
||||
* @param newNickname 新昵称
|
||||
* @param newEmail 新邮箱
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
public boolean updateUserInfo(Long userId, String newNickname, String newEmail) {
|
||||
// 1. 创建用户对象,设置要更新的字段
|
||||
Users users = new Users();
|
||||
users.setNickname(newNickname); // 设置要更新的昵称
|
||||
users.setEmail(newEmail); // 设置要更新的邮箱
|
||||
|
||||
// 2. 创建UpdateWrapper,构建更新条件
|
||||
UpdateWrapper<Users> updateWrapper = new UpdateWrapper<>();
|
||||
// 根据用户ID更新
|
||||
updateWrapper.eq("id", userId);
|
||||
// 可以添加额外的条件(如状态检查)
|
||||
updateWrapper.eq("status", 1); // 仅当用户状态为1(正常)时更新
|
||||
|
||||
// 3. 调用updateInfo方法执行更新
|
||||
int result = usersMapper.updateInfo(users, updateWrapper);
|
||||
|
||||
// 4. 返回更新结果(result > 0 表示更新成功)
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户名更新用户信息示例
|
||||
* @param username 用户名
|
||||
* @param newAvatar 新头像URL
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
public boolean updateUserAvatarByUsername(String username, String newAvatar) {
|
||||
// 1. 创建用户对象,设置要更新的字段
|
||||
Users users = new Users();
|
||||
users.setAvatar(newAvatar); // 设置要更新的头像URL
|
||||
|
||||
// 2. 创建UpdateWrapper,构建更新条件
|
||||
UpdateWrapper<Users> updateWrapper = new UpdateWrapper<>();
|
||||
// 根据用户名更新
|
||||
updateWrapper.eq("username", username);
|
||||
|
||||
// 3. 调用updateInfo方法执行更新
|
||||
int result = usersMapper.updateInfo(users, updateWrapper);
|
||||
|
||||
// 4. 返回更新结果
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 复杂条件更新示例
|
||||
* @param userIds 用户ID列表
|
||||
* @param newPhone 新手机号
|
||||
* @param newGender 新性别
|
||||
* @return 更新的用户数量
|
||||
*/
|
||||
public int batchUpdateUserInfo(List<Long> userIds, String newPhone, Integer newGender) {
|
||||
// 1. 创建用户对象,设置要更新的字段
|
||||
Users users = new Users();
|
||||
users.setPhone(newPhone); // 设置要更新的手机号
|
||||
users.setGender(newGender); // 设置要更新的性别
|
||||
|
||||
// 2. 创建UpdateWrapper,构建复杂更新条件
|
||||
UpdateWrapper<Users> updateWrapper = new UpdateWrapper<>();
|
||||
// 使用in条件,更新多个用户
|
||||
updateWrapper.in("id", userIds);
|
||||
// 添加额外条件
|
||||
updateWrapper.gt("create_time", "2023-01-01"); // 只更新2023年之后创建的用户
|
||||
updateWrapper.isNotNull("email"); // 只更新有邮箱的用户
|
||||
|
||||
// 3. 调用updateInfo方法执行更新
|
||||
return usersMapper.updateInfo(users, updateWrapper);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 使用说明
|
||||
|
||||
1. **创建Users对象**:只需要设置你想要更新的字段,不需要设置所有字段。
|
||||
|
||||
2. **构建UpdateWrapper**:
|
||||
- `eq(column, value)`:等于条件
|
||||
- `ne(column, value)`:不等于条件
|
||||
- `gt(column, value)`:大于条件
|
||||
- `ge(column, value)`:大于等于条件
|
||||
- `lt(column, value)`:小于条件
|
||||
- `le(column, value)`:小于等于条件
|
||||
- `in(column, values)`:IN条件,用于更新多条记录
|
||||
- `isNull(column)` / `isNotNull(column)`:NULL值判断
|
||||
- 可以链式调用多个条件
|
||||
|
||||
3. **返回值处理**:
|
||||
- 返回值表示更新操作影响的行数
|
||||
- 通常 `result > 0` 表示更新成功
|
||||
- 对于批量更新,可以直接使用返回值获取更新的记录数
|
||||
|
||||
4. **注意事项**:
|
||||
- 确保Users对象中设置了需要更新的字段
|
||||
- UpdateWrapper中的条件必须正确,避免更新到不应该更新的数据
|
||||
- 对于敏感信息更新,建议在调用前进行权限校验
|
||||
|
||||
## 常见错误
|
||||
|
||||
1. **忘记设置更新字段**:确保在Users对象中设置了需要更新的字段值
|
||||
2. **条件过于宽松**:避免使用没有限制条件的UpdateWrapper,这可能导致更新所有记录
|
||||
3. **字段名错误**:确保UpdateWrapper中使用的列名与数据库表中的列名一致
|
||||
|
||||
通过使用UpdateWrapper,你可以灵活地构建各种更新条件,而不需要编写复杂的SQL语句,同时也提高了代码的可读性和可维护性。
|
||||
@@ -7,12 +7,14 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 订单商品项表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("order_items")
|
||||
public class OrderItems {
|
||||
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 订单状态历史表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("order_status_history")
|
||||
public class OrderStatusHistory {
|
||||
|
||||
|
||||
@@ -7,12 +7,14 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 订单主表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("orders")
|
||||
public class Orders {
|
||||
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 支付信息表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("payments")
|
||||
public class Payments {
|
||||
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 权限信息表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("permissions")
|
||||
public class Permissions {
|
||||
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商品属性值表
|
||||
*/
|
||||
@Data
|
||||
|
||||
@Builder
|
||||
@TableName("product_attribute_values")
|
||||
public class ProductAttributeValues {
|
||||
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商品属性表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("product_attributes")
|
||||
public class ProductAttributes {
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.qf.backend.entity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -10,6 +12,8 @@ import java.util.Date;
|
||||
* 商品分类表
|
||||
*/
|
||||
@Data
|
||||
|
||||
@Builder
|
||||
@TableName("product_categories")
|
||||
public class ProductCategories {
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.qf.backend.entity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -10,6 +12,8 @@ import java.util.Date;
|
||||
* 商品图片表
|
||||
*/
|
||||
@Data
|
||||
|
||||
@Builder
|
||||
@TableName("product_images")
|
||||
public class ProductImages {
|
||||
|
||||
|
||||
@@ -6,12 +6,15 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 库存信息表
|
||||
*/
|
||||
@Data
|
||||
|
||||
@Builder
|
||||
@TableName("product_inventories")
|
||||
public class ProductInventories {
|
||||
|
||||
|
||||
@@ -7,12 +7,15 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商品SKU表
|
||||
*/
|
||||
@Data
|
||||
|
||||
@Builder
|
||||
@TableName("product_skus")
|
||||
public class ProductSkus {
|
||||
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商品基本信息表
|
||||
*/
|
||||
@Data
|
||||
|
||||
@Builder
|
||||
@TableName("products")
|
||||
public class Products {
|
||||
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 退款信息表
|
||||
*/
|
||||
@Data
|
||||
|
||||
@Builder
|
||||
@TableName("refunds")
|
||||
public class Refunds {
|
||||
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 角色-权限关联表
|
||||
*/
|
||||
@Data
|
||||
|
||||
@Builder
|
||||
@TableName("role_permissions")
|
||||
public class RolePermissions {
|
||||
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 角色信息表
|
||||
*/
|
||||
@Data
|
||||
|
||||
@Builder
|
||||
@TableName("roles")
|
||||
public class Roles {
|
||||
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店铺分类表
|
||||
*/
|
||||
@Data
|
||||
|
||||
@Builder
|
||||
@TableName("shop_categories")
|
||||
public class ShopCategories {
|
||||
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店铺评分表
|
||||
*/
|
||||
@Data
|
||||
|
||||
@Builder
|
||||
@TableName("shop_ratings")
|
||||
public class ShopRatings {
|
||||
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店铺信息表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("shops")
|
||||
public class Shops {
|
||||
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户详细信息表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("user_details")
|
||||
public class UserDetails {
|
||||
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package com.qf.backend.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户-角色关联表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("user_roles")
|
||||
public class UserRoles {
|
||||
|
||||
|
||||
@@ -6,12 +6,14 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户基本信息表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("users")
|
||||
public class Users {
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.OrderItems;
|
||||
|
||||
@@ -27,4 +28,20 @@ public interface OrderItemsMapper extends BaseMapper<OrderItems> {
|
||||
*/
|
||||
@Select("select * from order_items where product_id = #{productId}")
|
||||
List<OrderItems> selectByProductId(Long productId);
|
||||
|
||||
/**
|
||||
* 查询订单项信息
|
||||
* @param orderItems 订单项对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 订单项对象
|
||||
*/
|
||||
OrderItems selectInfo(OrderItems orderItems, QueryWrapper<OrderItems> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新订单项信息
|
||||
* @param orderItems 订单项对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(OrderItems orderItems, UpdateWrapper<OrderItems> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.OrderStatusHistory;
|
||||
|
||||
@@ -7,4 +9,19 @@ import com.qf.backend.entity.OrderStatusHistory;
|
||||
* 订单状态历史表 Mapper 接口
|
||||
*/
|
||||
public interface OrderStatusHistoryMapper extends BaseMapper<OrderStatusHistory> {
|
||||
/**
|
||||
* 查询订单状态历史信息
|
||||
* @param orderStatusHistory 订单状态历史对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 订单状态历史对象
|
||||
*/
|
||||
OrderStatusHistory selectInfo(OrderStatusHistory orderStatusHistory, QueryWrapper<OrderStatusHistory> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新订单状态历史信息
|
||||
* @param orderStatusHistory 订单状态历史对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(OrderStatusHistory orderStatusHistory, UpdateWrapper<OrderStatusHistory> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,30 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Orders;
|
||||
|
||||
/**
|
||||
* 订单主表 Mapper 接口
|
||||
* 订单信息表 Mapper 接口
|
||||
*/
|
||||
public interface OrdersMapper extends BaseMapper<Orders> {
|
||||
/**
|
||||
* 查询订单信息
|
||||
* @param orders 订单对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 订单对象
|
||||
*/
|
||||
Orders selectInfo(Orders orders, QueryWrapper<Orders> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新订单信息
|
||||
* @param orders 订单对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(Orders orders, UpdateWrapper<Orders> updateWrapper);
|
||||
|
||||
/**
|
||||
* 根据订单号查询订单
|
||||
* @param orderNumber 订单号
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Payments;
|
||||
|
||||
/**
|
||||
* 支付信息表 Mapper 接口
|
||||
* 支付记录表 Mapper 接口
|
||||
*/
|
||||
public interface PaymentsMapper extends BaseMapper<Payments> {
|
||||
/**
|
||||
* 查询支付记录信息
|
||||
* @param payments 支付记录对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 支付记录对象
|
||||
*/
|
||||
Payments selectInfo(Payments payments, QueryWrapper<Payments> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新支付记录信息
|
||||
* @param payments 支付记录对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(Payments payments, UpdateWrapper<Payments> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Permissions;
|
||||
|
||||
@@ -7,4 +9,19 @@ import com.qf.backend.entity.Permissions;
|
||||
* 权限信息表 Mapper 接口
|
||||
*/
|
||||
public interface PermissionsMapper extends BaseMapper<Permissions> {
|
||||
/**
|
||||
* 查询权限信息
|
||||
* @param permissions 权限对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 权限对象
|
||||
*/
|
||||
Permissions selectInfo(Permissions permissions, QueryWrapper<Permissions> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新权限信息
|
||||
* @param permissions 权限对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(Permissions permissions, UpdateWrapper<Permissions> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ProductAttributeValues;
|
||||
|
||||
@@ -7,4 +9,19 @@ import com.qf.backend.entity.ProductAttributeValues;
|
||||
* 商品属性值表 Mapper 接口
|
||||
*/
|
||||
public interface ProductAttributeValuesMapper extends BaseMapper<ProductAttributeValues> {
|
||||
/**
|
||||
* 查询商品属性值信息
|
||||
* @param productAttributeValues 商品属性值对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 商品属性值对象
|
||||
*/
|
||||
ProductAttributeValues selectInfo(ProductAttributeValues productAttributeValues, QueryWrapper<ProductAttributeValues> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新商品属性值信息
|
||||
* @param productAttributeValues 商品属性值对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(ProductAttributeValues productAttributeValues, UpdateWrapper<ProductAttributeValues> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ProductAttributes;
|
||||
|
||||
@@ -7,4 +9,19 @@ import com.qf.backend.entity.ProductAttributes;
|
||||
* 商品属性表 Mapper 接口
|
||||
*/
|
||||
public interface ProductAttributesMapper extends BaseMapper<ProductAttributes> {
|
||||
/**
|
||||
* 查询商品属性信息
|
||||
* @param productAttributes 商品属性对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 商品属性对象
|
||||
*/
|
||||
ProductAttributes selectInfo(ProductAttributes productAttributes, QueryWrapper<ProductAttributes> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新商品属性信息
|
||||
* @param productAttributes 商品属性对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(ProductAttributes productAttributes, UpdateWrapper<ProductAttributes> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ProductCategories;
|
||||
|
||||
@@ -7,4 +9,19 @@ import com.qf.backend.entity.ProductCategories;
|
||||
* 商品分类表 Mapper 接口
|
||||
*/
|
||||
public interface ProductCategoriesMapper extends BaseMapper<ProductCategories> {
|
||||
/**
|
||||
* 查询商品分类信息
|
||||
* @param productCategories 商品分类对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 商品分类对象
|
||||
*/
|
||||
ProductCategories selectInfo(ProductCategories productCategories, QueryWrapper<ProductCategories> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新商品分类信息
|
||||
* @param productCategories 商品分类对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(ProductCategories productCategories, UpdateWrapper<ProductCategories> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ProductImages;
|
||||
|
||||
@@ -7,4 +9,19 @@ import com.qf.backend.entity.ProductImages;
|
||||
* 商品图片表 Mapper 接口
|
||||
*/
|
||||
public interface ProductImagesMapper extends BaseMapper<ProductImages> {
|
||||
/**
|
||||
* 查询商品图片信息
|
||||
* @param productImages 商品图片对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 商品图片对象
|
||||
*/
|
||||
ProductImages selectInfo(ProductImages productImages, QueryWrapper<ProductImages> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新商品图片信息
|
||||
* @param productImages 商品图片对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(ProductImages productImages, UpdateWrapper<ProductImages> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ProductInventories;
|
||||
|
||||
/**
|
||||
* 库存信息表 Mapper 接口
|
||||
* 商品库存表 Mapper 接口
|
||||
*/
|
||||
public interface ProductInventoriesMapper extends BaseMapper<ProductInventories> {
|
||||
/**
|
||||
* 查询商品库存信息
|
||||
* @param productInventories 商品库存对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 商品库存对象
|
||||
*/
|
||||
ProductInventories selectInfo(ProductInventories productInventories, QueryWrapper<ProductInventories> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新商品库存信息
|
||||
* @param productInventories 商品库存对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(ProductInventories productInventories, UpdateWrapper<ProductInventories> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ProductSkus;
|
||||
|
||||
@@ -7,4 +9,19 @@ import com.qf.backend.entity.ProductSkus;
|
||||
* 商品SKU表 Mapper 接口
|
||||
*/
|
||||
public interface ProductSkusMapper extends BaseMapper<ProductSkus> {
|
||||
/**
|
||||
* 查询商品SKU信息
|
||||
* @param productSkus 商品SKU对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 商品SKU对象
|
||||
*/
|
||||
ProductSkus selectInfo(ProductSkus productSkus, QueryWrapper<ProductSkus> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新商品SKU信息
|
||||
* @param productSkus 商品SKU对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(ProductSkus productSkus, UpdateWrapper<ProductSkus> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Products;
|
||||
|
||||
/**
|
||||
* 商品基本信息表 Mapper 接口
|
||||
* 商品信息表 Mapper 接口
|
||||
*/
|
||||
public interface ProductsMapper extends BaseMapper<Products> {
|
||||
/**
|
||||
* 查询商品信息
|
||||
* @param products 商品对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 商品对象
|
||||
*/
|
||||
Products selectInfo(Products products, QueryWrapper<Products> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新商品信息
|
||||
* @param products 商品对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(Products products, UpdateWrapper<Products> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Refunds;
|
||||
|
||||
/**
|
||||
* 退款信息表 Mapper 接口
|
||||
* 退款记录表 Mapper 接口
|
||||
*/
|
||||
public interface RefundsMapper extends BaseMapper<Refunds> {
|
||||
/**
|
||||
* 查询退款记录信息
|
||||
* @param refunds 退款记录对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 退款记录对象
|
||||
*/
|
||||
Refunds selectInfo(Refunds refunds, QueryWrapper<Refunds> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新退款记录信息
|
||||
* @param refunds 退款记录对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(Refunds refunds, UpdateWrapper<Refunds> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.RolePermissions;
|
||||
|
||||
/**
|
||||
* 角色-权限关联表 Mapper 接口
|
||||
* 角色权限关联表 Mapper 接口
|
||||
*/
|
||||
public interface RolePermissionsMapper extends BaseMapper<RolePermissions> {
|
||||
/**
|
||||
* 查询角色权限关联信息
|
||||
* @param rolePermissions 角色权限关联对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 角色权限关联对象
|
||||
*/
|
||||
RolePermissions selectInfo(RolePermissions rolePermissions, QueryWrapper<RolePermissions> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新角色权限关联信息
|
||||
* @param rolePermissions 角色权限关联对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(RolePermissions rolePermissions, UpdateWrapper<RolePermissions> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Roles;
|
||||
|
||||
@@ -7,4 +9,18 @@ import com.qf.backend.entity.Roles;
|
||||
* 角色信息表 Mapper 接口
|
||||
*/
|
||||
public interface RolesMapper extends BaseMapper<Roles> {
|
||||
/**
|
||||
* 查询角色信息
|
||||
* @param roles 角色对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 角色对象
|
||||
*/
|
||||
Roles selectInfo(Roles roles, QueryWrapper<Roles> queryWrapper);
|
||||
/**
|
||||
* 更新角色信息
|
||||
* @param roles 角色对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(Roles roles, UpdateWrapper<Roles> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ShopCategories;
|
||||
|
||||
@@ -7,4 +9,19 @@ import com.qf.backend.entity.ShopCategories;
|
||||
* 店铺分类表 Mapper 接口
|
||||
*/
|
||||
public interface ShopCategoriesMapper extends BaseMapper<ShopCategories> {
|
||||
/**
|
||||
* 查询店铺分类信息
|
||||
* @param shopCategories 店铺分类对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 店铺分类对象
|
||||
*/
|
||||
ShopCategories selectInfo(ShopCategories shopCategories, QueryWrapper<ShopCategories> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新店铺分类信息
|
||||
* @param shopCategories 店铺分类对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(ShopCategories shopCategories, UpdateWrapper<ShopCategories> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.ShopRatings;
|
||||
|
||||
/**
|
||||
* 店铺评分表 Mapper 接口
|
||||
* 店铺评价表 Mapper 接口
|
||||
*/
|
||||
public interface ShopRatingsMapper extends BaseMapper<ShopRatings> {
|
||||
/**
|
||||
* 查询店铺评价信息
|
||||
* @param shopRatings 店铺评价对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 店铺评价对象
|
||||
*/
|
||||
ShopRatings selectInfo(ShopRatings shopRatings, QueryWrapper<ShopRatings> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新店铺评价信息
|
||||
* @param shopRatings 店铺评价对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(ShopRatings shopRatings, UpdateWrapper<ShopRatings> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Shops;
|
||||
|
||||
@@ -7,4 +9,19 @@ import com.qf.backend.entity.Shops;
|
||||
* 店铺信息表 Mapper 接口
|
||||
*/
|
||||
public interface ShopsMapper extends BaseMapper<Shops> {
|
||||
/**
|
||||
* 查询店铺信息
|
||||
* @param shops 店铺对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 店铺对象
|
||||
*/
|
||||
Shops selectInfo(Shops shops, QueryWrapper<Shops> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新店铺信息
|
||||
* @param shops 店铺对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(Shops shops, UpdateWrapper<Shops> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.UserDetails;
|
||||
|
||||
@@ -7,4 +9,19 @@ import com.qf.backend.entity.UserDetails;
|
||||
* 用户详细信息表 Mapper 接口
|
||||
*/
|
||||
public interface UserDetailsMapper extends BaseMapper<UserDetails> {
|
||||
/**
|
||||
* 查询用户详情信息
|
||||
* @param userDetails 用户详情对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 用户详情对象
|
||||
*/
|
||||
UserDetails selectInfo(UserDetails userDetails, QueryWrapper<UserDetails> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新用户详情信息
|
||||
* @param userDetails 用户详情对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(UserDetails userDetails, UpdateWrapper<UserDetails> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.UserRoles;
|
||||
|
||||
/**
|
||||
* 用户-角色关联表 Mapper 接口
|
||||
* 用户角色关联表 Mapper 接口
|
||||
*/
|
||||
public interface UserRolesMapper extends BaseMapper<UserRoles> {
|
||||
/**
|
||||
* 查询用户角色关联信息
|
||||
* @param userRoles 用户角色关联对象
|
||||
* @param queryWrapper 查询包装器
|
||||
* @return 用户角色关联对象
|
||||
*/
|
||||
UserRoles selectInfo(UserRoles userRoles, QueryWrapper<UserRoles> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新用户角色关联信息
|
||||
* @param userRoles 用户角色关联对象
|
||||
* @param updateWrapper 更新包装器
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateInfo(UserRoles userRoles, UpdateWrapper<UserRoles> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.qf.backend.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qf.backend.entity.Users;
|
||||
|
||||
@@ -7,4 +11,41 @@ import com.qf.backend.entity.Users;
|
||||
* 用户基本信息表 Mapper 接口
|
||||
*/
|
||||
public interface UsersMapper extends BaseMapper<Users> {
|
||||
/**
|
||||
* 根据用户名查询用户
|
||||
* @param username 用户名
|
||||
* @return 用户对象
|
||||
*/
|
||||
@Select("select * from users where username = #{username}")
|
||||
Users selectByUsername(String username);
|
||||
/**
|
||||
* 根据邮箱查询用户
|
||||
* @param email 邮箱
|
||||
* @return 用户对象
|
||||
*/
|
||||
@Select("select * from Users where email = #{email}")
|
||||
Users selectByEmail(String email);
|
||||
/**
|
||||
* 根据手机号查询用户
|
||||
* @param phone 手机号
|
||||
* @return 用户对象
|
||||
*/
|
||||
@Select("select * from Users where phone = #{phone}")
|
||||
Users selectByPhone(String phone);
|
||||
|
||||
/**
|
||||
* 查询用户信息
|
||||
* @param users 用户信息
|
||||
* @param queryWrapper 查询条件包装器
|
||||
* @return 用户对象
|
||||
*/
|
||||
Users selectInfo(Users users, QueryWrapper<Users> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
* @param users 用户信息
|
||||
* @param updateWrapper 更新条件包装器
|
||||
* @return 是否成功
|
||||
*/
|
||||
int updateInfo(Users users, UpdateWrapper<Users> updateWrapper);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.qf.backend.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -13,14 +15,11 @@ import com.qf.backend.exception.ErrorCode;
|
||||
import com.qf.backend.mapper.OrdersMapper;
|
||||
import com.qf.backend.service.OrdersService;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
|
||||
@Service
|
||||
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements OrdersService {
|
||||
@Autowired
|
||||
private OrdersMapper ordersMapper;
|
||||
@Autowired
|
||||
private Logger logger;
|
||||
private Logger logger = LoggerFactory.getLogger(OrdersServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public Result<Orders> getOrderByNumber(String orderNumber) {
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
|
||||
package com.qf.backend.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.qf.backend.entity.Roles;
|
||||
import com.qf.backend.mapper.RolesMapper;
|
||||
import com.qf.backend.service.RolesService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 30803
|
||||
*/
|
||||
@Service
|
||||
public class RolesServiceImpl extends ServiceImpl<RolesMapper, Roles> implements RolesService {
|
||||
|
||||
@Autowired
|
||||
private RolesMapper rolesMapper;
|
||||
|
||||
// 根据角色名称查询角色
|
||||
@Override
|
||||
public Roles getRoleByName(String roleName) {
|
||||
try {
|
||||
if (roleName == null) {
|
||||
return null;
|
||||
}
|
||||
Roles roles = rolesMapper.selectOne(new QueryWrapper<Roles>().eq("role_name", roleName));
|
||||
if (roles == null) {
|
||||
return null;
|
||||
}
|
||||
return roles;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询所有角色
|
||||
@Override
|
||||
public List<Roles> listAllRoles() {
|
||||
|
||||
throw new UnsupportedOperationException("Unimplemented method 'listAllRoles'");
|
||||
}
|
||||
// 根据ID查询角色
|
||||
@Override
|
||||
public Roles getRoleById(Long id) {
|
||||
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getRoleById'");
|
||||
}
|
||||
// 根据用户ID查询角色
|
||||
@Override
|
||||
public List<Roles> listRolesByUserId(Long userId) {
|
||||
|
||||
throw new UnsupportedOperationException("Unimplemented method 'listRolesByUserId'");
|
||||
}
|
||||
// 创建角色
|
||||
@Override
|
||||
public boolean createRole(Roles roles) {
|
||||
|
||||
throw new UnsupportedOperationException("Unimplemented method 'createRole'");
|
||||
}
|
||||
// 更新角色
|
||||
@Override
|
||||
public boolean updateRole(Roles roles) {
|
||||
|
||||
throw new UnsupportedOperationException("Unimplemented method 'updateRole'");
|
||||
}
|
||||
// 批量删除角色
|
||||
@Override
|
||||
public boolean batchDeleteRoles(List<Long> ids) {
|
||||
|
||||
throw new UnsupportedOperationException("Unimplemented method 'batchDeleteRoles'");
|
||||
}
|
||||
// 删除角色
|
||||
@Override
|
||||
public boolean deleteRole(Long id) {
|
||||
|
||||
throw new UnsupportedOperationException("Unimplemented method 'deleteRole'");
|
||||
}
|
||||
}
|
||||
244
src/main/java/com/qf/backend/service/impl/UsersServiceImpl.java
Normal file
244
src/main/java/com/qf/backend/service/impl/UsersServiceImpl.java
Normal file
@@ -0,0 +1,244 @@
|
||||
package com.qf.backend.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.qf.backend.common.Result;
|
||||
import com.qf.backend.common.ResultUtils;
|
||||
import com.qf.backend.entity.Users;
|
||||
import com.qf.backend.exception.ErrorCode;
|
||||
import com.qf.backend.mapper.UsersMapper;
|
||||
import com.qf.backend.service.UsersService;
|
||||
|
||||
@Service
|
||||
public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements UsersService {
|
||||
|
||||
@Autowired
|
||||
private UsersMapper usersMapper;
|
||||
|
||||
// 根据用户名查询用户
|
||||
@Override
|
||||
public Result<Users> getUserByUsername(String username) {
|
||||
|
||||
try {
|
||||
if (username == null || username.isEmpty()) {
|
||||
return ResultUtils.fail(ErrorCode.INVALID_PARAM);
|
||||
}
|
||||
Users users = usersMapper.selectByUsername(username);
|
||||
if (users == null) {
|
||||
return ResultUtils.fail(ErrorCode.USER_NOT_FOUND);
|
||||
}
|
||||
return ResultUtils.success(users);
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.fail(ErrorCode.DATABASE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// 根据邮箱查询用户
|
||||
@Override
|
||||
public Result<Users> getUserByEmail(String email) {
|
||||
|
||||
try {
|
||||
if (email == null || email.isEmpty()) {
|
||||
return ResultUtils.fail(ErrorCode.INVALID_PARAM);
|
||||
}
|
||||
Users users = usersMapper.selectByEmail(email);
|
||||
if (users == null) {
|
||||
return ResultUtils.fail(ErrorCode.USER_NOT_FOUND);
|
||||
}
|
||||
return ResultUtils.success(users);
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.fail(ErrorCode.DATABASE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
//创建用户
|
||||
@Override
|
||||
public Result<Boolean> createUser(Users users) {
|
||||
|
||||
try {
|
||||
// 调用封装的验证方法
|
||||
Result<Boolean> validationResult = validateUserBeforeCreate(users);
|
||||
if (validationResult != null) {
|
||||
return validationResult;
|
||||
}
|
||||
// 加密密码
|
||||
users.setPassword(new BCryptPasswordEncoder().encode(users.getPassword()));
|
||||
int result = usersMapper.insert(users);
|
||||
if (result <= 0) {
|
||||
return ResultUtils.fail(ErrorCode.DATABASE_ERROR);
|
||||
}
|
||||
return ResultUtils.success();
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.fail(ErrorCode.DATABASE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新用户信息
|
||||
@Override
|
||||
public Result<Boolean> updateUser(Users users) {
|
||||
|
||||
try {
|
||||
// 调用封装的验证方法
|
||||
Result<Boolean> validationResult = validateUserBeforeCreate(users);
|
||||
if (validationResult != null) {
|
||||
return validationResult;
|
||||
}
|
||||
// 更新用户信息
|
||||
int result = usersMapper.updateInfo(users, new UpdateWrapper<Users>().set("username", users.getUsername()).set("email", users.getEmail()).set("phone", users.getPhone()).set("avatar", users.getAvatar()).eq("id", users.getId()));
|
||||
if (result <= 0) {
|
||||
return ResultUtils.fail(ErrorCode.DATABASE_ERROR);
|
||||
}
|
||||
return ResultUtils.success();
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.fail(ErrorCode.DATABASE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
@Override
|
||||
public Result<Boolean> deleteUser(Long id) {
|
||||
|
||||
try {
|
||||
if (id == null) {
|
||||
return ResultUtils.fail(ErrorCode.MISSING_PARAM);
|
||||
}
|
||||
// 检查用户是否存在
|
||||
Users users = getUserByIdAndCheckExist(id);
|
||||
if (users == null) {
|
||||
return ResultUtils.fail(ErrorCode.USER_NOT_FOUND);
|
||||
}
|
||||
int result = usersMapper.deleteById(id);
|
||||
if (result <= 0) {
|
||||
return ResultUtils.fail(ErrorCode.DATABASE_ERROR);
|
||||
}
|
||||
return ResultUtils.success();
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.fail(ErrorCode.DATABASE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// 查询所有用户
|
||||
@Override
|
||||
public Result<List<Users>> listAllUsers() {
|
||||
|
||||
try {
|
||||
List<Users> usersList = usersMapper.selectList(null);
|
||||
if (usersList == null || usersList.isEmpty()) {
|
||||
return ResultUtils.fail(ErrorCode.NOT_FOUND);
|
||||
}
|
||||
return ResultUtils.success(usersList);
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.fail(ErrorCode.DATABASE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// 分页查询用户
|
||||
@Override
|
||||
public Result<List<Users>> listUsersByPage(int page, int size) {
|
||||
|
||||
throw new UnsupportedOperationException("Unimplemented method 'listUsersByPage'");
|
||||
}
|
||||
|
||||
// 根据ID查询用户
|
||||
@Override
|
||||
public Result<Users> getUserById(Long id) {
|
||||
|
||||
try {
|
||||
if (id == null) {
|
||||
return ResultUtils.fail(ErrorCode.MISSING_PARAM);
|
||||
}
|
||||
Users users = getUserByIdAndCheckExist(id);
|
||||
if (users == null) {
|
||||
return ResultUtils.fail(ErrorCode.USER_NOT_FOUND);
|
||||
}
|
||||
return ResultUtils.success(users);
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.fail(ErrorCode.DATABASE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新用户密码
|
||||
@Override
|
||||
public Result<Boolean> updatePassword(Long id, String newPassword) {
|
||||
|
||||
try {
|
||||
if (id == null || newPassword == null || newPassword.isEmpty()) {
|
||||
return ResultUtils.fail(ErrorCode.MISSING_PARAM);
|
||||
}
|
||||
Users users = getUserByIdAndCheckExist(id);
|
||||
if (users == null) {
|
||||
return ResultUtils.fail(ErrorCode.USER_NOT_FOUND);
|
||||
}
|
||||
// 加密新密码
|
||||
users.setPassword(new BCryptPasswordEncoder().encode(newPassword));
|
||||
// 更新密码
|
||||
int result = usersMapper.updateInfo(users, new UpdateWrapper<Users>().set("password", users.getPassword()).eq("id", id));
|
||||
if (result <= 0) {
|
||||
return ResultUtils.fail(ErrorCode.DATABASE_ERROR);
|
||||
}
|
||||
return ResultUtils.success();
|
||||
} catch (Exception e) {
|
||||
return ResultUtils.fail(ErrorCode.DATABASE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询用户并检查是否存在
|
||||
* @param id 用户ID
|
||||
* @return 用户对象,如果用户不存在则返回null
|
||||
*/
|
||||
private Users getUserByIdAndCheckExist(Long id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
QueryWrapper<Users> queryWrapper = new QueryWrapper<Users>().eq("id", id);
|
||||
return usersMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证用户信息是否合法且不存在重复
|
||||
*
|
||||
* @param users 用户对象
|
||||
* @return 验证失败时返回错误Result,验证成功时返回null
|
||||
*/
|
||||
private Result<Boolean> validateUserBeforeCreate(Users users) {
|
||||
// 检查用户对象是否为空
|
||||
if (users == null) {
|
||||
return ResultUtils.fail(ErrorCode.MISSING_PARAM);
|
||||
}
|
||||
// 检查必要字段是否为空
|
||||
if (users.getUsername() == null || users.getUsername().isEmpty()) {
|
||||
return ResultUtils.fail(ErrorCode.MISSING_PARAM);
|
||||
}
|
||||
if (users.getEmail() == null || users.getEmail().isEmpty()) {
|
||||
return ResultUtils.fail(ErrorCode.MISSING_PARAM);
|
||||
}
|
||||
if (users.getPassword() == null || users.getPassword().isEmpty()) {
|
||||
return ResultUtils.fail(ErrorCode.MISSING_PARAM);
|
||||
}
|
||||
// 检查用户名是否已存在
|
||||
Users existingUserByUsername = usersMapper.selectByUsername(users.getUsername());
|
||||
if (existingUserByUsername != null) {
|
||||
return ResultUtils.fail(ErrorCode.USER_EXISTED);
|
||||
}
|
||||
// 检查邮箱是否已存在
|
||||
Users existingUserByEmail = usersMapper.selectByEmail(users.getEmail());
|
||||
if (existingUserByEmail != null) {
|
||||
return ResultUtils.fail(ErrorCode.USER_EXISTED);
|
||||
}
|
||||
// 检查手机号是否已存在
|
||||
Users existingUserByPhone = usersMapper.selectByPhone(users.getPhone());
|
||||
if (existingUserByPhone != null) {
|
||||
return ResultUtils.fail(ErrorCode.USER_EXISTED);
|
||||
}
|
||||
return null; // 验证通过
|
||||
}
|
||||
|
||||
}
|
||||
136
src/main/java/com/qf/backend/util/ValidateUtil.java
Normal file
136
src/main/java/com/qf/backend/util/ValidateUtil.java
Normal file
@@ -0,0 +1,136 @@
|
||||
package com.qf.backend.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 参数验证工具类
|
||||
* 用于验证字符串是否为空,以及实体类中指定关键字的属性是否为空
|
||||
*/
|
||||
public class ValidateUtil {
|
||||
|
||||
private ValidateUtil() {
|
||||
// 私有构造方法,防止实例化
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查字符串是否为空
|
||||
* @param str 待检查的字符串
|
||||
* @return 如果字符串为null或空字符串或只包含空白字符,则返回true;否则返回false
|
||||
*/
|
||||
public static boolean isEmpty(String str) {
|
||||
return str == null || str.trim().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查字符串是否非空
|
||||
* @param str 待检查的字符串
|
||||
* @return 如果字符串不为null且不为空字符串且不只包含空白字符,则返回true;否则返回false
|
||||
*/
|
||||
public static boolean isNotEmpty(String str) {
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证字符串非空
|
||||
* @param str 待验证的字符串
|
||||
* @param paramName 参数名,用于错误提示
|
||||
* @throws IllegalArgumentException 如果字符串为空,则抛出异常
|
||||
*/
|
||||
public static void validateString(String str, String paramName) {
|
||||
if (isEmpty(str)) {
|
||||
throw new IllegalArgumentException(paramName + " cannot be empty or null");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证实体类中与关键字匹配的字符串属性是否为空
|
||||
* @param entity 实体对象
|
||||
* @param keywords 关键字数组,用于匹配属性名
|
||||
* @throws IllegalArgumentException 如果实体对象为null,或者匹配的属性值为空,则抛出异常
|
||||
* @throws IllegalAccessException 如果反射访问属性失败
|
||||
* @note 如果未提供关键字,则验证实体类中所有字符串属性都不为空
|
||||
* @note 如果提供了关键字,则验证实体类中与关键字匹配的字符串属性都不为空
|
||||
* @note 关键字匹配是不区分大小写的
|
||||
* @note 如果实体类中不存在与关键字匹配的字符串属性,则抛出异常
|
||||
* @note 如果实体类中存在多个与关键字匹配的字符串属性,只验证第一个匹配的属性
|
||||
* @note 如果实体类中存在与关键字匹配的非字符串属性,忽略该属性
|
||||
*/
|
||||
public static void validateEntity(Object entity, String... keywords) throws IllegalAccessException {
|
||||
if (entity == null) {
|
||||
throw new IllegalArgumentException("Entity cannot be null");
|
||||
}
|
||||
|
||||
if (keywords == null || keywords.length == 0) {
|
||||
// 如果没有提供关键字,则验证实体类中所有字符串属性都不为空
|
||||
for (Field field : entity.getClass().getDeclaredFields()) {
|
||||
// 设置字段可访问
|
||||
field.setAccessible(true);
|
||||
|
||||
// 检查字段是否为字符串类型
|
||||
if (field.getType() == String.class) {
|
||||
String fieldValue = (String) field.get(entity);
|
||||
if (isEmpty(fieldValue)) {
|
||||
throw new IllegalArgumentException(field.getName() + " cannot be empty or null");
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 将关键字转换为小写,用于不区分大小写的匹配
|
||||
Set<String> keywordSet = new HashSet<>();
|
||||
for (String keyword : keywords) {
|
||||
if (isNotEmpty(keyword)) {
|
||||
keywordSet.add(keyword.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
// 获取实体类的所有字段,包括私有字段
|
||||
Class<?> clazz = entity.getClass();
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
|
||||
for (Field field : fields) {
|
||||
// 设置字段可访问
|
||||
field.setAccessible(true);
|
||||
|
||||
String fieldName = field.getName().toLowerCase();
|
||||
|
||||
// 检查字段名是否包含关键字
|
||||
for (String keyword : keywordSet) {
|
||||
if (fieldName.contains(keyword)) {
|
||||
// 如果是字符串类型,检查是否为空
|
||||
if (field.getType() == String.class) {
|
||||
String fieldValue = (String) field.get(entity);
|
||||
if (isEmpty(fieldValue)) {
|
||||
throw new IllegalArgumentException(field.getName() + " cannot be empty or null");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用参数验证方法
|
||||
* 如果是String类型,直接验证是否为空
|
||||
* 如果是实体类,验证其与关键字匹配的属性
|
||||
* @param param 参数对象
|
||||
* @param keywords 关键字数组
|
||||
* @throws IllegalArgumentException 验证失败时抛出异常
|
||||
* @throws IllegalAccessException 反射访问失败时抛出异常
|
||||
*/
|
||||
public static void validateParam(Object param, String... keywords) throws IllegalAccessException {
|
||||
if (param == null) {
|
||||
throw new IllegalArgumentException("Parameter cannot be null");
|
||||
}
|
||||
|
||||
if (param instanceof String) {
|
||||
validateString((String) param, "parameter");
|
||||
} else {
|
||||
validateEntity(param, keywords);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
spring.application.name=backend
|
||||
|
||||
server.port=7071
|
||||
# 数据库连接配置
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/TaoTaoWang?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true
|
||||
spring.datasource.username=root
|
||||
|
||||
Reference in New Issue
Block a user