用户模块
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
// }
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user