提交 b9458b12 authored 作者: zhengfg's avatar zhengfg

去除session和cookie的应用之前的备用版本

上级 15f5304f
......@@ -14,7 +14,6 @@ import java.util.Map;
/**
* 提供给第三方api
*
* @author G
*
*/
......
......@@ -36,12 +36,11 @@ public class NetWorkSpider {
JsonArray dataArray0= rateJson.getAsJsonArray("Data");
JsonArray dataArray1= (JsonArray) dataArray0.get(0);
JsonArray dataArray2= (JsonArray) dataArray1.get(0);
Integer price=dataArray2.get(0).getAsInt();
Integer priceWeight=dataArray2.get(4).getAsInt();
int price=dataArray2.get(0).getAsInt();
int priceWeight=dataArray2.get(4).getAsInt();
BigDecimal priceDecimal = BigDecimal.valueOf(price);
BigDecimal weightDecimal = BigDecimal.valueOf(priceWeight);
BigDecimal exchangeRate=priceDecimal.divide(weightDecimal);
return exchangeRate;
return priceDecimal.divide(weightDecimal);
}
}
......@@ -25,9 +25,8 @@ public class StripePay {
chargeParams.put("amount", amount);
chargeParams.put("currency", "usd");
// 会出现在付款后页面
// chargeParams.put("description", "Charge for jenny.rosen@example.com");
/** chargeParams.put("description", "Charge for jenny.rosen@example.com");*/
chargeParams.put("source",token);
Charge charge=Charge.create(chargeParams);
return charge;
return Charge.create(chargeParams);
}
}
package com.diaoyun.zion.chinafrica.client;
import org.apache.http.Consts;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
......@@ -79,7 +81,7 @@ public class SsoFilter extends ClientFilter {
SessionUtils.invalidate(request);
String backUrl=getBackUrl(request);
String ssoLoginUrl = new StringBuilder().append(ssoServerUrl)
.append("/login?backUrl=").append(URLEncoder.encode(backUrl, "utf-8")).toString();
.append("/login?backUrl=").append(URLEncoder.encode(backUrl, Consts.UTF_8.name())).toString();
response.sendRedirect(ssoLoginUrl);
}
......
package com.diaoyun.zion.chinafrica.client;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.base.ResultCode;
import com.diaoyun.zion.master.common.TokenManager;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
import com.diaoyun.zion.master.exception.ValidateException;
import com.diaoyun.zion.master.util.CookieUtils;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -22,7 +20,7 @@ import javax.servlet.http.HttpServletRequest;
*
* @author G
*/
@Component
@Configuration
@Aspect
public class TokenVerification {
@Autowired
......@@ -37,6 +35,8 @@ public class TokenVerification {
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfPlatformController.*(..))" +
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfStationItemController.*(..))" +
"&&!execution(* com.diaoyun.zion.chinafrica.controller.LoginController.*(..))" +
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfProblemController.*(..))" +
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfContactController.*(..))" +
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfUserInfoController.getUserIdentifyCode(..))")
public void controllerAspect() {
......@@ -50,12 +50,10 @@ public class TokenVerification {
//不需要登录
if (StringUtils.isNotBlank(token) && tokenManager.validate(token) != null) {
return pjp.proceed();
//return "redirect:" + authBackUrl(backUrl, token);
}
else {
result=new Result("请先登录").setCode(ResultCode.NEED_LOGIN);
result=new Result().setCode(ResultCodeEnum.NEED_LOGIN.getCode()).setMessage(ResultCodeEnum.NEED_LOGIN.getDesc());
}
return result;
}
}
package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.client.SessionUser;
import com.diaoyun.zion.chinafrica.client.SessionUtils;
import com.diaoyun.zion.chinafrica.client.SsoFilter;
import com.diaoyun.zion.chinafrica.constant.KeyConstant;
import com.diaoyun.zion.chinafrica.entity.TbCfUserInfoEntity;
import com.diaoyun.zion.chinafrica.service.TbCfUserInfoService;
import com.diaoyun.zion.chinafrica.vo.TbCfUserInfoVo;
import com.diaoyun.zion.master.base.BaseController;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.base.ResultCode;
import com.diaoyun.zion.master.base.StateConstant;
import com.diaoyun.zion.master.common.TokenManager;
import com.diaoyun.zion.master.enums.UserTypeEnum;
import com.diaoyun.zion.master.util.CookieUtils;
import com.diaoyun.zion.master.util.IdUtil;
import com.diaoyun.zion.master.util.PasswordProvider;
import com.diaoyun.zion.master.validator.Validator;
import com.diaoyun.zion.master.validator.annotation.ValidateParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
/**
* 用户登录
......@@ -65,7 +46,6 @@ public class LoginController extends BaseController {
@ApiOperation(value = "注册并登录")
@PostMapping(value = "/register")
@ResponseBody
public Result<TbCfUserInfoVo> registerAndLogin(@ApiParam("用户信息") @RequestBody TbCfUserInfoVo tbCfUserInfoVo) {
Result result = tbCfUserInfoService.registerAndLogin(tbCfUserInfoVo);
return result;
......@@ -89,7 +69,6 @@ public class LoginController extends BaseController {
*/
@ApiOperation("登录")
@PostMapping
@ResponseBody
public Result<TbCfUserInfoVo> login(@ApiParam(value = "登录名") @RequestParam(required = false) String account,
@ApiParam(value = "密码") @RequestParam(required = false) String password) {
Result result = tbCfUserInfoService.login(getIpAddr(request), account,password);
......@@ -99,7 +78,7 @@ public class LoginController extends BaseController {
/*@ApiOperation(value = "登录")
@GetMapping("/form")
@ResponseBody
public Result login(@ApiParam(value = "登录名") @RequestParam(required = false) String account,
@ApiParam(value = "密码") @RequestParam(required = false) String password) {
Result result;
......@@ -125,7 +104,7 @@ public class LoginController extends BaseController {
*/
@ApiOperation("第三方登录")
@PostMapping("/thirdParty")
@ResponseBody
public Result<TbCfUserInfoVo> loginByThirdParty(@ApiParam("第三方账号") @RequestParam(required = false) String amount,
@ApiParam("用户昵称 url编码") @RequestParam(required = false) String nick,
@ApiParam("账号类型") @RequestParam(required = false) String userType) throws UnsupportedEncodingException {
......
......@@ -32,7 +32,6 @@ public class LogoutController {
@ApiOperation("登出")
@GetMapping
@ResponseBody
public Result logout() {
Result result=tbCfUserInfoService.logout();
return result;
......
......@@ -7,9 +7,10 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONObject;
import org.apache.http.Consts;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.net.URISyntaxException;
......@@ -25,7 +26,7 @@ import java.util.concurrent.TimeoutException;
* @date 2019-08-22 15:51:16
*/
@Api(tags = "数据爬虫")
@Controller
@RestController
@RequestMapping("/spider")
public class SpiderController {
......@@ -34,12 +35,10 @@ public class SpiderController {
@ApiOperation("获取商品详情")
@PostMapping("/item/detail")
@ResponseBody
public Result getItemDetail(@ApiParam("targetUrl 需要先进行url编码") @RequestBody DetailParamVo detailParamVo) throws InterruptedException, ExecutionException, URISyntaxException, IOException, TimeoutException {
String targetUrl= URLDecoder.decode(detailParamVo.getTargetUrl(),"UTF-8");
String targetUrl= URLDecoder.decode(detailParamVo.getTargetUrl(), Consts.UTF_8.name());
JSONObject itemMap=spiderService.getItemDetail(targetUrl);
Result result=new Result(itemMap,"商品规格信息");
return result;
return new Result<>(itemMap,"商品规格信息");
}
......
......@@ -3,13 +3,20 @@ package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.service.TbCfAddressService;
import com.diaoyun.zion.chinafrica.vo.TbCfAddressVo;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.validator.Validator;
import com.diaoyun.zion.master.validator.annotation.ValidateParam;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
......@@ -26,43 +33,49 @@ public class TbCfAddressController {
@ApiOperation("获取用户所有地址")
@GetMapping
@ResponseBody
public Result<List<TbCfAddressVo>> getUserInfoList() {
List<TbCfAddressVo> TbCfAddressVoList=tbCfAddressService.getUserInfoList();
return new Result(TbCfAddressVoList);
List<TbCfAddressVo> tbCfAddressVoList=tbCfAddressService.getUserInfoList();
return new Result<>(tbCfAddressVoList);
}
@ApiOperation("增加用户地址信息")
@PostMapping
@ResponseBody
public Result addUserInfo(@ApiParam("地址信息") @RequestBody TbCfAddressVo tbCfAddressVo) {
tbCfAddressVo=tbCfAddressService.saveAddress(tbCfAddressVo);
return new Result(tbCfAddressVo,"新增成功");
return new Result<>(tbCfAddressVo);
}
@ApiOperation("修改用户地址信息")
@PutMapping(value="/{addressId}")
@ResponseBody
public Result updateUserInfo(@ApiParam("地址id") @PathVariable("addressId")String addressId, @ApiParam("地址信息") @RequestBody TbCfAddressVo tbCfAddressVo) {
tbCfAddressVo.setAddressId(addressId);
tbCfAddressVo=tbCfAddressService.updateAddress(tbCfAddressVo);
return new Result(tbCfAddressVo,"修改成功");
return new Result<>(tbCfAddressVo);
}
@ApiOperation("删除用户地址信息")
@DeleteMapping(value="/{addressId}")
@ResponseBody
public Result deleteUserInfo(@ApiParam("地址id") @PathVariable("addressId")String addressId) {
int res=tbCfAddressService.delete(addressId);
return new Result(res,"删除成功");
if(res>0) {
return new Result<>(ResultCodeEnum.SUCCESS.getDesc());
} else {
return new Result<>().setCode(ResultCodeEnum.ERROR.getCode()).setMessage(ResultCodeEnum.ERROR.getDesc());
}
}
@ApiOperation("设置为默认地址")
@PutMapping(value="/default/{addressId}")
@ResponseBody
public Result configDefaultAddress(@ApiParam("地址id") @PathVariable("addressId")String addressId) {
int res=tbCfAddressService.configDefaultAddress(addressId);
return new Result(res,"设置成功");
if(res>0) {
return new Result<>(ResultCodeEnum.SUCCESS.getDesc());
} else {
return new Result<>().setCode(ResultCodeEnum.ERROR.getCode()).setMessage(ResultCodeEnum.ERROR.getDesc());
}
}
}
......@@ -6,7 +6,7 @@ import com.diaoyun.zion.master.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -23,7 +23,7 @@ import java.util.Map;
* @date 2019-08-30 09:54:02
*/
@Api(tags = "报关类型")
@Controller
@RestController
@RequestMapping("categoryhs")
public class TbCfCategoryHsController {
@Autowired
......@@ -34,11 +34,9 @@ public class TbCfCategoryHsController {
*/
@ApiOperation("查看所有列表")
@RequestMapping("/queryAll")
@ResponseBody
public Result<List<TbCfCategoryHsEntity>> queryAll() {
List<TbCfCategoryHsEntity> list = tbCfCategoryHsService.queryList(null);
return new Result().setData(list);
return new Result<>(list);
}
......
package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.entity.TbCfContactEntity;
import com.diaoyun.zion.chinafrica.service.TbCfContactService;
import com.diaoyun.zion.master.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 联系管理Controller
*
* @author lipengjun
* @date 2019-09-17 18:03:40
*/
@Api(tags = "联系方式")
@RestController
@RequestMapping("contact")
public class TbCfContactController {
@Autowired
private TbCfContactService tbCfContactService;
@ApiOperation("获取联系方式")
@GetMapping
public Result getContactList() {
return tbCfContactService.getContactList();
}
}
......@@ -9,7 +9,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -25,7 +25,7 @@ import java.util.concurrent.Executors;
* @date 2019-08-14 09:11:48
*/
@Api(tags = "优惠券")
@Controller
@RestController
@RequestMapping("coupon")
public class TbCfCouponController {
@Autowired
......@@ -33,10 +33,8 @@ public class TbCfCouponController {
@ApiOperation("领取优惠券")
@GetMapping("/{couponId}")
@ResponseBody
public Result<TbCfCouponEntity> takeCoupon(@ApiParam("优惠券")@PathVariable("couponId")String couponId) {
Result result= tbCfCouponService.takeCoupon(couponId);
return result;
return tbCfCouponService.takeCoupon(couponId);
}
......
......@@ -2,7 +2,7 @@ package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.service.TbCfCouponUseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
/**
......@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
* @author G
* @date 2019-08-14 09:11:47
*/
@Controller
@RestController
@RequestMapping("tbcfcouponUse")
public class TbCfCouponUseController {
@Autowired
......
......@@ -6,7 +6,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -22,7 +22,7 @@ import java.util.Map;
* @date 2019-08-30 09:47:20
*/
//@Api
@Controller
@RestController
@RequestMapping("expcatrel")
@Deprecated
public class TbCfExpCatRelController {
......@@ -31,7 +31,7 @@ public class TbCfExpCatRelController {
@ApiOperation("关联运费模板和商品种类")
@PostMapping("/buildRelate")
@ResponseBody
public Result buildRelate(@ApiParam("包含分类id数组和模板id") @RequestBody Map<String,Object> param) {
List<String> categoryIdArray= (List<String>) param.get("categoryIds");
String tempalteId= (String) param.get("tempalteId");
......
......@@ -7,7 +7,7 @@ import com.diaoyun.zion.master.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -24,24 +24,21 @@ import java.util.Map;
* @date 2019-08-14 09:11:48
*/
//@Api(tags = "运费模板")
@Controller
@RestController
@RequestMapping("expressTemplate")
public class TbCfExpressTemplateController {
@Autowired
private TbCfExpressTemplateService tbCfExpressTemplateService;
/**
* 查看所有运费模板
*/
@ApiOperation("查看所有运费模板")
@RequestMapping("/queryAll")
@ResponseBody
public Result queryAll() {
Map<String, Object> params=null;
List<TbCfExpressTemplateEntity> list = tbCfExpressTemplateService.queryList(params);
return new Result().setData(list);
return new Result<>(list);
}
......
......@@ -2,7 +2,7 @@ package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.service.TbCfFeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -18,7 +18,7 @@ import java.util.Map;
* @author G
* @date 2019-08-14 09:11:48
*/
@Controller
@RestController
@RequestMapping("fee")
public class TbCfFeeController {
@Autowired
......
package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.entity.TbCfFeedbackEntity;
import com.diaoyun.zion.chinafrica.service.TbCfFeedbackService;
import com.diaoyun.zion.master.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
/**
......@@ -11,10 +18,16 @@ import org.springframework.web.bind.annotation.RequestMapping;
* @author lipengjun
* @date 2019-09-05 16:51:07
*/
@Controller
@RequestMapping("tbcffeedback")
@Api(tags = "反馈情况")
@RestController
@RequestMapping("feedback")
public class TbCfFeedbackController {
@Autowired
private TbCfFeedbackService tbCfFeedbackService;
@ApiOperation("提交反馈")
@PostMapping
public Result saveFeedback(@ApiParam("反馈情况") @RequestBody TbCfFeedbackEntity tbCfFeedbackEntity) {
return tbCfFeedbackService.saveFeedback(tbCfFeedbackEntity);
}
}
......@@ -2,7 +2,7 @@ package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.service.TbCfFinanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -18,7 +18,7 @@ import java.util.Map;
* @author G
* @date 2019-08-14 09:11:48
*/
@Controller
@RestController
@RequestMapping("tbcffinance")
public class TbCfFinanceController {
@Autowired
......
package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.entity.TbCfHomePageEntity;
import com.diaoyun.zion.chinafrica.service.TbCfHomePageService;
import com.diaoyun.zion.master.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 启动页Controller
*
* @author lipengjun
* @date 2019-09-16 18:21:16
*/
@Api(tags = "启动页")
@RestController
@RequestMapping("startPage")
public class TbCfHomePageController {
@Autowired
private TbCfHomePageService tbCfHomePageService;
@ApiOperation("获取启动页图片")
@GetMapping("/img")
public Result<List<TbCfHomePageEntity>> getStartPageImage() {
return tbCfHomePageService.getStartPageImage();
}
}
......@@ -4,21 +4,15 @@ import com.diaoyun.zion.chinafrica.service.TbCfCartRecordRService;
import com.diaoyun.zion.chinafrica.service.TbCfItemDetailService;
import com.diaoyun.zion.chinafrica.vo.TbCfCartItemDetailVo;
import com.diaoyun.zion.chinafrica.vo.TbCfItemDetailVo;
import com.diaoyun.zion.chinafrica.vo.TbCfUserInfoVo;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.base.ResultCode;
import com.diaoyun.zion.master.validator.Validator;
import com.diaoyun.zion.master.validator.annotation.ValidateParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
* 商品详情Controller
......@@ -27,7 +21,7 @@ import java.util.Map;
* @date 2019-08-16 15:51:16
*/
@Api(tags = "商品相关")
@Controller
@RestController
@RequestMapping("/item")
public class TbCfItemDetailController {
@Autowired
......@@ -40,44 +34,34 @@ public class TbCfItemDetailController {
@ApiOperation("加入到购物车")
@PostMapping("/cart")
@ResponseBody
public Result addToCart(@ApiParam("商品详情") @RequestBody TbCfItemDetailVo tbCfItemDetailVo) {
Result result =tbCfItemDetailService.addToCart(tbCfItemDetailVo);
return result;
return tbCfItemDetailService.addToCart(tbCfItemDetailVo);
}
@ApiOperation("改变购物车的商品勾选状态")
@PutMapping("/state/{cartRecordId}/{checkFlag}")
@ResponseBody
public Result changeItemState(@ApiParam("购物车记录id")@PathVariable ("cartRecordId") String cartRecordId,
@ApiParam("勾选状态 0不选中,1选中")@PathVariable ("checkFlag") Integer checkFlag) {
Result result =tbCfItemDetailService.changeItemState(cartRecordId,checkFlag);
return result;
return tbCfItemDetailService.changeItemState(cartRecordId,checkFlag);
}
@ApiOperation("更改购物车商品数量")
@PutMapping("/cart/{itemId}/{itemNum}")
@ResponseBody
public Result changeItemNum(@ApiParam("商品Id")@PathVariable String itemId, @ApiParam("商品数量")@PathVariable int itemNum) {
Result result =tbCfItemDetailService.changeItemNum(itemId,itemNum);
return result;
return tbCfItemDetailService.changeItemNum(itemId,itemNum);
}
@ApiOperation("从购物车删除商品")
@PostMapping("/cart/delete")
@ResponseBody
public Result deleteItems(@ApiParam("商品Id数组") @RequestBody String[] cartRecordIds) {
Result result =tbCfCartRecordRService.deleteItems(cartRecordIds);
return result;
return tbCfCartRecordRService.deleteItems(cartRecordIds);
}
@ApiOperation("获取用户购物车内的商品")
@GetMapping("/cart")
@ResponseBody
public Result<List<TbCfCartItemDetailVo>> getCartItem() {
List<TbCfCartItemDetailVo> tbCfCartItemDetailList =tbCfItemDetailService.getCartItemList();
Result result =new Result(tbCfCartItemDetailList);
return result;
return new Result<>(tbCfCartItemDetailList);
}
}
......@@ -2,7 +2,7 @@ package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.service.TbCfItemOrderRService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -18,7 +18,7 @@ import java.util.Map;
* @author G
* @date 2019-08-14 09:11:48
*/
@Controller
@RestController
@RequestMapping("tbcfitemorderr")
public class TbCfItemOrderRController {
@Autowired
......
package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.entity.TbCfOrderEntity;
import com.diaoyun.zion.chinafrica.service.TbCfOrderService;
import com.diaoyun.zion.chinafrica.vo.TbCfOrderVo;
import com.diaoyun.zion.master.base.Result;
import com.github.pagehelper.PageInfo;
import com.stripe.exception.StripeException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
/**
* Controller
......@@ -26,7 +23,7 @@ import java.util.concurrent.ExecutionException;
* @date 2019-08-14 09:11:48
*/
@Api(tags = "订单")
@Controller
@RestController
@RequestMapping("order")
public class TbCfOrderController {
@Autowired
......@@ -34,27 +31,22 @@ public class TbCfOrderController {
@ApiOperation("用户结算,返回订单")
@GetMapping("/settle")
@ResponseBody
public Result<TbCfOrderVo> settleAccount() throws IOException, URISyntaxException, ExecutionException, InterruptedException {
Result result = tbCfOrderService.settleAccount();
return result;
public Result<TbCfOrderVo> settleAccount() throws IOException, URISyntaxException, ExecutionException, InterruptedException, TimeoutException {
return tbCfOrderService.settleAccount();
}
@ApiOperation("用户确定下单")
@PostMapping("/place")
@ResponseBody
public Result placeOrder(@ApiParam("订单详情") @RequestBody TbCfOrderVo tbCfOrderVo) throws IOException, URISyntaxException, ExecutionException, InterruptedException {
Result result = tbCfOrderService.placeOrder(tbCfOrderVo);
return result;
public Result placeOrder(@ApiParam("订单详情") @RequestBody TbCfOrderVo tbCfOrderVo) throws IOException, URISyntaxException, ExecutionException, InterruptedException, TimeoutException {
return tbCfOrderService.placeOrder(tbCfOrderVo);
}
@ApiOperation("获取用户订单 默认10条")
@GetMapping
@ResponseBody
/**
* pageNum 页数
* pageSize 每页大小
*/
@ApiOperation("获取用户订单 默认10条")
@GetMapping
public Result<PageInfo> getUserOrderList(@ApiParam(value = "页数") @RequestParam(required = false) Integer pageNum,
@ApiParam(value ="每页大小") @RequestParam(required = false) Integer pageSize) {
if (pageNum == null) {
......@@ -63,31 +55,33 @@ public class TbCfOrderController {
if (pageSize == null) {
pageSize = 10;
}
Result result = tbCfOrderService.getUserOrderList(pageNum, pageSize);
return result;
return tbCfOrderService.getUserOrderList(pageNum, pageSize);
}
@ApiOperation("获取stripe公钥")
@GetMapping("/stripe")
@ResponseBody
public Result<String> getStripePublicKey() {
Result result = tbCfOrderService.getStripePublicKey();
return result;
return tbCfOrderService.getStripePublicKey();
}
@ApiOperation("发起订单支付")
@PostMapping("/pay/{orderId}/{token}")
@ResponseBody
public Result payForOrder(@ApiParam("订单id")@PathVariable("orderId")String orderId,@ApiParam("支付token")@PathVariable("token")String token) {
Result result = tbCfOrderService.payForOrder(orderId,token);
return result;
return tbCfOrderService.payForOrder(orderId,token);
}
@ApiOperation("根据订单id,查询物流详情")
@GetMapping("/logistics/{orderId}")
public Result queryOrderLogistics(@ApiParam("订单id")@PathVariable String orderId) {
return tbCfOrderService.queryOrderLogistics(orderId);
}
/*
@ApiOperation("取消订单")
@DeleteMapping
@ResponseBody
public Result cancelOrder*/
}
......@@ -6,7 +6,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
* @date 2019-09-05 16:51:07
*/
@Api(tags = "独立站")
@Controller
@RestController
@RequestMapping("platform")
public class TbCfPlatformController {
@Autowired
......@@ -27,7 +27,6 @@ public class TbCfPlatformController {
@ApiOperation("获取平台独立站")
@GetMapping
@ResponseBody
public Result getPlatformList(@ApiParam(value = "页数 默认1") @RequestParam(required = false) Integer pageNum,
@ApiParam(value ="每页大小 默认10") @RequestParam(required = false) Integer pageSize) {
if (pageNum == null) {
......@@ -36,8 +35,7 @@ public class TbCfPlatformController {
if (pageSize == null) {
pageSize = 10;
}
Result result = tbCfPlatformService.getPlatformList(pageNum,pageSize);
return result;
return tbCfPlatformService.getPlatformList(pageNum,pageSize);
}
}
......@@ -2,7 +2,7 @@ package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.service.TbCfPlatformOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -18,7 +18,7 @@ import java.util.Map;
* @author G
* @date 2019-08-14 09:11:48
*/
@Controller
@RestController
@RequestMapping("tbcfplatformorder")
public class TbCfPlatformOrderController {
@Autowired
......
package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.service.TbCfProblemService;
import com.diaoyun.zion.master.base.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
/**
* 常见问题Controller
*
* @author lipengjun
* @date 2019-09-05 16:51:07
*/
@Controller
@RequestMapping("tbcfproblem")
@Api(tags = "常见问题")
@RestController
@RequestMapping("problem")
public class TbCfProblemController {
@Autowired
private TbCfProblemService tbCfProblemService;
@ApiOperation("获取常见问题 默认10条")
@GetMapping
public Result<PageInfo> getProblemList(@ApiParam(value = "页数") @RequestParam(required = false) Integer pageNum,
@ApiParam(value ="每页大小") @RequestParam(required = false) Integer pageSize) {
if (pageNum == null) {
pageNum = 1;
}
if (pageSize == null) {
pageSize = 10;
}
return tbCfProblemService.getProblemList(pageNum, pageSize);
}
}
......@@ -6,7 +6,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
* @date 2019-09-05 16:51:07
*/
@Api(tags="商品独立站")
@Controller
@RestController
@RequestMapping("itemStation")
public class TbCfStationItemController {
@Autowired
......@@ -27,7 +27,6 @@ public class TbCfStationItemController {
@ApiOperation("获取商品独立站")
@GetMapping
@ResponseBody
public Result getItemStationList(@ApiParam(value = "页数 默认1") @RequestParam(required = false) Integer pageNum,
@ApiParam(value ="每页大小 默认10") @RequestParam(required = false) Integer pageSize) {
if (pageNum == null) {
......@@ -36,8 +35,7 @@ public class TbCfStationItemController {
if (pageSize == null) {
pageSize = 10;
}
Result result = tbCfStationItemService.getItemStationList(pageNum,pageSize);
return result;
return tbCfStationItemService.getItemStationList(pageNum,pageSize);
}
}
......@@ -2,7 +2,7 @@ package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.service.TbCfStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
/**
......@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
* @author lipengjun
* @date 2019-09-05 16:51:07
*/
@Controller
@RestController
@RequestMapping("tbcfstore")
public class TbCfStoreController {
@Autowired
......
......@@ -3,7 +3,7 @@ package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.service.TbCfTakeCouponService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
* @author lipengjun
* @date 2019-08-29 11:33:33
*/
@Controller
@RestController
@RequestMapping("tbcftakecoupon")
public class TbCfTakeCouponController {
@Autowired
......
......@@ -2,7 +2,7 @@ package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.service.TbCfTaxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -18,7 +18,7 @@ import java.util.Map;
* @author G
* @date 2019-08-14 09:11:48
*/
@Controller
@RestController
@RequestMapping("tbcftax")
public class TbCfTaxController {
@Autowired
......
package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.constant.KeyConstant;
import com.diaoyun.zion.chinafrica.entity.TbCfUserInfoEntity;
import com.diaoyun.zion.chinafrica.service.TbCfUserInfoService;
import com.diaoyun.zion.chinafrica.vo.TbCfUserInfoVo;
import com.diaoyun.zion.master.base.BaseController;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.base.ResultCode;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
import com.diaoyun.zion.master.util.PasswordProvider;
import com.diaoyun.zion.master.validator.Validator;
import com.diaoyun.zion.master.validator.annotation.ValidateParam;
......@@ -15,9 +14,9 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.mail.EmailException;
import org.apache.http.Consts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
......@@ -47,15 +46,13 @@ public class TbCfUserInfoController extends BaseController {
*/
@ApiOperation(value = "获取邮箱验证码")
@GetMapping(value = "/register/identifyCode/{email}/{nick}")
@ResponseBody
public Result getUserIdentifyCode(@ApiParam("用户邮箱") @PathVariable("email") @ValidateParam({Validator.NOT_BLANK}) String email,
@ApiParam("用户昵称 url编码") @PathVariable("nick") @ValidateParam({Validator.NOT_BLANK}) String nick) throws EmailException, TemplateException, IOException {
nick= URLDecoder.decode(nick,"UTF-8");
nick= URLDecoder.decode(nick, Consts.UTF_8.name());
Integer identifyCode = tbCfUserInfoService.sendRegisterIdentifyCode(email, nick);
request.getSession().setAttribute(KeyConstant.IDENTIFY_CODE, identifyCode);
// TODO 不能返回验证码,先做测试 identifyCode.toString(),
Result result=new Result("验证码已发送");
return result;
return new Result("Verification code has been sent");
}
/**
......@@ -70,21 +67,17 @@ public class TbCfUserInfoController extends BaseController {
*/
@ApiOperation("修改用户信息")
@PutMapping()
@ResponseBody
@PutMapping
public Result updateUserInfo(@ApiParam ("用户信息")@RequestBody TbCfUserInfoVo tbCfUserInfoVo) {
int res=tbCfUserInfoService.updateUserInfo(tbCfUserInfoVo);
return new Result(res, "修改成功");
return new Result(res, ResultCodeEnum.SUCCESS.getDesc());
}
@ApiOperation("修改用户密码")
@PutMapping(value="/password/{newPassword}/{oldPassword}")
@ResponseBody
public Result updatePassWord(@ApiParam("新密码") @PathVariable @ValidateParam({Validator.NOT_BLANK}) String newPassword
,@ApiParam("旧密码") @PathVariable @ValidateParam({Validator.NOT_BLANK}) String oldPassword) {
Result result =tbCfUserInfoService.updatePassWord(PasswordProvider.encrypt(newPassword),PasswordProvider.encrypt(oldPassword));
return result;
return tbCfUserInfoService.updatePassWord(PasswordProvider.encrypt(newPassword),PasswordProvider.encrypt(oldPassword));
}
......
package com.diaoyun.zion.chinafrica.dao;
import com.diaoyun.zion.chinafrica.entity.TbCfContactEntity;
import com.diaoyun.zion.master.dao.BaseDao;
import java.util.List;
/**
* 联系管理Dao
*
* @author lipengjun
* @date 2019-09-17 18:03:40
*/
public interface TbCfContactDao extends BaseDao<TbCfContactEntity> {
/**
* 获取有效的联系方式
* @return
*/
List<TbCfContactEntity> getContactList();
}
package com.diaoyun.zion.chinafrica.dao;
import com.diaoyun.zion.chinafrica.entity.TbCfExpTemKeywordEntity;
import com.diaoyun.zion.chinafrica.entity.TbCfExpressTemplateEntity;
import com.diaoyun.zion.master.dao.BaseDao;
import java.util.List;
/**
* 运费模板关键字对应表Dao
*
* @author lipengjun
* @date 2019-09-16 15:22:46
*/
public interface TbCfExpTemKeywordDao extends BaseDao<TbCfExpTemKeywordEntity> {
/**
* 根据keyword获取运费模板
* @param keyword
* @return
*/
List<TbCfExpressTemplateEntity> getTemplateByKeyword(String keyword);
}
package com.diaoyun.zion.chinafrica.dao;
import com.diaoyun.zion.chinafrica.entity.TbCfHomePageEntity;
import com.diaoyun.zion.master.dao.BaseDao;
import java.util.List;
/**
* 启动页Dao
*
* @author lipengjun
* @date 2019-09-16 18:21:16
*/
public interface TbCfHomePageDao extends BaseDao<TbCfHomePageEntity> {
/**
* 获取有效的启动页图片
* @return
*/
List<TbCfHomePageEntity> getStartPageImage();
}
......@@ -3,6 +3,8 @@ package com.diaoyun.zion.chinafrica.dao;
import com.diaoyun.zion.chinafrica.entity.TbCfProblemEntity;
import com.diaoyun.zion.master.dao.BaseDao;
import java.util.List;
/**
* 常见问题Dao
*
......@@ -11,4 +13,9 @@ import com.diaoyun.zion.master.dao.BaseDao;
*/
public interface TbCfProblemDao extends BaseDao<TbCfProblemEntity> {
/**
* 获取常见问题
* @return
*/
List<TbCfProblemEntity> getProblemList();
}
package com.diaoyun.zion.chinafrica.entity;
import java.io.Serializable;
import java.util.Date;
/**
* 联系管理实体
* 表名 tb_cf_contact
*
* @author lipengjun
* @date 2019-09-17 18:03:40
*/
public class TbCfContactEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 联系id
*/
private String contactId;
/**
* 联系方式
*/
private String contactWay;
/**
* 联系详情
*/
private String contactDetail;
/**
* 是否有效
*/
private Integer enableFlag;
/**
* 设置:联系id
*/
public void setContactId(String contactId) {
this.contactId = contactId;
}
/**
* 获取:联系id
*/
public String getContactId() {
return contactId;
}
/**
* 设置:联系方式
*/
public void setContactWay(String contactWay) {
this.contactWay = contactWay;
}
/**
* 获取:联系方式
*/
public String getContactWay() {
return contactWay;
}
/**
* 设置:联系详情
*/
public void setContactDetail(String contactDetail) {
this.contactDetail = contactDetail;
}
/**
* 获取:联系详情
*/
public String getContactDetail() {
return contactDetail;
}
/**
* 设置:是否有效
*/
public void setEnableFlag(Integer enableFlag) {
this.enableFlag = enableFlag;
}
/**
* 获取:是否有效
*/
public Integer getEnableFlag() {
return enableFlag;
}
}
package com.diaoyun.zion.chinafrica.entity;
import java.io.Serializable;
import java.util.Date;
/**
* 运费模板关键字对应表实体
* 表名 tb_cf_exp_tem_keyword
*
* @author lipengjun
* @date 2019-09-16 15:22:46
*/
public class TbCfExpTemKeywordEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
private String id;
/**
* 模板id,express_template
*/
private String templateId;
/**
* 关键字
*/
private String keyword;
/**
* 设置:
*/
public void setId(String id) {
this.id = id;
}
/**
* 获取:
*/
public String getId() {
return id;
}
/**
* 设置:模板id,express_template
*/
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
/**
* 获取:模板id,express_template
*/
public String getTemplateId() {
return templateId;
}
/**
* 设置:关键字
*/
public void setKeyword(String keyword) {
this.keyword = keyword;
}
/**
* 获取:关键字
*/
public String getKeyword() {
return keyword;
}
}
......@@ -117,4 +117,25 @@ public class TbCfExpressTemplateEntity implements Serializable {
public Date getCreateTime() {
return createTime;
}
@Override
public boolean equals(Object obj) {
if(obj==null)
return false;
if(this==obj)
return true;
if(obj instanceof TbCfExpressTemplateEntity) {
TbCfExpressTemplateEntity templateEntity =(TbCfExpressTemplateEntity) obj;
if(templateEntity.templateId.equals(this.templateId)) {
return true;
}
}
return false;
}
@Override
public int hashCode() {
return templateId.hashCode();
}
}
......@@ -33,6 +33,10 @@ public class TbCfFeedbackEntity implements Serializable {
* 创建时间
*/
private Date createTime;
/**
* 用户id
*/
private String userId;
/**
* 设置:反馈id
......@@ -99,4 +103,12 @@ public class TbCfFeedbackEntity implements Serializable {
public Date getCreateTime() {
return createTime;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
package com.diaoyun.zion.chinafrica.entity;
import java.io.Serializable;
import java.util.Date;
/**
* 启动页实体
* 表名 tb_cf_home_page
*
* @author lipengjun
* @date 2019-09-16 18:21:16
*/
public class TbCfHomePageEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 启动页id
*/
private String pageId;
/**
* 图片名称
*/
private String imgName;
/**
* 排序
*/
private Integer sort;
/**
* 图片链接
*/
private String linkUrl;
/**
* 跳转链接
*/
private String imgUrl;
/**
* 是否支持浏览
*/
private Integer scanFlag;
/**
* 是否跳转
*/
private Integer redirectFlag;
/**
* 是否可用
*/
private Integer enableFlag;
/**
* 设置:启动页id
*/
public void setPageId(String pageId) {
this.pageId = pageId;
}
/**
* 获取:启动页id
*/
public String getPageId() {
return pageId;
}
/**
* 设置:图片名称
*/
public void setImgName(String imgName) {
this.imgName = imgName;
}
/**
* 获取:图片名称
*/
public String getImgName() {
return imgName;
}
/**
* 设置:排序
*/
public void setSort(Integer sort) {
this.sort = sort;
}
/**
* 获取:排序
*/
public Integer getSort() {
return sort;
}
/**
* 设置:图片链接
*/
public void setLinkUrl(String linkUrl) {
this.linkUrl = linkUrl;
}
/**
* 获取:图片链接
*/
public String getLinkUrl() {
return linkUrl;
}
/**
* 设置:跳转链接
*/
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
/**
* 获取:跳转链接
*/
public String getImgUrl() {
return imgUrl;
}
/**
* 设置:是否支持浏览
*/
public void setScanFlag(Integer scanFlag) {
this.scanFlag = scanFlag;
}
/**
* 获取:是否支持浏览
*/
public Integer getScanFlag() {
return scanFlag;
}
/**
* 设置:是否跳转
*/
public void setRedirectFlag(Integer redirectFlag) {
this.redirectFlag = redirectFlag;
}
/**
* 获取:是否跳转
*/
public Integer getRedirectFlag() {
return redirectFlag;
}
/**
* 设置:是否可用
*/
public void setEnableFlag(Integer enableFlag) {
this.enableFlag = enableFlag;
}
/**
* 获取:是否可用
*/
public Integer getEnableFlag() {
return enableFlag;
}
}
......@@ -29,6 +29,10 @@ public class TbCfProblemEntity implements Serializable {
* 是否展示
*/
private Integer enableFlag;
/**
* 排序
*/
private Integer sort;
/**
* 创建时间
*/
......@@ -99,4 +103,12 @@ public class TbCfProblemEntity implements Serializable {
public Date getCreateTime() {
return createTime;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
}
package com.diaoyun.zion.chinafrica.service;
import com.diaoyun.zion.chinafrica.entity.TbCfContactEntity;
import com.diaoyun.zion.master.base.Result;
import java.util.List;
import java.util.Map;
/**
* 联系管理Service接口
*
* @author lipengjun
* @date 2019-09-17 18:03:40
*/
public interface TbCfContactService {
/**
* 根据主键查询实体
*
* @param id 主键
* @return 实体
*/
TbCfContactEntity queryObject(String contactId);
/**
* 分页查询
*
* @param map 参数
* @return list
*/
List<TbCfContactEntity> queryList(Map<String, Object> map);
/**
* 分页统计总数
*
* @param map 参数
* @return 总数
*/
int queryTotal(Map<String, Object> map);
/**
* 保存实体
*
* @param tbCfContact 实体
* @return 保存条数
*/
int save(TbCfContactEntity tbCfContact);
/**
* 根据主键更新实体
*
* @param tbCfContact 实体
* @return 更新条数
*/
int update(TbCfContactEntity tbCfContact);
/**
* 根据主键删除
*
* @param contactId
* @return 删除条数
*/
int delete(String contactId);
/**
* 根据主键批量删除
*
* @param contactIds
* @return 删除条数
*/
int deleteBatch(String[] contactIds);
/**
* 获取有效的联系方式
* @return
*/
Result getContactList();
}
package com.diaoyun.zion.chinafrica.service;
import com.diaoyun.zion.chinafrica.entity.TbCfExpTemKeywordEntity;
import java.util.List;
import java.util.Map;
/**
* 运费模板关键字对应表Service接口
*
* @author lipengjun
* @date 2019-09-16 15:22:46
*/
public interface TbCfExpTemKeywordService {
/**
* 根据主键查询实体
*
* @param id 主键
* @return 实体
*/
TbCfExpTemKeywordEntity queryObject(Integer id);
/**
* 分页查询
*
* @param map 参数
* @return list
*/
List<TbCfExpTemKeywordEntity> queryList(Map<String, Object> map);
/**
* 分页统计总数
*
* @param map 参数
* @return 总数
*/
int queryTotal(Map<String, Object> map);
/**
* 保存实体
*
* @param tbCfExpTemKeyword 实体
* @return 保存条数
*/
int save(TbCfExpTemKeywordEntity tbCfExpTemKeyword);
/**
* 根据主键更新实体
*
* @param tbCfExpTemKeyword 实体
* @return 更新条数
*/
int update(TbCfExpTemKeywordEntity tbCfExpTemKeyword);
/**
* 根据主键删除
*
* @param id
* @return 删除条数
*/
int delete(Integer id);
/**
* 根据主键批量删除
*
* @param ids
* @return 删除条数
*/
int deleteBatch(Integer[] ids);
}
package com.diaoyun.zion.chinafrica.service;
import com.diaoyun.zion.chinafrica.entity.TbCfFeedbackEntity;
import com.diaoyun.zion.master.base.Result;
import java.util.List;
import java.util.Map;
......@@ -16,7 +17,7 @@ public interface TbCfFeedbackService {
/**
* 根据主键查询实体
*
* @param id 主键
* @param feedbackId 主键
* @return 实体
*/
TbCfFeedbackEntity queryObject(String feedbackId);
......@@ -68,4 +69,11 @@ public interface TbCfFeedbackService {
* @return 删除条数
*/
int deleteBatch(String[] feedbackIds);
/**
* 提交反馈
* @param tbCfFeedbackEntity
* @return
*/
Result saveFeedback(TbCfFeedbackEntity tbCfFeedbackEntity);
}
package com.diaoyun.zion.chinafrica.service;
import com.diaoyun.zion.chinafrica.entity.TbCfHomePageEntity;
import com.diaoyun.zion.master.base.Result;
import java.util.List;
import java.util.Map;
/**
* 启动页Service接口
*
* @author lipengjun
* @date 2019-09-16 18:21:16
*/
public interface TbCfHomePageService {
/**
* 根据主键查询实体
*
* @param id 主键
* @return 实体
*/
TbCfHomePageEntity queryObject(String pageId);
/**
* 分页查询
*
* @param map 参数
* @return list
*/
List<TbCfHomePageEntity> queryList(Map<String, Object> map);
/**
* 分页统计总数
*
* @param map 参数
* @return 总数
*/
int queryTotal(Map<String, Object> map);
/**
* 保存实体
*
* @param tbCfHomePage 实体
* @return 保存条数
*/
int save(TbCfHomePageEntity tbCfHomePage);
/**
* 根据主键更新实体
*
* @param tbCfHomePage 实体
* @return 更新条数
*/
int update(TbCfHomePageEntity tbCfHomePage);
/**
* 根据主键删除
*
* @param pageId
* @return 删除条数
*/
int delete(String pageId);
/**
* 根据主键批量删除
*
* @param pageIds
* @return 删除条数
*/
int deleteBatch(String[] pageIds);
/**
* 获取有效的启动页图片
* @return
*/
Result getStartPageImage();
}
......@@ -10,6 +10,7 @@ import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
/**
* Service接口
......@@ -80,7 +81,7 @@ public interface TbCfOrderService {
*
* @return
*/
Result settleAccount() throws IOException, URISyntaxException, ExecutionException, InterruptedException;
Result settleAccount() throws IOException, URISyntaxException, ExecutionException, InterruptedException, TimeoutException;
/**
* 用户下单
......@@ -88,7 +89,7 @@ public interface TbCfOrderService {
* @param tbCfOrderVo
* @return
*/
Result placeOrder(TbCfOrderVo tbCfOrderVo) throws IOException, URISyntaxException, ExecutionException, InterruptedException;
Result placeOrder(TbCfOrderVo tbCfOrderVo) throws IOException, URISyntaxException, ExecutionException, InterruptedException, TimeoutException;
/**
* 获取用户订单列表
......@@ -120,4 +121,11 @@ public interface TbCfOrderService {
* @return
*/
Result payForOrder(String orderId, String token) ;
/**
* 根据订单id,获取物流详情
* @param orderId
* @return
*/
Result queryOrderLogistics(String orderId);
}
package com.diaoyun.zion.chinafrica.service;
import com.diaoyun.zion.chinafrica.entity.TbCfProblemEntity;
import com.diaoyun.zion.master.base.Result;
import java.util.List;
import java.util.Map;
......@@ -68,4 +69,12 @@ public interface TbCfProblemService {
* @return 删除条数
*/
int deleteBatch(String[] problemIds);
/**
* 获取常见问题
* @param pageNum
* @param pageSize
* @return
*/
Result getProblemList(Integer pageNum, Integer pageSize);
}
......@@ -28,8 +28,7 @@ public class SpiderServiceImpl implements SpiderService {
//判断链接属于哪个平台
PlatformEnum platformEnum=judgeUrlType(targetUrl);
IItemSpider iItemSpider=ItemSpiderFactory.getSpider(platformEnum);
JSONObject itemMap=iItemSpider.captureItem(targetUrl);
return itemMap;
return iItemSpider.captureItem(targetUrl);
}
@Override
......@@ -39,8 +38,7 @@ public class SpiderServiceImpl implements SpiderService {
if(StringUtils.isBlank(currency)) {
currency="FOREXUSDCNY";
}
BigDecimal exchangeRate=NetWorkSpider.getRateFromHexun(currency);
return exchangeRate;
return NetWorkSpider.getRateFromHexun(currency);
}
private PlatformEnum judgeUrlType(String targetUrl) {
......
......@@ -113,16 +113,16 @@ public class TbCfAddressServiceImpl implements TbCfAddressService {
String token = CookieUtils.getCookie(request, TokenManager.TOKEN);
TbCfUserInfoVo tbCfUserInfoVo = tokenManager.validate(token);
String userId=tbCfUserInfoVo.getUserId();
List<TbCfAddressEntity> TbCfAddressList=tbCfAddressDao.queryListByUserId(userId);
List<TbCfAddressVo> TbCfAddressVoList=new ArrayList<>();
if(TbCfAddressList!=null) {
for(TbCfAddressEntity tbCfAddress:TbCfAddressList) {
List<TbCfAddressEntity> tbCfAddressList=tbCfAddressDao.queryListByUserId(userId);
List<TbCfAddressVo> tbCfAddressVoList=new ArrayList<>();
if(tbCfAddressList!=null) {
for(TbCfAddressEntity tbCfAddress:tbCfAddressList) {
TbCfAddressVo tbCfAddressVo = new TbCfAddressVo();
BeanUtils.copyProperties(tbCfAddress,tbCfAddressVo);
TbCfAddressVoList.add(tbCfAddressVo);
tbCfAddressVoList.add(tbCfAddressVo);
}
}
return TbCfAddressVoList;
return tbCfAddressVoList;
}
@Override
......@@ -136,7 +136,7 @@ public class TbCfAddressServiceImpl implements TbCfAddressService {
user.setDefaultAddressId(addressId);
int userCount=tbCfUserInfoDao.update(user);
//重置用户地址
int resetCount=tbCfAddressDao.resetDefaulFlag(userId);
tbCfAddressDao.resetDefaulFlag(userId);//int resetCount=
//更新地址默认标志
TbCfAddressEntity tbCfAddressEntity = new TbCfAddressEntity();
tbCfAddressEntity.setAddressId(addressId);
......
......@@ -4,7 +4,7 @@ import com.diaoyun.zion.chinafrica.dao.TbCfCartRecordRDao;
import com.diaoyun.zion.chinafrica.entity.TbCfCartRecordREntity;
import com.diaoyun.zion.chinafrica.service.TbCfCartRecordRService;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.base.ResultCode;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
import com.diaoyun.zion.master.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -63,9 +63,9 @@ public class TbCfCartRecordRServiceImpl implements TbCfCartRecordRService {
public Result deleteItems(String[] cartRecordIds) {
int res=tbCfCartRecordRDao.deleteItems(cartRecordIds);
if(res>0) {
return new Result("修改成功");
return new Result(ResultCodeEnum.SUCCESS.getDesc());
} else {
return new Result("修改失败").setCode(ResultCode.ERROR);
return new Result().setCode(ResultCodeEnum.ERROR.getCode()).setMessage("fail to edit");
}
}
}
package com.diaoyun.zion.chinafrica.service.impl;
import com.diaoyun.zion.chinafrica.dao.TbCfContactDao;
import com.diaoyun.zion.chinafrica.entity.TbCfContactEntity;
import com.diaoyun.zion.chinafrica.service.TbCfContactService;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* 联系管理Service实现类
*
* @author lipengjun
* @date 2019-09-17 18:03:40
*/
@Service("tbCfContactService")
public class TbCfContactServiceImpl implements TbCfContactService {
@Autowired
private TbCfContactDao tbCfContactDao;
@Override
public TbCfContactEntity queryObject(String contactId) {
return tbCfContactDao.queryObject(contactId);
}
@Override
public List<TbCfContactEntity> queryList(Map<String, Object> map) {
return tbCfContactDao.queryList(map);
}
@Override
public int queryTotal(Map<String, Object> map) {
return tbCfContactDao.queryTotal(map);
}
@Override
public int save(TbCfContactEntity tbCfContact) {
tbCfContact.setContactId(IdUtil.createIdbyUUID());
return tbCfContactDao.save(tbCfContact);
}
@Override
public int update(TbCfContactEntity tbCfContact) {
return tbCfContactDao.update(tbCfContact);
}
@Override
public int delete(String contactId) {
return tbCfContactDao.delete(contactId);
}
@Override
public int deleteBatch(String[] contactIds) {
return tbCfContactDao.deleteBatch(contactIds);
}
@Override
public Result getContactList() {
List<TbCfContactEntity> contactList=tbCfContactDao.getContactList();
return new Result<>(contactList);
}
}
......@@ -8,10 +8,10 @@ import com.diaoyun.zion.chinafrica.entity.TbCfTakeCouponEntity;
import com.diaoyun.zion.chinafrica.service.TbCfCouponService;
import com.diaoyun.zion.chinafrica.vo.TbCfUserInfoVo;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.base.ResultCode;
import com.diaoyun.zion.master.base.StateConstant;
import com.diaoyun.zion.master.common.RedisCache;
import com.diaoyun.zion.master.common.TokenManager;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
import com.diaoyun.zion.master.util.CookieUtils;
import com.diaoyun.zion.master.util.IdUtil;
import org.apache.commons.lang3.StringUtils;
......@@ -91,23 +91,23 @@ public class TbCfCouponServiceImpl implements TbCfCouponService {
@Override
public Result takeCoupon(String couponId) {
Result result=new Result();
Result<TbCfCouponEntity> result=new Result<>();
//获取用户
String token = CookieUtils.getCookie(request, TokenManager.TOKEN);
TbCfUserInfoVo tbCfUserInfoVo = tokenManager.validate(token);
//判断用户是否已经领取
boolean takeFlag=repeatTakeCoupon(tbCfUserInfoVo.getUserId(),couponId);
if(takeFlag) {
result.setCode(ResultCode.ERROR).setMessage("你已经领取了此优惠券");
result.setCode(ResultCodeEnum.ERROR.getCode()).setMessage("You have already received this coupon");
} else {
TbCfCouponEntity tbCfCouponEntity=grabCoupon(couponId);
if(tbCfCouponEntity!=null) {
//发放优惠券
giveOutCoupon(tbCfUserInfoVo.getUserId(),tbCfCouponEntity);
result.setData(tbCfCouponEntity);
result.setMessage("领取成功");
result.setMessage("Successfully received");
} else {
result.setCode(ResultCode.ERROR).setMessage("已经被抢光了!");
result.setCode(ResultCodeEnum.ERROR.getCode()).setMessage("The coupon has been snapped up");
}
}
......@@ -161,7 +161,7 @@ public class TbCfCouponServiceImpl implements TbCfCouponService {
/**
* 设置优惠券缓存
* @param couponMap
* @param couponMap 优惠券map
*/
private void setCouponCache(Map<String, TbCfCouponEntity> couponMap) {
redisCache.set(KeyConstant.COUPON,couponMap);
......@@ -169,16 +169,12 @@ public class TbCfCouponServiceImpl implements TbCfCouponService {
/**
* 判断用户是否已经领取
* @param couponId
* @return
* @param couponId 优惠券id
* @return true or false
*/
private boolean repeatTakeCoupon(String userId,String couponId) {
String takeId=tbCfTakeCouponDao.queryTakeByCouponId(userId,couponId);
if(StringUtils.isBlank(takeId)) {
return false;
} else {
return true;
}
return !StringUtils.isBlank(takeId);
}
private void giveOutCoupon(String userId,TbCfCouponEntity tbCfCoupon) {
......@@ -191,8 +187,8 @@ public class TbCfCouponServiceImpl implements TbCfCouponService {
tbCfTakeCouponEntity.setUserId(userId);
tbCfTakeCouponEntity.setEnableFlag(StateConstant.VALID);
tbCfTakeCouponDao.save(tbCfTakeCouponEntity);
//更改原优惠券记录 不更改,因为会被覆盖,改为查询统计来获取已经领取的优惠券数量
//update(tbCfCoupon);
//不需要更改原优惠券记录 不更改,因为会被覆盖,改为查询统计来获取已经领取的优惠券数量
}
}
......@@ -4,6 +4,7 @@ import com.diaoyun.zion.chinafrica.dao.TbCfExpCatRelDao;
import com.diaoyun.zion.chinafrica.entity.TbCfExpCatRelEntity;
import com.diaoyun.zion.chinafrica.service.TbCfExpCatRelService;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
import com.diaoyun.zion.master.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -72,6 +73,11 @@ public class TbCfExpCatRelServiceImpl implements TbCfExpCatRelService {
tbCfExpCatRelList.add(tbCfExpCatRelEntity);
}
int res=tbCfExpCatRelDao.buildRelate(tbCfExpCatRelList);
return new Result("关联成功");
if(res>0) {
return new Result(ResultCodeEnum.SUCCESS.getDesc());
} else {
return new Result().setCode(ResultCodeEnum.ERROR.getCode()).setMessage(ResultCodeEnum.DAO_ERROR.getDesc());
}
}
}
package com.diaoyun.zion.chinafrica.service.impl;
import com.diaoyun.zion.chinafrica.dao.TbCfExpTemKeywordDao;
import com.diaoyun.zion.chinafrica.entity.TbCfExpTemKeywordEntity;
import com.diaoyun.zion.chinafrica.service.TbCfExpTemKeywordService;
import com.diaoyun.zion.master.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* 运费模板关键字对应表Service实现类
*
* @author lipengjun
* @date 2019-09-16 15:22:46
*/
@Service("tbCfExpTemKeywordService")
public class TbCfExpTemKeywordServiceImpl implements TbCfExpTemKeywordService {
@Autowired
private TbCfExpTemKeywordDao tbCfExpTemKeywordDao;
@Override
public TbCfExpTemKeywordEntity queryObject(Integer id) {
return tbCfExpTemKeywordDao.queryObject(id);
}
@Override
public List<TbCfExpTemKeywordEntity> queryList(Map<String, Object> map) {
return tbCfExpTemKeywordDao.queryList(map);
}
@Override
public int queryTotal(Map<String, Object> map) {
return tbCfExpTemKeywordDao.queryTotal(map);
}
@Override
public int save(TbCfExpTemKeywordEntity tbCfExpTemKeyword) {
tbCfExpTemKeyword.setId(IdUtil.createIdbyUUID());
return tbCfExpTemKeywordDao.save(tbCfExpTemKeyword);
}
@Override
public int update(TbCfExpTemKeywordEntity tbCfExpTemKeyword) {
return tbCfExpTemKeywordDao.update(tbCfExpTemKeyword);
}
@Override
public int delete(Integer id) {
return tbCfExpTemKeywordDao.delete(id);
}
@Override
public int deleteBatch(Integer[] ids) {
return tbCfExpTemKeywordDao.deleteBatch(ids);
}
}
......@@ -3,10 +3,19 @@ package com.diaoyun.zion.chinafrica.service.impl;
import com.diaoyun.zion.chinafrica.dao.TbCfFeedbackDao;
import com.diaoyun.zion.chinafrica.entity.TbCfFeedbackEntity;
import com.diaoyun.zion.chinafrica.service.TbCfFeedbackService;
import com.diaoyun.zion.chinafrica.vo.TbCfUserInfoVo;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.base.StateConstant;
import com.diaoyun.zion.master.common.TokenManager;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
import com.diaoyun.zion.master.util.CookieUtils;
import com.diaoyun.zion.master.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -21,6 +30,13 @@ public class TbCfFeedbackServiceImpl implements TbCfFeedbackService {
@Autowired
private TbCfFeedbackDao tbCfFeedbackDao;
@Autowired
@Qualifier("redisTokenManager")
private TokenManager tokenManager;
@Autowired
private HttpServletRequest request; //自动注入request
@Override
public TbCfFeedbackEntity queryObject(String feedbackId) {
return tbCfFeedbackDao.queryObject(feedbackId);
......@@ -56,4 +72,23 @@ public class TbCfFeedbackServiceImpl implements TbCfFeedbackService {
public int deleteBatch(String[] feedbackIds) {
return tbCfFeedbackDao.deleteBatch(feedbackIds);
}
@Override
public Result saveFeedback(TbCfFeedbackEntity tbCfFeedbackEntity) {
Result result=new Result();
//获取用户
String token = CookieUtils.getCookie(request, TokenManager.TOKEN);
TbCfUserInfoVo tbCfUserInfoVo = tokenManager.validate(token);
tbCfFeedbackEntity.setFeedbackId(IdUtil.createIdbyUUID());
tbCfFeedbackEntity.setUserId(tbCfUserInfoVo.getUserId());
tbCfFeedbackEntity.setEnableFlag(StateConstant.VALID);
tbCfFeedbackEntity.setCreateTime(new Date());
int res=tbCfFeedbackDao.save(tbCfFeedbackEntity);
if(res>0) {
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
} else {
result.setCode(ResultCodeEnum.DAO_ERROR.getCode()).setMessage(ResultCodeEnum.DAO_ERROR.getDesc());
}
return result;
}
}
package com.diaoyun.zion.chinafrica.service.impl;
import com.diaoyun.zion.chinafrica.dao.TbCfHomePageDao;
import com.diaoyun.zion.chinafrica.entity.TbCfHomePageEntity;
import com.diaoyun.zion.chinafrica.service.TbCfHomePageService;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* 启动页Service实现类
*
* @author lipengjun
* @date 2019-09-16 18:21:16
*/
@Service("tbCfHomePageService")
public class TbCfHomePageServiceImpl implements TbCfHomePageService {
@Autowired
private TbCfHomePageDao tbCfHomePageDao;
@Override
public TbCfHomePageEntity queryObject(String pageId) {
return tbCfHomePageDao.queryObject(pageId);
}
@Override
public List<TbCfHomePageEntity> queryList(Map<String, Object> map) {
return tbCfHomePageDao.queryList(map);
}
@Override
public int queryTotal(Map<String, Object> map) {
return tbCfHomePageDao.queryTotal(map);
}
@Override
public int save(TbCfHomePageEntity tbCfHomePage) {
tbCfHomePage.setPageId(IdUtil.createIdbyUUID());
return tbCfHomePageDao.save(tbCfHomePage);
}
@Override
public int update(TbCfHomePageEntity tbCfHomePage) {
return tbCfHomePageDao.update(tbCfHomePage);
}
@Override
public int delete(String pageId) {
return tbCfHomePageDao.delete(pageId);
}
@Override
public int deleteBatch(String[] pageIds) {
return tbCfHomePageDao.deleteBatch(pageIds);
}
@Override
public Result getStartPageImage() {
List<TbCfHomePageEntity> homePageList=tbCfHomePageDao.getStartPageImage();
return new Result<>(homePageList).setMessage("images of start page");
}
}
......@@ -9,9 +9,9 @@ import com.diaoyun.zion.chinafrica.vo.TbCfCartItemDetailVo;
import com.diaoyun.zion.chinafrica.vo.TbCfItemDetailVo;
import com.diaoyun.zion.chinafrica.vo.TbCfUserInfoVo;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.base.ResultCode;
import com.diaoyun.zion.master.base.StateConstant;
import com.diaoyun.zion.master.common.TokenManager;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
import com.diaoyun.zion.master.util.CookieUtils;
import com.diaoyun.zion.master.util.IdUtil;
import org.springframework.beans.BeanUtils;
......@@ -100,7 +100,7 @@ public class TbCfItemDetailServiceImpl implements TbCfItemDetailService {
tbCfCartRecordREntity.setUserId(tbCfUserInfoVo.getUserId());
tbCfCartRecordREntity.setCreateTime(new Date());
tbCfCartRecordRDao.save(tbCfCartRecordREntity);
return new Result("成功加入购物车");
return new Result(ResultCodeEnum.SUCCESS.getDesc());
}
@Override
......@@ -110,9 +110,9 @@ public class TbCfItemDetailServiceImpl implements TbCfItemDetailService {
tbCfItemDetailEntity.setItemNum(itemNum);
int res=tbCfItemDetailDao.update(tbCfItemDetailEntity);
if(res>0) {
return new Result("修改成功");
return new Result(ResultCodeEnum.SUCCESS.getDesc());
} else {
return new Result("修改失败").setCode(ResultCode.ERROR);
return new Result().setCode(ResultCodeEnum.ERROR.getCode()).setMessage("fail to edit");
}
}
......@@ -123,16 +123,15 @@ public class TbCfItemDetailServiceImpl implements TbCfItemDetailService {
String token = CookieUtils.getCookie(request, TokenManager.TOKEN);
TbCfUserInfoVo tbCfUserInfoVo = tokenManager.validate(token);
String userId=tbCfUserInfoVo.getUserId();
List<TbCfCartItemDetailVo> TbCfCartItemDetailList=tbCfItemDetailDao.getCartItemList(userId,null);
return TbCfCartItemDetailList;
return tbCfItemDetailDao.getCartItemList(userId,null);
}
@Override
public Result changeItemState(String cartRecordId, Integer checkFlag) {
Result result=new Result("修改成功");
Result result=new Result(ResultCodeEnum.SUCCESS.getDesc());
int res=tbCfItemDetailDao.changeItemState(cartRecordId,checkFlag);
if(res<1) {
result.setMessage("修改失败");
result.setCode(ResultCodeEnum.ERROR.getCode()).setMessage("fail to edit");
}
return result;
}
......
......@@ -5,7 +5,6 @@ import com.diaoyun.zion.chinafrica.entity.TbCfPlatformEntity;
import com.diaoyun.zion.chinafrica.service.TbCfPlatformService;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.util.IdUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -13,6 +12,8 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import static com.github.pagehelper.page.PageMethod.startPage;
/**
* 平台管理Service实现类
*
......@@ -62,11 +63,10 @@ public class TbCfPlatformServiceImpl implements TbCfPlatformService {
@Override
public Result getPlatformList(Integer pageNum, Integer pageSize) {
Result result = new Result();
PageHelper.startPage(pageNum,pageSize);
Result<PageInfo> result = new Result<>();
startPage(pageNum,pageSize);
List<TbCfPlatformEntity> tbCfPlatformList=tbCfPlatformDao.getPlatformList();
PageInfo<TbCfPlatformEntity> pageInfo = new PageInfo<>(tbCfPlatformList);
//List<TbCfPlatformEntity> pagingPlatformList=pageInfo.getList();
result.setData(pageInfo);
return result;
}
......
......@@ -3,13 +3,17 @@ package com.diaoyun.zion.chinafrica.service.impl;
import com.diaoyun.zion.chinafrica.dao.TbCfProblemDao;
import com.diaoyun.zion.chinafrica.entity.TbCfProblemEntity;
import com.diaoyun.zion.chinafrica.service.TbCfProblemService;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.util.IdUtil;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import static com.github.pagehelper.page.PageMethod.startPage;
/**
* 常见问题Service实现类
*
......@@ -56,4 +60,14 @@ public class TbCfProblemServiceImpl implements TbCfProblemService {
public int deleteBatch(String[] problemIds) {
return tbCfProblemDao.deleteBatch(problemIds);
}
@Override
public Result getProblemList(Integer pageNum, Integer pageSize) {
Result<PageInfo> result = new Result<>();
startPage(pageNum,pageSize);
List<TbCfProblemEntity> problemList=tbCfProblemDao.getProblemList();
PageInfo<TbCfProblemEntity> pageInfo = new PageInfo<>(problemList);
result.setData(pageInfo);
return result;
}
}
......@@ -6,7 +6,6 @@ import com.diaoyun.zion.chinafrica.entity.TbCfStationItemEntity;
import com.diaoyun.zion.chinafrica.service.TbCfStationItemService;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.util.IdUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -14,6 +13,8 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import static com.github.pagehelper.page.PageMethod.startPage;
/**
* 站点商品Service实现类
*
......@@ -63,11 +64,10 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
@Override
public Result getItemStationList(Integer pageNum, Integer pageSize) {
Result result = new Result();
PageHelper.startPage(pageNum,pageSize);
Result<PageInfo> result = new Result<>();
startPage(pageNum,pageSize);
List<TbCfPlatformEntity> tbCfPlatformList=tbCfStationItemDao.getItemStationList();
PageInfo<TbCfPlatformEntity> pageInfo = new PageInfo<>(tbCfPlatformList);
//List<TbCfPlatformEntity> pagingPlatformList=pageInfo.getList();
result.setData(pageInfo);
return result;
}
......
......@@ -9,11 +9,11 @@ import com.diaoyun.zion.chinafrica.entity.TbCfUserInfoEntity;
import com.diaoyun.zion.chinafrica.service.TbCfUserInfoService;
import com.diaoyun.zion.chinafrica.vo.TbCfUserInfoVo;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.base.ResultCode;
import com.diaoyun.zion.master.base.StateConstant;
import com.diaoyun.zion.master.bo.EmailTemplateBo;
import com.diaoyun.zion.master.common.TokenManager;
import com.diaoyun.zion.master.config.DomainProperties;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
import com.diaoyun.zion.master.enums.SexEnum;
import com.diaoyun.zion.master.enums.TrueFalseEnum;
import com.diaoyun.zion.master.enums.UserTypeEnum;
......@@ -23,6 +23,7 @@ import com.diaoyun.zion.master.validator.Validator;
import freemarker.template.TemplateException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.mail.EmailException;
import org.apache.http.Consts;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -115,14 +116,14 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
Result result = new Result();
Integer identifyCode = (Integer) request.getSession().getAttribute(KeyConstant.IDENTIFY_CODE);
if (identifyCode == null || identifyCode.intValue() != tbCfUserInfoVo.getCaptcha().intValue()) {
result.setCode(ResultCode.VALIDATE_ERROR);
result.setMessage("验证码错误");
result.setCode(ResultCodeEnum.VALIDATE_ERROR.getCode());
result.setMessage("Verification code error");
} else {
//验证邮箱有没有被注册
TbCfUserInfoEntity existUser = findByAccount(tbCfUserInfoVo.getEmail());
if (existUser == null) {
//验证邮箱格式
Validator.NOT_BLANK.validate("邮箱", tbCfUserInfoVo.getEmail());
Validator.NOT_BLANK.validate("email", tbCfUserInfoVo.getEmail());
TbCfUserInfoEntity tbCfUserInfoEntity = new TbCfUserInfoEntity();
/**
......@@ -142,11 +143,11 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
String token = createToken(tbCfUserInfoVo);
addTokenInCookie(token, request, response);
SessionUtils.setSessionUser(request, new SessionUser(token, tbCfUserInfoVo.getAccount()));
result.setMessage("注册成功!");
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
result.setData(tbCfUserInfoVo);
} else {
result.setCode(ResultCode.VALIDATE_ERROR);
result.setMessage("邮箱已被注册!");
result.setCode(ResultCodeEnum.VALIDATE_ERROR.getCode());
result.setMessage("The mailbox has been registered");
}
tbCfUserInfoVo.setEnableFlag(StateConstant.VALID);
......@@ -168,7 +169,7 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
if(StringUtils.isBlank(account)||StringUtils.isBlank(password)) {
tokenManager.remove(token);
CookieUtils.removeCookie(response, TokenManager.TOKEN, "/", null);
result.setCode(ResultCode.NEED_LOGIN).setMessage("请重新登录");
result.setCode(ResultCodeEnum.NEED_LOGIN.getCode()).setMessage(ResultCodeEnum.NEED_LOGIN.getDesc());
} else {
password = PasswordProvider.encrypt(password);
result = loginOfficial(ip, account,password, token);
......@@ -186,8 +187,8 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
result = loginOfficial(ip, account,password, token);
}
} else {
Validator.NOT_BLANK.validate("账号", account);
Validator.NOT_BLANK.validate("密码", password);
Validator.NOT_BLANK.validate("account", account);
Validator.NOT_BLANK.validate("password", password);
password = PasswordProvider.encrypt(password);
result = loginOfficial(ip, account, password, null);
......@@ -209,11 +210,11 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
Result result = new Result();
TbCfUserInfoEntity user = findByAccount(account);
if (user == null) {
result.setCode(ResultCode.ERROR).setMessage("账号不存在");
result.setCode(ResultCodeEnum.ERROR.getCode()).setMessage("Account does not exist");
} else if (user.getPassword()!=null&&!user.getPassword().equals(password)) {
result.setCode(ResultCode.ERROR).setMessage("密码不正确");
result.setCode(ResultCodeEnum.ERROR.getCode()).setMessage("The password is incorrect");
} else if (TrueFalseEnum.FALSE.getValue().equals(user.getEnableFlag())) {
result.setCode(ResultCode.ERROR).setMessage("已被用户禁用");
result.setCode(ResultCodeEnum.ERROR.getCode()).setMessage("User is disabled");
CookieUtils.removeCookie(response, TokenManager.TOKEN, "/", null);
} else {
user.setLastLoginIp(ip);
......@@ -233,7 +234,7 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
tokenManager.addToken(token, loginUser);
}
SessionUtils.setSessionUser(request, new SessionUser(token, loginUser.getAccount()));
result.setData(loginUser).setMessage("登录成功");
result.setData(loginUser).setMessage(ResultCodeEnum.SUCCESS.getDesc());
}
return result;
}
......@@ -254,9 +255,9 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
int res = tbCfUserInfoDao.updatePassWord(userId, newPassword, oldPassword);
if (res > 0) {
logout();
result.setMessage("修改成功");
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
} else {
result.setCode(ResultCode.ERROR).setMessage("旧密码错误");
result.setCode(ResultCodeEnum.ERROR.getCode()).setMessage("The original password is wrong");
}
return result;
}
......@@ -268,7 +269,7 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
tokenManager.remove(token);
}
SessionUtils.invalidate(request);
return new Result("已退出登录");
return new Result("login out");
}
@Override
......@@ -293,7 +294,7 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
TbCfUserInfoVo tbCfUserInfoVo = tokenManager.validate(token);
if (tbCfUserInfoVo == null) {
CookieUtils.removeCookie(response, TokenManager.TOKEN, "/", null);
result.setCode(ResultCode.ERROR).setMessage("请重新登录");
result.setCode(ResultCodeEnum.ERROR.getCode()).setMessage("please login again");
} else {
if(StringUtils.isBlank(account)) {
account=tbCfUserInfoVo.getAccount();
......@@ -303,12 +304,11 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
}
loginByThirdPartyOfficial(token, ip,account ,nick , result);
}
//return "redirect:" + authBackUrl(backUrl, token);
} else {
Validator.NOT_BLANK.validate("账号", account);
Validator.NOT_BLANK.validate("用户昵称", nick);
Validator.NOT_BLANK.validate("用户类型", userType);
nick = URLDecoder.decode(nick, "UTF-8");
Validator.NOT_BLANK.validate("account", account);
Validator.NOT_BLANK.validate("nick", nick);
Validator.NOT_BLANK.validate("userType", userType);
nick = URLDecoder.decode(nick, Consts.UTF_8.name());
//根据账号找用户
TbCfUserInfoEntity oldUser = findByAccount(account);
//新用户则注册
......@@ -339,9 +339,9 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
tbCfUserInfoDao.update(oldUser);
//为用户添加token
buildUserToken(oldUser);
result.setData(oldUser).setMessage("登录成功");
result.setData(oldUser).setMessage(ResultCodeEnum.SUCCESS.getDesc());
} else {
result.setCode(ResultCode.NEED_LOGIN).setMessage("请重新登录");
result.setCode(ResultCodeEnum.NEED_LOGIN.getCode()).setMessage("please login again");
}
}
......@@ -413,11 +413,11 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
TbCfUserInfoVo loginUser = new TbCfUserInfoVo();
BeanUtils.copyProperties(user, loginUser);
tokenManager.addToken(token, loginUser);
result.setData(user).setMessage("登录成功");
result.setData(user).setMessage(ResultCodeEnum.SUCCESS.getDesc());
} else {
tokenManager.remove(token);
CookieUtils.removeCookie(response, TokenManager.TOKEN, "/", null);
result.setCode(ResultCode.NEED_LOGIN).setMessage("请重新登录");
result.setCode(ResultCodeEnum.NEED_LOGIN.getCode()).setMessage("please login again");
}
}
......
package com.diaoyun.zion.master.base;
import java.io.Serializable;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
/**
* 返回结果
*
* @author Joe
*/
public class Result<T> implements Serializable {
public class Result<T> {
/**
* 结果体
......@@ -30,7 +29,7 @@ public class Result<T> implements Serializable {
* code 默认成功
*/
public Result() {
this.code = ResultCode.SUCCESS;
this.code = ResultCodeEnum.SUCCESS.getCode();
}
public Result(Integer code) {
......@@ -43,7 +42,7 @@ public class Result<T> implements Serializable {
* @param message
*/
public Result(String message) {
this.code = ResultCode.SUCCESS;
this.code = ResultCodeEnum.SUCCESS.getCode();
this.message = message;
}
......@@ -52,7 +51,7 @@ public class Result<T> implements Serializable {
* @param data
*/
public Result(T data) {
this.code = ResultCode.SUCCESS;
this.code = ResultCodeEnum.SUCCESS.getCode();
this.data = data;
}
......@@ -67,7 +66,7 @@ public class Result<T> implements Serializable {
* @param message
*/
public Result(T data, String message) {
this.code = ResultCode.SUCCESS;
this.code = ResultCodeEnum.SUCCESS.getCode();
this.data = data;
this.message = message;
}
......
package com.diaoyun.zion.master.base;
/**
* 基础返回码,具体业务返回码可继承ResultCode
*
* @author Joe
*/
public class ResultCode {
public final static int SUCCESS = 1;// 成功
public final static int NEED_LOGIN = 0000;// 需要登录
// 通用错误以9开头
public final static int ERROR = 9999;// 未知错误
public final static int APPLICATION_ERROR = 9000;// 应用级错误
public final static int VALIDATE_ERROR = 9001;// 参数验证错误
public final static int SERVICE_ERROR = 9002;// 业务逻辑验证错误
public final static int CACHE_ERROR = 9003;// 缓存访问错误
public final static int DAO_ERROR = 9004;// 数据访问错误
}
package com.diaoyun.zion.master.base;
import com.diaoyun.zion.master.enums.ResponseCodeEnum;
//import com.fasterxml.jackson.annotation.JsonIgnore;
import java.io.Serializable;
//保证序列化json的时候,如果是null的对象,key也会消失
/*
这里加这个的原因是:
当登陆失败的话返回的是{
status : 1
msg : 密码错误
而data是一个有key的空节点,即value = null
}
这样的话data将不会出现在json之中了。
补充:
将该标记放在属性上,如果该属性为NULL则不参与序列化
如果放在类上边,那对这个类的全部属性起作用
Include.Include.ALWAYS 默认
Include.NON_DEFAULT 属性为默认值不序列化
Include.NON_EMPTY 属性为 空(“”) 或者为 NULL 都不序列化
Include.NON_NULL 属性为NULL 不序列化 。
*/
//@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class ServerResponse<T> implements Serializable {
private int status; //状态
private String msg; //信息
private T data; //数据
//定义4个构造方法
//1
private ServerResponse(int status) {
this.status = status;
}
//2
private ServerResponse(int status,T data){
this.status = status;
this.data = data;
}
//3
private ServerResponse(int status,String msg,T data){
this.status = status;
this.msg = msg;
this.data = data;
}
//4
private ServerResponse(int status,String msg){
this.status = status;
this.msg = msg;
}
//@JsonIgnore
//使之不在json序列化结果当中
//即json里面不会出现这个
public boolean isSuccess(){
//如果status == 0 则返回true
//SUCCESS的枚举值为0
return this.status == ResponseCodeEnum.SUCCESS.getCode();
}
//返回状态
public int getStatus(){
return status;
}
public T getData(){
return data;
}
public String getMsg(){
return msg;
}
//调用status构造器
public static <T> ServerResponse<T> createBySuccess(){
return new ServerResponse<T>(ResponseCodeEnum.SUCCESS.getCode());
}
//调用4号构造器
public static <T> ServerResponse<T> createBySuccessMessage(String msg){
return new ServerResponse<T>(ResponseCodeEnum.SUCCESS.getCode(),msg);
}
public static <T> ServerResponse<T> createBySuccess(T data){
return new ServerResponse<T>(ResponseCodeEnum.SUCCESS.getCode(),data);
}
public static <T> ServerResponse<T> createBySuccess(String msg,T data){
return new ServerResponse<T>(ResponseCodeEnum.SUCCESS.getCode(),msg,data);
}
public static <T> ServerResponse<T> createByError(){
return new ServerResponse<T>(ResponseCodeEnum.ERROR.getCode(),ResponseCodeEnum.ERROR.getDesc());
}
public static <T> ServerResponse<T> createByErrorMessage(String errorMessage){
return new ServerResponse<T>(ResponseCodeEnum.ERROR.getCode(),errorMessage);
}
public static <T> ServerResponse<T> createByErrorCodeMessage(int errorCode,String errorMessage){
return new ServerResponse<T>(errorCode,errorMessage);
}
}
......@@ -4,6 +4,7 @@ import org.apache.ibatis.cache.CacheException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.RedisTemplate;
......@@ -15,12 +16,13 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@Component
@Component("redisCache")
public class RedisCache<T> {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Resource(name="redisTemplate")
@Autowired
@Qualifier("redisTemplate")
private RedisTemplate<String, T> redisTemplate;
public static final String KEY_SET_PREFIX = "_set:";
......
......@@ -4,7 +4,9 @@ import com.diaoyun.zion.chinafrica.vo.TbCfUserInfoVo;
import com.diaoyun.zion.master.config.DomainProperties;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -17,7 +19,8 @@ public class RedisTokenManager extends TokenManager {
@Autowired
private DomainProperties domainProperties;
@Resource
@Autowired
@Qualifier("redisCache")
private RedisCache<TbCfUserInfoVo> redisCache;
@Override
......
......@@ -6,11 +6,11 @@ import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Component("domainProperties")
@PropertySource({"classpath:properties/domain.properties"})
/**
* domain.properties 配置类
*/
@Component("domainProperties")
@PropertySource({"classpath:properties/domain.properties"})
public class DomainProperties {
@Autowired
......
package com.diaoyun.zion.master.enums;
@Deprecated
public enum ResponseCodeEnum {
SUCCESS(0,"SUCCESS"),
ERROR(1,"ERROR"),
......
package com.diaoyun.zion.master.enums;
public enum ResultCodeEnum {
SUCCESS(1,"success"),
ERROR(9999,"unknown error"),
APPLICATION_ERROR(9000,"application error"),
VALIDATE_ERROR(9001,"validate error"),
SERVICE_ERROR(9002,"service error"),
CACHE_ERROR(9003,"cache error"),
DAO_ERROR(9004,"dao error"),
NEED_LOGIN(10,"need login"),
ILLEGAL_ARGUMENT(2,"illegal argument");
//成员变量(常量)
private final int code;
private final String desc;
//构造方法
ResultCodeEnum(int code, String desc){
this.code = code;
this.desc = desc;
}
//普通函数
public int getCode(){
return code;
}
public String getDesc(){
return desc;
}
}
package com.diaoyun.zion.master.exception;
import com.diaoyun.zion.master.base.ResultCode;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
/**
* 应用异常
......@@ -14,7 +14,7 @@ public class ApplicationException extends RuntimeException{
public static final String MESSAGE = "应用异常";
protected int code = ResultCode.APPLICATION_ERROR;
protected int code = ResultCodeEnum.APPLICATION_ERROR.getCode();
public ApplicationException() {
super(MESSAGE);
......
package com.diaoyun.zion.master.exception;
import com.diaoyun.zion.master.base.ResultCode;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
/**
* 数据访问异常
......@@ -19,7 +20,7 @@ public class DaoException extends ApplicationException {
public DaoException(String message) {
super(message);
this.code = ResultCode.DAO_ERROR;
this.code = ResultCodeEnum.DAO_ERROR.getCode();
}
public DaoException(int code, String message) {
......@@ -29,7 +30,7 @@ public class DaoException extends ApplicationException {
public DaoException(String message, Throwable cause) {
super(message, cause);
this.code = ResultCode.DAO_ERROR;
this.code = ResultCodeEnum.DAO_ERROR.getCode();
}
public DaoException(int code, String message, Throwable cause) {
......@@ -39,6 +40,6 @@ public class DaoException extends ApplicationException {
public DaoException(Throwable cause) {
super(cause);
this.code = ResultCode.DAO_ERROR;
this.code = ResultCodeEnum.DAO_ERROR.getCode();
}
}
......@@ -2,7 +2,7 @@ package com.diaoyun.zion.master.exception;
import com.alibaba.fastjson.JSON;
import com.diaoyun.zion.master.base.Result;
import com.diaoyun.zion.master.base.ResultCode;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
......@@ -34,7 +34,7 @@ public class ExceptionResolver implements HandlerExceptionResolver {
result = new Result(ae.getCode(),ae.getMessage());
}
else {
result = new Result(ResultCode.ERROR,exception.getMessage());
result = new Result(ResultCodeEnum.ERROR.getCode(),exception.getMessage());
logger.error(exception.getMessage(), exception);
}
......
package com.diaoyun.zion.master.exception;
import com.diaoyun.zion.master.base.ResultCode;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
/**
* 业务逻辑异常
......@@ -19,7 +20,7 @@ public class ServiceException extends ApplicationException{
public ServiceException(String message) {
super(message);
this.code = ResultCode.SERVICE_ERROR;
this.code = ResultCodeEnum.SERVICE_ERROR.getCode();
}
public ServiceException(int code, String message) {
......@@ -29,7 +30,7 @@ public class ServiceException extends ApplicationException{
public ServiceException(String message, Throwable cause) {
super(message, cause);
this.code = ResultCode.SERVICE_ERROR;
this.code = ResultCodeEnum.SERVICE_ERROR.getCode();
}
public ServiceException(int code, String message, Throwable cause) {
......@@ -39,6 +40,6 @@ public class ServiceException extends ApplicationException{
public ServiceException(Throwable cause) {
super(cause);
this.code = ResultCode.SERVICE_ERROR;
this.code = ResultCodeEnum.SERVICE_ERROR.getCode();
}
}
package com.diaoyun.zion.master.exception;
import com.diaoyun.zion.master.base.ResultCode;
import com.diaoyun.zion.master.enums.ResultCodeEnum;
/**
* 验证异常
......@@ -20,7 +20,7 @@ public class ValidateException extends ApplicationException {
public ValidateException(String message) {
super(message);
this.code = ResultCode.VALIDATE_ERROR;
this.code = ResultCodeEnum.VALIDATE_ERROR.getCode();
}
public ValidateException(int code, String message) {
......@@ -30,7 +30,7 @@ public class ValidateException extends ApplicationException {
public ValidateException(String message, Throwable cause) {
super(message, cause);
this.code = ResultCode.VALIDATE_ERROR;
this.code = ResultCodeEnum.VALIDATE_ERROR.getCode();
}
public ValidateException(int code, String message, Throwable cause) {
......@@ -40,6 +40,6 @@ public class ValidateException extends ApplicationException {
public ValidateException(Throwable cause) {
super(cause);
this.code = ResultCode.VALIDATE_ERROR;
this.code = ResultCodeEnum.VALIDATE_ERROR.getCode();
}
}
......@@ -4,6 +4,7 @@ import com.diaoyun.zion.master.util.HttpClientUtil;
import com.diaoyun.zion.master.util.SortUtil;
import net.sf.json.JSONObject;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.http.Consts;
import java.util.Map;
import java.util.SortedMap;
......@@ -19,7 +20,7 @@ public abstract class AbstractTencentCallable<T> implements Callable<Map<String,
protected T param;
//编码方式
protected String charencode;
protected String charset;
@Override
public Map<String, Object> call() throws Exception {
......@@ -28,10 +29,10 @@ public abstract class AbstractTencentCallable<T> implements Callable<Map<String,
// TODO 去除class说明,或许可以尝试别的方法
paramMap.remove("class");
SortedMap<String, Object> sortMap = new TreeMap<String, Object>(paramMap);
String sign = SortUtil.createSign(sortMap,charencode);
String sign = SortUtil.createSign(sortMap,charset);
paramMap.put("sign", sign);
//发送请求
String resultStr = HttpClientUtil.createConnection(this.app_url, paramMap,charencode);
String resultStr = HttpClientUtil.createConnection(this.app_url, paramMap,charset);
Map<String, Object> resultMap = JSONObject.fromObject(resultStr);
return resultMap;
}
......
......@@ -9,6 +9,8 @@ import com.diaoyun.zion.master.util.SortUtil;
import com.diaoyun.zion.master.util.SpringContextUtil;
import net.sf.json.JSONObject;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.http.Consts;
import org.apache.http.protocol.HTTP;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -27,13 +29,12 @@ public class TranslateCallable extends AbstractTencentCallable<TencentTranslateP
this.app_id = Integer.valueOf(domainProperties.getProperty("tencent.translate.app_id"));
this.app_url = domainProperties.getProperty("tencent.translate.app_url");
this.param = param;
this.charencode="UTF-8";
this.charset=Consts.UTF_8.name();
}
// TODO 泛型
@Override
public Map<String, Object> call() throws Exception {
//logger.info("call()方法被自动调用!!! " + Thread.currentThread().getName());
//填充参数
fillParam(param);
Map<String, Object> resultMap = super.call();
......
......@@ -19,7 +19,7 @@ public class WordposCallable extends AbstractTencentCallable<TencentWordsegParam
this.app_id = Integer.valueOf(domainProperties.getProperty("tencent.translate.app_id"));
this.app_url = domainProperties.getProperty("tencent.wordpos.app_url");
this.param = param;
this.charencode="GBK";
this.charset="GBK";
}
@Override
......
package com.diaoyun.zion.master.util;
import org.apache.http.Consts;
import org.springframework.util.Base64Utils;
import javax.crypto.Cipher;
......@@ -23,8 +24,8 @@ public class AESUtils {
*/
public static String encrypt(String key, String value) {
try {
IvParameterSpec iv = new IvParameterSpec(INIT_VECTOR.getBytes("UTF-8"));
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
IvParameterSpec iv = new IvParameterSpec(INIT_VECTOR.getBytes(Consts.UTF_8.name()));
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(Consts.UTF_8.name()), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
......@@ -46,8 +47,8 @@ public class AESUtils {
*/
public static String decrypt(String key, String encrypted) {
try {
IvParameterSpec iv = new IvParameterSpec(INIT_VECTOR.getBytes("UTF-8"));
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
IvParameterSpec iv = new IvParameterSpec(INIT_VECTOR.getBytes(Consts.UTF_8.name()));
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(Consts.UTF_8.name()), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
......
......@@ -8,6 +8,7 @@ import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import org.apache.http.Consts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -32,7 +33,7 @@ public class EmailHelper {
/*Configuration cfg = new Configuration(Configuration.VERSION_2_3_28);
// 初始化一些配置
cfg.setDirectoryForTemplateLoading(new File("/"));
cfg.setDefaultEncoding("UTF-8");
cfg.setDefaultEncoding(Consts.UTF_8.name());
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);*/
Template t = configuration.getTemplate(templateName);
Map<String, Object> model = new HashMap<>();
......@@ -41,7 +42,7 @@ public class EmailHelper {
String html = FreeMarkerTemplateUtils.processTemplateIntoString(t, model);
HtmlEmail email = new HtmlEmail();//创建一个HtmlEmail实例对象
email.setHostName(domainProperties.getProperty("email.hostName"));//邮箱的SMTP服务器,一般123邮箱的是smtp.123.com,qq邮箱为smtp.qq.com
email.setCharset("utf-8");//设置发送的字符类型
email.setCharset(Consts.UTF_8.name());//设置发送的字符类型
//email.addTo("zhengfanguang@163.com");//设置收件人
email.addTo(toEmail);//设置收件人
email.setFrom(domainProperties.getProperty("email.from.email"), domainProperties.getProperty("email.from.name"));//发送人的邮箱为自己的,用户名可以随便填
......
......@@ -2,9 +2,11 @@ package com.diaoyun.zion.master.util;
import com.diaoyun.zion.chinafrica.enums.PlatformEnum;
import com.google.common.collect.Lists;
import net.sf.json.JSONObject;
import org.apache.http.*;
import org.apache.http.client.CookieStore;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.client.utils.URIBuilder;
......@@ -24,10 +26,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
public class HttpClientUtil {
private static Logger logger = LoggerFactory.getLogger(HttpClientUtil.class);
......@@ -74,9 +73,9 @@ public class HttpClientUtil {
result = new DeflateDecompressingEntity(result);
}
}*/
String defaultCharset="UTF-8";
String defaultCharset=Consts.UTF_8.name();
if(PlatformEnum.TM.getValue().equals(sourceType)) {
defaultCharset="UTF-8";
defaultCharset=Consts.UTF_8.name();
}
String content = EntityUtils.toString(result, defaultCharset);
//logger.info(content);
......@@ -170,22 +169,23 @@ public class HttpClientUtil {
}
//发送请求
public static String createConnection(String url,Map<String, Object> paramMap,String charencode) throws IOException {
public static String createConnection(String url,Map<String, Object> paramMap,String charset) throws IOException {
List<NameValuePair> formparams = setHttpParams(paramMap);
String param = URLEncodedUtils.format(formparams, charencode);
String param = URLEncodedUtils.format(formparams, charset);
HttpGet httpGet = new HttpGet(); //构建一个GET请求
httpGet.setURI(URI.create(url + "?" + param));
CloseableHttpClient httpClient=createBrowserClient();
HttpResponse sibResponse=httpClient.execute(httpGet);
HttpEntity sibResult = sibResponse.getEntity();//拿到返回的HttpResponse的"实体"
String sibContent = EntityUtils.toString(sibResult);
return sibContent;
return EntityUtils.toString(sibResult);
}
private static List<NameValuePair> setHttpParams(Map<String, Object> paramsMap) {
List<NameValuePair> list = new ArrayList<NameValuePair>();
for (String key : paramsMap.keySet()) {
list.add(new BasicNameValuePair(key, String.valueOf(paramsMap.get(key))));
List<NameValuePair> list = new ArrayList<>();
for (Map.Entry<String, Object> stringObjectEntry : paramsMap.entrySet()) {
String key = stringObjectEntry.getKey();
String value = (String) stringObjectEntry.getValue();
list.add(new BasicNameValuePair(key, value));
}
return list;
}
......@@ -199,11 +199,37 @@ public class HttpClientUtil {
URL url = new URL(targetUrl);
//构建URI
URI uri=new URI(url.getProtocol(), url.getHost(), url.getPath(), url.getQuery(), null);
List<NameValuePair> params = URLEncodedUtils.parse(uri, Charset.forName("UTF-8"));
List<NameValuePair> params = URLEncodedUtils.parse(uri, Charset.forName(Consts.UTF_8.name()));
Map<String,String> paramMap=new HashMap<>();
for (NameValuePair param : params) {
paramMap.put(param.getName(),param.getValue());
}
return paramMap;
}
/**
* 获取商品物流信息 TODO 还需验证
* @param url
* @param paramMap
* @return
* @throws URISyntaxException
* @throws IOException
*/
public static String getItemTrack(String url,Map<String,Object> paramMap) throws URISyntaxException, IOException {
List<NameValuePair> formparams = setHttpParams(paramMap);
String param = URLEncodedUtils.format(formparams, Consts.UTF_8.name());
HttpPost httpPost = new HttpPost(); //构建一个Post请求
httpPost.setURI(URI.create(url + "?" + param));
//构造自定义的HttpClient对象
CloseableHttpClient sibClient = HttpClients.custom().build();
//执行请求,传入HttpContext,将会得到请求结果的信息
HttpResponse sibResponse=sibClient.execute(httpPost);
//拿到返回的HttpResponse的"实体"
HttpEntity sibResult = sibResponse.getEntity();
String sibContent = EntityUtils.toString(sibResult);
//unicode 解码
//关闭连接
sibClient.close();
return sibContent;
}
}
......@@ -13,7 +13,7 @@ public class SortUtil {
* @param parameters
* @return
*/
public static String createSign(SortedMap<String,Object> parameters,String charencode) throws UnsupportedEncodingException {
public static String createSign(SortedMap<String,Object> parameters,String charset) throws UnsupportedEncodingException {
StringBuffer sb = new StringBuffer();
Set es = parameters.entrySet();//所有参与传参的参数按照accsii排序(升序)
Iterator it = es.iterator();
......@@ -22,7 +22,7 @@ public class SortUtil {
String k = (String)entry.getKey();
Object v = entry.getValue();
if(null != v && !"".equals(v)) {
v=URLEncoder.encode(v+"",charencode);
v=URLEncoder.encode(v+"",charset);
sb.append(k + "=" + v + "&");
}
}
......
......@@ -58,9 +58,9 @@ public class WordposHelper {
Map<String,Object> resultMap=future.get(10000, TimeUnit.MILLISECONDS);
if(resultMap!=null&&(int)resultMap.get("ret")==0) {
Map<String,Object> dataMap=(Map<String,Object>)resultMap.get("data");
JSONArray tokens = (JSONArray) dataMap.get("base_tokens");
JSONArray tokens = (JSONArray) dataMap.get("mix_tokens");//base_tokens
valeMap.put("base_tokens",tokens);
logger.info(tokens.toString());
//logger.info(tokens.toString());
} else {
logger.error("翻译出错");
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.diaoyun.zion.chinafrica.dao.TbCfContactDao">
<resultMap type="com.diaoyun.zion.chinafrica.entity.TbCfContactEntity" id="tbCfContactMap">
<result property="contactId" column="contact_id"/>
<result property="contactWay" column="contact_way"/>
<result property="contactDetail" column="contact_detail"/>
<result property="enableFlag" column="enable_flag"/>
</resultMap>
<select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfContactEntity">
select
`contact_id`,
`contact_way`,
`contact_detail`,
`enable_flag`
from tb_cf_contact
where contact_id = #{id}
</select>
<select id="queryList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfContactEntity">
select
`contact_id`,
`contact_way`,
`contact_detail`,
`enable_flag`
from tb_cf_contact
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by contact_id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from tb_cf_contact
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
</select>
<insert id="save" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfContactEntity">
insert into tb_cf_contact(
`contact_id`,
`contact_way`,
`contact_detail`,
`enable_flag`)
values(
#{contactId},
#{contactWay},
#{contactDetail},
#{enableFlag})
</insert>
<update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfContactEntity">
update tb_cf_contact
<set>
<if test="contactWay != null">`contact_way` = #{contactWay}, </if>
<if test="contactDetail != null">`contact_detail` = #{contactDetail}, </if>
<if test="enableFlag != null">`enable_flag` = #{enableFlag}</if>
</set>
where contact_id = #{contactId}
</update>
<delete id="delete">
delete from tb_cf_contact where contact_id = #{value}
</delete>
<delete id="deleteBatch">
delete from tb_cf_contact where contact_id in
<foreach item="contactId" collection="array" open="(" separator="," close=")">
#{contactId}
</foreach>
</delete>
<!--获取有效的联系方式-->
<select id="getContactList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfContactEntity">
select * from tb_cf_contact where enable_flag=1
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.diaoyun.zion.chinafrica.dao.TbCfExpTemKeywordDao">
<resultMap type="com.diaoyun.zion.chinafrica.entity.TbCfExpTemKeywordEntity" id="tbCfExpTemKeywordMap">
<result property="id" column="id"/>
<result property="templateId" column="template_id"/>
<result property="keyword" column="keyword"/>
</resultMap>
<select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfExpTemKeywordEntity">
select
`id`,
`template_id`,
`keyword`
from tb_cf_exp_tem_keyword
where id = #{id}
</select>
<select id="queryList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfExpTemKeywordEntity">
select
`id`,
`template_id`,
`keyword`
from tb_cf_exp_tem_keyword
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from tb_cf_exp_tem_keyword
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
</select>
<insert id="save" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfExpTemKeywordEntity" useGeneratedKeys="true" keyProperty="id">
insert into tb_cf_exp_tem_keyword(
`template_id`,
`keyword`)
values(
#{templateId},
#{keyword})
</insert>
<update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfExpTemKeywordEntity">
update tb_cf_exp_tem_keyword
<set>
<if test="templateId != null">`template_id` = #{templateId}, </if>
<if test="keyword != null">`keyword` = #{keyword}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
delete from tb_cf_exp_tem_keyword where id = #{value}
</delete>
<delete id="deleteBatch">
delete from tb_cf_exp_tem_keyword where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!--根据keyword获取运费模板-->
<select id="getTemplateByKeyword" resultType="com.diaoyun.zion.chinafrica.entity.TbCfExpressTemplateEntity">
select t2.* from tb_cf_exp_tem_keyword t1,tb_cf_express_template t2 where t1.keyword=#{keyword}
and t1.template_id=t2.template_id
</select>
</mapper>
\ No newline at end of file
......@@ -9,6 +9,7 @@
<result property="answer" column="answer"/>
<result property="enableFlag" column="enable_flag"/>
<result property="createTime" column="create_time"/>
<result property="userId" column="user_id"/>
</resultMap>
<select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfFeedbackEntity">
......@@ -17,7 +18,8 @@
`question`,
`answer`,
`enable_flag`,
`create_time`
`create_time`,
`user_id`
from tb_cf_feedback
where feedback_id = #{id}
</select>
......@@ -28,7 +30,8 @@
`question`,
`answer`,
`enable_flag`,
`create_time`
`create_time`,
`user_id`
from tb_cf_feedback
WHERE 1=1
<if test="name != null and name.trim() != ''">
......@@ -61,13 +64,16 @@
`question`,
`answer`,
`enable_flag`,
`create_time`)
`create_time`,
`user_id`)
values(
#{feedbackId},
#{question},
#{answer},
#{enableFlag},
#{createTime})
#{createTime},
#{userId}
)
</insert>
<update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfFeedbackEntity">
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.diaoyun.zion.chinafrica.dao.TbCfHomePageDao">
<resultMap type="com.diaoyun.zion.chinafrica.entity.TbCfHomePageEntity" id="tbCfHomePageMap">
<result property="pageId" column="page_id"/>
<result property="imgName" column="img_name"/>
<result property="sort" column="sort"/>
<result property="linkUrl" column="link_url"/>
<result property="imgUrl" column="img_url"/>
<result property="scanFlag" column="scan_flag"/>
<result property="redirectFlag" column="redirect_flag"/>
<result property="enableFlag" column="enable_flag"/>
</resultMap>
<select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfHomePageEntity">
select
`page_id`,
`img_name`,
`sort`,
`link_url`,
`img_url`,
`scan_flag`,
`redirect_flag`,
`enable_flag`
from tb_cf_home_page
where page_id = #{id}
</select>
<select id="queryList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfHomePageEntity">
select
`page_id`,
`img_name`,
`sort`,
`link_url`,
`img_url`,
`scan_flag`,
`redirect_flag`,
`enable_flag`
from tb_cf_home_page
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by page_id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from tb_cf_home_page
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
</select>
<insert id="save" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfHomePageEntity">
insert into tb_cf_home_page(
`page_id`,
`img_name`,
`sort`,
`link_url`,
`img_url`,
`scan_flag`,
`redirect_flag`,
`enable_flag`)
values(
#{pageId},
#{imgName},
#{sort},
#{linkUrl},
#{imgUrl},
#{scanFlag},
#{redirectFlag},
#{enableFlag})
</insert>
<update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfHomePageEntity">
update tb_cf_home_page
<set>
<if test="imgName != null">`img_name` = #{imgName}, </if>
<if test="sort != null">`sort` = #{sort}, </if>
<if test="linkUrl != null">`link_url` = #{linkUrl}, </if>
<if test="imgUrl != null">`img_url` = #{imgUrl}, </if>
<if test="scanFlag != null">`scan_flag` = #{scanFlag}, </if>
<if test="redirectFlag != null">`redirect_flag` = #{redirectFlag}, </if>
<if test="enableFlag != null">`enable_flag` = #{enableFlag}</if>
</set>
where page_id = #{pageId}
</update>
<delete id="delete">
delete from tb_cf_home_page where page_id = #{value}
</delete>
<delete id="deleteBatch">
delete from tb_cf_home_page where page_id in
<foreach item="pageId" collection="array" open="(" separator="," close=")">
#{pageId}
</foreach>
</delete>
<!--获取有效的启动页图片-->
<select id="getStartPageImage" resultType="com.diaoyun.zion.chinafrica.entity.TbCfHomePageEntity">
select * from tb_cf_home_page where enable_flag=1 order by sort desc;
</select>
</mapper>
\ No newline at end of file
......@@ -8,6 +8,7 @@
<result property="question" column="question"/>
<result property="answer" column="answer"/>
<result property="enableFlag" column="enable_flag"/>
<result property="sort" column="sort"/>
<result property="createTime" column="create_time"/>
</resultMap>
......@@ -17,6 +18,7 @@
`question`,
`answer`,
`enable_flag`,
`sort`,
`create_time`
from tb_cf_problem
where problem_id = #{id}
......@@ -28,6 +30,7 @@
`question`,
`answer`,
`enable_flag`,
`sort`,
`create_time`
from tb_cf_problem
WHERE 1=1
......@@ -61,12 +64,14 @@
`question`,
`answer`,
`enable_flag`,
`sort`,
`create_time`)
values(
#{problemId},
#{question},
#{answer},
#{enableFlag},
#{sort},
#{createTime})
</insert>
......@@ -77,6 +82,7 @@
<if test="answer != null">`answer` = #{answer}, </if>
<if test="enableFlag != null">`enable_flag` = #{enableFlag}, </if>
<if test="createTime != null">`create_time` = #{createTime}</if>
<if test="sort != null">`sort` = #{sort}</if>
</set>
where problem_id = #{problemId}
</update>
......@@ -92,4 +98,9 @@
</foreach>
</delete>
<!--获取常见问题-->
<select id="getProblemList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfProblemEntity">
select * from tb_cf_problem where enable_flag=1 order by sort desc
</select>
</mapper>
\ No newline at end of file
......@@ -5,6 +5,7 @@ import com.diaoyun.zion.chinafrica.service.TbCfCouponService;
import com.diaoyun.zion.chinafrica.service.impl.TbCfOrderServiceImpl;
import com.diaoyun.zion.master.thread.TaskLimitSemaphore;
import com.diaoyun.zion.master.util.WordposHelper;
import com.google.gson.Gson;
import com.stripe.exception.StripeException;
import freemarker.template.Configuration;
import org.apache.http.*;
......@@ -50,7 +51,7 @@ public class ZionApplicationTests {
String html = FreeMarkerTemplateUtils.processTemplateIntoString(t, model);
HtmlEmail email=new HtmlEmail();//创建一个HtmlEmail实例对象
email.setHostName("smtp.yeah.net");//邮箱的SMTP服务器,一般123邮箱的是smtp.123.com,qq邮箱为smtp.qq.com
email.setCharset("utf-8");//设置发送的字符类型
email.setCharset(Consts.UTF_8.name());//设置发送的字符类型
email.addTo("zhengfanguang@163.com");//设置收件人
email.setFrom("chinafrica@yeah.net","chinafrica");//发送人的邮箱为自己的,用户名可以随便填
email.setAuthentication("chinafrica@yeah.net","diaoyun2019");//设置发送人的邮箱和用户名和授权码(授权码是自己设置的)
......@@ -80,7 +81,7 @@ public class ZionApplicationTests {
paramMap.put("beginTime","1564548584");
paramMap.put("endTime","1564558584");
List<NameValuePair> formparams = setHttpParams(paramMap);
String param = URLEncodedUtils.format(formparams, "UTF-8");
String param = URLEncodedUtils.format(formparams, Consts.UTF_8.name());
HttpGet httpGet = new HttpGet(); //构建一个GET请求
httpGet.setURI(URI.create(url + "?" + param));
HttpResponse response = client.execute(httpGet);//提交GET请求
......@@ -263,8 +264,8 @@ public class ZionApplicationTests {
System.out.println(json);
*/
/*计算运费*/
ExecutorService threadPool = Executors.newFixedThreadPool(20);
/*分词********************/
/*ExecutorService threadPool = Executors.newFixedThreadPool(20);
TbCfOrderServiceImpl tbCfOrderServiceImpl =new TbCfOrderServiceImpl();
long a=System.currentTimeMillis();
List<Map<String, Object>> futureList= new ArrayList<>();
......@@ -274,28 +275,22 @@ public class ZionApplicationTests {
titleMap.put("text", text);
WordposHelper.separeteText(futureList, titleMap, text);
}
/*for(int i=0;i<10;i++) {
threadPool.submit(()->{
try {
//Map<String, Object> res=tbCfOrderServiceImpl.separateText("夏季短袖衬衫男韩版修身免烫中袖衬衣男潮流帅气休闲五分袖黑色寸");
//System.out.println(res);
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
});
}*/
WordposHelper.waitForResult(futureList);
long b=System.currentTimeMillis();
System.out.println(b-a);
while (true) {
}
}*/
/*分词 END*****************8***/
List<String> cartRecordIdArray = new ArrayList<>();
cartRecordIdArray.add("a");
cartRecordIdArray.add("b");
cartRecordIdArray.add("c");
cartRecordIdArray.add("d");
String[] cartRecordIds = cartRecordIdArray.toArray(new String[0]);
System.out.println(cartRecordIds[0]+cartRecordIds[1]+cartRecordIds[2]+cartRecordIds[3]);
}
/*private void translateProp(Map<String, Object> propMap) throws ExecutionException, InterruptedException {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论