完成了第一版

This commit is contained in:
chen-xin-zhi 2025-05-14 19:37:40 +08:00
parent 6e5557d8e0
commit 3c48d562a8
5 changed files with 24 additions and 10 deletions

View File

@ -192,10 +192,10 @@ public class ProjectController {
@Operation(summary = "web端管理员添加项目", description = "参数项目添加请求体权限管理员方法名addProject") @Operation(summary = "web端管理员添加项目", description = "参数项目添加请求体权限管理员方法名addProject")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目管理", content = "web端管理员添加项目") @SysLog(title = "项目管理", content = "web端管理员添加项目")
public BaseResponse<Boolean> addProject(@Valid @RequestBody ProjectAddRequest projectAddRequest) { public BaseResponse<Long> addProject(@Valid @RequestBody ProjectAddRequest projectAddRequest) {
Project project = commonService.copyProperties(projectAddRequest, Project.class); Project project = commonService.copyProperties(projectAddRequest, Project.class);
projectService.save(project); projectService.save(project);
return ResultUtils.success(true); return ResultUtils.success(project.getId());
} }
/** /**

View File

@ -75,6 +75,9 @@ public class ProjectDetailController {
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目明细管理", content = "web端管理员添加项目明细") @SysLog(title = "项目明细管理", content = "web端管理员添加项目明细")
public BaseResponse<Boolean> addProjectDetail(@Valid @RequestBody ProjectDetailAddRequest projectDetailAddRequest) { public BaseResponse<Boolean> addProjectDetail(@Valid @RequestBody ProjectDetailAddRequest projectDetailAddRequest) {
Long proId = projectDetailAddRequest.getProjectId();
Project pro = projectService.getById(proId);
ThrowUtils.throwIf(pro == null, ErrorCode.OPERATION_ERROR, "项目不存在");
ProjectDetail projectDetail = commonService.copyProperties(projectDetailAddRequest, ProjectDetail.class); ProjectDetail projectDetail = commonService.copyProperties(projectDetailAddRequest, ProjectDetail.class);
projectDetailService.save(projectDetail); projectDetailService.save(projectDetail);

View File

@ -13,10 +13,12 @@ import com.greenorange.promotion.model.dto.CommonBatchRequest;
import com.greenorange.promotion.model.dto.projectNotification.ProjectNotificationAddRequest; import com.greenorange.promotion.model.dto.projectNotification.ProjectNotificationAddRequest;
import com.greenorange.promotion.model.dto.projectNotification.ProjectNotificationQueryRequest; import com.greenorange.promotion.model.dto.projectNotification.ProjectNotificationQueryRequest;
import com.greenorange.promotion.model.dto.projectNotification.ProjectNotificationUpdateRequest; import com.greenorange.promotion.model.dto.projectNotification.ProjectNotificationUpdateRequest;
import com.greenorange.promotion.model.entity.Project;
import com.greenorange.promotion.model.entity.ProjectNotification; import com.greenorange.promotion.model.entity.ProjectNotification;
import com.greenorange.promotion.model.vo.projectNotification.ProjectNotificationVO; import com.greenorange.promotion.model.vo.projectNotification.ProjectNotificationVO;
import com.greenorange.promotion.service.common.CommonService; import com.greenorange.promotion.service.common.CommonService;
import com.greenorange.promotion.service.project.ProjectNotificationService; import com.greenorange.promotion.service.project.ProjectNotificationService;
import com.greenorange.promotion.service.project.ProjectService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@ -47,6 +49,9 @@ public class ProjectNotificationController {
@Resource @Resource
private CommonService commonService; private CommonService commonService;
@Resource
private ProjectService projectService;
/** /**
* web端管理员添加项目通知 * web端管理员添加项目通知
* @param projectNotificationAddRequest 项目通知添加请求体 * @param projectNotificationAddRequest 项目通知添加请求体
@ -57,6 +62,9 @@ public class ProjectNotificationController {
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "项目通知管理", content = "web端管理员添加项目通知") @SysLog(title = "项目通知管理", content = "web端管理员添加项目通知")
public BaseResponse<Boolean> addProjectNotification(@Valid @RequestBody ProjectNotificationAddRequest projectNotificationAddRequest) { public BaseResponse<Boolean> addProjectNotification(@Valid @RequestBody ProjectNotificationAddRequest projectNotificationAddRequest) {
Long proId = projectNotificationAddRequest.getProjectId();
Project pro = projectService.getById(proId);
ThrowUtils.throwIf(pro == null, ErrorCode.OPERATION_ERROR, "项目不存在");
ProjectNotification projectNotification = commonService.copyProperties(projectNotificationAddRequest, ProjectNotification.class); ProjectNotification projectNotification = commonService.copyProperties(projectNotificationAddRequest, ProjectNotification.class);
projectNotificationService.save(projectNotification); projectNotificationService.save(projectNotification);
return ResultUtils.success(true); return ResultUtils.success(true);
@ -105,7 +113,6 @@ public class ProjectNotificationController {
public BaseResponse<ProjectNotificationVO> queryProjectNotificationById(@Valid @RequestBody CommonRequest commonRequest) { public BaseResponse<ProjectNotificationVO> queryProjectNotificationById(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId(); Long id = commonRequest.getId();
ProjectNotification projectNotification = projectNotificationService.getById(id); ProjectNotification projectNotification = projectNotificationService.getById(id);
ThrowUtils.throwIf(projectNotification == null, ErrorCode.OPERATION_ERROR, "当前项目通知不存在");
ProjectNotificationVO projectNotificationVO = commonService.copyProperties(projectNotification, ProjectNotificationVO.class); ProjectNotificationVO projectNotificationVO = commonService.copyProperties(projectNotification, ProjectNotificationVO.class);
return ResultUtils.success(projectNotificationVO); return ResultUtils.success(projectNotificationVO);
} }
@ -122,9 +129,7 @@ public class ProjectNotificationController {
@SysLog(title = "项目通知管理", content = "web端管理员根据项目id查询项目通知") @SysLog(title = "项目通知管理", content = "web端管理员根据项目id查询项目通知")
public BaseResponse<List<ProjectNotificationVO>> queryProjectNotificationByPid(@Valid @RequestBody CommonRequest commonRequest) { public BaseResponse<List<ProjectNotificationVO>> queryProjectNotificationByPid(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId(); Long id = commonRequest.getId();
LambdaQueryWrapper<ProjectNotification> lambdaQueryWrapper = new LambdaQueryWrapper<>(); List<ProjectNotification> projectNotificationList = commonService.findByFieldEqTargetField(ProjectNotification::getProjectId, id, projectNotificationService);
lambdaQueryWrapper.eq(ProjectNotification::getProjectId, id);
List<ProjectNotification> projectNotificationList = projectNotificationService.list(lambdaQueryWrapper);
List<ProjectNotificationVO> projectNotificationVOS = commonService.convertList(projectNotificationList, ProjectNotificationVO.class); List<ProjectNotificationVO> projectNotificationVOS = commonService.convertList(projectNotificationList, ProjectNotificationVO.class);
return ResultUtils.success(projectNotificationVOS); return ResultUtils.success(projectNotificationVOS);
} }

View File

@ -13,10 +13,12 @@ import com.greenorange.promotion.model.dto.CommonBatchRequest;
import com.greenorange.promotion.model.dto.promoCode.PromoCodeAddRequest; import com.greenorange.promotion.model.dto.promoCode.PromoCodeAddRequest;
import com.greenorange.promotion.model.dto.promoCode.PromoCodeQueryRequest; import com.greenorange.promotion.model.dto.promoCode.PromoCodeQueryRequest;
import com.greenorange.promotion.model.dto.promoCode.PromoCodeUpdateRequest; import com.greenorange.promotion.model.dto.promoCode.PromoCodeUpdateRequest;
import com.greenorange.promotion.model.entity.Project;
import com.greenorange.promotion.model.entity.PromoCode; import com.greenorange.promotion.model.entity.PromoCode;
import com.greenorange.promotion.model.entity.UserInfo; import com.greenorange.promotion.model.entity.UserInfo;
import com.greenorange.promotion.model.vo.promoCode.PromoCodeVO; import com.greenorange.promotion.model.vo.promoCode.PromoCodeVO;
import com.greenorange.promotion.service.common.CommonService; import com.greenorange.promotion.service.common.CommonService;
import com.greenorange.promotion.service.project.ProjectService;
import com.greenorange.promotion.service.project.PromoCodeService; import com.greenorange.promotion.service.project.PromoCodeService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -48,6 +50,9 @@ public class PromoCodeController {
@Resource @Resource
private CommonService commonService; private CommonService commonService;
@Resource
private ProjectService projectService;
/** /**
* web端管理员添加推广码 * web端管理员添加推广码
* @param promoCodeAddRequest 推广码添加请求体 * @param promoCodeAddRequest 推广码添加请求体
@ -58,6 +63,9 @@ public class PromoCodeController {
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "推广码管理", content = "web端管理员添加推广码") @SysLog(title = "推广码管理", content = "web端管理员添加推广码")
public BaseResponse<Boolean> addPromoCode(@Valid @RequestBody PromoCodeAddRequest promoCodeAddRequest) { public BaseResponse<Boolean> addPromoCode(@Valid @RequestBody PromoCodeAddRequest promoCodeAddRequest) {
Long proId = promoCodeAddRequest.getProjectId();
Project pro = projectService.getById(proId);
ThrowUtils.throwIf(pro == null, ErrorCode.OPERATION_ERROR, "项目不存在");
PromoCode promoCode = commonService.copyProperties(promoCodeAddRequest, PromoCode.class); PromoCode promoCode = commonService.copyProperties(promoCodeAddRequest, PromoCode.class);
promoCodeService.save(promoCode); promoCodeService.save(promoCode);
return ResultUtils.success(true); return ResultUtils.success(true);
@ -127,7 +135,6 @@ public class PromoCodeController {
public BaseResponse<PromoCodeVO> queryPromoCodeById(@Valid @RequestBody CommonRequest commonRequest) { public BaseResponse<PromoCodeVO> queryPromoCodeById(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId(); Long id = commonRequest.getId();
PromoCode promoCode = promoCodeService.getById(id); PromoCode promoCode = promoCodeService.getById(id);
ThrowUtils.throwIf(promoCode == null, ErrorCode.OPERATION_ERROR, "当前推广码不存在");
PromoCodeVO promoCodeVO = commonService.copyProperties(promoCode, PromoCodeVO.class); PromoCodeVO promoCodeVO = commonService.copyProperties(promoCode, PromoCodeVO.class);
return ResultUtils.success(promoCodeVO); return ResultUtils.success(promoCodeVO);
} }

View File

@ -30,10 +30,10 @@ public class ${entityName}Controller {
@Operation(summary = "web端管理员添加${entityComment}", description = "参数:${entityComment}添加请求体权限管理员方法名add${entityName}") @Operation(summary = "web端管理员添加${entityComment}", description = "参数:${entityComment}添加请求体权限管理员方法名add${entityName}")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "${entityComment}管理", content = "web端管理员添加${entityComment}") @SysLog(title = "${entityComment}管理", content = "web端管理员添加${entityComment}")
public BaseResponse<Boolean> add${entityName}(@Valid @RequestBody ${entityName}AddRequest ${entityNameLower}AddRequest) { public BaseResponse<Long> add${entityName}(@Valid @RequestBody ${entityName}AddRequest ${entityNameLower}AddRequest) {
${entityName} ${entityNameLower} = commonService.copyProperties(${entityNameLower}AddRequest, ${entityName}.class); ${entityName} ${entityNameLower} = commonService.copyProperties(${entityNameLower}AddRequest, ${entityName}.class);
${entityNameLower}Service.save(${entityNameLower}); ${entityNameLower}Service.save(${entityNameLower});
return ResultUtils.success(true); return ResultUtils.success(${entityNameLower}.getId());
} }
/** /**
@ -93,7 +93,6 @@ public class ${entityName}Controller {
public BaseResponse<${entityName}VO> query${entityName}ById(@Valid @RequestBody CommonRequest commonRequest) { public BaseResponse<${entityName}VO> query${entityName}ById(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId(); Long id = commonRequest.getId();
${entityName} ${entityNameLower} = ${entityNameLower}Service.getById(id); ${entityName} ${entityNameLower} = ${entityNameLower}Service.getById(id);
ThrowUtils.throwIf(${entityNameLower} == null, ErrorCode.OPERATION_ERROR, "当前${entityComment}不存在");
${entityName}VO ${entityNameLower}VO = commonService.copyProperties(${entityNameLower}, ${entityName}VO.class); ${entityName}VO ${entityNameLower}VO = commonService.copyProperties(${entityNameLower}, ${entityName}VO.class);
return ResultUtils.success(${entityNameLower}VO); return ResultUtils.success(${entityNameLower}VO);
} }