Authored by mlge

代码迁移

package com.yohobuy.platform.operations.model;
/*package com.yohobuy.platform.operations.model;
import com.yoho.tools.common.beans.page.PageRequest;
/**
*//**
* Created by x.wang on 2018/3/9.
*/
*//*
public class VerifiedImgReqVO extends PageRequest {
private Integer imgType;
... ... @@ -16,4 +16,4 @@ public class VerifiedImgReqVO extends PageRequest {
public void setImgType(Integer imgType) {
this.imgType = imgType;
}
}
}*/
... ...
... ... @@ -31,7 +31,7 @@ public class SettingsController extends BasicController{
@RequestMapping("/update")
@ResponseBody
public ApiResponse update(@RequestBody SettingsBO req){
public ApiResponse settingsUpdate(@RequestBody SettingsBO req){
logger.info("SettingsController.update req {}",req);
if (null == req){
return handleParamIsNull();
... ...
... ... @@ -13,10 +13,7 @@ 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.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
... ... @@ -52,7 +49,7 @@ public class TemplatedComponentController extends BasicController{
@RequestMapping(value = "/getTemplatedComponent/{id}")
@ResponseBody
public ApiResponse getTemplatedComponent(@PathVariable("id") Integer id){
public ApiResponse getTemplatedComponent(@RequestParam("id") Integer id){
if(IntegerUtils.withOutBizSign(id)){
return handleParamIsNull();
}
... ... @@ -67,7 +64,7 @@ public class TemplatedComponentController extends BasicController{
@RequestMapping(value = "/getParamsOfOneTemplatedComponent/{id}")
@ResponseBody
public ApiResponse getParamsOfOneTemplatedComponent(@PathVariable("id") Integer id){
public ApiResponse getParamsOfOneTemplatedComponent(@RequestParam("id") Integer id){
if(IntegerUtils.withOutBizSign(id)){
return handleParamIsNull();
}
... ...
... ... @@ -3,13 +3,15 @@ package com.yohobuy.platform.operations.restapi;
import com.yoho.tools.common.beans.page.PageResponse;
import com.yohobuy.platform.dal.users.model.VerifiedGraphicImg;
import com.yohobuy.platform.model.common.ApiResponse;
import com.yohobuy.platform.operations.model.VerifiedImgReqVO;
import com.yohobuy.platform.model.operations.request.VerifiedImgReqVO;
import com.yohobuy.platform.operations.model.VerifiedImgVO;
import com.yohobuy.platform.operations.service.IVerifiedImgService;
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;
import org.springframework.web.multipart.MultipartFile;
... ... @@ -29,7 +31,7 @@ public class VerifiedImgController {
@RequestMapping("/getVerifiedImgList")
@ResponseBody
public ApiResponse getVerifiedImgList(VerifiedImgReqVO pageRequest) {
public ApiResponse getVerifiedImgList(@RequestBody VerifiedImgReqVO pageRequest) {
logger.info("Request getVerifiedImgList begin with param {}", pageRequest);
PageResponse<VerifiedImgVO> pageResponse = verifiedImgService.getVerifiedImgList(pageRequest.getStartIndex(), pageRequest.getRows(), pageRequest.getImgType());
... ... @@ -49,7 +51,7 @@ public class VerifiedImgController {
return new ApiResponse.ApiResponseBuilder().code(200).message("删除成功.").build();
}
@RequestMapping("/uploadVerifiedImg")
/* @RequestMapping("/uploadVerifiedImg")
@ResponseBody
public ApiResponse uploadVerifiedImg(MultipartHttpServletRequest request, String uploadFileName) {
logger.info("uploadVerifiedImg, fileName = {},", uploadFileName);
... ... @@ -78,11 +80,11 @@ public class VerifiedImgController {
logger.error("batch upload Image fail, exception {}", e.getMessage(), e);
return new ApiResponse(400, "上传失败:" + e.getMessage(), null);
}
}
}*/
@RequestMapping("/addVerifiedImg")
@ResponseBody
public ApiResponse addVerifiedImg(VerifiedGraphicImg verifiedGraphicImg) {
public ApiResponse addVerifiedImg(@RequestBody VerifiedGraphicImg verifiedGraphicImg) {
logger.info("addVerifiedImg, param = {},", verifiedGraphicImg);
try {
... ... @@ -96,7 +98,7 @@ public class VerifiedImgController {
@RequestMapping("/updateVerifiedImg")
@ResponseBody
public ApiResponse updateVerifiedImg(VerifiedGraphicImg verifiedGraphicImg) {
public ApiResponse updateVerifiedImg(@RequestBody VerifiedGraphicImg verifiedGraphicImg) {
logger.info("updateVerifiedImg, param = {},", verifiedGraphicImg);
try {
... ...
... ... @@ -7,9 +7,11 @@ import com.yoho.core.rest.client.ServiceCaller;
import com.yohobuy.platform.common.restapi.ApiResponse;
import com.yohobuy.platform.dal.unionType.model.QrcodeUnionType;
import com.yohobuy.platform.model.common.PageResponseRows;
import com.yohobuy.platform.model.operations.request.WechatImageReqBO;
import com.yohobuy.platform.model.unionType.bo.QrcodeUnionTypeReqBo;
import com.yohobuy.platform.operations.service.IWechatManageService;
import org.apache.commons.lang.StringUtils;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -19,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Map;
... ... @@ -74,6 +77,19 @@ public class WechatManageController {
return new ApiResponse.ApiResponseBuilder().data(result).build();
}
// /**
// * 新增带有参数的二维码
// *
// * @return
// */
// @RequestMapping("/addUnionTypeQrcode")
// @ResponseBody
// public ApiResponse addUnionTypeQrcode(@RequestParam("params") String params, HttpSession session) {
// logger.info("Enter WechatManageController.getUnionTypeQrcodeList qrcodeUnionTypeReqBo is {}", params);
// wechatManageService.addUnionTypeQrcode(JSON.parseObject(params, QrcodeUnionTypeReqBo.class), session);
// return new ApiResponse.ApiResponseBuilder().data(null).build();
// }
/**
* 新增带有参数的二维码
*
... ... @@ -81,21 +97,24 @@ public class WechatManageController {
*/
@RequestMapping("/addUnionTypeQrcode")
@ResponseBody
public ApiResponse addUnionTypeQrcode(@RequestParam("params") String params, HttpSession session) {
public ApiResponse addUnionTypeQrcode(@RequestParam("params") String params, @RequestParam(value = "account",required = false) String account,
@RequestParam(value="dept_id",required = false) String dept_id, @RequestParam(value="user_id",required = false) String user_id ) {
logger.info("Enter WechatManageController.getUnionTypeQrcodeList qrcodeUnionTypeReqBo is {}", params);
wechatManageService.addUnionTypeQrcode(JSON.parseObject(params, QrcodeUnionTypeReqBo.class), session);
wechatManageService.addUnionTypeQrcode(JSON.parseObject(params, QrcodeUnionTypeReqBo.class),account,dept_id,user_id );
return new ApiResponse.ApiResponseBuilder().data(null).build();
}
/**
* 更新带有参数的二维码的部分字段
* 备注(代码迁移时,去除参数Httpsession--逻辑里没用到)
*
* @return
*/
@RequestMapping("/updateUnionTypeQrcode")
@ResponseBody
public ApiResponse updateUnionTypeQrcode(@RequestBody QrcodeUnionTypeReqBo reqBo, HttpSession session) {
public ApiResponse updateUnionTypeQrcode(@RequestBody QrcodeUnionTypeReqBo reqBo) {
logger.info("Enter WechatManageController.updateUnionTypeQrcode reqBo is {}", reqBo);
wechatManageService.updateUnionTypeQrcode(reqBo, session);
wechatManageService.updateUnionTypeQrcode(reqBo);
return new ApiResponse.ApiResponseBuilder().data(null).build();
}
... ...
... ... @@ -32,13 +32,13 @@ public interface IWechatManageService {
* 增加带参数的二维码
* @param reqBo
*/
public void addUnionTypeQrcode(QrcodeUnionTypeReqBo reqBo,HttpSession session);
public void addUnionTypeQrcode(QrcodeUnionTypeReqBo reqBo,String account,String dept_id,String user_id);
/**
* 更新带参数的二维码
* @param reqBo
*/
public void updateUnionTypeQrcode(QrcodeUnionTypeReqBo reqBo,HttpSession session);
public void updateUnionTypeQrcode(QrcodeUnionTypeReqBo reqBo);
String getQrcodeByUnionType(String unionType);
}
... ...
... ... @@ -57,7 +57,7 @@ public class WechatManageServiceImpl implements IWechatManageService {
* 增加带参数的二维码
* @param reqBo
*/
public void addUnionTypeQrcode(QrcodeUnionTypeReqBo reqBo,HttpSession session){
public void addUnionTypeQrcode(QrcodeUnionTypeReqBo reqBo,String account,String dept_id, String user_id ){
// 1.检查参数
if (StringUtils.isEmpty(reqBo.getActionName())
... ... @@ -98,7 +98,7 @@ public class WechatManageServiceImpl implements IWechatManageService {
throw new ServiceException(501, "生成带有参数的二维码失败!");
}
QrcodeUnionType qrcodeUnionType = buildQrcodeUnionType(reqBo, session, apiResponse);
QrcodeUnionType qrcodeUnionType = buildQrcodeUnionType(reqBo, account, dept_id,user_id, apiResponse);
// 3.存库
qrcodeUnionTypeDAO.insertSelective(qrcodeUnionType);
... ... @@ -108,7 +108,7 @@ public class WechatManageServiceImpl implements IWechatManageService {
* 更新带参数的二维码
* @param reqBo
*/
public void updateUnionTypeQrcode(QrcodeUnionTypeReqBo reqBo,HttpSession session){
public void updateUnionTypeQrcode(QrcodeUnionTypeReqBo reqBo){
// 1.检查数据
if (reqBo == null || reqBo.getId() == null) {
... ... @@ -132,7 +132,7 @@ public class WechatManageServiceImpl implements IWechatManageService {
qrcodeUnionTypeDAO.updateByPrimaryKeySelective(qrcodeUnionTypeUpdate);
}
private QrcodeUnionType buildQrcodeUnionType(QrcodeUnionTypeReqBo reqBo, HttpSession session, ApiResponse apiResponse) {
private QrcodeUnionType buildQrcodeUnionType(QrcodeUnionTypeReqBo reqBo,String account,String dept_id,String user_id, ApiResponse apiResponse) {
QrcodeUnionType qrcodeUnionType = new QrcodeUnionType();
qrcodeUnionType.setActionName(reqBo.getActionName());
qrcodeUnionType.setUnionType(reqBo.getUnionType());
... ... @@ -147,16 +147,23 @@ public class WechatManageServiceImpl implements IWechatManageService {
qrcodeUnionType.setUrl(dataJson.getString("url"));
try{
if (session != null){
UserInfoResponseBO userInfoResponseBO = (UserInfoResponseBO) session.getAttribute(PlatformConstant.USER_SESSION);
if (userInfoResponseBO != null){
qrcodeUnionType.setCreater(userInfoResponseBO.getAccount());
qrcodeUnionType.setDeptId(userInfoResponseBO.getDept_id());
}
//代码迁移 --httpsession 无法传递,此处修改
if (StringUtils.isNotBlank(account) || StringUtils.isNotBlank(dept_id) ){
qrcodeUnionType.setCreater(account);
qrcodeUnionType.setDeptId(dept_id);
}else{
UserHelper userHelper = new UserHelper();
qrcodeUnionType.setCreater(userHelper.getUserId() != null ? String.valueOf(userHelper.getUserId()): null);
qrcodeUnionType.setCreater(user_id);
}
// if (session != null){
// UserInfoResponseBO userInfoResponseBO = (UserInfoResponseBO) session.getAttribute(PlatformConstant.USER_SESSION);
// if (userInfoResponseBO != null){
// qrcodeUnionType.setCreater(userInfoResponseBO.getAccount());
// qrcodeUnionType.setDeptId(userInfoResponseBO.getDept_id());
// }
// }else{
// UserHelper userHelper = new UserHelper();
// qrcodeUnionType.setCreater(userHelper.getUserId() != null ? String.valueOf(userHelper.getUserId()): null);
// }
}catch (Exception e){
logger.warn("session get userinfo error is {}", e);
... ...