Authored by mlge

代码迁移

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();
}
}
... ...
... ... @@ -51,13 +51,13 @@ public class WechatManageController {
*/
@RequestMapping("/getUnionTypeQrcodeList")
@ResponseBody
public ApiResponse getUnionTypeQrcodeList(@RequestParam int account, @RequestParam int page, @RequestParam int rows) {
public ApiResponse getUnionTypeQrcodeList(@RequestParam("account") int account,@RequestParam(value = "unionType", required = false) String unionType, @RequestParam("page") int page, @RequestParam("rows") int rows) {
logger.info("Enter WechatManageController.getUnionTypeQrcodeList account {},page {},limit {}", account, page, rows);
if (account < 1) {
return new ApiResponse.ApiResponseBuilder().code(400).message("公众号类型为空!").data(null).build();
}
PageResponseRows<QrcodeUnionType> result = wechatManageService.getUnionTypeQrcodeList(account, page, rows);
PageResponseRows<QrcodeUnionType> result = wechatManageService.getUnionTypeQrcodeList(account,unionType, page, rows);
return new ApiResponse.ApiResponseBuilder().data(result).build();
}
... ... @@ -68,7 +68,7 @@ public class WechatManageController {
*/
@RequestMapping("/getUnionTypeQrcodeById")
@ResponseBody
public ApiResponse getUnionTypeQrcodeById(@RequestParam int id) {
public ApiResponse getUnionTypeQrcodeById(@RequestParam("id") int id) {
logger.info("Enter WechatManageController.getUnionTypeQrcodeList id {}", id);
if (id < 1) {
return new ApiResponse.ApiResponseBuilder().code(400).message("参数错误!").data(null).build();
... ...
package com.yohobuy.platform.operations.service;
import com.yoho.tools.common.beans.page.PageResponse;
import com.yohobuy.platform.model.operations.request.LikedActivityReqBo;
import com.yohobuy.platform.model.operations.request.LikedDetailReqBo;
/**
* Created by qing.zhao on 2018/11/9.
*/
public interface LikedActivityService {
PageResponse<LikedActivityReqBo> selectLikedActivityList(LikedActivityReqBo likedActivityReqBo);
void addLikedActivity(LikedActivityReqBo likedActivityReqBo);
void updateLikedActivity(LikedActivityReqBo likedActivityReqBo);
LikedDetailReqBo selectDetailByActivityId(Integer id);
void updateLikedDetail(LikedDetailReqBo likedDetailReqBo);
}
... ...
package com.yohobuy.platform.operations.service.impl;
import com.yoho.tools.common.beans.page.PageResponse;
import com.yoho.tools.common.utils.DateUtil;
import com.yohobuy.platform.common.convert.Convert;
import com.yohobuy.platform.dal.operations.LikedActivityMapper;
import com.yohobuy.platform.dal.operations.LikedDetailMapper;
import com.yohobuy.platform.dal.operations.TemplatePraiseCountMapper;
import com.yohobuy.platform.dal.operations.model.LikedActivity;
import com.yohobuy.platform.dal.operations.model.LikedDetail;
import com.yohobuy.platform.dal.operations.model.TemplatePraiseCount;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* Created by qing.zhao on 2018/11/9.
*/
@Service
public class LikedActivityServiceImpl implements LikedActivityService {
@Autowired
private LikedActivityMapper likedActivityMapper;
@Autowired
private LikedDetailMapper likedDetailMapper;
@Autowired
private TemplatePraiseCountMapper templatePraiseCountMapper;
@Autowired
private Convert convert;
@Override
public PageResponse<LikedActivityReqBo> selectLikedActivityList(LikedActivityReqBo likedActivityReqBo) {
Integer count = likedActivityMapper.selectLikedActivityCount(likedActivityReqBo);
if (count <= 0){
return null;
}
List<LikedActivity> likedActivityList = likedActivityMapper.selectLikedActivityList(likedActivityReqBo);
List<Integer> idList = new ArrayList<>();
likedActivityList.forEach(likedActivity -> idList.add(likedActivity.getId()));
List<TemplatePraiseCount> templatePraiseCountList = templatePraiseCountMapper.selectTemplatePraiseCountById(idList);
List<LikedActivityReqBo> likedActivityBoList = convert.convertFromList(likedActivityList,LikedActivityReqBo.class);
for (LikedActivityReqBo likedActivity : likedActivityBoList){
likedActivity.setCreateTimeStr(DateUtil.int2DateStr(likedActivity.getCreateTime(),DateUtil.DATE_TIME_FORMAT));
for (TemplatePraiseCount templatePraiseCount : templatePraiseCountList){
if (likedActivity.getId().equals(Integer.parseInt(templatePraiseCount.getTemplateId()))){
likedActivity.setLikedNum(templatePraiseCount.getTotal());
}
}
}
return new PageResponse<>(count,likedActivityBoList);
}
@Override
public void addLikedActivity(LikedActivityReqBo likedActivityReqBo) {
likedActivityReqBo.setCreateTime(DateUtil.getCurrentTimeSeconds());
likedActivityMapper.insertLikedActivity(likedActivityReqBo);
}
@Override
public void updateLikedActivity(LikedActivityReqBo likedActivityReqBo) {
likedActivityReqBo.setUpdateTime(DateUtil.getCurrentTimeSeconds());
likedActivityMapper.updateLikedActivity(likedActivityReqBo);
}
@Override
public LikedDetailReqBo selectDetailByActivityId(Integer id) {
LikedDetail likedDetail = likedDetailMapper.selectDetailByActivityId(id);
LikedDetailReqBo likedDetailReqBo = new LikedDetailReqBo();
convert.convertFrom(likedDetail, likedDetailReqBo, LikedDetailReqBo.class);
return likedDetailReqBo;
}
@Override
public void updateLikedDetail(LikedDetailReqBo likedDetailReqBo) {
likedDetailMapper.updateLikedDetail(likedDetailReqBo);
}
}
... ...
... ... @@ -12,6 +12,7 @@ import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.operations.MiniappRewardRespBo;
import com.yohobuy.platform.model.operations.request.MiniappRewardsReq;
import com.yohobuy.platform.operations.service.IMiniappRewardsService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -183,12 +184,15 @@ public class MiniappRewardsServiceImpl implements IMiniappRewardsService {
ids.add(rewards.getCouponId());
}
}
List<Coupon> coupons = couponMapper.selectCouponsByBatchId(ids);
result.forEach(x -> coupons.forEach(coupon -> {
if(coupon.getId().equals(x.getCouponId())){
x.setCouponSendNum(coupon.getSendNum());
x.setCouponTotalNum(coupon.getCouponNum());
} }));
if(CollectionUtils.isNotEmpty(ids)){
List<Coupon> coupons = couponMapper.selectCouponsByBatchId(ids);
result.forEach(x -> coupons.forEach(coupon -> {
if(coupon.getId().equals(x.getCouponId())){
x.setCouponSendNum(coupon.getSendNum());
x.setCouponTotalNum(coupon.getCouponNum());
} }));
}
return result;
}
}
... ...
... ... @@ -135,6 +135,8 @@ datasources:
- com.yohobuy.platform.dal.operations.AppStartImageMapper
- com.yohobuy.platform.dal.operations.IMiniappRewardsDao
- com.yohobuy.platform.dal.operations.IRedpacketConfigDao
- com.yohobuy.platform.dal.operations.LikedActivityMapper
- com.yohobuy.platform.dal.operations.LikedDetailMapper
yh_shops:
servers:
- 192.168.102.219:3306
... ... @@ -474,6 +476,7 @@ datasources:
- com.yohobuy.platform.dal.show.IShowCommentDao
- com.yohobuy.platform.dal.show.MarkedSnsImageMapper
- com.yohobuy.platform.dal.show.SnsProductMapper
- com.yohobuy.platform.dal.operations.TemplatePraiseCountMapper
yh_cms:
servers:
... ...
... ... @@ -133,6 +133,8 @@ datasources:
- com.yohobuy.platform.dal.operations.AppStartImageMapper
- com.yohobuy.platform.dal.operations.IMiniappRewardsDao
- com.yohobuy.platform.dal.operations.IRedpacketConfigDao
- com.yohobuy.platform.dal.operations.LikedActivityMapper
- com.yohobuy.platform.dal.operations.LikedDetailMapper
yh_shops:
servers:
- ${jdbc.mysql.yhshops.master}
... ... @@ -477,6 +479,7 @@ datasources:
- com.yohobuy.platform.dal.show.IShowCommentDao
- com.yohobuy.platform.dal.show.MarkedSnsImageMapper
- com.yohobuy.platform.dal.show.SnsProductMapper
- com.yohobuy.platform.dal.operations.TemplatePraiseCountMapper
yh_setting:
servers:
... ...