Commit 81a14283 authored by jiaorz's avatar jiaorz

Merge branch 'base-modify' of http://113.105.137.151:22280/youjj/cloud-platform into base-modify

parents 7c6df77d ce2ae719
......@@ -102,7 +102,7 @@ public class AuthController {
if(result==null){
data.put("status",1001);
}else {
String token=appAuthService.getToken(username,result.getInteger("userid"));
String token=appAuthService.getToken(username,result.getInteger("userId"));
data.put("token",token);
}
}
......@@ -122,7 +122,7 @@ public class AuthController {
if(result==null){
data.put("status",1001);
}else {
String token=appAuthService.getToken(result.getString("username"),result.getInteger("userid"));
String token=appAuthService.getToken(result.getString("username"),result.getInteger("userId"));
data.put("token",token);
}
}
......@@ -141,7 +141,7 @@ public class AuthController {
if(result==null){
data.put("status",1001);
}else {
String token=appAuthService.getToken(username,result.getInteger("userid"));
String token=appAuthService.getToken(username,result.getInteger("userId"));
data.put("token",token);
}
}
......@@ -154,11 +154,13 @@ public class AuthController {
log.info(username+"----require reset...");
JSONObject data=appAuthService.reset(username,mobilecode,password);
if(data!=null&&data.getInteger("status")== ResultCode.SUCCESS_CODE){
JwtAuthenticationRequest authenticationRequest=new JwtAuthenticationRequest();
authenticationRequest.setUsername(username);
authenticationRequest.setPassword(password);
String token=appAuthService.login(authenticationRequest);
data.put("token",token);
JSONObject result=data.getJSONObject("data");
if(result==null){
data.put("status",1001);
}else {
String token=appAuthService.getToken(username,result.getInteger("userId"));
data.put("token",token);
}
}
return data;
}
......
......@@ -3,6 +3,8 @@ package com.github.wxiaoqi.security.common.exception;
import com.github.wxiaoqi.security.common.constant.RestCode;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import java.util.Map;
/**
* Created by ace on 2017/9/8.
*/
......@@ -50,4 +52,13 @@ public class BaseException extends RuntimeException {
super(ResultCode.getMsg(code));
this.status = code;
}
// public BaseException(int code, Map<String, Object> map) {
// String msg = ResultCode.getMsg(code);
// if(null != map && map.size() > 0){
// for(String)
//
// }
// this.status = code;
// }
}
......@@ -40,7 +40,12 @@ public class EntityUtils {
* @author 王浩彬
*/
public static <T> void setCreateInfo(T entity){
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
HttpServletRequest request;
try {
request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
}catch (Exception e) {
request = null;
}
String hostIp = "";
String name = "";
String id = "";
......@@ -81,7 +86,12 @@ public class EntityUtils {
* @author 王浩彬
*/
public static <T> void setUpdatedInfo(T entity){
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
HttpServletRequest request;
try {
request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
}catch (Exception e) {
request = null;
}
String hostIp = "";
String name = "";
String id = "";
......
......@@ -5,6 +5,10 @@ import com.github.wxiaoqi.security.common.util.SystemProperty;
public class ResultCode {
////////////////////////////参数相关///////////////////////////
public static int PARAM_ILLEGAL_CODE = Integer.valueOf(SystemProperty.getResultConfig("PARAM_ILLEGAL_CODE"));
public static int PARAM_EXPIRE_CODE = Integer.valueOf(SystemProperty.getResultConfig("PARAM_EXPIRE_CODE"));
// 操作成功
public static int SUCCESS_CODE = Integer.valueOf(SystemProperty.getResultConfig("SUCCESS_CODE"));
// 操作失败
......@@ -128,11 +132,11 @@ public class ResultCode {
// 账户已禁用
public static int ACCOUNTINFO_ISDEL = Integer.valueOf(SystemProperty.getResultConfig("ACCOUNTINFO_ISDEL"));
// 监控设备不存在
public static int DEVICE_NOTEXIST_CODE = Integer.valueOf(SystemProperty.getResultConfig("DEVICE_NOTEXIST_CODE"));
// 设备access_token获取失败
public static int DEVICE_TOKEN_NOTEXIST_CODE = Integer
.valueOf(SystemProperty.getResultConfig("DEVICE_TOKEN_NOTEXIST_CODE"));
// // 监控设备不存在
// public static int DEVICE_NOTEXIST_CODE = Integer.valueOf(SystemProperty.getResultConfig("DEVICE_NOTEXIST_CODE"));
// // 设备access_token获取失败
// public static int DEVICE_TOKEN_NOTEXIST_CODE = Integer
// .valueOf(SystemProperty.getResultConfig("DEVICE_TOKEN_NOTEXIST_CODE"));
// 操作频繁提示
public static int API_MAX_CODE = Integer.valueOf(SystemProperty.getResultConfig("API_MAX_CODE"));
......
......@@ -32,6 +32,14 @@ RSTOKEN_NULL_CODE=1007
DB_OPERATION_FAIL_CODE=1008
1008=数据库操作失败
#参数非法
PARAM_ILLEGAL_CODE=1011
1011=参数非法,请修改
#参数时效已过时
PARAM_EXPIRE_CODE=1010
1010=参数时效已过时,不能使用
#请求微信接口失败
WXAPI_CODE=2001
#微信用不不存在
......@@ -146,10 +154,10 @@ NICKNAME_NULL_CODE=9006
ACCOUNTINFO_ISDEL=9007
9007=账户已禁用
DEVICE_NOTEXIST_CODE=1005
1005=监控设备不存在
DEVICE_TOKEN_NOTEXIST_CODE=1006
1005=设备access_token获取失败
#DEVICE_NOTEXIST_CODE=1005
#1005=监控设备不存在
#DEVICE_TOKEN_NOTEXIST_CODE=1006
#1005=设备access_token获取失败
REPEAT_SUB_CODE=1008
......
package com.github.wxiaoqi.security.admin.entity;
import lombok.Data;
import javax.persistence.Column;
@Data
public class AppUserManage {
private AppUserLogin appUserLogin;
private AppUserDetail appUserDetail;
private BaseUserMember baseUserMember;
}
......@@ -55,6 +55,8 @@ public class AppUserCollectBiz extends BaseBiz<AppUserCollectMapper, AppUserColl
TourGood tourGood=tourFeign.one(typeId);
if(tourGood!=null){
BeanUtils.copyProperties(collect,tourGood);
collect.setId(null);
collect.setStatus(0);
insertSelective(collect);
}
......
package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.entity.*;
import com.github.wxiaoqi.security.admin.mapper.*;
import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import tk.mybatis.mapper.entity.Example;
/**
* app用户管理业务逻辑层
*
* @author Administrator
*/
@Service
public class AppUserManageBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail> {
@Autowired
private AppUserLoginMapper appUserLoginMapper;
/**
* 根据条件查询
*
* @param appUserVo
* @return
*/
public AppUserVo findAllByQuery(AppUserVo appUserVo) {
return mapper.selectAppUserManage(appUserVo);
}
@Transactional
public void deleteAppUser(Integer id) {
AppUserLogin appUserLogin = new AppUserLogin();
appUserLogin.setIsdel(1);
Example example = new Example(AppUserLogin.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id", id);
appUserLogin.setUpdatetime(System.currentTimeMillis());
appUserLoginMapper.updateByExampleSelective(appUserLogin, example);
AppUserDetail appUserDetail = new AppUserDetail();
appUserDetail.setIsdel(1);
appUserDetail.setUpdatetime(System.currentTimeMillis());
Example detailExample = new Example(AppUserLogin.class);
Example.Criteria detailCriteria = detailExample.createCriteria();
criteria.andEqualTo("id", id);
mapper.updateByExampleSelective(appUserDetail, detailCriteria);
}
public AppUserVo findOneById(Integer id) {
return mapper.getUserInfo(id);
}
@Transactional
public void save(AppUserVo appUserVo) {
AppUserLogin appUserLogin = new AppUserLogin();
AppUserDetail appUserDetail = new AppUserDetail();
try {
BeanUtilsBean.getInstance().copyProperties(appUserLogin, appUserVo);
BeanUtilsBean.getInstance().copyProperties(appUserDetail, appUserVo);
if (appUserVo.getUserid() == null || appUserVo.getUserid() == 0) {
//设置登录用户信息
appUserLogin.setIsdel(0);
appUserLogin.setCreatetime(System.currentTimeMillis());
appUserLogin.setCertificationStatus(0);
appUserLogin.setStatus(0);
//设置用户详情
appUserDetail.setIsdel(0);
if (appUserDetail.getIsMember() == null) {
appUserDetail.setIsMember(0);
}
appUserLoginMapper.insertSelective(appUserLogin);
mapper.insertSelective(appUserDetail);
} else {
appUserLogin.setUpdatetime(System.currentTimeMillis());
appUserDetail.setUpdatetime(System.currentTimeMillis());
appUserLoginMapper.updateByPrimaryKeySelective(appUserLogin);
mapper.updateByPrimaryKeySelective(appUserDetail);
}
} catch (Exception e) {
e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
}
}
......@@ -95,6 +95,7 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper,BaseUserMemb
Integer totalNumber=userMemberVo.getTotalNumber()==null?0:userMemberVo.getTotalNumber();
BaseUserMember baseUserMember=new BaseUserMember();
baseUserMember.setId(userMemberVo.getId());
baseUserMember.setUserId(userId);
if(type==1){
/*if((freeDays-lockDays)>0&&(freeDays-lockDays)>=days){
baseUserMember.setLockDays(lockDays+days);
......
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.AppUserDetail;
import com.github.wxiaoqi.security.admin.entity.AppUserManage;
import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
......@@ -10,5 +11,5 @@ public interface AppUserDetailMapper extends Mapper<AppUserDetail> {
//查询用户信息
public AppUserVo getUserInfo(@Param("userId") Integer userId);
AppUserVo selectAppUserManage(AppUserVo appUserVo);
}
\ No newline at end of file
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.entity.AppUserManage;
import tk.mybatis.mapper.common.Mapper;
public interface AppUserLoginMapper extends Mapper<AppUserLogin> {
......
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.AppUser;
import com.github.wxiaoqi.security.admin.entity.AppUserManage;
import com.github.wxiaoqi.security.admin.entity.Group;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
......@@ -17,4 +18,6 @@ public interface AppUserMapper extends Mapper<AppUser> {
int insertAppUserGroup(@Param("appUserId") Integer appUserId, @Param("groups") Set<Integer> groups);
int deleteAppUserGroup(Integer appUserId);
}
package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.AppUserManageBiz;
import com.github.wxiaoqi.security.admin.entity.AppUserManage;
import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import org.springframework.web.bind.annotation.*;
/**
* app用户管理类
* @author Administrator
*/
@RestController
@RequestMapping("appUsersManage")
public class AppUsersManageController extends BaseController<AppUserManageBiz,AppUserManage> {
/**
* 查询所有
* @return
*/
@GetMapping("/findAll")
public ObjectRestResponse<AppUserVo> findAllByQuery(@RequestBody AppUserVo appUserVo){
return ObjectRestResponse.succ(baseBiz.findAllByQuery(appUserVo));
}
/**
* 删除
* @param id
* @return
*/
@DeleteMapping("/deleteById/{id}")
public ObjectRestResponse deleteById(@PathVariable Integer id){
baseBiz.deleteAppUser(id);
return ObjectRestResponse.succ();
}
/**
* 查询一条
* @param id
* @return
*/
@GetMapping("/findOneById/{id}")
public ObjectRestResponse<AppUserVo> findOneById(@PathVariable Integer id){
return ObjectRestResponse.succ(baseBiz.findOneById(id));
}
@PostMapping("/save")
public ObjectRestResponse save(@RequestBody AppUserVo appUserVo){
baseBiz.save(appUserVo);
return ObjectRestResponse.succ();
}
}
......@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.UserMemberLevelBiz;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -27,6 +28,11 @@ public class MemberLevelController {
return memberBiz.getLevesls();
}
@RequestMapping(value = "/app/unauth/level/list", method = RequestMethod.GET)
public ObjectRestResponse<List<BaseUserMemberLevel>>list() throws Exception {
return ObjectRestResponse.succ(memberBiz.getLevesls());
}
@RequestMapping(value = "/app/unauth/level/{type}", method = RequestMethod.GET)
public @ResponseBody
BaseUserMemberLevel level(@PathVariable Integer type) throws Exception {
......
......@@ -153,7 +153,7 @@ public class AppUserRest {
@RequestMapping(value = "/user/reset", method = RequestMethod.POST)
public @ResponseBody
JSONObject login(
JSONObject reset(
@RequestParam(value="username",defaultValue="")String username,
@RequestParam(value="mobilecode",defaultValue="")String mobilecode,
@RequestParam(value="password",defaultValue="")String password
......
......@@ -241,8 +241,8 @@ public class AppPermissionService {
userLogin.setUsername(username);
appUserLoginBiz.updateSelectiveById(userLogin);
}
data.put("im_token",access_token);
data.put("im_UserId",imUserId);
data.put("imToken",access_token);
data.put("imUserId",imUserId);
}
if (data != null) {
......@@ -273,6 +273,7 @@ public class AppPermissionService {
if (StringUtils.isNotBlank(userVo.getHeadimgurl())) {
data.put("headerurl", userVo.getHeadimgurl());
}
data.put("certificationStatus", userVo.getCertificationStatus());
}
// 缓存操作
String token = "";
......@@ -282,7 +283,7 @@ public class AppPermissionService {
// 返回结果
// data.put("token", token);
data.put("username", username);
data.put("userid", userid);
data.put("userId", userid);
}
return data;
......@@ -366,8 +367,8 @@ public class AppPermissionService {
String imPassword=userLogin.getImPassword();
if(StringUtils.isNotBlank(imPassword)&&imUserId!=null&&imUserId>0){
String access_token=loginIm(username,imPassword,imUserId);
data.put("im_token",access_token);
data.put("im_UserId",imUserId);
data.put("imToken",access_token);
data.put("imUserId",imUserId);
}
if (data != null) {
return JsonResultUtil.createSuccessResultWithObj(data);
......@@ -453,8 +454,8 @@ public class AppPermissionService {
String imPassword=userLogin.getImPassword();
if(StringUtils.isNotBlank(imPassword)&&imUserId!=null&&imUserId>0){
String access_token=loginIm(userLogin.getUsername(),imPassword,imUserId);
data.put("im_token",access_token);
data.put("im_UserId",imUserId);
data.put("imToken",access_token);
data.put("imUserId",imUserId);
}
if (data != null) {
return JsonResultUtil.createSuccessResultWithObj(data);
......@@ -495,8 +496,8 @@ public class AppPermissionService {
String imPassword=user.getImPassword();
if(StringUtils.isNotBlank(imPassword)&&imUserId!=null&&imUserId>0){
String access_token=loginIm(username,imPassword,imUserId);
data.put("im_token",access_token);
data.put("im_UserId",imUserId);
data.put("imToken",access_token);
data.put("imUserId",imUserId);
}
if (data != null) {
return JsonResultUtil.createSuccessResultWithObj(data);
......@@ -531,6 +532,14 @@ public class AppPermissionService {
Integer userid = user.getId();
String nickname = SystemConfig.USER_NIKENAME_DEFAULT + (int) ((Math.random() * 9 + 1) * 100000);
JSONObject data = autoLogin(userid, user.getUsername(), SystemConfig.USER_HEADER_URL_DEFAULT, nickname);
// 到im注册,获取返回结果
Integer imUserId=user.getImUserid();
String imPassword=user.getImPassword();
if(StringUtils.isNotBlank(imPassword)&&imUserId!=null&&imUserId>0){
String access_token=loginIm(username,imPassword,imUserId);
data.put("imToken",access_token);
data.put("imUserId",imUserId);
}
if (data != null) {
return JsonResultUtil.createSuccessResultWithObj(data);
}
......
......@@ -28,6 +28,92 @@
<select id="getUserInfo" resultMap="AppUserVoMap">
select l.im_userid,l.username,l.wx_openid,l.unionid,l.openid,l.status,l.id_number,l.certification_status,d.* from app_user_login l
left join app_user_detail d
on d.userid = l.id where d.userid = #{userId} limit 1
on d.userid = l.id
where d.userid = #{userId} limit 1
</select>
<select id="selectAppUserManage" parameterType="Integer" resultMap="AppUserVoMap">
select l.im_userid,l.username,l.wx_openid,l.unionid,l.openid,l.status,l.id_number,l.certification_status,d.* from app_user_login l
left join app_user_detail d
on d.userid = l.id where 1=1
<if test="id != null">
and d.id =#{id}
</if>
<if test="userid != null" >
and d.userid = #{userId}
</if>
<if test="username != null" >
and l.username=#{username}
</if>
<if test="imUserd != null" >
and l.im_userid=#{imUserid}
</if>
<if test="wxOpenid != null" >
and l.wx_openid=#{wxOpenid}
</if>
<if test="unionid != null" >
and l.unionid=#{unionid}
</if>
<if test="openid != null" >
and l.openid=#{openid}
</if>
<if test="status != null" >
and l.status=#{status}
</if>
<if test="idNumber != null" >
and l.id_number=#{idNumber}
</if>
<if test="certificationStatus != null" >
and l.certification_status=#{certificationStatus}
</if>
<if test="isMember != null" >
and d.is member=#{isMember}
</if>
<if test="nickname != null" >
and d.nickname=#{nickname}
</if>
<if test="realname != null" >
and d.realname=#{realname}
</if>
<if test="email != null" >
and d.email=#{email}
</if>
<if test="sex != null" >
and d.sex=#{sex}
</if>
<if test="birthday != null" >
and d.birthday=#{birthday}
</if>
<if test="personSign != null" >
and d.person_sign=#{personSign}
</if>
<if test="remark != null" >
and d.remark=#{remark}
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -21,4 +21,6 @@
right join app_group_member agm on bg.id = agm.group_id
where user_id = #{id}
</select>
</mapper>
\ No newline at end of file
......@@ -17,8 +17,6 @@ import java.util.Enumeration;
* @description 设置请求头部信息,防止微服务之间调用请求头部信息丢失
* @data 2019/6/25 16:22
*/
@Configuration
@Component
public class HeaderConfig implements RequestInterceptor {
@Override
......
package com.xxfc.platform.app.entity.vo;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/6/28 9:34
*/
@Data
public class BannerVo {
/**
* 封面地址
*/
private String cover;
/**
* 跳转链接地址
*/
private String url;
}
......@@ -4,10 +4,12 @@ import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.app.entity.Banner;
import com.xxfc.platform.app.entity.vo.BannerVo;
import com.xxfc.platform.app.mapper.BannerMapper;
import org.springframework.stereotype.Service;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -30,12 +32,16 @@ public class BannerBiz extends BaseBiz<BannerMapper,Banner> {
this.deleteById(id);
}*/
public List<Banner> findBannerList(Integer type) {
Banner banner = new Banner();
banner.setIsDel(0);
banner.setType(type);
//mapper.findByType(type);
return mapper.findBannerListByType(type);
public List<BannerVo> findBannerList(Integer type) {
List<BannerVo> bannerVos = new ArrayList<>();
List<Banner> banners = mapper.findBannerListByType(type);
banners.forEach(banner -> {
BannerVo bannerVo = new BannerVo();
bannerVo.setCover(banner.getCover());
banner.setUrl(banner.getUrl());
bannerVos.add(bannerVo);
});
return bannerVos;
}
/*
......
......@@ -2,7 +2,7 @@ package com.xxfc.platform.app.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.app.biz.BannerBiz;
import com.xxfc.platform.app.entity.Banner;
import com.xxfc.platform.app.entity.vo.BannerVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -33,7 +33,7 @@ public class BannerController {
if (type==null) {
return ObjectRestResponse.createDefaultFail();
}
List<Banner> bannerList = bannerBiz.findBannerList(type);
List<BannerVo> bannerList = bannerBiz.findBannerList(type);
return ObjectRestResponse.succ(bannerList);
}
}
......@@ -5,8 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;
/**
......@@ -92,5 +92,20 @@ public class CampsiteShopPageDTO implements Serializable {
@ApiModelProperty(value = "创建时间", hidden = true)
private Long crtTime;
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CampsiteShopPageDTO that = (CampsiteShopPageDTO) o;
return Objects.equals(id, that.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}
......@@ -6,6 +6,7 @@
<groupId>com.xxfc.common</groupId>
<artifactId>xx-common-platform-web</artifactId>
<version>2.0-SNAPSHOT</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxfc.platform</groupId>
......@@ -18,6 +19,17 @@
<artifactId>xx-campsite-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.wxiaoqi</groupId>
<artifactId>ace-common</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.2.0.Final</version>
</dependency>-->
</dependencies>
<build>
<plugins>
......
......@@ -61,12 +61,14 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper,CampsiteShop> {
campsiteShopPageDataVO.setPageSize(pageDataVO.getPageSize());
campsiteShopPageDataVO.setPageNum(pageDataVO.getPageNum());
if (CollectionUtils.isEmpty(campsiteShopPageDTOS)){
campsiteShopPageDataVO.setData(new ArrayList<CampsiteShopPageVo>());
return campsiteShopPageDataVO;
}
if (log.isDebugEnabled()){
log.debug("根据type=【{}】查询到的店铺数据:【{}】",type,campsiteShopPageDTOS);
}
List<CampsiteShopPageVo> campsiteShopPageVoList = new ArrayList<>();
campsiteShopPageDTOS = campsiteShopPageDTOS.stream().distinct().collect(Collectors.toList());
for (CampsiteShopPageDTO campsiteShopPageDTO : campsiteShopPageDTOS) {
CampsiteShopPageVo campsiteShopPageVo = new CampsiteShopPageVo();
BeanUtils.copyProperties(campsiteShopPageDTO,campsiteShopPageVo);
......
......@@ -41,7 +41,7 @@
FROM `campsite_shop_tag` cst
left JOIN `campsite_shop` cs on cst.shop_id=cs.id
left JOIN `campsite_tag` ct on cst.tag_id=ct.id
where cs.sale_state=1
where cs.sale_state=1 and cs.is_del=0
<if test="typeId!=null">
and cst.tag_id=#{typeId}
</if>
......@@ -51,7 +51,7 @@
<select id="findAllByHome" resultType="com.github.wxiaoqi.security.common.vo.GoodDataVO">
select cs.id as `id`,cs.name as `name`,cs.logo as `imgUrl`,cs.province_name as `name1`,cs.longitude,cs.latitude
FROM `campsite_shop` cs
where cs.sale_state=1
where cs.sale_state=1 and cs.is_del=0
order by cs.hot desc
limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER}
</select>
......
......@@ -81,6 +81,7 @@ public class UserBiz {
return baseResponse;
}
/**
* 登录
* @param map
......
......@@ -14,12 +14,10 @@ public class AddRentVehicleDTO{
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//开始时间
@Column(name = "start_time")
@ApiModelProperty(value = "开始时间")
private Long startTime;
//结束时间
@Column(name = "end_time")
@ApiModelProperty(value = "结束时间")
private Long endTime;
......@@ -36,12 +34,10 @@ public class AddRentVehicleDTO{
private String bookEndDate;
//天数
@Column(name = "day_num")
@ApiModelProperty(value = "天数")
private Integer dayNum;
//取车地点
@Column(name = "start_addr")
@ApiModelProperty(value = "取车地点")
private String startAddr;
......@@ -51,7 +47,6 @@ public class AddRentVehicleDTO{
private String endAddr;
//取车城市编号
@Column(name = "start_city")
@ApiModelProperty(value = "取车城市编号")
private Integer startCity;
......@@ -61,7 +56,6 @@ public class AddRentVehicleDTO{
private Integer endCity;
//取车城市名称
@Column(name = "start_city_name")
@ApiModelProperty(value = "取车城市名称")
private String startCityName;
......@@ -71,30 +65,42 @@ public class AddRentVehicleDTO{
private String endCityName;
//司机类型 1--公司司机;2--自己司机
@Column(name = "driver_type")
@ApiModelProperty(value = "司机类型 1--公司司机;2--自己司机")
private Integer driverType;
//自己司机ids
@Column(name = "my_driver_ids")
@ApiModelProperty(value = "自己司机ids")
private String myDriverIds;
//出发公司Id
@Column(name = "start_company_id")
@ApiModelProperty(value = "出发公司Id")
private Integer startCompanyId;
//结束公司Id
@Column(name = "end_company_id")
@ApiModelProperty(value = "结束公司Id")
private Integer endCompanyId;
//车型id
@Column(name = "model_id")
@ApiModelProperty(value = "车型id")
private Integer modelId;
//车型id
@ApiModelProperty(value = "是否购买免赔")
private Integer damageSafe;
/**
* 是否使用出租免费天数
*/
@ApiModelProperty(value = "是否使用出租免费天数")
private Integer rentFreeDay;
/**
* 优惠券ids
*/
@ApiModelProperty(value = "优惠券ids")
private String couponIds;
public void setStartTime(Long startTime) {
this.startTime = startTime;
this.bookStartDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneOffset.ofHours(8)));
......
......@@ -68,4 +68,10 @@ public class AddTourDTO {
@Column(name = "has_insure")
@ApiModelProperty(value = "是否保险标记 1--要保险;0--不需要")
Integer hasInsure;
/**
* 优惠券ids
*/
@ApiModelProperty(value = "优惠券ids")
private String couponIds;
}
......@@ -167,12 +167,13 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
*/
public void cancel(BaseOrder baseOrder) {
if(cancelAble.get(baseOrder.getType()).contains(baseOrder.getStatus())) {
int updateResult = this.updateSelectiveByIdRe(new BaseOrder(){{
BaseOrder updateOrder = new BaseOrder(){{
setId(baseOrder.getId());
setStatus(OrderStatusEnum.ORDER_CANCEL.getCode());
setCancelReason(baseOrder.getCancelReason());
setVersion(baseOrder.getVersion());
}});
}};
int updateResult = this.updateSelectiveByIdRe(updateOrder);
//如果取消失败,则抛异常
if(updateResult <= 0) {
......@@ -181,7 +182,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
//触发退款流程
//判断是否已支付
if(baseOrder.getHasPay().equals(SYS_TRUE)) {
if(SYS_TRUE.equals(baseOrder.getHasPay())) {
//判断订单类型
if(OrderTypeEnum.RentVehicle.getCode().equals(baseOrder.getType())) {
OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{
......
package com.xxfc.platform.order.config;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.CustomExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -52,5 +53,14 @@ public class RabbitUserConfig {
public Binding cfgDelayBinding(Queue cfgDelayQueue, CustomExchange cfgUserDelayExchange){
return BindingBuilder.bind(cfgDelayQueue).to(cfgUserDelayExchange).with(ORDER_CANCEL_KEY).noargs();
}
// @Bean
// public RabbitListenerContainerFactory<?> rabbitListenerContainerFactory(ConnectionFactory connectionFactory){
// SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
// factory.setConnectionFactory(connectionFactory);
//// factory.setMessageConverter(new Jackson2JsonMessageConverter());
// factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
// return factory;
// }
}
......@@ -56,7 +56,7 @@ public class RabbitConsumer {
* 其中的参数如果为true是把消息退回到queue但是有可能被其它的consumer(集群)接收到,
* 设置为false是只补发给当前的consumer
*/
channel.basicRecover(false);
channel.basicRecover(true);
}
}
}
......@@ -70,6 +70,9 @@ public class BaseOrderController extends CommonBaseController {
@Autowired
OrderMemberDetailBiz orderMemberDetailBiz;
@Value("${gateway.insideHost}")
String insideHost;
@Value("${gateway.host}")
String host;
......@@ -256,7 +259,7 @@ public class BaseOrderController extends CommonBaseController {
orderPayVo.setBody(baseOrder.getName());
orderPayVo.setBuyerIp(StringUtils.defaultIfBlank(request.getHeader("userHost"), ClientUtil.getClientIp(request)));
orderPayVo.setChannel(PayChannelEnum.ORDER_CRT.getCode());
orderPayVo.setNotifyUrl(host + order + notifyUrl + "?orderNo=" + baseOrder.getNo());
orderPayVo.setNotifyUrl(insideHost + order + notifyUrl + "?orderNo=" + baseOrder.getNo());
orderPayVo.setSubject(baseOrder.getName());
orderPayVo.setUserId(baseOrder.getUserId());
ObjectRestResponse response = BeanUtil.toBean(thirdFeign.wx(orderPayVo), ObjectRestResponse.class);
......
......@@ -38,7 +38,7 @@ public class OrderTourVerificationController extends CommonBaseController {
@Autowired
UserFeign userFeign;
public UserDTO getUserInfo(){ return userFeign.userinfoByToken(userAuthConfig.getToken(request)).getData();}
public UserDTO getUserInfo(){ return userFeign.userinfoByToken(userAuthConfig.getToken(request)).getData();}
@RequestMapping(value = "/verification/orderlist",method = RequestMethod.GET)
@ApiOperation(value = "旅游核销订单列表")
......
......@@ -87,31 +87,12 @@ public abstract class AbstractOrderHandle<Biz extends BaseBiz, Detail extends Or
detail.setOrderId(detail.getOrder().getId());
detailBiz.insertSelective(detail);
detail.getOrder().setDetailId(detail.getId());
baseOrderBiz.updateSelectiveById(detail.getOrder());
int updateResult =baseOrderBiz.updateSelectiveByIdRe(detail.getOrder());
if(updateResult > 0) {
detail.getOrder().setVersion(detail.getOrder().getVersion() + 1);
}
}
// /**
// * 创建订单及其多子项
// * @param details
// */
// public void createOrder(List<Detail> details) {
// BaseOrder order = createOrder();
// for(Detail detail : details) {
// preHandleDetail(order, detail);
// }
// handleDetail(details);
// }
//
// /**
// * 处理订单多子项
// * @param details
// */
// public void handleDetail(List<Detail> details){
// for(Detail detail : details) {
// detailBiz.insertSelective(detail);
// }
// }
/**
* 计算价格
* @param detail
......
......@@ -92,7 +92,8 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
super.handleDetail(bo);
//发送定时取消订单(30分钟)
rabbitProduct.sendDelayMessage(bo.getOrder(), 1000L * 60 * 30);
//rabbitProduct.sendDelayMessage(bo.getOrder(), 1000L * 60 * 30);
rabbitProduct.sendDelayMessage(bo.getOrder(), 1000L * 60 * 5);
}
@Override
......@@ -116,7 +117,10 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
AppUserDTO dto = detail.getAppUserDTO();
//如果用户存在,并且为会员,并且车辆有优惠价
if(null != dto && null != detail.getRentFreeDay() && detail.getRentFreeDay() > 0 && dto.getRentFreeDays() > 0) {
if(null != dto && null != detail.getRentFreeDay() && detail.getRentFreeDay() > 0 ) {
if(dto.getRentFreeDays() <= 0) {
throw new BaseException(ResultCode.PARAM_EXPIRE_CODE);
}
if(detail.getDayNum() > dto.getRentFreeDays()) {
freeDayNum = dto.getRentFreeDays();
}else {
......@@ -127,6 +131,8 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
vehicleDayNum = detail.getDayNum();
}
detail.setFreeDays(freeDayNum);
//计算价格
//计算车辆费用
VehicleModel vehicleModel = vehicleFeign.get(detail.getModelId()).getData();
......@@ -136,7 +142,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
String[] prices = StrUtil.isBlank(vehicleModel.getRentDiscountPrice())
?new String[]{vehicleModel.getPrice().toString(),vehicleModel.getPrice().toString(),vehicleModel.getPrice().toString()}
:vehicleModel.getRentDiscountPrice().split(",");
switch (MemberEnum.getByCode(detail.getAppUserDTO().getIsMember())) {
switch (MemberEnum.getByCode(detail.getAppUserDTO().getMemberLevel())) {
case NORMAL:
modelAmount = handleDiscount(vehicleModel, prices, NORMAL);
break;
......@@ -199,7 +205,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
private BigDecimal handleDiscount(VehicleModel vehicleModel, String[] prices, MemberEnum memberEnum) {
BigDecimal modelAmount;//会员比例
if(DISCOUNT_STATUS_MEMBER.equals(vehicleModel.getRentDiscountStatus())) {
modelAmount = new BigDecimal(String.valueOf((memberEnum.getPercent()/100))).multiply(vehicleModel.getPrice());
modelAmount = new BigDecimal(String.valueOf((memberEnum.getPercent()/100d))).multiply(vehicleModel.getPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
}else {
//会员固定价列表
modelAmount = new BigDecimal(prices[(memberEnum.getCode() - 1)]);
......@@ -220,7 +226,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
childrenStr.append(",${tem_0104}");
}
if(childrenStr.length() > 0){
childrenStr.deleteCharAt(1);
childrenStr.deleteCharAt(0);
}
return childrenStr.toString();
}
......@@ -242,6 +248,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
private void acquireVehicle(RentVehicleBO detail) {
//根据车型、时间、距离,门店,预定车辆
RentVehicleBookDTO rentVehicleBookDTO = BeanUtil.toBean(detail.getBookVehicleVO(), RentVehicleBookDTO.class);
rentVehicleBookDTO.setModelId(detail.getModelId());
rentVehicleBookDTO.setUserName(BaseContextHandler.getName());
ObjectRestResponse<VehicleBookRecord> orr = vehicleFeign.rentApplyVehicle(rentVehicleBookDTO);
detail.setVehicleId(orr.getData().getVehicleId());
......
......@@ -209,11 +209,10 @@ public class OrderTourService extends AbstractOrderHandle<OrderTourDetailBiz, To
childrenStr.append(",${tem_0203}");
}
String str = childrenStr.toString();
if(str.length() > 0) {
str = str.substring(1, str.length());
if(childrenStr.length() > 0){
childrenStr.deleteCharAt(0);
}
return str;
return childrenStr.toString();
}
/**
......
......@@ -31,7 +31,7 @@ public class GoodSiteDTO {
//分公司id
@ApiModelProperty(value = "分公司id")
private String companyId;
private Integer companyId;
/**
* 地址-省/直辖市(编码)
......
......@@ -50,7 +50,7 @@ public class TourGoodSite implements Serializable {
*/
@Column(name = "company_id")
@ApiModelProperty(value = "分公司id")
private String companyId;
private Integer companyId;
/**
* 地址-省/直辖市(编码)
......@@ -64,7 +64,7 @@ public class TourGoodSite implements Serializable {
*/
@Column(name = "province_name")
@ApiModelProperty("地址-省/直辖市(名称)")
private Integer provinceName;
private String provinceName;
/**
* 地址-市(编码)
......@@ -78,7 +78,7 @@ public class TourGoodSite implements Serializable {
*/
@Column(name = "city_name")
@ApiModelProperty("地址-市(名称)")
private Integer cityName;
private String cityName;
/**
* 出发时间
......
......@@ -92,6 +92,6 @@ public interface TourFeign {
@RequestParam(value = "limit",defaultValue = "4") Integer limit);
//获取商品信息
@RequestMapping(value = "/app/unauth/one", method = RequestMethod.GET)
@RequestMapping(value = "/good/app/unauth/one", method = RequestMethod.GET)
public TourGood one(@RequestParam(value = "goodId",defaultValue = "0") Integer goodId);
}
......@@ -78,6 +78,8 @@ public class TourGoodDetailBiz extends BaseBiz<TourGoodMapper, TourGood> {
//获取出行时间
List<TourDepartTimeVo> timelist = priceMapper.getAllByGoodId(id);
detailVo.setTourDepartTimeVo(timelist);
Integer stock=priceMapper.getTotalStock(id);
detailVo.setStock(stock);
//获取出发地点
List<TourDepartVo> departList = siteMapper.getlistByGoodId(id);
detailVo.setTourDepartVo(departList);
......
......@@ -127,13 +127,13 @@ public class TourTagBannerBiz extends BaseBiz<TourTagBannerMapper,TourTagBanner>
* @param tourTagBannerDTOS
*/
@Transactional(rollbackFor = Exception.class)
public void updateTourBannerByBatch(List<TourTagBannerDTO> tourTagBannerDTOS,UserDTO userDTO) {
public void updateTourBannerByBatch(List<TourTagBannerDTO> tourTagBannerDTOS,Integer tagId,UserDTO userDTO) {
List<Long> tourTagBannerIds = tourTagBannerDTOS.stream().filter(tourTagBannerDTO -> Objects.nonNull(tourTagBannerDTO.getId())).map(TourTagBannerDTO::getId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(tourTagBannerIds)){
mapper.updateTourBannerStatusByTagannerIdsAndTagId(tourTagBannerIds,tourTagBannerDTOS.get(0).getTagId(),1);
mapper.updateTourBannerStatusByTagannerIdsAndTagId(tourTagBannerIds,tagId,1);
}else {
if (CollectionUtils.isNotEmpty(tourTagBannerDTOS)){
mapper.updateTourTagBannerStatusByTagId(tourTagBannerDTOS.get(0).getTagId(),1,Instant.now().toEpochMilli());
if (CollectionUtils.isEmpty(tourTagBannerDTOS)){
mapper.updateTourTagBannerStatusByTagId(tagId,1,Instant.now().toEpochMilli());
}
}
List<TourTagBannerDTO> tagBannerDTOS = tourTagBannerDTOS.stream().filter(tourTagBannerDTO -> Objects.isNull(tourTagBannerDTO.getId())).collect(Collectors.toList());
......@@ -169,4 +169,5 @@ public class TourTagBannerBiz extends BaseBiz<TourTagBannerMapper,TourTagBanner>
}
return tourTagBannerDTOS.stream().collect(Collectors.groupingBy(TourTagBannerDTO::getTagId));
}
}
\ No newline at end of file
......@@ -210,7 +210,7 @@ public class TourTagBiz extends BaseBiz<TourTagMapper,TourTag> {
if (CollectionUtils.isNotEmpty(tourTagBannerDTOS)){
tourTagBannerDTOS.stream().filter(tourTagBannerDTO -> Objects.isNull(tourTagBannerDTO.getTagId())).peek(tourTagBannerDTO -> tourTagBannerDTO.setTagId(tourTagDTO.getId())).count();
}
tourTagBannerBiz.updateTourBannerByBatch(tourTagBannerDTOS,userDTO);
tourTagBannerBiz.updateTourBannerByBatch(tourTagBannerDTOS,tourTagAndBannerDTO.getTourTagDTO().getId(),userDTO);
return effrows;
}
......
......@@ -18,6 +18,9 @@ public interface TourGoodSpePriceMapper extends Mapper<TourGoodSpePrice> {
List<TourDepartTimeVo> getAllByGoodId(@Param("goodId") Integer goodId);
//获取总库存
Integer getTotalStock(@Param("goodId") Integer goodId);
//减库存
int updStockById(@Param("id") Integer id,@Param("number") Integer number,@Param("type") Integer type);
......
package com.xxfc.platform.tour.rest;
import com.github.wxiaoqi.security.common.msg.ListRestResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.tour.biz.TourTagBannerBiz;
import com.xxfc.platform.tour.dto.TourTagBannerDTO;
import com.xxfc.platform.tour.entity.TourTagBanner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -16,7 +16,6 @@ public class TourTagBannerController extends BaseController<TourTagBannerBiz,Tou
@Autowired
private TourTagBannerBiz tagBannerBiz;
@GetMapping("/app/unauth/findById/{tid}")
......@@ -26,7 +25,10 @@ public class TourTagBannerController extends BaseController<TourTagBannerBiz,Tou
return ObjectRestResponse.succ(tourTagBanners);
}
@GetMapping("/app/unauth/findByType/{type}")
public ObjectRestResponse findByType(@PathVariable Integer type) {
List<TourTagBannerDTO> tourTagBannerDTOS = tagBannerBiz.findTourTagBannersByTagId(type);
return ObjectRestResponse.succ(tourTagBannerDTOS);
}
}
\ No newline at end of file
......@@ -34,7 +34,7 @@ public class TourUserController extends TourBaseController<TourUserBiz> {
@GetMapping("/app/unauth/getTourUser/{isChild}")
public ObjectRestResponse findListByTourUserByIsChild(@PathVariable int isChild){
AppUserDTO userInfo = getUserInfo();
Integer id = userInfo.getId();
Integer id = userInfo.getUserid();
List<TourUser> tourUsers= baseBiz.findListByTourUserByIsChild(id,isChild);
return ObjectRestResponse.succ(tourUsers);
......@@ -115,7 +115,7 @@ public class TourUserController extends TourBaseController<TourUserBiz> {
if (userInfo==null||userInfo.getUserid()==null||userInfo.getUserid()==0) {
ObjectRestResponse.createDefaultFail();
}
Integer id = userInfo.getId();
Integer id = userInfo.getUserid();
List<TourUser> tourUsers= baseBiz.getTourUser(id);
return ObjectRestResponse.succ(tourUsers);
}
......
......@@ -84,7 +84,7 @@
from tour_good g
LEFT JOIN tour_good_tag tag ON g.id=tag.good_id
LEFT JOIN tour_tag t ON tag.tag_id=t.id
where g.recommend=1
where g.recommend=1 and g.status=1 and g.is_del=0
GROUP BY g.id
ORDER BY g.rank DESC ,g.id DESC
limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER}
......
......@@ -41,6 +41,11 @@
FROM tour_good_spe_price WHERE good_id=#{goodId} and is_del=0 ORDER BY start_time
</select>
<!-- 获取出行时间 -->
<select id="getTotalStock" resultType="Integer" >
SELECT IFNULL(SUM(stock),0) as stock FROM tour_good_spe_price WHERE good_id=#{goodId} and is_del=0 and IFNULL(DATEDIFF(start_time,NOW()),0)>0
</select>
<!-- 减库存-->
<update id="updStockById">
update tour_good_spe_price set
......
package com.xxfc.platform.universal.api;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.model.JuheResult;
import com.xxfc.platform.universal.vo.TrafficViolations;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
//@FeignClient(name = "xx-universal")
@RequestMapping("/3p/tv")
public interface ITrafficViolationsFeign {
}
package com.xxfc.platform.universal.api;
import com.xxfc.platform.universal.model.JuheResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient("xx-third-party")
@RequestMapping("3p/tv")
public interface ITrafficViolationsService {
/**
* 获取支持的城市
* @param province
* @return
*/
@RequestMapping(value = "city", method = RequestMethod.GET)
JuheResult getCityInfo(String province);
/**
* 查违章
* @param city 城市代码
* @param hphm 车牌号码
* @param hpzl 车辆类型 01:大车,02:小车
* @param engineno 发动机号
* @param classno 车架号
* @return
*/
@RequestMapping(value = "trafficViolations", method = RequestMethod.GET)
JuheResult queryTrafficViolations(String city, String hphm, String hpzl, String engineno, String classno);
/**
* 获取剩余查询次数
* @return
*/
@RequestMapping(value = "balance", method = RequestMethod.GET)
JuheResult getBalance();
/**
* 根据车牌查归属地
* @param hphm 车牌号码
* @return
*/
@RequestMapping(value = "carPre", method = RequestMethod.GET)
JuheResult carPre(String hphm);
}
package com.xxfc.platform.universal.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import tk.mybatis.mapper.annotation.KeySql;
import tk.mybatis.mapper.code.IdentityDialect;
import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
@Data
public class LicensePlateType implements Serializable {
/**
* id
*/
@Id
@KeySql(dialect = IdentityDialect.MYSQL)
private Integer id;
/**
* 车型代码
*/
private String code;
/**
* 车型类型
*/
private String type;
/**
* 创建时间
*/
@Column(name = "create_date")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT-8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date createDate;
/**
* 修改时间
*/
@Column(name = "update_date")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT-8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateDate;
public LicensePlateType(String code, String type) {
this.code=code;
this.type=type;
}
public LicensePlateType() {
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LicensePlateType that = (LicensePlateType) o;
return code.equals(that.code) &&
type.equals(that.type);
}
@Override
public int hashCode() {
return Objects.hash(code, type);
}
}
package com.xxfc.platform.universal.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import tk.mybatis.mapper.annotation.KeySql;
import tk.mybatis.mapper.code.IdentityDialect;
import javax.persistence.Column;
import javax.persistence.Id;
import java.util.Date;
@Data
public class SearchableCity {
@Id
@KeySql(dialect = IdentityDialect.MYSQL)
private Integer id;
private String code;
@Column(name = "city_name")
private String cityName;
@Column(name = "create_date")
@DateTimeFormat(pattern ="yyyy-MM-dd HH:mm:ss" )
@JsonFormat(timezone = "GMT-8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date createDate;
@Column(name = "update_date")
@DateTimeFormat(pattern ="yyyy-MM-dd HH:mm:ss" )
@JsonFormat(timezone = "GMT-8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateDate;
}
......@@ -5,11 +5,9 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.entity.OrderRefund;
import com.xxfc.platform.universal.vo.OrderPayVo;
import com.xxfc.platform.universal.vo.OrderRefundVo;
import com.xxfc.platform.universal.vo.TrafficViolations;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
......@@ -30,4 +28,25 @@ public interface ThirdFeign {
@RequestMapping(value = "/refund/app/wx", method = RequestMethod.POST)
public ObjectRestResponse<String> refund(@RequestBody OrderRefundVo orderRefundVo);
/**
* 获取支持的城市
* @return
*/
@GetMapping("/city")
ObjectRestResponse getCityInfo();
/**
* 违章车辆查询
* @return
*/
@PostMapping("/trafficViolations")
ObjectRestResponse queryTrafficViolations(@RequestBody TrafficViolations trafficViolations) ;
/**
* 车辆类型查询
* @return
*/
@GetMapping("/LicensePlateType")
ObjectRestResponse getLicensePlateType();
}
package com.xxfc.platform.universal.vo;
import lombok.Data;
@Data
public class TrafficViolations {
/**
* 车牌类型
*/
private String type;
/**
* 车牌号码
*/
private String plateno;
/**
* 发动机号
*/
private String engineno;
/**
* 车架号
*/
private String frameno;
}
......@@ -72,6 +72,10 @@
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
</dependency>
</dependencies>
<build>
......
......@@ -19,7 +19,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableAceCache
@EnableTransactionManagement
@tk.mybatis.spring.annotation.MapperScan(basePackages = "com.xxfc.platform.universal.mapper")
@EnableFeignClients(value = {"com.github.wxiaoqi.security.auth.client.feign", "com.xxfc.platform","com.github.wxiaoqi.security.admin.feign"},defaultConfiguration = HeaderConfig.class)
@EnableFeignClients(value = {"com.xxfc.platform","com.github.wxiaoqi.security"},defaultConfiguration = HeaderConfig.class)
public class UniversalApplication {
public static void main(String[] args) {
......
package com.xxfc.platform.universal.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.xxfc.platform.universal.entity.LicensePlateType;
import com.xxfc.platform.universal.mapper.LicensePlateTypeMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls;
import java.sql.SQLDataException;
import java.sql.SQLException;
import java.util.List;
@Service
public class LicensePlateTypeBiz extends BaseBiz<LicensePlateTypeMapper, LicensePlateType> {
/**
* 获取车牌类型和和编码
* @param licensePlateTypes
*/
@Transactional
public void insertLicensePlateType(List<LicensePlateType> licensePlateTypes) {
mapper.insertLicensePlateType(licensePlateTypes);
}
/**
* 修改数据库数据
* @param licensePlateTypes
* @throws SQLException
*/
@Transactional
public void updateLicensePlateType(List<LicensePlateType> licensePlateTypes) throws SQLException {
// List<LicensePlateType> saveLicensePlateTypes = mapper.selectAll();
// HashSet<LicensePlateType> judgeSet = new HashSet<>();
// judgeSet.addAll(saveLicensePlateTypes);
// for (LicensePlateType licensePlateType : licensePlateTypes) {
//
// if (judgeSet.add(licensePlateType)) {
//
// mapper.updateByExample()
// }
// }
for (LicensePlateType licensePlateType : licensePlateTypes) {
Example exa = Example.builder(LicensePlateType.class)
.where(
WeekendSqls.<LicensePlateType>custom()
.andEqualTo(LicensePlateType::getCode,licensePlateType.getCode())
).build();
int flag = mapper.updateByExample(licensePlateType,exa);
if (flag==0) {
insertSelective(licensePlateType);
}
if (flag>1) {
throw new SQLException("修改错误,同时修改多条数据");
}
}
}
}
......@@ -50,7 +50,14 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> {
Integer amount=orderPayVo.getAmount();
log.error("---下单---order_no====="+order_no+"--支付订单号--trade_no===="+trade_no+"--金额---amount===="+amount);
//报名费回调路径
String jsParam = WXPay.apppay(1+"",orderPayVo.getBody(),"https://"+ SystemConfig.weixinHost+"/api/universal/pay/app/unauth/notify" ,trade_no,orderPayVo.getBuyerIp(),0);
//临时处理
amount = amount/100000;
if(amount <= 0) {
amount = 1;
}
String jsParam = WXPay.apppay(amount+"",orderPayVo.getBody(),"https://"+ SystemConfig.weixinHost+"/api/universal/pay/app/unauth/notify" ,trade_no,orderPayVo.getBuyerIp(),0);
log.info("报名费回调路径jsParam:"+jsParam);
if(!StringUtils.isBlank(jsParam))
{
......
package com.xxfc.platform.universal.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.universal.entity.SearchableCity;
import com.xxfc.platform.universal.mapper.SearchableCityMapper;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@Service
public class SearchableCityBiz extends BaseBiz<SearchableCityMapper, SearchableCity> {
public void insertSearchableCities(ArrayList<SearchableCity> searchableCities) {
mapper.insertSearchableCities(searchableCities);
}
}
package com.xxfc.platform.universal.controller;
import com.xxfc.platform.universal.api.ITrafficViolationsService;
import com.xxfc.platform.universal.model.JuheResult;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.service.TrafficViolationsService;
import com.xxfc.platform.universal.vo.TrafficViolations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("3p/tv")
public class TrafficViolationsController {
//implements ITrafficViolationsService {
// @Autowired
// TrafficViolationsService tvService;
//
// @Override
// @GetMapping("city")
// public JuheResult getCityInfo(String province) {
// return tvService.getCity(province);
// }
//
// @Override
// @GetMapping("trafficViolations")
// public JuheResult queryTrafficViolations(String city, String hphm, String hpzl, String engineno, String classno) {
// return tvService.queryViolations(city, hphm, hpzl, engineno, classno);
// }
//
// @Override
// @GetMapping("balance")
// public JuheResult getBalance() {
// return tvService.queryBalance();
// }
//
// @Override
// @GetMapping("carPre")
// public JuheResult carPre(String hphm) {
// return tvService.queryCityByHphm(hphm);
// }
@Autowired
TrafficViolationsService tvService;
/**
* 获取支持的城市
* @return
*/
@GetMapping("/city")
public ObjectRestResponse getCityInfo() {
try {
return ObjectRestResponse.succ(JSONObject.parse(tvService.getCity()));
} catch (Exception e) {
e.printStackTrace();
return ObjectRestResponse.createDefaultFail();
}
}
/**
* 违章车辆查询
* @return
*/
@PostMapping("/trafficViolations")
public ObjectRestResponse queryTrafficViolations(@RequestBody TrafficViolations trafficViolations) {
try {
return ObjectRestResponse.succ(JSONObject.parse(tvService.queryViolations(trafficViolations)));
} catch (Exception e) {
e.printStackTrace();
return ObjectRestResponse.createDefaultFail();
}
}
/**
* 车辆类型查询
* @return
*/
@GetMapping("/LicensePlateType")
public ObjectRestResponse getLicensePlateType() {
try {
return ObjectRestResponse.succ(tvService.getLicensePlateType());
} catch (Exception e) {
e.printStackTrace();
return ObjectRestResponse.createDefaultFail();
}
}
}
package com.xxfc.platform.universal.mapper;
import com.xxfc.platform.universal.entity.LicensePlateType;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface LicensePlateTypeMapper extends Mapper<LicensePlateType> {
void insertLicensePlateType(@Param("licensePlateTypes") List<LicensePlateType> licensePlateTypes);
}
package com.xxfc.platform.universal.mapper;
import com.xxfc.platform.universal.entity.SearchableCity;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.ArrayList;
public interface SearchableCityMapper extends Mapper<SearchableCity> {
void insertSearchableCities(@Param(value = "searchableCities") ArrayList<SearchableCity> searchableCities);
}
#\u8BA4\u8BC1\u63A5\u53E3\u9700\u8981\u643A\u5E26\u7684\u53C2\u6570
#A\u8BA4\u8BC1
#A-\u8BA4\u8BC1
certif.cHost=https://idcert.market.alicloudapi.com
certif.cPath=/idcard
certif.cMethod=GET
certif.cAppcode=acea1c8811f748b3a65815f11db357c4
#1.\u8BF7\u6C42
#\u8EAB\u4EFD\u8BC1\u53F7\u5B57\u6BB5\u540D\u79F0
certif.idCardName=idCard
#\u59D3\u540D\u5B57\u6BB5\u540D\u79F0
certif.cName=name
#2.\u54CD\u5E94
#\u9519\u8BEF\u7801\u5B57\u6BB5\u540D
certif.certifRet=status
#\u8BA4\u8BC1\u6210\u529F\u7801
certif.certifResultCode=01
#B\u56FE\u7247\u89E3\u6790
#B-\u56FE\u7247\u89E3\u6790
certif.iHost=https://ocridcard.market.alicloudapi.com
certif.iPath =/idimages
certif.iPath=/idimages
certif.iMethod=POST
certif.iAppcode =acea1c8811f748b3a65815f11db357c4
certif.iAppcode=acea1c8811f748b3a65815f11db357c4
#1.\u8BF7\u6C42
#\u56FE\u7247url\u5B57\u6BB5\u540D
certif.picName=image
......@@ -34,7 +28,6 @@ certif.typeName=idCardSide
certif.frontParameter=front
#\u56FE\u7247\u80CC\u9762\u6807\u8BC6\u53C2\u6570
certif.backParameter=back
#2.\u54CD\u5E94
#\u56FE\u7247\u89E3\u6790\u54CD\u5E94\u643A\u5E26\u9519\u8BEF\u7801\u5B57\u6BB5\u540D
certif.imageRet=code
......@@ -48,3 +41,9 @@ certif.numberName=code
certif.iName=name
#\u8EAB\u4EFD\u8BC1\u5230\u671F\u65F6\u95F4\u5B57\u6BB5\u540D
certif.expirationDateName=expiryDate
#C-\u8FDD\u7AE0\u8F66\u8F86\u67E5\u8BE2
#\u63A5\u53E3appcode
ALIYUN.CODE=acea1c8811f748b3a65815f11db357c4
#\u8FD4\u56DE\u53C2\u6570\u7C7B\u578B(HTML/JSON/JSONP/XML)
RETURN.TYPE=JSON
\ No newline at end of file
......@@ -135,9 +135,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
}
@Cache(key = "vehical")
// @Cache(key = "vehical")
public Vehicle get(String id){
return mapper.selectByPrimaryKey(id);
Vehicle vehicle = mapper.selectByPrimaryKey(id);
return vehicle;
}
/**
......
......@@ -13,33 +13,39 @@ import com.xxfc.platform.vehicle.pojo.AddOrUpdateAccompanyingItem;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.pojo.QueryAccompanyItemVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author Administrator
*/
@RestController
@RequestMapping("/accompanyingItem")
@IgnoreClientToken
@Slf4j
public class AccompanyingItemController extends BaseController<AccompanyingItemBiz> {
@Autowired
AccompanyingItemBiz accompanyingItemBiz;
@RequestMapping(value ="/{id}",method = RequestMethod.GET)
private RestResponse<AccompanyingItem> get(@PathVariable Integer id) throws Exception{
/**
*
* @param id
* @return
* @throws Exception
*/
@GetMapping(value ="/{id}")
public RestResponse<AccompanyingItem> get(@PathVariable Integer id) throws Exception{
return RestResponse.codeAndData(RestResponse.SUC_CODE,baseBiz.get(id));
}
@RequestMapping(value ="/all",method = RequestMethod.GET)
private RestResponse<List<AccompanyingItem>> getAll(){
return RestResponse.codeAndData(RestResponse.SUC_CODE,accompanyingItemBiz.getAll());
public RestResponse<List<AccompanyingItem>> getAll(){
return RestResponse.codeAndData(RestResponse.SUC_CODE,baseBiz.getAll());
}
@RequestMapping(value ="/page",method = RequestMethod.GET)
private RestResponse<PageDataVO<AccompanyingItem>> getByPage(@RequestParam String queryAccompanyItemVoJson) throws Exception{
public RestResponse<PageDataVO<AccompanyingItem>> getByPage(@RequestParam String queryAccompanyItemVoJson) throws Exception{
QueryAccompanyItemVo queryAccompanyItemVo = null;
try {
queryAccompanyItemVo = JSON.parseObject(queryAccompanyItemVoJson,QueryAccompanyItemVo.class);
......@@ -52,17 +58,17 @@ public class AccompanyingItemController extends BaseController<AccompanyingItemB
}
@RequestMapping(value ="",method = RequestMethod.POST)
private RestResponse<Integer> add(@RequestBody AddOrUpdateAccompanyingItem addOrUpdateAccompanyingItem) throws Exception{
public RestResponse<Integer> add(@RequestBody AddOrUpdateAccompanyingItem addOrUpdateAccompanyingItem) throws Exception{
return baseBiz.add(addOrUpdateAccompanyingItem);
}
@RequestMapping(value ="",method = RequestMethod.PUT)
private RestResponse<Integer> update(@RequestBody AddOrUpdateAccompanyingItem addOrUpdateAccompanyingItem) throws Exception{
public RestResponse<Integer> update(@RequestBody AddOrUpdateAccompanyingItem addOrUpdateAccompanyingItem) throws Exception{
return baseBiz.update(addOrUpdateAccompanyingItem);
}
@RequestMapping(value ="/{id}",method = RequestMethod.DELETE)
private RestResponse<Integer> del(@PathVariable Integer id) throws Exception{
public RestResponse<Integer> del(@PathVariable Integer id) throws Exception{
return baseBiz.del(id);
}
}
......@@ -12,12 +12,18 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 片区
*/
@RestController
@RequestMapping("/area")
@Slf4j
@IgnoreClientToken
public class AreaController extends BaseController<AreaBiz, Area> {
/**
* 获取所有片区
* @return
*/
@GetMapping("/findAll")
public RestResponse<List<Area>> findAll(){
return RestResponse.suc(baseBiz.selectListAll());
......
......@@ -24,15 +24,14 @@
, st_distance_sphere(point(#{lon}, #{lat}), point(longitude, latitude)) as distance
</if>
from branch_company
<trim prefix="where" suffixOverrides="and">
<if test="addrCity != null">
addr_city = #{addrCity}
</if>
<if test="lon != null and lat != null">
longitude is not null and latitude is not null
</if>
</trim>
<where>
<if test="addrCity != null">
and addr_city = #{addrCity}
</if>
<if test="lon != null and lat != null">
and longitude is not null and latitude is not null
</if>
</where>
<if test="lon != null and lat != null">
order by distance asc
</if>
......
<?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.xxfc.platform.universal.mapper.LicensePlateTypeMapper">
<insert id="insertLicensePlateType" parameterType="List" >
insert into license_plate_type (code,type,create_date,update_date) values
<foreach collection="licensePlateTypes" item="lpt" index="index" separator=",">
(#{lpt.code},#{lpt.createDate},#{lpt.updateDate})
</foreach>
</insert>
</mapper>
\ No newline at end of file
......@@ -66,7 +66,7 @@
left join
vehicle_book_info vbi on v.`id` = vbi.vehicle
</if>
LEFT JOIN branch_company bc ON v.park_branch_company_id = bc.id 58 left join branch_company bc on v.`subordinate_branch` = bc.id
LEFT JOIN branch_company bc ON v.park_branch_company_id = bc.id
LEFT JOIN branch_company bc1 ON v.expect_destination_branch_company_id = bc1.id
where
v.is_del=0
......@@ -333,7 +333,8 @@
</if>
<include refid="searchUsableSql"/>
and vm.id is not null
and bc.id is not null
GROUP BY model_id, company_id
<if test="lon != null and lat != null">, distance</if>
......
......@@ -13,6 +13,8 @@ import com.alibaba.fastjson.JSONObject;
import com.github.stuxuhai.jpinyin.PinyinHelper;
import com.github.wxiaoqi.security.common.msg.TableResultResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.google.common.collect.Sets;
import com.mysql.cj.conf.RuntimeProperty;
import com.xxfc.platform.vehicle.VehicleApplication;
import com.xxfc.platform.vehicle.biz.SysRegionBiz;
import com.xxfc.platform.vehicle.constant.RedisKey;
......@@ -29,9 +31,8 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.io.PrintStream;
import java.util.*;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes={VehicleApplication.class})
......@@ -59,6 +60,8 @@ public class RegionTest {
public class NewData{
Long id;
String name;
String lat;
String lon;
}
@Data
......@@ -131,34 +134,61 @@ public class RegionTest {
System.out.println("test");
}
@Test
public void test1() {
int i = DateTime.now().getMinuteOfDay() / 5;
System.out.println("DateTime.now().getMinuteOfDay() / 5++++++++++++"+i);
String redisLockKey = RedisKey.SYS_REGION_REFRESH_LOCK +i;//同一日每5分钟只刷新一次
System.out.println("redisLockKey++++++++++++++++"+redisLockKey);
String s = String.valueOf(DateTime.now().getMillis());
System.out.println("s++++++++++++++++++"+s);
Boolean suc = customRedisTemplate.opsForValue().setIfAbsent(redisLockKey, s);
Boolean test1 = customRedisTemplate.opsForValue().setIfAbsent("1", "2");
Boolean test2 = customRedisTemplate.opsForValue().setIfAbsent("1", "3");
System.out.println("test1///////////////////////////////"+test1);
System.out.println("test2///////////////////////////////"+test2);
System.out.println("suc++++++++++++++++++++"+suc);
}
// @Test
// public void test1() {
// int i = DateTime.now().getMinuteOfDay() / 5;
// System.out.println("DateTime.now().getMinuteOfDay() / 5++++++++++++"+i);
// String redisLockKey = RedisKey.SYS_REGION_REFRESH_LOCK +i;//同一日每5分钟只刷新一次
// System.out.println("redisLockKey++++++++++++++++"+redisLockKey);
// String s = String.valueOf(DateTime.now().getMillis());
// System.out.println("s++++++++++++++++++"+s);
// Boolean suc = customRedisTemplate.opsForValue().setIfAbsent(redisLockKey, s);
// Boolean test1 = customRedisTemplate.opsForValue().setIfAbsent("1", "2");
// Boolean test2 = customRedisTemplate.opsForValue().setIfAbsent("1", "3");
// System.out.println("test1///////////////////////////////"+test1);
// System.out.println("test2///////////////////////////////"+test2);
// System.out.println("suc++++++++++++++++++++"+suc);
// }
//
// @Test
// public void testRedis() {
// SysRegion sysRegion = getSysRegion(1);
// System.out.println("sysRegion+++++++++"+sysRegion);
// System.out.println("TEST_REDIS_KEY+++++++++++" + TEST_REDIS_KEY);
// }
//
// @Cache(key = TEST_REDIS_KEY)
// private SysRegion getSysRegion(int id){
// SysRegion sysRegion = sysRegionBiz.selectById(2);
// return sysRegion;
// }
@Test
public void testRedis() {
SysRegion sysRegion = getSysRegion(1);
System.out.println("sysRegion+++++++++"+sysRegion);
System.out.println("TEST_REDIS_KEY+++++++++++" + TEST_REDIS_KEY);
}
@Cache(key = TEST_REDIS_KEY)
private SysRegion getSysRegion(int id){
SysRegion sysRegion = sysRegionBiz.selectById(2);
return sysRegion;
}
@Test
public void testStream(){
List<Integer> integers = Arrays.asList(1, 3, 5, 7, 9,9);
HashSet<Integer> objects = new HashSet<>();
objects.addAll(integers);
System.out.println(objects);
System.out.println("获取最小值");
Optional<Integer> min = objects.parallelStream().min(Integer::compareTo);
if (min.isPresent()) {
System.out.println(min.get());
}
System.out.println("获取最大");
Optional<Integer> max = integers.parallelStream().max(Integer::compareTo);
if (max.isPresent()) {
System.out.println(max.get());
}
System.out.println("排序");
integers.stream().sorted().forEach(elem -> System.out.println(elem));
System.out.println("筛选");
integers.parallelStream().filter(e ->e>1).filter(e -> e<9).forEach(e -> System.out.println(e));
System.out.println("list的总和为");
integers.stream().reduce((a,b) -> a+b).ifPresent(System.out::println);
}
}
......@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -31,4 +32,38 @@ public class TimeTest {
DateTime startDay =DateTime.parse("2019-06-04", DEFAULT_DATE_TIME_FORMATTER);
System.out.println("test");
}
@Test
public void testStream() throws Exception {
ArrayList<Student> students = new ArrayList<>();
students.add(new Student("张1","11"));
students.add(new Student("张2","12"));
students.add(new Student("张3","13"));
students.add(new Student("张4","14"));
students.add(new Student("张5","15"));
int i=0;
students.forEach(student -> student.setCode(1));
students.forEach(System.out::println);
}
}
@Data
class Student implements Serializable {
private String name;
private String age;
private int code;
public Student(String name, String age, int code) {
this.name=name;
this.age=age;
this.code=code;
}
public Student(String name, String age) {
this.name=name;
this.age=age;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment