|
|
|
@ -1,12 +1,14 @@ |
|
|
|
package com.example.demo.controller.coin; |
|
|
|
|
|
|
|
import com.example.demo.config.interfac.Log; |
|
|
|
import com.example.demo.domain.vo.coin.Page; |
|
|
|
import com.example.demo.domain.vo.coin.RechargeActivity; |
|
|
|
import com.example.demo.domain.vo.coin.Result; |
|
|
|
import com.example.demo.service.coin.RechargeActivityCenterService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
@ -16,7 +18,7 @@ import java.util.List; |
|
|
|
* @ClassName RechargeActivityCenterController |
|
|
|
* @description: 充值活动中心管理 |
|
|
|
* @author: Double |
|
|
|
* @create: 2025−10-28 14:23 |
|
|
|
* @create: 2025−11-04 14:23 |
|
|
|
* @Version 1.0 |
|
|
|
**/ |
|
|
|
|
|
|
|
@ -31,26 +33,46 @@ public class RechargeActivityCenterController { |
|
|
|
private RechargeActivityCenterService rechargeActivityCenterService; |
|
|
|
|
|
|
|
|
|
|
|
// 查询活动 |
|
|
|
@Log("根据ID查询充值活动") |
|
|
|
@PostMapping("/selectActivity") |
|
|
|
public Result selectActivity(@RequestBody RechargeActivity activity) { |
|
|
|
/** |
|
|
|
* 导出用户权限数据 |
|
|
|
* |
|
|
|
* @param page 导出请求参数) |
|
|
|
* @return 导出结果(成功返回活动信息,失败返回错误信息) |
|
|
|
* @throws NullPointerException 当参数为空时抛出(如activity为null、关键属性为null) |
|
|
|
* @throws IllegalArgumentException 当参数无效时抛出(如活动ID非法、参数格式错误) |
|
|
|
*/ |
|
|
|
@Log("条件查询充值活动") |
|
|
|
@PostMapping("/queryActivity") |
|
|
|
public Result queryActivity(@RequestBody Page page) { |
|
|
|
try { |
|
|
|
RechargeActivity selectResult = rechargeActivityCenterService.selectActivityById(activity); |
|
|
|
if (selectResult == null) { |
|
|
|
return Result.error("查询失败:未找到该活动"); |
|
|
|
//校验参数 |
|
|
|
if (ObjectUtils.isEmpty(page.getPageNum())) { |
|
|
|
return Result.error("页码数为空!"); |
|
|
|
} |
|
|
|
return Result.success(selectResult); |
|
|
|
if (ObjectUtils.isEmpty(page.getPageSize())) { |
|
|
|
return Result.error("页大小为空!"); |
|
|
|
} |
|
|
|
if (page.getRechargeActivity() == null) { |
|
|
|
return Result.error("查询失败:活动信息不能为空"); |
|
|
|
} |
|
|
|
return Result.success(rechargeActivityCenterService.queryActivity(page.getPageNum(), page.getPageSize(),page.getRechargeActivity())); |
|
|
|
} catch (NullPointerException e) { |
|
|
|
log.error("查询活动失败:空指针异常,ID={}", activity.getId(), e); |
|
|
|
log.error("查询活动失败:空指针异常", e); |
|
|
|
return Result.error("查询失败:数据为空"); |
|
|
|
} catch (IllegalArgumentException e) { |
|
|
|
log.error("查询活动失败:参数异常,ID={}", activity.getId(), e); |
|
|
|
log.error("查询活动失败:参数异常", e); |
|
|
|
return Result.error("查询失败:" + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 动 |
|
|
|
/** |
|
|
|
* 新增充值活动 |
|
|
|
* |
|
|
|
* @param activity 充值活动请求参数(包含活动名称、活动规则等信息) |
|
|
|
* @return 新增结果(成功返回提示信息,失败返回错误原因) |
|
|
|
* @throws NullPointerException 当请求参数为空时抛出(如activity为null、活动名称等关键属性为null) |
|
|
|
* @throws IllegalArgumentException 当请求参数无效时抛出(如活动名称为空字符串、参数格式不符合要求等) |
|
|
|
*/ |
|
|
|
@Log("新增充值活动") |
|
|
|
@PostMapping("/addActivity") |
|
|
|
public Result addActivity(@RequestBody RechargeActivity activity) { |
|
|
|
@ -61,6 +83,25 @@ public class RechargeActivityCenterController { |
|
|
|
if (activity.getActivityName() == null || activity.getActivityName().trim().isEmpty()) { |
|
|
|
return Result.error("添加失败:活动名称不能为空"); |
|
|
|
} |
|
|
|
if (activity.getBusinessBelong() == null || activity.getBusinessBelong().trim().isEmpty()) { |
|
|
|
return Result.error("添加失败:业绩归属地不能为空"); |
|
|
|
}else if (activity.getBusinessBelong().equals("活动归属地")) { |
|
|
|
if (activity.getArea() == null || activity.getArea().trim().isEmpty()) { |
|
|
|
return Result.error("添加失败:地区不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (activity.getStartTime() == null) { |
|
|
|
return Result.error("添加失败:活动开始时间不能为空"); |
|
|
|
} |
|
|
|
if (activity.getEndTime() == null) { |
|
|
|
return Result.error("添加失败:活动结束时间不能为空"); |
|
|
|
} |
|
|
|
if (activity.getEndTime().before(activity.getStartTime())) { |
|
|
|
return Result.error("添加失败:活动结束时间必须晚于活动开始时间"); |
|
|
|
} |
|
|
|
if (activity.getCreator() == null || activity.getCreator().trim().isEmpty()) { |
|
|
|
return Result.error("添加失败:添加人不能为空"); |
|
|
|
} |
|
|
|
rechargeActivityCenterService.addActivity(activity); |
|
|
|
return Result.success("添加活动成功"); |
|
|
|
} catch (NullPointerException e) { |
|
|
|
@ -72,19 +113,45 @@ public class RechargeActivityCenterController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 更新活动 |
|
|
|
/** |
|
|
|
* 更新充值活动 |
|
|
|
* |
|
|
|
* @param activity 充值活动更新参数(包含活动ID、待更新的活动名称等信息) |
|
|
|
* @return 更新结果(成功返回提示信息,失败返回错误原因) |
|
|
|
* @throws NullPointerException 当请求参数为空时抛出(如activity为null、活动ID、活动名称等关键属性为null) |
|
|
|
* @throws IllegalArgumentException 当请求参数无效时抛出(如活动名称为空字符串、活动ID格式错误等) |
|
|
|
*/ |
|
|
|
@Log("更新充值活动") |
|
|
|
@PostMapping("/updateActivity") |
|
|
|
public Result updateActivity(@RequestBody RechargeActivity activity) { |
|
|
|
try { |
|
|
|
if (activity == null) { |
|
|
|
return Result.error("更新失败:活动信息不能为空"); |
|
|
|
return Result.error("添加失败:活动信息不能为空"); |
|
|
|
} |
|
|
|
if (activity.getId() == null) { |
|
|
|
return Result.error("更新失败:活动ID不能为空"); |
|
|
|
return Result.error("添加失败:活动ID不能为空"); |
|
|
|
} |
|
|
|
if (activity.getActivityName() == null || activity.getActivityName().trim().isEmpty()) { |
|
|
|
return Result.error("更新失败:活动名称不能为空"); |
|
|
|
return Result.error("添加失败:活动名称不能为空"); |
|
|
|
} |
|
|
|
if (activity.getBusinessBelong() == null || activity.getBusinessBelong().trim().isEmpty()) { |
|
|
|
return Result.error("添加失败:业绩归属地不能为空"); |
|
|
|
}else if (activity.getBusinessBelong().equals("活动归属地")) { |
|
|
|
if (activity.getArea() == null || activity.getArea().trim().isEmpty()) { |
|
|
|
return Result.error("添加失败:地区不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (activity.getStartTime() == null) { |
|
|
|
return Result.error("添加失败:活动开始时间不能为空"); |
|
|
|
} |
|
|
|
if (activity.getEndTime() == null) { |
|
|
|
return Result.error("添加失败:活动结束时间不能为空"); |
|
|
|
} |
|
|
|
if (activity.getEndTime().before(activity.getStartTime())) { |
|
|
|
return Result.error("添加失败:活动结束时间必须晚于活动开始时间"); |
|
|
|
} |
|
|
|
if (activity.getCreator() == null || activity.getCreator().trim().isEmpty()) { |
|
|
|
return Result.error("添加失败:添加人不能为空"); |
|
|
|
} |
|
|
|
rechargeActivityCenterService.updateActivity(activity); |
|
|
|
return Result.success("更新活动成功"); |
|
|
|
@ -97,21 +164,28 @@ public class RechargeActivityCenterController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 删除活动 |
|
|
|
/** |
|
|
|
* 删除充值活动 |
|
|
|
* |
|
|
|
* @param activity 待删除的充值活动ID |
|
|
|
* @return 删除结果(成功返回提示信息,失败返回错误原因) |
|
|
|
* @throws NullPointerException 当活动ID为空时抛出(如id为null) |
|
|
|
* @throws IllegalArgumentException 当活动ID无效时抛出(如id为负数、非整数格式等不符合业务要求的情况) |
|
|
|
*/ |
|
|
|
@Log("删除充值活动") |
|
|
|
@PostMapping("/deleteActivity") |
|
|
|
public Result deleteActivity(@RequestParam Integer id) { |
|
|
|
public Result deleteActivity(@RequestBody RechargeActivity activity) { |
|
|
|
try { |
|
|
|
if (id == null) { |
|
|
|
if (activity.getId() == null) { |
|
|
|
return Result.error("删除失败:活动ID不能为空"); |
|
|
|
} |
|
|
|
rechargeActivityCenterService.deleteActivity(id); |
|
|
|
rechargeActivityCenterService.deleteActivity(activity); |
|
|
|
return Result.success("删除活动成功"); |
|
|
|
} catch (NullPointerException e) { |
|
|
|
log.error("删除活动失败:空指针异常,ID={}", id, e); |
|
|
|
log.error("删除活动失败:空指针异常", e); |
|
|
|
return Result.error("删除失败:数据为空"); |
|
|
|
} catch (IllegalArgumentException e) { |
|
|
|
log.error("删除活动失败:参数异常,ID={}", id, e); |
|
|
|
log.error("删除活动失败:参数异常", e); |
|
|
|
return Result.error("删除失败:" + e.getMessage()); |
|
|
|
} |
|
|
|
} |