51 lines
1.6 KiB
Java
51 lines
1.6 KiB
Java
package com.example.caseData.controller;
|
|
|
|
import com.example.caseData.common.Response;
|
|
import com.example.caseData.dto.T;
|
|
import com.example.caseData.exception.BusinessException;
|
|
import com.example.caseData.request.RewardPointRequest.rewardPoint;
|
|
import com.example.caseData.service.RewardPointService;
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
@Slf4j
|
|
@RestController
|
|
@RequestMapping("/api")
|
|
public class RewardPointController {
|
|
@Resource
|
|
private HttpServletRequest httpServletRequest;
|
|
|
|
@Resource
|
|
private RewardPointService rewardService;
|
|
|
|
/**
|
|
* 临床病例库-打赏
|
|
*/
|
|
@PostMapping("/reward")
|
|
public Response<T> RewardPoint(@Validated() @ModelAttribute rewardPoint r) {
|
|
// 判断参数
|
|
if (r.getType() != 1 && r.getType() != 2 && r.getType() != 3){
|
|
return Response.error("操作失败");
|
|
}
|
|
|
|
String userId = (String) httpServletRequest.getAttribute("userId");
|
|
|
|
try {
|
|
boolean res = rewardService.RewardPoint(userId,r);
|
|
if (!res){
|
|
return Response.error("操作失败");
|
|
}
|
|
} catch (BusinessException e) {
|
|
return Response.error(e.getMessage());
|
|
}
|
|
|
|
return Response.success();
|
|
}
|
|
}
|