|
|
package com.yohobuy.platform.operations.restapi;
|
|
|
|
|
|
import com.yoho.tools.common.beans.page.PageResponse;
|
|
|
import com.yohobuy.platform.model.common.ApiResponse;
|
|
|
import com.yohobuy.platform.model.operations.request.LikedActivityReqBo;
|
|
|
import com.yohobuy.platform.model.operations.request.LikedDetailReqBo;
|
|
|
import com.yohobuy.platform.operations.service.LikedActivityService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
/**
|
|
|
* Created by qing.zhao on 2018/1/15.
|
|
|
*/
|
|
|
@Controller
|
|
|
@RequestMapping("/liked")
|
|
|
public class LikedActivityController {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(LikedActivityController.class);
|
|
|
|
|
|
@Autowired
|
|
|
LikedActivityService likedActivityService;
|
|
|
|
|
|
@RequestMapping("likedActivityList")
|
|
|
@ResponseBody
|
|
|
public ApiResponse likedActivityList(@RequestBody LikedActivityReqBo likedActivityReqBo){
|
|
|
logger.info("LikedActivityController :: likedActivityList params is {}",likedActivityReqBo);
|
|
|
PageResponse<LikedActivityReqBo> response = new PageResponse();
|
|
|
try {
|
|
|
response = likedActivityService.selectLikedActivityList(likedActivityReqBo);
|
|
|
}catch (Exception e){
|
|
|
logger.error("LikedActivityController :: likedActivityList error!", e);
|
|
|
return new ApiResponse.ApiResponseBuilder().code(500).message("获取点赞活动列表失败!").build();
|
|
|
}
|
|
|
return new ApiResponse.ApiResponseBuilder().code(200).data(response).message("获取点赞活动列表成功!").build();
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/addLikedActivity")
|
|
|
@ResponseBody
|
|
|
public ApiResponse addLikedActivity(@RequestBody LikedActivityReqBo likedActivityReqBo){
|
|
|
logger.info("LikedActivityController :: addLikedActivity params is {}", likedActivityReqBo);
|
|
|
if(null == likedActivityReqBo){
|
|
|
return new ApiResponse.ApiResponseBuilder().code(500).message("入参为空!").build();
|
|
|
}
|
|
|
try {
|
|
|
likedActivityService.addLikedActivity(likedActivityReqBo);
|
|
|
}catch (Exception e){
|
|
|
logger.error("LikedActivityController :: addLikedActivity error!", e);
|
|
|
return new ApiResponse.ApiResponseBuilder().code(500).message("添加点赞活动失败!").build();
|
|
|
}
|
|
|
return new ApiResponse.ApiResponseBuilder().code(200).message("添加点赞活动成功!").build();
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/updateLikedActivity")
|
|
|
@ResponseBody
|
|
|
public ApiResponse updateLikedActivity(@RequestBody LikedActivityReqBo likedActivityReqBo){
|
|
|
logger.info("LikedActivityController :: updateLikedActivity params is {}", likedActivityReqBo);
|
|
|
try {
|
|
|
likedActivityService.updateLikedActivity(likedActivityReqBo);
|
|
|
}catch (Exception e){
|
|
|
logger.error("LikedActivityController :: updateLikedActivity error!", e);
|
|
|
return new ApiResponse.ApiResponseBuilder().code(500).message("更新点赞活动失败!").build();
|
|
|
}
|
|
|
return new ApiResponse.ApiResponseBuilder().code(200).message("更新点赞活动成功!").build();
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/selectDetailByActivityId")
|
|
|
@ResponseBody
|
|
|
public ApiResponse selectDetailByActivityId(@RequestBody LikedActivityReqBo likedActivityReq){
|
|
|
logger.info("LikedActivityController :: selectDetailByActivityId params is {}", likedActivityReq);
|
|
|
if (null == likedActivityReq.getId()){
|
|
|
return new ApiResponse.ApiResponseBuilder().code(200).message("活动ID不可为空!").build();
|
|
|
}
|
|
|
LikedDetailReqBo likedDetailBo = new LikedDetailReqBo();
|
|
|
try {
|
|
|
likedDetailBo = likedActivityService.selectDetailByActivityId(likedActivityReq.getId());
|
|
|
}catch (Exception e){
|
|
|
logger.error("LikedActivityController :: selectDetailByActivityId error!", e);
|
|
|
return new ApiResponse.ApiResponseBuilder().code(500).message("获取点赞活动详情失败!").build();
|
|
|
}
|
|
|
return new ApiResponse.ApiResponseBuilder().code(200).data(likedDetailBo).message("获取点赞活动详情成功!").build();
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/updateLikedDetail")
|
|
|
@ResponseBody
|
|
|
public ApiResponse updateLikedDetail(@RequestBody LikedDetailReqBo likedDetailReqBo){
|
|
|
logger.info("LikedActivityController :: updateLikedDetail params is {}", likedDetailReqBo);
|
|
|
try {
|
|
|
likedActivityService.updateLikedDetail(likedDetailReqBo);
|
|
|
}catch (Exception e){
|
|
|
logger.error("LikedActivityController :: updateLikedDetail error!", e);
|
|
|
return new ApiResponse.ApiResponseBuilder().code(500).message("更新点赞详情失败!").build();
|
|
|
}
|
|
|
return new ApiResponse.ApiResponseBuilder().code(200).message("更新成功!").build();
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|