用户模块

This commit is contained in:
chen-xin-zhi 2025-05-07 04:14:21 +08:00
parent e1b1bfc721
commit 6e0576df5b
42 changed files with 1882 additions and 96 deletions

View File

@ -68,10 +68,10 @@ public class PermissionCheck {
String userPassword = decodedJWT.getClaim("userPassword").asString();
// 将账号存入request用于记录日志
request.setAttribute("userAccount", userAccount);
// 打印token的过期时间
Date expiresAt = decodedJWT.getExpiresAt();
String formatExpiresAt = DateUtil.format(expiresAt, "yyyy-MM-dd HH:mm:ss");
log.info("Token过期时间为:" + formatExpiresAt);
// // 打印token的过期时间
// Date expiresAt = decodedJWT.getExpiresAt();
// String formatExpiresAt = DateUtil.format(expiresAt, "yyyy-MM-dd HH:mm:ss");
// log.info("Token过期时间为:" + formatExpiresAt);
LambdaQueryWrapper<UserInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UserInfo::getUserAccount, userAccount).eq(UserInfo::getUserPassword, userPassword);
UserInfo userInfo = userInfoService.getOne(lambdaQueryWrapper);

View File

@ -1,5 +1,6 @@
package com.greenorange.promotion.controller.project;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.greenorange.promotion.annotation.RequiresPermission;
import com.greenorange.promotion.annotation.SysLog;
@ -13,7 +14,9 @@ import com.greenorange.promotion.model.dto.project.ProjectAddRequest;
import com.greenorange.promotion.model.dto.project.ProjectQueryRequest;
import com.greenorange.promotion.model.dto.project.ProjectUpdateRequest;
import com.greenorange.promotion.model.entity.Project;
import com.greenorange.promotion.model.entity.ProjectNotification;
import com.greenorange.promotion.model.vo.project.ProjectVO;
import com.greenorange.promotion.model.vo.projectNotification.ProjectNotificationVO;
import com.greenorange.promotion.service.common.CommonService;
import com.greenorange.promotion.service.project.ProjectService;
import io.swagger.v3.oas.annotations.Operation;
@ -145,4 +148,6 @@ public class ProjectController {
voPage.setTotal(page.getTotal());
return ResultUtils.success(voPage);
}
}

View File

@ -0,0 +1,133 @@
package com.greenorange.promotion.controller.projectDetail;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.greenorange.promotion.annotation.RequiresPermission;
import com.greenorange.promotion.annotation.SysLog;
import com.greenorange.promotion.common.BaseResponse;
import com.greenorange.promotion.common.ErrorCode;
import com.greenorange.promotion.common.ResultUtils;
import com.greenorange.promotion.constant.UserConstant;
import com.greenorange.promotion.exception.ThrowUtils;
import com.greenorange.promotion.model.dto.CommonBatchRequest;
import com.greenorange.promotion.model.dto.projectDetail.ProjectDetailAddRequest;
import com.greenorange.promotion.model.dto.projectDetail.ProjectDetailQueryRequest;
import com.greenorange.promotion.model.dto.projectDetail.ProjectDetailUpdateRequest;
import com.greenorange.promotion.model.entity.ProjectDetail;
import com.greenorange.promotion.model.vo.projectDetail.ProjectDetailVO;
import com.greenorange.promotion.service.common.CommonService;
import com.greenorange.promotion.service.project.ProjectDetailService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.greenorange.promotion.model.dto.CommonRequest;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 项目明细 控制器
*/
@RestController
@RequestMapping("projectDetail")
@Slf4j
@Tag(name = "项目明细管理")
public class ProjectDetailController {
@Resource
private ProjectDetailService projectDetailService;
@Resource
private CommonService commonService;
/**
* web端管理员添加项目明细
* @param projectDetailAddRequest 项目明细添加请求体
* @return 是否添加成功
*/
@PostMapping("add")
@Operation(summary = "web端管理员添加项目明细", description = "参数项目明细添加请求体权限管理员方法名addProjectDetail")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目明细管理", content = "web端管理员添加项目明细")
public BaseResponse<Boolean> addProjectDetail(@Valid @RequestBody ProjectDetailAddRequest projectDetailAddRequest) {
ProjectDetail projectDetail = commonService.copyProperties(projectDetailAddRequest, ProjectDetail.class);
projectDetailService.save(projectDetail);
return ResultUtils.success(true);
}
/**
* web端管理员根据id修改项目明细信息
* @param projectDetailUpdateRequest 项目明细更新请求体
* @return 是否更新成功
*/
@PostMapping("update")
@Operation(summary = "web端管理员更新项目明细", description = "参数项目明细更新请求体权限管理员方法名updateProjectDetail")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目明细管理", content = "web端管理员根据id修改项目明细信息")
public BaseResponse<Boolean> updateProjectDetail(@Valid @RequestBody ProjectDetailUpdateRequest projectDetailUpdateRequest) {
ProjectDetail projectDetail = commonService.copyProperties(projectDetailUpdateRequest, ProjectDetail.class);
projectDetailService.updateById(projectDetail);
return ResultUtils.success(true);
}
/**
* web端管理员根据id删除项目明细
* @param commonRequest 项目明细删除请求体
* @return 是否删除成功
*/
@PostMapping("delete")
@Operation(summary = "web端管理员根据id删除项目明细", description = "参数项目明细删除请求体权限管理员方法名delProjectDetail")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目明细管理", content = "web端管理员根据id删除项目明细")
public BaseResponse<Boolean> delProjectDetail(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
projectDetailService.removeById(id);
return ResultUtils.success(true);
}
/**
* web端管理员根据id查询项目明细
* @param commonRequest 项目明细查询请求体
* @return 项目明细信息
*/
@PostMapping("queryById")
@Operation(summary = "web端管理员根据id查询项目明细", description = "参数项目明细查询请求体权限管理员方法名queryProjectDetailById")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目明细管理", content = "web端管理员根据id查询项目明细")
public BaseResponse<ProjectDetailVO> queryProjectDetailById(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
ProjectDetail projectDetail = projectDetailService.getById(id);
ThrowUtils.throwIf(projectDetail == null, ErrorCode.OPERATION_ERROR, "当前项目明细不存在");
ProjectDetailVO projectDetailVO = commonService.copyProperties(projectDetail, ProjectDetailVO.class);
return ResultUtils.success(projectDetailVO);
}
/**
* web端管理员根据项目id查询项目明细
* @param commonRequest 项目id
* @return 项目明细列表
*/
@PostMapping("query/pid")
@Operation(summary = "web端管理员根据项目id查询项目明细", description = "参数项目id权限管理员方法名queryProjectDetailByPid")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目明细管理", content = "web端管理员根据项目id查询项目明细")
public BaseResponse<List<ProjectDetailVO>> queryProjectDetailByPid(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
LambdaQueryWrapper<ProjectDetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ProjectDetail::getProjectId, id);
List<ProjectDetail> projectDetailList = projectDetailService.list(lambdaQueryWrapper);
List<ProjectDetailVO> projectDetailVOS = commonService.convertList(projectDetailList, ProjectDetailVO.class);
return ResultUtils.success(projectDetailVOS);
}
}

View File

@ -0,0 +1,133 @@
package com.greenorange.promotion.controller.projectNotification;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.greenorange.promotion.annotation.RequiresPermission;
import com.greenorange.promotion.annotation.SysLog;
import com.greenorange.promotion.common.BaseResponse;
import com.greenorange.promotion.common.ErrorCode;
import com.greenorange.promotion.common.ResultUtils;
import com.greenorange.promotion.constant.UserConstant;
import com.greenorange.promotion.exception.ThrowUtils;
import com.greenorange.promotion.model.dto.CommonBatchRequest;
import com.greenorange.promotion.model.dto.projectNotification.ProjectNotificationAddRequest;
import com.greenorange.promotion.model.dto.projectNotification.ProjectNotificationQueryRequest;
import com.greenorange.promotion.model.dto.projectNotification.ProjectNotificationUpdateRequest;
import com.greenorange.promotion.model.entity.ProjectNotification;
import com.greenorange.promotion.model.vo.projectNotification.ProjectNotificationVO;
import com.greenorange.promotion.service.common.CommonService;
import com.greenorange.promotion.service.project.ProjectNotificationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.greenorange.promotion.model.dto.CommonRequest;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 项目通知 控制器
*/
@RestController
@RequestMapping("projectNotification")
@Slf4j
@Tag(name = "项目通知管理")
public class ProjectNotificationController {
@Resource
private ProjectNotificationService projectNotificationService;
@Resource
private CommonService commonService;
/**
* web端管理员添加项目通知
* @param projectNotificationAddRequest 项目通知添加请求体
* @return 是否添加成功
*/
@PostMapping("add")
@Operation(summary = "web端管理员添加项目通知", description = "参数项目通知添加请求体权限管理员方法名addProjectNotification")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目通知管理", content = "web端管理员添加项目通知")
public BaseResponse<Boolean> addProjectNotification(@Valid @RequestBody ProjectNotificationAddRequest projectNotificationAddRequest) {
ProjectNotification projectNotification = commonService.copyProperties(projectNotificationAddRequest, ProjectNotification.class);
projectNotificationService.save(projectNotification);
return ResultUtils.success(true);
}
/**
* web端管理员根据id修改项目通知信息
* @param projectNotificationUpdateRequest 项目通知更新请求体
* @return 是否更新成功
*/
@PostMapping("update")
@Operation(summary = "web端管理员更新项目通知", description = "参数项目通知更新请求体权限管理员方法名updateProjectNotification")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目通知管理", content = "web端管理员根据id修改项目通知信息")
public BaseResponse<Boolean> updateProjectNotification(@Valid @RequestBody ProjectNotificationUpdateRequest projectNotificationUpdateRequest) {
ProjectNotification projectNotification = commonService.copyProperties(projectNotificationUpdateRequest, ProjectNotification.class);
projectNotificationService.updateById(projectNotification);
return ResultUtils.success(true);
}
/**
* web端管理员根据id删除项目通知
* @param commonRequest 项目通知删除请求体
* @return 是否删除成功
*/
@PostMapping("delete")
@Operation(summary = "web端管理员根据id删除项目通知", description = "参数项目通知删除请求体权限管理员方法名delProjectNotification")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目通知管理", content = "web端管理员根据id删除项目通知")
public BaseResponse<Boolean> delProjectNotification(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
projectNotificationService.removeById(id);
return ResultUtils.success(true);
}
/**
* web端管理员根据id查询项目通知
* @param commonRequest 项目通知查询请求体
* @return 项目通知信息
*/
@PostMapping("queryById")
@Operation(summary = "web端管理员根据id查询项目通知", description = "参数项目通知查询请求体权限管理员方法名queryProjectNotificationById")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目通知管理", content = "web端管理员根据id查询项目通知")
public BaseResponse<ProjectNotificationVO> queryProjectNotificationById(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
ProjectNotification projectNotification = projectNotificationService.getById(id);
ThrowUtils.throwIf(projectNotification == null, ErrorCode.OPERATION_ERROR, "当前项目通知不存在");
ProjectNotificationVO projectNotificationVO = commonService.copyProperties(projectNotification, ProjectNotificationVO.class);
return ResultUtils.success(projectNotificationVO);
}
/**
* web端管理员根据项目id查询项目通知
* @param commonRequest 项目id
* @return 项目通知列表
*/
@PostMapping("query/pid")
@Operation(summary = "web端管理员根据项目id查询项目通知", description = "参数项目id权限管理员方法名queryProjectNotificationByPid")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目通知管理", content = "web端管理员根据项目id查询项目通知")
public BaseResponse<List<ProjectNotificationVO>> queryProjectNotificationByPid(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
LambdaQueryWrapper<ProjectNotification> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ProjectNotification::getProjectId, id);
List<ProjectNotification> projectNotificationList = projectNotificationService.list(lambdaQueryWrapper);
List<ProjectNotificationVO> projectNotificationVOS = commonService.convertList(projectNotificationList, ProjectNotificationVO.class);
return ResultUtils.success(projectNotificationVOS);
}
}

View File

@ -1,6 +1,7 @@
package com.greenorange.promotion.controller.user;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.greenorange.promotion.annotation.RequiresPermission;
@ -16,15 +17,19 @@ import com.greenorange.promotion.model.dto.CommonRequest;
import com.greenorange.promotion.model.dto.CommonStringRequest;
import com.greenorange.promotion.model.dto.user.*;
import com.greenorange.promotion.model.entity.UserInfo;
import com.greenorange.promotion.model.entity.UserMainInfo;
import com.greenorange.promotion.model.vo.user.UserInfoVO;
import com.greenorange.promotion.model.vo.userMainInfo.UserMainInfoVO;
import com.greenorange.promotion.service.common.CommonService;
import com.greenorange.promotion.service.user.UserInfoService;
import com.greenorange.promotion.service.user.UserMainInfoService;
import com.greenorange.promotion.utils.JWTUtils;
import com.greenorange.promotion.utils.RegexUtils;
import com.greenorange.promotion.utils.SendSmsUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import lombok.extern.slf4j.Slf4j;
@ -48,6 +53,10 @@ public class UserInfoController {
private UserInfoService userInfoService;
@Resource
private UserMainInfoService userMainInfoService;
@Resource
private CommonService commonService;
@ -75,6 +84,21 @@ public class UserInfoController {
}
/**
* 小程序端用户根据id获取上级邀请码
* @param commonRequest 用户id
* @return 上级邀请码
*/
@PostMapping("inviteCode")
@Operation(summary = "小程序端用户根据id获取上级邀请码", description = "参数用户id权限管理员boss, admin)方法名getParentUserInviteCode")
@SysLog(title = "用户管理", content = "小程序端用户根据id获取上级邀请码")
public BaseResponse<String> getParentUserInviteCode(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
UserInfo userInfo = userInfoService.getById(id);
return ResultUtils.success(userInfo.getInvitationCode());
}
/**
* 小程序端用户注册
@ -120,19 +144,75 @@ public class UserInfoController {
/**
* 小程序用户重置密码
* 小程序用户重置密码外部
* @param userInfoResetRequest 小程序用户密码重置请求体
* @return 是否重置成功
*/
@PostMapping("mini/reset/pwd")
@Operation(summary = "小程序用户重置密码", description = "参数小程序用户密码重置请求体权限管理员boss, admin)方法名userInfoMiniResetPwd")
@SysLog(title = "用户管理", content = "小程序用户重置密码")
public BaseResponse<Boolean> userInfoMiniResetPwd(@Valid @RequestBody UserInfoResetRequest userInfoResetRequest) {
@PostMapping("mini/out/reset/pwd")
@Operation(summary = "小程序用户重置密码(外部)", description = "参数小程序用户密码重置请求体权限管理员boss, admin)方法名userInfoMiniOuterResetPwd")
@SysLog(title = "用户管理", content = "小程序用户重置密码(外部)")
public BaseResponse<Boolean> userInfoMiniOuterResetPwd(@Valid @RequestBody UserInfoResetRequest userInfoResetRequest) {
userInfoService.userInfoMiniResetPwd(userInfoResetRequest);
return ResultUtils.success(true);
}
/**
* 小程序用户重置密码内部
* @param userInfoResetRequest 小程序用户密码重置请求体
* @return 是否重置成功
*/
@PostMapping("mini/in/reset/pwd")
@Operation(summary = "小程序用户重置密码(内部)", description = "参数小程序用户密码重置请求体权限管理员boss, admin)方法名userInfoMiniInnerResetPwd")
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
@SysLog(title = "用户管理", content = "小程序用户重置密码(内部)")
public BaseResponse<Boolean> userInfoMiniInnerResetPwd(@Valid @RequestBody UserInfoResetRequest userInfoResetRequest) {
userInfoService.userInfoMiniResetPwd(userInfoResetRequest);
return ResultUtils.success(true);
}
/**
* 小程序端用户根据jwt获取用户信息
* @return 用户信息
*/
@GetMapping("get/jwt")
@Operation(summary = "小程序端用户根据jwt获取用户信息", description = "参数权限管理员boss, admin)方法名getMiniUserInfoByJWT")
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
@SysLog(title = "用户管理", content = "小程序端用户根据jwt获取用户信息")
public BaseResponse<UserInfoVO> getMiniUserInfoByJWT(HttpServletRequest request) {
String userAccount = (String) request.getAttribute("userAccount");
LambdaQueryWrapper<UserInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UserInfo::getUserAccount, userAccount);
UserInfo userInfo = userInfoService.getOne(lambdaQueryWrapper);
UserInfoVO userInfoVO = commonService.copyProperties(userInfo, UserInfoVO.class);
return ResultUtils.success(userInfoVO);
}
/**
* 小程序端用户根据jwt获取用户主要信息
* @return 用户信息
*/
@GetMapping("get/main/jwt")
@Operation(summary = "小程序端用户根据jwt获取用户主要信息", description = "参数权限管理员boss, admin)方法名getMiniUserInfoByJWT")
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
@SysLog(title = "用户管理", content = "小程序端用户根据jwt获取用户主要信息")
public BaseResponse<UserMainInfoVO> getMiniUserMainInfoByJWT(HttpServletRequest request) {
String userAccount = (String) request.getAttribute("userAccount");
LambdaQueryWrapper<UserInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UserInfo::getUserAccount, userAccount);
UserInfo userInfo = userInfoService.getOne(lambdaQueryWrapper);
Long id = userInfo.getId();
LambdaQueryWrapper<UserMainInfo> userMainInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
userMainInfoLambdaQueryWrapper.eq(UserMainInfo::getUserId, id);
UserMainInfo userMainInfo = userMainInfoService.getOne(userMainInfoLambdaQueryWrapper);
UserMainInfoVO userMainInfoVO = commonService.copyProperties(userMainInfo, UserMainInfoVO.class);
return ResultUtils.success(userMainInfoVO);
}
/**

View File

@ -0,0 +1,148 @@
package com.greenorange.promotion.controller.userMainInfo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.greenorange.promotion.annotation.RequiresPermission;
import com.greenorange.promotion.annotation.SysLog;
import com.greenorange.promotion.common.BaseResponse;
import com.greenorange.promotion.common.ErrorCode;
import com.greenorange.promotion.common.ResultUtils;
import com.greenorange.promotion.constant.UserConstant;
import com.greenorange.promotion.exception.ThrowUtils;
import com.greenorange.promotion.model.dto.CommonBatchRequest;
import com.greenorange.promotion.model.dto.userMainInfo.UserMainInfoAddRequest;
import com.greenorange.promotion.model.dto.userMainInfo.UserMainInfoQueryRequest;
import com.greenorange.promotion.model.dto.userMainInfo.UserMainInfoUpdateRequest;
import com.greenorange.promotion.model.entity.UserMainInfo;
import com.greenorange.promotion.model.vo.userMainInfo.UserMainInfoVO;
import com.greenorange.promotion.service.common.CommonService;
import com.greenorange.promotion.service.user.UserMainInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.greenorange.promotion.model.dto.CommonRequest;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 用户主要信息 控制器
*/
@RestController
@RequestMapping("userMainInfo")
@Slf4j
@Tag(name = "用户主要信息管理")
public class UserMainInfoController {
@Resource
private UserMainInfoService userMainInfoService;
@Resource
private CommonService commonService;
/**
* web端管理员添加用户主要信息
* @param userMainInfoAddRequest 用户主要信息添加请求体
* @return 是否添加成功
*/
@PostMapping("add")
@Operation(summary = "web端管理员添加用户主要信息", description = "参数用户主要信息添加请求体权限管理员方法名addUserMainInfo")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "用户主要信息管理", content = "web端管理员添加用户主要信息")
public BaseResponse<Boolean> addUserMainInfo(@Valid @RequestBody UserMainInfoAddRequest userMainInfoAddRequest) {
UserMainInfo userMainInfo = commonService.copyProperties(userMainInfoAddRequest, UserMainInfo.class);
userMainInfoService.save(userMainInfo);
return ResultUtils.success(true);
}
/**
* web端管理员根据id修改用户主要信息信息
* @param userMainInfoUpdateRequest 用户主要信息更新请求体
* @return 是否更新成功
*/
@PostMapping("update")
@Operation(summary = "web端管理员更新用户主要信息", description = "参数用户主要信息更新请求体权限管理员方法名updateUserMainInfo")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "用户主要信息管理", content = "web端管理员根据id修改用户主要信息信息")
public BaseResponse<Boolean> updateUserMainInfo(@Valid @RequestBody UserMainInfoUpdateRequest userMainInfoUpdateRequest) {
UserMainInfo userMainInfo = commonService.copyProperties(userMainInfoUpdateRequest, UserMainInfo.class);
userMainInfoService.updateById(userMainInfo);
return ResultUtils.success(true);
}
/**
* web端管理员根据id删除用户主要信息
* @param commonRequest 用户主要信息删除请求体
* @return 是否删除成功
*/
@PostMapping("delete")
@Operation(summary = "web端管理员根据id删除用户主要信息", description = "参数用户主要信息删除请求体权限管理员方法名delUserMainInfo")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "用户主要信息管理", content = "web端管理员根据id删除用户主要信息")
public BaseResponse<Boolean> delUserMainInfo(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
userMainInfoService.removeById(id);
return ResultUtils.success(true);
}
/**
* web端管理员批量删除用户主要信息
* @param commonBatchRequest 用户主要信息批量删除请求体
* @return 是否删除成功
*/
@PostMapping("delBatch")
@Operation(summary = "web端管理员批量删除用户主要信息", description = "参数用户主要信息批量删除请求体权限管理员方法名delBatchUserMainInfo")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "用户主要信息管理", content = "web端管理员批量删除用户主要信息")
public BaseResponse<Boolean> delBatchUserMainInfo(@Valid @RequestBody CommonBatchRequest commonBatchRequest) {
List<Long> ids = commonBatchRequest.getIds();
userMainInfoService.removeByIds(ids);
return ResultUtils.success(true);
}
/**
* web端管理员根据id查询用户主要信息
* @param commonRequest 用户主要信息查询请求体
* @return 用户主要信息信息
*/
@PostMapping("queryById")
@Operation(summary = "web端管理员根据id查询用户主要信息", description = "参数用户主要信息查询请求体权限管理员方法名queryUserMainInfoById")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "用户主要信息管理", content = "web端管理员根据id查询用户主要信息")
public BaseResponse<UserMainInfoVO> queryUserMainInfoById(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
UserMainInfo userMainInfo = userMainInfoService.getById(id);
ThrowUtils.throwIf(userMainInfo == null, ErrorCode.OPERATION_ERROR, "当前用户主要信息不存在");
UserMainInfoVO userMainInfoVO = commonService.copyProperties(userMainInfo, UserMainInfoVO.class);
return ResultUtils.success(userMainInfoVO);
}
// /**
// * Web端管理员分页查询用户主要信息
// * @param userMainInfoQueryRequest 用户主要信息查询请求体
// * @return 用户主要信息列表
// */
// @PostMapping("page")
// @Operation(summary = "Web端管理员分页查询用户主要信息", description = "参数用户主要信息查询请求体权限管理员方法名listUserMainInfoByPage")
// @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
// @SysLog(title = "用户主要信息管理", content = "Web端管理员分页查询用户主要信息")
// public BaseResponse<Page<UserMainInfoVO>> listUserMainInfoByPage(@Valid @RequestBody UserMainInfoQueryRequest userMainInfoQueryRequest) {
// long current = userMainInfoQueryRequest.getCurrent();
// long pageSize = userMainInfoQueryRequest.getPageSize();
// QueryWrapper<UserMainInfo> queryWrapper = userMainInfoService.getQueryWrapper(userMainInfoQueryRequest);
// Page<UserMainInfo> page = userMainInfoService.page(new Page<>(current, pageSize), queryWrapper);
// List<UserMainInfo> userMainInfoList = page.getRecords();
// List<UserMainInfoVO> userMainInfoVOList = commonService.convertList(userMainInfoList, UserMainInfoVO.class);
// Page<UserMainInfoVO> voPage = new Page<>(current, pageSize);
// voPage.setRecords(userMainInfoVOList);
// voPage.setPages(page.getPages());
// voPage.setTotal(page.getTotal());
// return ResultUtils.success(voPage);
// }
}

View File

@ -3,22 +3,23 @@ package com.greenorange.promotion.controller.wechat;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.greenorange.promotion.annotation.RequiresPermission;
import com.greenorange.promotion.common.BaseResponse;
import com.greenorange.promotion.common.ErrorCode;
import com.greenorange.promotion.common.ResultUtils;
import com.greenorange.promotion.config.WxAccessToken;
import com.greenorange.promotion.constant.UserConstant;
import com.greenorange.promotion.model.dto.CommonStringRequest;
import com.greenorange.promotion.service.wechat.WechatGetQrcodeService;
import com.greenorange.promotion.utils.QRCodeUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@ -38,9 +39,6 @@ import java.util.Map;
public class WechatGetQrcodeController {
private final static String ACCESS_TOKEN_KEY = "accessToken";
@Resource
private RedisTemplate<String, Object> redisTemplate;
@ -57,76 +55,23 @@ public class WechatGetQrcodeController {
@GetMapping("/get/token")
@Operation(summary = "(小程序端)获取接口调用凭据", description = "参数:无, 权限:所有人, 方法名getAccessToken")
public BaseResponse<WxAccessToken> getAccessToken() {
String accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY);
if (accessToken == null) {
accessToken = wechatGetQrcodeService.getAccessToken().getAccess_token();
}
WxAccessToken wxAccessToken = WxAccessToken.builder()
.access_token(accessToken)
.expires_in("7200").build();
WxAccessToken wxAccessToken = wechatGetQrcodeService.getApiAccessToken();
return ResultUtils.success(wxAccessToken);
}
/**
* 微信小程序获取二维码
* @return
* @throws IOException
*/
@PostMapping("/get/qrcode")
@Operation(summary = "微信小程序获取二维码", description = "参数:无, 权限:所有人, 方法名getQrcode")
public BaseResponse<String> getQrcode() throws IOException {
String accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY);
if (accessToken == null) {
accessToken = wechatGetQrcodeService.getAccessToken().getAccess_token();
}
Map<String, Object> param = new HashMap<>();
param.put("page", "pages/test/test");
param.put("scene", "a=1");
param.put("width", 430); // 宽度
param.put("check_path", false);
param.put("env_version", "develop");
String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken;
String jsonParams = JSONUtil.toJsonStr(param);
byte[] responseBytes = HttpUtil.createPost(url)
.header("Content-Type", "application/json")
.body(jsonParams)
.execute()
.bodyBytes();
// 将二维码数据转换为 BufferedImage
BufferedImage qrImage = ImageIO.read(new ByteArrayInputStream(responseBytes));
// 获取用户头像
String avatarUrl = "https://img.picui.cn/free/2025/04/09/67f5d7bd6b368.jpg"; // 假设这是用户头像的URL
BufferedImage avatarImage = QRCodeUtil.getScaledAvatar(avatarUrl, 188, 188);
// 获取空白图像
String blankUrl = "https://www.helloimg.com/i/2025/04/07/67f34b0490d07.png";
// 加载一张空白图片来覆盖logo假设是透明背景的图片
BufferedImage blankImage = QRCodeUtil.getScaledAvatar(blankUrl, 196, 196); // 空白图片路径
// 将头像转换为圆形
BufferedImage circularAvatar = QRCodeUtil.getCircularImage(avatarImage);
// 将空白头像转换为圆形
BufferedImage circularBlank = QRCodeUtil.getCircularImage(blankImage);
// 合并二维码和空白图片
BufferedImage mergedWithBlank = QRCodeUtil.addImages(qrImage, circularBlank, 116, 116); // 偏移量根据需要调整
// 合并二维码和头像
BufferedImage resultImage = QRCodeUtil.addImages(mergedWithBlank, circularAvatar, 120, 120);
// 将合成后的图片转换为 Base64 编码
InputStream resultStream = QRCodeUtil.bufferedImageToInputStream(resultImage);
byte[] resultBytes = resultStream.readAllBytes();
// 生成图片并保存
try (FileOutputStream fos = new FileOutputStream("qrcode.png")) {
fos.write(resultBytes); // 将二进制数据写入文件
} catch (IOException e) {
e.printStackTrace();
return ResultUtils.error(ErrorCode.OPERATION_ERROR, "保存二维码图片失败");
}
// 将二维码转换为Base64编码
String base64Image = "data:image/jpeg;base64," + Base64.getEncoder().encodeToString(responseBytes);
return ResultUtils.success(base64Image);
// @RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
public BaseResponse<String> getQrcode(@Valid @RequestBody CommonStringRequest commonStringRequest) throws IOException {
String inviteCode = commonStringRequest.getTemplateString();
String view = wechatGetQrcodeService.getWxQrCode(inviteCode);
return ResultUtils.success(view);
}

View File

@ -24,8 +24,16 @@ public class Generator {
// 根路径
private static final String ROOT_PATH = "/src/main/java";
// 作者
private static final String AUTHOR = "chenxinzhi";
// 表注释
private static final String TABLE_COMMENT = "推广码";
// 实体类名
private static final String ENTITY_NAME = "PromoCode";
// 表名
private static final String TABLE_NAME = "promo_code";
// 实体类属性名
private static final String ENTITY_NAME_LOWER = "fileInfo";
private static final String ENTITY_NAME_LOWER = "promoCode";
// 父包名
private static final String PARENT_PATH = "com.greenorange.promotion";
@ -48,17 +56,6 @@ public class Generator {
private static final String VO_TEMPLATE = "/templates/vo/VO.java.vm";
// 作者
private static final String AUTHOR = "chenxinzhi";
// 表注释
private static final String TABLE_COMMENT = "文件";
// 实体类名
private static final String ENTITY_NAME = "FileInfo";
// 表名
private static final String TABLE_NAME = "file_info";
public static void main(String[] args) {

View File

@ -0,0 +1,18 @@
package com.greenorange.promotion.mapper;
import com.greenorange.promotion.model.entity.ProjectDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author 35880
* @description 针对表project_detail(项目明细表)的数据库操作Mapper
* @createDate 2025-05-07 03:47:58
* @Entity com.greenorange.promotion.model.entity.ProjectDetail
*/
public interface ProjectDetailMapper extends BaseMapper<ProjectDetail> {
}

View File

@ -0,0 +1,18 @@
package com.greenorange.promotion.mapper;
import com.greenorange.promotion.model.entity.ProjectNotification;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author 35880
* @description 针对表project_notification(项目通知表)的数据库操作Mapper
* @createDate 2025-05-07 03:31:03
* @Entity com.greenorange.promotion.model.entity.ProjectNotification
*/
public interface ProjectNotificationMapper extends BaseMapper<ProjectNotification> {
}

View File

@ -0,0 +1,18 @@
package com.greenorange.promotion.mapper;
import com.greenorange.promotion.model.entity.UserMainInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author 35880
* @description 针对表user_main_info(用户主要信息表)的数据库操作Mapper
* @createDate 2025-05-07 00:53:58
* @Entity com.greenorange.promotion.model.entity.UserMainInfo
*/
public interface UserMainInfoMapper extends BaseMapper<UserMainInfo> {
}

View File

@ -0,0 +1,54 @@
package com.greenorange.promotion.model.dto.projectDetail;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 项目明细添加请求体
*/
@Data
@Schema(description = "项目明细添加请求体", requiredProperties = {
"projectDetailName",
"projectSettlementPrice",
"maxCommissionRate",
"projectId",
})
public class ProjectDetailAddRequest implements Serializable {
/**
* 项目明细名称
*/
@NotBlank(message = "项目明细名称不能为空")
@Schema(description = "项目明细名称", example = "")
private String projectDetailName;
/**
* 项目结算价
*/
@Schema(description = "项目结算价", example = "")
private BigDecimal projectSettlementPrice;
/**
* 最大抽佣比例
*/
@Schema(description = "最大抽佣比例", example = "")
private Integer maxCommissionRate;
/**
* 项目ID
*/
@Min(value = 1L, message = "项目ID ID不能小于1")
@Schema(description = "项目ID", example = "")
private Long projectId;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,58 @@
package com.greenorange.promotion.model.dto.projectDetail;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import com.greenorange.promotion.common.PageRequest;
/**
* 项目明细查询请求体继承自分页请求 PageRequest
*/
@Data
@Schema(description = "项目明细查询请求体", requiredProperties = {"current", "pageSize"})
public class ProjectDetailQueryRequest extends PageRequest implements Serializable {
/**
* 项目明细ID
*/
@Min(value = 1L, message = "项目明细ID ID不能小于1")
@Schema(description = "项目明细ID", example = "")
private Long id;
/**
* 项目明细名称
*/
@NotBlank(message = "项目明细名称不能为空")
@Schema(description = "项目明细名称", example = "")
private String projectDetailName;
/**
* 项目结算价
*/
@Schema(description = "项目结算价", example = "")
private BigDecimal projectSettlementPrice;
/**
* 最大抽佣比例
*/
@Schema(description = "最大抽佣比例", example = "")
private Integer maxCommissionRate;
/**
* 项目ID
*/
@Min(value = 1L, message = "项目ID ID不能小于1")
@Schema(description = "项目ID", example = "")
private Long projectId;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,61 @@
package com.greenorange.promotion.model.dto.projectDetail;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 项目明细更新请求体
*/
@Data
@Schema(description = "项目明细更新请求体", requiredProperties = {
"id",
"projectDetailName",
"projectSettlementPrice",
"maxCommissionRate",
"projectId",
})
public class ProjectDetailUpdateRequest implements Serializable {
/**
* 项目明细ID
*/
@Min(value = 1L, message = "项目明细ID ID不能小于1")
@Schema(description = "项目明细ID", example = "")
private Long id;
/**
* 项目明细名称
*/
@NotBlank(message = "项目明细名称不能为空")
@Schema(description = "项目明细名称", example = "")
private String projectDetailName;
/**
* 项目结算价
*/
@Schema(description = "项目结算价", example = "")
private BigDecimal projectSettlementPrice;
/**
* 最大抽佣比例
*/
@Schema(description = "最大抽佣比例", example = "")
private Integer maxCommissionRate;
/**
* 项目ID
*/
@Min(value = 1L, message = "项目ID ID不能小于1")
@Schema(description = "项目ID", example = "")
private Long projectId;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,47 @@
package com.greenorange.promotion.model.dto.projectNotification;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* 项目通知添加请求体
*/
@Data
@Schema(description = "项目通知添加请求体", requiredProperties = {
"notificationTitle",
"notificationContent",
"projectId",
})
public class ProjectNotificationAddRequest implements Serializable {
/**
* 通知标题
*/
@NotBlank(message = "通知标题不能为空")
@Schema(description = "通知标题", example = "")
private String notificationTitle;
/**
* 通知内容
*/
@NotBlank(message = "通知内容不能为空")
@Schema(description = "通知内容", example = "")
private String notificationContent;
/**
* 项目ID
*/
@Min(value = 1L, message = "项目ID ID不能小于1")
@Schema(description = "项目ID", example = "")
private Long projectId;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,51 @@
package com.greenorange.promotion.model.dto.projectNotification;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import com.greenorange.promotion.common.PageRequest;
/**
* 项目通知查询请求体继承自分页请求 PageRequest
*/
@Data
@Schema(description = "项目通知查询请求体", requiredProperties = {"current", "pageSize"})
public class ProjectNotificationQueryRequest extends PageRequest implements Serializable {
/**
* 通知ID
*/
@Min(value = 1L, message = "通知ID ID不能小于1")
@Schema(description = "通知ID", example = "")
private Long id;
/**
* 通知标题
*/
@NotBlank(message = "通知标题不能为空")
@Schema(description = "通知标题", example = "")
private String notificationTitle;
/**
* 通知内容
*/
@NotBlank(message = "通知内容不能为空")
@Schema(description = "通知内容", example = "")
private String notificationContent;
/**
* 项目ID
*/
@Min(value = 1L, message = "项目ID ID不能小于1")
@Schema(description = "项目ID", example = "")
private Long projectId;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,54 @@
package com.greenorange.promotion.model.dto.projectNotification;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* 项目通知更新请求体
*/
@Data
@Schema(description = "项目通知更新请求体", requiredProperties = {
"id",
"notificationTitle",
"notificationContent",
"projectId",
})
public class ProjectNotificationUpdateRequest implements Serializable {
/**
* 通知ID
*/
@Min(value = 1L, message = "通知ID ID不能小于1")
@Schema(description = "通知ID", example = "")
private Long id;
/**
* 通知标题
*/
@NotBlank(message = "通知标题不能为空")
@Schema(description = "通知标题", example = "")
private String notificationTitle;
/**
* 通知内容
*/
@NotBlank(message = "通知内容不能为空")
@Schema(description = "通知内容", example = "")
private String notificationContent;
/**
* 项目ID
*/
@Min(value = 1L, message = "项目ID ID不能小于1")
@Schema(description = "项目ID", example = "")
private Long projectId;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -46,7 +46,7 @@ public class UserInfoAddRequest implements Serializable {
* 账号
*/
@NotBlank(message = "账号不能为空")
@Size(min = 6, max = 10, message = "账号长度在 6 到 10 个字符")
@Size(min = 6, max = 11, message = "账号长度在 6 到 11 个字符")
@Schema(description = "账号", example = "qingcheng")
private String userAccount;

View File

@ -18,7 +18,7 @@ public class UserInfoLoginRequest implements Serializable {
* 账号
*/
@NotBlank(message = "账号不能为空")
@Size(min = 6, max = 10, message = "账号长度在 6 到 10 个字符")
@Size(min = 6, max = 11, message = "账号长度在 6 到 11 个字符")
@Schema(description = "账号", example = "qingcheng")
private String userAccount;

View File

@ -53,7 +53,7 @@ public class UserInfoUpdateRequest implements Serializable {
* 账号
*/
@NotBlank(message = "账号不能为空")
@Size(min = 6, max = 10, message = "账号长度在 6 到 10 个字符")
@Size(min = 6, max = 11, message = "账号长度在 6 到 11 个字符")
@Schema(description = "账号", example = "qingcheng")
private String userAccount;

View File

@ -0,0 +1,82 @@
package com.greenorange.promotion.model.dto.userMainInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 用户主要信息添加请求体
*/
@Data
@Schema(description = "用户主要信息添加请求体", requiredProperties = {
"teamSize",
"parentEarnings",
"currentBalance",
"withdrawalAmount",
"withdrawnAmount",
"totalIncome",
"userId",
"inviteQrCode",
})
public class UserMainInfoAddRequest implements Serializable {
/**
* 团队人数不包括自己
*/
@Schema(description = "团队人数(不包括自己)", example = "")
private Integer teamSize;
/**
* 给上级带来的收益
*/
@Schema(description = "给上级带来的收益", example = "")
private BigDecimal parentEarnings;
/**
* 当前余额
*/
@Schema(description = "当前余额", example = "")
private BigDecimal currentBalance;
/**
* 提现中的金额
*/
@Schema(description = "提现中的金额", example = "")
private BigDecimal withdrawalAmount;
/**
* 已提现的金额
*/
@Schema(description = "已提现的金额", example = "")
private BigDecimal withdrawnAmount;
/**
* 累计收入
*/
@Schema(description = "累计收入", example = "")
private BigDecimal totalIncome;
/**
* 用户id
*/
@Min(value = 1L, message = "用户id ID不能小于1")
@Schema(description = "用户id", example = "")
private Long userId;
/**
* 邀请二维码
*/
@NotBlank(message = "邀请二维码不能为空")
@Schema(description = "邀请二维码", example = "")
private String inviteQrCode;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,82 @@
package com.greenorange.promotion.model.dto.userMainInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import com.greenorange.promotion.common.PageRequest;
/**
* 用户主要信息查询请求体继承自分页请求 PageRequest
*/
@Data
@Schema(description = "用户主要信息查询请求体", requiredProperties = {"current", "pageSize"})
public class UserMainInfoQueryRequest extends PageRequest implements Serializable {
/**
* 主键ID
*/
@Min(value = 1L, message = "主键ID ID不能小于1")
@Schema(description = "主键ID", example = "")
private Long id;
/**
* 团队人数不包括自己
*/
@Schema(description = "团队人数(不包括自己)", example = "")
private Integer teamSize;
/**
* 给上级带来的收益
*/
@Schema(description = "给上级带来的收益", example = "")
private BigDecimal parentEarnings;
/**
* 当前余额
*/
@Schema(description = "当前余额", example = "")
private BigDecimal currentBalance;
/**
* 提现中的金额
*/
@Schema(description = "提现中的金额", example = "")
private BigDecimal withdrawalAmount;
/**
* 已提现的金额
*/
@Schema(description = "已提现的金额", example = "")
private BigDecimal withdrawnAmount;
/**
* 累计收入
*/
@Schema(description = "累计收入", example = "")
private BigDecimal totalIncome;
/**
* 用户id
*/
@Min(value = 1L, message = "用户id ID不能小于1")
@Schema(description = "用户id", example = "")
private Long userId;
/**
* 邀请二维码
*/
@NotBlank(message = "邀请二维码不能为空")
@Schema(description = "邀请二维码", example = "")
private String inviteQrCode;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,89 @@
package com.greenorange.promotion.model.dto.userMainInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 用户主要信息更新请求体
*/
@Data
@Schema(description = "用户主要信息更新请求体", requiredProperties = {
"id",
"teamSize",
"parentEarnings",
"currentBalance",
"withdrawalAmount",
"withdrawnAmount",
"totalIncome",
"userId",
"inviteQrCode",
})
public class UserMainInfoUpdateRequest implements Serializable {
/**
* 主键ID
*/
@Min(value = 1L, message = "主键ID ID不能小于1")
@Schema(description = "主键ID", example = "")
private Long id;
/**
* 团队人数不包括自己
*/
@Schema(description = "团队人数(不包括自己)", example = "")
private Integer teamSize;
/**
* 给上级带来的收益
*/
@Schema(description = "给上级带来的收益", example = "")
private BigDecimal parentEarnings;
/**
* 当前余额
*/
@Schema(description = "当前余额", example = "")
private BigDecimal currentBalance;
/**
* 提现中的金额
*/
@Schema(description = "提现中的金额", example = "")
private BigDecimal withdrawalAmount;
/**
* 已提现的金额
*/
@Schema(description = "已提现的金额", example = "")
private BigDecimal withdrawnAmount;
/**
* 累计收入
*/
@Schema(description = "累计收入", example = "")
private BigDecimal totalIncome;
/**
* 用户id
*/
@Min(value = 1L, message = "用户id ID不能小于1")
@Schema(description = "用户id", example = "")
private Long userId;
/**
* 邀请二维码
*/
@NotBlank(message = "邀请二维码不能为空")
@Schema(description = "邀请二维码", example = "")
private String inviteQrCode;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,62 @@
package com.greenorange.promotion.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
* 项目明细表
* @TableName project_detail
*/
@TableName(value ="project_detail")
@Data
public class ProjectDetail implements Serializable {
/**
* 项目明细ID
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 项目明细名称
*/
private String projectDetailName;
/**
* 项目结算价
*/
private BigDecimal projectSettlementPrice;
/**
* 最大抽佣比例
*/
private Integer maxCommissionRate;
/**
* 项目ID
*/
private Long projectId;
/**
* 是否删除
*/
private Integer isDelete;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,56 @@
package com.greenorange.promotion.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 项目通知表
* @TableName project_notification
*/
@TableName(value ="project_notification")
@Data
public class ProjectNotification implements Serializable {
/**
* 通知ID
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 通知标题
*/
private String notificationTitle;
/**
* 通知内容
*/
private String notificationContent;
/**
* 项目ID
*/
private Long projectId;
/**
* 是否删除
*/
private Integer isDelete;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,82 @@
package com.greenorange.promotion.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
* 用户主要信息表
* @TableName user_main_info
*/
@TableName(value ="user_main_info")
@Data
public class UserMainInfo implements Serializable {
/**
* 主键ID
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 团队人数不包括自己
*/
private Integer teamSize;
/**
* 给上级带来的收益
*/
private BigDecimal parentEarnings;
/**
* 当前余额
*/
private BigDecimal currentBalance;
/**
* 提现中的金额
*/
private BigDecimal withdrawalAmount;
/**
* 已提现的金额
*/
private BigDecimal withdrawnAmount;
/**
* 累计收入
*/
private BigDecimal totalIncome;
/**
* 用户id
*/
private Long userId;
/**
* 邀请二维码
*/
private String inviteQrCode;
/**
* 是否删除
*/
private Integer isDelete;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,50 @@
package com.greenorange.promotion.model.vo.projectDetail;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 项目明细 视图对象
*/
@Data
@Schema(description = "项目明细 视图对象")
public class ProjectDetailVO implements Serializable {
/**
* 项目明细ID
*/
@Schema(description = "项目明细ID", example = "1")
private Long id;
/**
* 项目明细名称
*/
@Schema(description = "项目明细名称", example = "${field.example}")
private String projectDetailName;
/**
* 项目结算价
*/
@Schema(description = "项目结算价", example = "${field.example}")
private BigDecimal projectSettlementPrice;
/**
* 最大抽佣比例
*/
@Schema(description = "最大抽佣比例", example = "${field.example}")
private Integer maxCommissionRate;
/**
* 项目ID
*/
@Schema(description = "项目ID", example = "${field.example}")
private Long projectId;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,44 @@
package com.greenorange.promotion.model.vo.projectNotification;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 项目通知 视图对象
*/
@Data
@Schema(description = "项目通知 视图对象")
public class ProjectNotificationVO implements Serializable {
/**
* 项目通知ID
*/
@Schema(description = "项目通知ID", example = "1")
private Long id;
/**
* 通知标题
*/
@Schema(description = "通知标题", example = "${field.example}")
private String notificationTitle;
/**
* 通知内容
*/
@Schema(description = "通知内容", example = "${field.example}")
private String notificationContent;
/**
* 项目ID
*/
@Schema(description = "项目ID", example = "${field.example}")
private Long projectId;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,74 @@
package com.greenorange.promotion.model.vo.userMainInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 用户主要信息 视图对象
*/
@Data
@Schema(description = "用户主要信息 视图对象")
public class UserMainInfoVO implements Serializable {
/**
* 用户主要信息ID
*/
@Schema(description = "用户主要信息ID", example = "1")
private Long id;
/**
* 团队人数不包括自己
*/
@Schema(description = "团队人数(不包括自己)", example = "${field.example}")
private Integer teamSize;
/**
* 给上级带来的收益
*/
@Schema(description = "给上级带来的收益", example = "${field.example}")
private BigDecimal parentEarnings;
/**
* 当前余额
*/
@Schema(description = "当前余额", example = "${field.example}")
private BigDecimal currentBalance;
/**
* 提现中的金额
*/
@Schema(description = "提现中的金额", example = "${field.example}")
private BigDecimal withdrawalAmount;
/**
* 已提现的金额
*/
@Schema(description = "已提现的金额", example = "${field.example}")
private BigDecimal withdrawnAmount;
/**
* 累计收入
*/
@Schema(description = "累计收入", example = "${field.example}")
private BigDecimal totalIncome;
/**
* 用户id
*/
@Schema(description = "用户id", example = "${field.example}")
private Long userId;
/**
* 邀请二维码
*/
@Schema(description = "邀请二维码", example = "${field.example}")
private String inviteQrCode;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -79,7 +79,6 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo>
String fileName = multipartFile.getOriginalFilename();
// 获取文件类型
String fileType = FileUtil.getSuffix(fileName);
// 获取文件路径
// 获取view值
String view = RandomStringUtils.random(8, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
// 获取文件路径

View File

@ -0,0 +1,13 @@
package com.greenorange.promotion.service.project;
import com.greenorange.promotion.model.entity.ProjectDetail;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author 35880
* @description 针对表project_detail(项目明细表)的数据库操作Service
* @createDate 2025-05-07 03:47:58
*/
public interface ProjectDetailService extends IService<ProjectDetail> {
}

View File

@ -0,0 +1,13 @@
package com.greenorange.promotion.service.project;
import com.greenorange.promotion.model.entity.ProjectNotification;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author 35880
* @description 针对表project_notification(项目通知表)的数据库操作Service
* @createDate 2025-05-07 03:31:03
*/
public interface ProjectNotificationService extends IService<ProjectNotification> {
}

View File

@ -0,0 +1,22 @@
package com.greenorange.promotion.service.project.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.greenorange.promotion.model.entity.ProjectDetail;
import com.greenorange.promotion.service.project.ProjectDetailService;
import com.greenorange.promotion.mapper.ProjectDetailMapper;
import org.springframework.stereotype.Service;
/**
* @author 35880
* @description 针对表project_detail(项目明细表)的数据库操作Service实现
* @createDate 2025-05-07 03:47:58
*/
@Service
public class ProjectDetailServiceImpl extends ServiceImpl<ProjectDetailMapper, ProjectDetail>
implements ProjectDetailService{
}

View File

@ -0,0 +1,22 @@
package com.greenorange.promotion.service.project.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.greenorange.promotion.model.entity.ProjectNotification;
import com.greenorange.promotion.service.project.ProjectNotificationService;
import com.greenorange.promotion.mapper.ProjectNotificationMapper;
import org.springframework.stereotype.Service;
/**
* @author 35880
* @description 针对表project_notification(项目通知表)的数据库操作Service实现
* @createDate 2025-05-07 03:31:03
*/
@Service
public class ProjectNotificationServiceImpl extends ServiceImpl<ProjectNotificationMapper, ProjectNotification>
implements ProjectNotificationService{
}

View File

@ -0,0 +1,13 @@
package com.greenorange.promotion.service.user;
import com.greenorange.promotion.model.entity.UserMainInfo;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author 35880
* @description 针对表user_main_info(用户主要信息表)的数据库操作Service
* @createDate 2025-05-07 00:53:58
*/
public interface UserMainInfoService extends IService<UserMainInfo> {
}

View File

@ -14,9 +14,12 @@ import com.greenorange.promotion.exception.ThrowUtils;
import com.greenorange.promotion.mapper.UserInfoMapper;
import com.greenorange.promotion.model.dto.user.*;
import com.greenorange.promotion.model.entity.UserInfo;
import com.greenorange.promotion.model.entity.UserMainInfo;
import com.greenorange.promotion.model.enums.UserRoleEnum;
import com.greenorange.promotion.service.common.CommonService;
import com.greenorange.promotion.service.user.UserInfoService;
import com.greenorange.promotion.service.user.UserMainInfoService;
import com.greenorange.promotion.service.wechat.WechatGetQrcodeService;
import com.greenorange.promotion.utils.JWTUtils;
import com.greenorange.promotion.utils.RegexUtils;
import com.greenorange.promotion.utils.SendSmsUtil;
@ -27,6 +30,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@ -48,10 +52,18 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
private CommonService commonService;
@Resource
private UserMainInfoService userMainInfoService;
@Resource
private RedisTemplate<String, String> redisTemplate;
@Resource
private WechatGetQrcodeService wechatGetQrcodeService;
/**
* 获取查询条件
*/
@ -120,11 +132,22 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
UserInfo myUserInfo = commonService.copyProperties(userInfoRegisterRequest, UserInfo.class);
userInfo.setParentUserId(parentUserInfo.getId());
userInfo.setInvitationCode(RandomUtil.randomNumbers(6));
userInfo.setUserAccount(RandomUtil.randomNumbers(8));
userInfo.setUserAccount(phoneNumber);
userInfo.setUserRole(UserConstant.DEFAULT_ROLE);
userInfo.setUserAvatar(UserConstant.USER_DEFAULT_AVATAR);
userInfo.setSuperUserList(parentUserInfo.getSuperUserList() + "," + parentUserInfo.getId());
this.save(myUserInfo);
UserMainInfo userMainInfo = new UserMainInfo();
userMainInfo.setUserId(myUserInfo.getId());
// 生成邀请二维码
try {
String view = wechatGetQrcodeService.getWxQrCode(myUserInfo.getInvitationCode());
userMainInfo.setInviteQrCode(view);
} catch (IOException e) {
e.printStackTrace();
}
userMainInfoService.save(userMainInfo);
}
@ -143,7 +166,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
ThrowUtils.throwIf(userInfo == null, ErrorCode.OPERATION_ERROR, "手机号未注册");
Map<String, String> payload = new HashMap<>();
payload.put("phoneNumber", phoneNumber);
payload.put("userAccount", phoneNumber);
payload.put("userPassword", userPassword);
return jwtUtils.generateToken(payload);
}
@ -172,7 +195,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
String userPassword = userInfo.getUserPassword();
Map<String, String> payload = new HashMap<>();
payload.put("phoneNumber", phoneNumber);
payload.put("userAccount", phoneNumber);
payload.put("userPassword", userPassword);
return jwtUtils.generateToken(payload);
}

View File

@ -0,0 +1,22 @@
package com.greenorange.promotion.service.user.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.greenorange.promotion.model.entity.UserMainInfo;
import com.greenorange.promotion.service.user.UserMainInfoService;
import com.greenorange.promotion.mapper.UserMainInfoMapper;
import org.springframework.stereotype.Service;
/**
* @author 35880
* @description 针对表user_main_info(用户主要信息表)的数据库操作Service实现
* @createDate 2025-05-07 00:53:58
*/
@Service
public class UserMainInfoServiceImpl extends ServiceImpl<UserMainInfoMapper, UserMainInfo>
implements UserMainInfoService{
}

View File

@ -2,6 +2,8 @@ package com.greenorange.promotion.service.wechat;
import com.greenorange.promotion.config.WxAccessToken;
import java.io.IOException;
public interface WechatGetQrcodeService {
/**
@ -9,4 +11,15 @@ public interface WechatGetQrcodeService {
*/
WxAccessToken getAccessToken();
/**
* 获取接口调用凭据
*/
WxAccessToken getApiAccessToken();
/**
* 微信小程序获取二维码
*/
String getWxQrCode(String inviteCode) throws IOException;
}

View File

@ -2,24 +2,49 @@ package com.greenorange.promotion.service.wechat.impl;
import ch.qos.logback.core.util.MD5Util;
import cn.hutool.core.io.FileUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.google.gson.Gson;
import com.greenorange.promotion.common.ErrorCode;
import com.greenorange.promotion.common.ResultUtils;
import com.greenorange.promotion.config.WxAccessToken;
import com.greenorange.promotion.exception.BusinessException;
import com.greenorange.promotion.model.entity.FileInfo;
import com.greenorange.promotion.service.file.FileInfoService;
import com.greenorange.promotion.service.wechat.WechatGetQrcodeService;
import com.greenorange.promotion.utils.QRCodeUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Resource;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Service
public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
// 上传文件的服务器存储目录
private static final String UPLOAD_DIR = "D:/qingcheng/image/";
private final static String ACCESS_TOKEN_KEY = "accessToken";
// 优化设置一个合理的缓冲区大小
private static final int BUFFER_SIZE = 8192; // 8 KB
@Resource
private RedisTemplate<String, Object> redisTemplate;
@ -33,6 +58,10 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
private String appSecret;
@Resource
private FileInfoService fileInfoService;
/**
* 获取接口调用凭据
*/
@ -51,4 +80,108 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
redisTemplate.opsForValue().set(ACCESS_TOKEN_KEY, access_token, 7200, TimeUnit.SECONDS);
return wxAccessToken;
}
@Override
public WxAccessToken getApiAccessToken() {
String accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY);
if (accessToken == null) {
accessToken = this.getAccessToken().getAccess_token();
}
WxAccessToken wxAccessToken = WxAccessToken.builder()
.access_token(accessToken)
.expires_in("7200").build();
return wxAccessToken;
}
/**
* 获取微信小程序二维码
*/
@Override
public String getWxQrCode(String inviteCode) throws IOException {
String accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY);
if (accessToken == null) {
accessToken = this.getAccessToken().getAccess_token();
}
Map<String, Object> param = new HashMap<>();
param.put("page", "pages/login/login");
param.put("scene", "invitationCode=" + inviteCode);
param.put("width", 430); // 宽度
param.put("check_path", false);
param.put("env_version", "develop");
String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken;
String jsonParams = JSONUtil.toJsonStr(param);
byte[] responseBytes = HttpUtil.createPost(url)
.header("Content-Type", "application/json")
.body(jsonParams)
.execute()
.bodyBytes();
// 将二维码数据转换为 BufferedImage
BufferedImage qrImage = ImageIO.read(new ByteArrayInputStream(responseBytes));
// // 获取用户头像
// String avatarUrl = "https://img.picui.cn/free/2025/04/09/67f5d7bd6b368.jpg"; // 假设这是用户头像的URL
// BufferedImage avatarImage = QRCodeUtil.getScaledAvatar(avatarUrl, 188, 188);
// // 获取空白图像
// String blankUrl = "https://www.helloimg.com/i/2025/04/07/67f34b0490d07.png";
// // 加载一张空白图片来覆盖logo假设是透明背景的图片
// BufferedImage blankImage = QRCodeUtil.getScaledAvatar(blankUrl, 196, 196); // 空白图片路径
// // 将头像转换为圆形
// BufferedImage circularAvatar = QRCodeUtil.getCircularImage(avatarImage);
// // 将空白头像转换为圆形
// BufferedImage circularBlank = QRCodeUtil.getCircularImage(blankImage);
// // 合并二维码和空白图片
// BufferedImage mergedWithBlank = QRCodeUtil.addImages(qrImage, circularBlank, 116, 116); // 偏移量根据需要调整
// // 合并二维码和头像
// BufferedImage resultImage = QRCodeUtil.addImages(mergedWithBlank, circularAvatar, 120, 120);
// 将合成后的图片转换为 Base64 编码
InputStream resultStream = QRCodeUtil.bufferedImageToInputStream(qrImage);
byte[] resultBytes = resultStream.readAllBytes();
// 创建上传目录如果不存在
String biz = "default";
String fileName = "qrcode.png";
// 获取文件类型
String fileType = FileUtil.getSuffix(fileName);
// 获取文件路径
String filePath = String.format("%s-%s", biz, fileName);
// 获取view值
String view = RandomStringUtils.random(8, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
File file = new File(UPLOAD_DIR + filePath);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();// 如果路径不存在则创建
}
// 将文件上传到目标位置
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file), BUFFER_SIZE)) {
bos.write(resultBytes);
} catch (IOException e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR, "文件上传失败,失败原因:" + e.getMessage());
}
// 生成图片并保存
// try (FileOutputStream fos = new FileOutputStream(UPLOAD_DIR)) {
// fos.write(resultBytes); // 将二进制数据写入文件
// } catch (IOException e) {
// e.printStackTrace();
// }
// 将二维码转换为Base64编码
// String base64Image = "data:image/jpeg;base64," + Base64.getEncoder().encodeToString(responseBytes);
// 获取文件大小
Double fileSize = file.length() / 1024.0;
fileSize = Double.valueOf(String.format("%.2f", fileSize));
// 获取文件哈希值
InputStream inputStream = new FileInputStream(file);
String hashValue = DigestUtils.sha256Hex(inputStream);
// 保存文件
FileInfo fileInfo = FileInfo.builder()
.name(fileName)
.type(fileType)
.path(filePath)
.size(fileSize)
.fileView(view)
.biz(biz)
.hashValue(hashValue)
.build();
fileInfoService.save(fileInfo);
return view;
}
}

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.greenorange.promotion.mapper.ProjectDetailMapper">
<resultMap id="BaseResultMap" type="com.greenorange.promotion.model.entity.ProjectDetail">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="projectDetailName" column="projectDetailName" jdbcType="VARCHAR"/>
<result property="projectSettlementPrice" column="projectSettlementPrice" jdbcType="DECIMAL"/>
<result property="maxCommissionRate" column="maxCommissionRate" jdbcType="INTEGER"/>
<result property="projectId" column="projectId" jdbcType="BIGINT"/>
<result property="isDelete" column="isDelete" jdbcType="TINYINT"/>
<result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,projectDetailName,projectSettlementPrice,
maxCommissionRate,projectId,isDelete,
createTime,updateTime
</sql>
</mapper>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.greenorange.promotion.mapper.ProjectNotificationMapper">
<resultMap id="BaseResultMap" type="com.greenorange.promotion.model.entity.ProjectNotification">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="notificationTitle" column="notificationTitle" jdbcType="VARCHAR"/>
<result property="notificationContent" column="notificationContent" jdbcType="VARCHAR"/>
<result property="projectId" column="projectId" jdbcType="BIGINT"/>
<result property="isDelete" column="isDelete" jdbcType="TINYINT"/>
<result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,notificationTitle,notificationContent,
projectId,isDelete,createTime,
updateTime
</sql>
</mapper>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.greenorange.promotion.mapper.UserMainInfoMapper">
<resultMap id="BaseResultMap" type="com.greenorange.promotion.model.entity.UserMainInfo">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="teamSize" column="teamSize" jdbcType="INTEGER"/>
<result property="parentEarnings" column="parentEarnings" jdbcType="DECIMAL"/>
<result property="currentBalance" column="currentBalance" jdbcType="DECIMAL"/>
<result property="withdrawalAmount" column="withdrawalAmount" jdbcType="DECIMAL"/>
<result property="withdrawnAmount" column="withdrawnAmount" jdbcType="DECIMAL"/>
<result property="totalIncome" column="totalIncome" jdbcType="DECIMAL"/>
<result property="userId" column="userId" jdbcType="BIGINT"/>
<result property="isDelete" column="isDelete" jdbcType="TINYINT"/>
<result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,teamSize,parentEarnings,
currentBalance,withdrawalAmount,withdrawnAmount,
totalIncome,userId,isDelete,
createTime,updateTime
</sql>
</mapper>