Commit d827ece0 by testdl

代码合并,解决冲突

parents b682691c 38641b91
package com.jumeirah.api.app.controller; package com.jumeirah.api.app.controller;
import com.jumeirah.common.param.MerchantUserPageParam; import com.jumeirah.common.param.MerchantPageParam;
import com.jumeirah.common.service.MerchantService;
import com.jumeirah.common.service.MerchantUserService; import com.jumeirah.common.service.MerchantUserService;
import com.jumeirah.common.vo.MerchantUserQueryForAppVo; import com.jumeirah.common.vo.MerchantQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController; import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.Paging;
...@@ -33,14 +34,17 @@ public class AirIntroducedController extends BaseController { ...@@ -33,14 +34,17 @@ public class AirIntroducedController extends BaseController {
@Autowired @Autowired
private MerchantUserService merchantUserService; private MerchantUserService merchantUserService;
@Autowired
private MerchantService merchantService;
/** /**
* 商家分页列表 * 商家分页列表
*/ */
@PostMapping("/getPageList") @PostMapping("/getPageList")
@OperationLog(name = "航空公司介绍分页列表", type = OperationLogType.PAGE) @OperationLog(name = "航空公司介绍分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "航空公司介绍分页列表", response = MerchantUserQueryForAppVo.class) @ApiOperation(value = "航空公司介绍分页列表", response = MerchantQueryVo.class)
public ApiResult<Paging<MerchantUserQueryForAppVo>> getMerchantUserPageList(@Validated @RequestBody MerchantUserPageParam merchantUserPageParam) throws Exception { public ApiResult<Paging<MerchantQueryVo>> getMerchantPageList(@Validated @RequestBody MerchantPageParam merchantPageParam) throws Exception {
Paging<MerchantUserQueryForAppVo> paging = merchantUserService.getMerchantUserPageListForApp(merchantUserPageParam); Paging<MerchantQueryVo> paging = merchantService.getMerchantPageList(merchantPageParam);
return ApiResult.ok(paging); return ApiResult.ok(paging);
} }
} }
......
package com.jumeirah.api.app.controller;
import com.jumeirah.common.entity.Merchant;
import com.jumeirah.common.param.MerchantPageParam;
import com.jumeirah.common.service.MerchantService;
import com.jumeirah.common.vo.MerchantQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 航空公司商家表 控制器
*
* @author giao
* @since 2020-10-13
*/
@Slf4j
@RestController
@RequestMapping("/app/merchant")
@Api(value = "航空公司商家表API", tags = {"航空公司航空公司商家表"})
public class MerchantController extends BaseController {
@Autowired
private MerchantService merchantService;
/**
* 添加航空公司商家表
*/
@PostMapping("/add")
@OperationLog(name = "添加航空公司商家表", type = OperationLogType.ADD)
@ApiOperation(value = "添加航空公司商家表")
public ApiResult<Boolean> addMerchant(@Validated(Add.class) @RequestBody Merchant merchant) throws Exception {
boolean flag = merchantService.saveMerchant(merchant);
return ApiResult.result(flag);
}
/**
* 修改航空公司商家表
*/
@PostMapping("/update")
@OperationLog(name = "修改航空公司商家表", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改航空公司商家表")
public ApiResult<Boolean> updateMerchant(@Validated(Update.class) @RequestBody Merchant merchant) throws Exception {
boolean flag = merchantService.updateMerchant(merchant);
return ApiResult.result(flag);
}
/**
* 删除航空公司商家表
*/
@PostMapping("/delete/{id}")
@OperationLog(name = "删除航空公司商家表", type = OperationLogType.DELETE)
@ApiOperation(value = "删除航空公司商家表")
public ApiResult<Boolean> deleteMerchant(@PathVariable("id") Long id) throws Exception {
boolean flag = merchantService.deleteMerchant(id);
return ApiResult.result(flag);
}
/**
* 获取航空公司商家表详情
*/
@GetMapping("/info/{id}")
@OperationLog(name = "航空公司商家表详情", type = OperationLogType.INFO)
@ApiOperation(value = "航空公司商家表详情")
public ApiResult<MerchantQueryVo> getMerchant(@PathVariable("id") Long id) throws Exception {
MerchantQueryVo merchantQueryVo = merchantService.getMerchantById(id);
return ApiResult.ok(merchantQueryVo);
}
/**
* 航空公司商家表分页列表
*/
@PostMapping("/getPageList")
@OperationLog(name = "航空公司商家表分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "航空公司商家表分页列表")
public ApiResult<Paging<MerchantQueryVo>> getMerchantPageList(@Validated @RequestBody MerchantPageParam merchantPageParam) throws Exception {
Paging<MerchantQueryVo> paging = merchantService.getMerchantPageList(merchantPageParam);
return ApiResult.ok(paging);
}
}
...@@ -56,7 +56,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties ...@@ -56,7 +56,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.filter.DelegatingFilterProxy; import org.springframework.web.filter.DelegatingFilterProxy;
import javax.servlet.DispatcherType; import javax.servlet.DispatcherType;
...@@ -204,14 +203,13 @@ public class ShiroConfig { ...@@ -204,14 +203,13 @@ public class ShiroConfig {
ShiroLoginService shiroLoginService, ShiroLoginService shiroLoginService,
SysLoginRedisService sysLoginRedisService, SysLoginRedisService sysLoginRedisService,
ShiroProperties shiroProperties, ShiroProperties shiroProperties,
JwtProperties jwtProperties, JwtProperties jwtProperties) {
RedisTemplate redisTemplate) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
// 设置安全管理器 // 设置安全管理器
shiroFilterFactoryBean.setSecurityManager(securityManager); shiroFilterFactoryBean.setSecurityManager(securityManager);
// 设置过滤器 // 设置过滤器
Map<String, Filter> filterMap = getFilterMap(shiroLoginService, sysLoginRedisService, jwtProperties, redisTemplate); Map<String, Filter> filterMap = getFilterMap(shiroLoginService, jwtProperties);
shiroFilterFactoryBean.setFilters(filterMap); shiroFilterFactoryBean.setFilters(filterMap);
// 设置过滤器顺序 // 设置过滤器顺序
Map<String, String> filterChainMap = getFilterChainDefinitionMap(shiroProperties); Map<String, String> filterChainMap = getFilterChainDefinitionMap(shiroProperties);
...@@ -226,11 +224,9 @@ public class ShiroConfig { ...@@ -226,11 +224,9 @@ public class ShiroConfig {
* @return * @return
*/ */
private Map<String, Filter> getFilterMap(ShiroLoginService shiroLoginService, private Map<String, Filter> getFilterMap(ShiroLoginService shiroLoginService,
SysLoginRedisService loginRedisService, JwtProperties jwtProperties) {
JwtProperties jwtProperties,
RedisTemplate redisTemplate) {
Map<String, Filter> filterMap = new LinkedHashMap<>(); Map<String, Filter> filterMap = new LinkedHashMap<>();
filterMap.put(JWT_FILTER_NAME, new JwtFilter(shiroLoginService, loginRedisService, jwtProperties, redisTemplate)); filterMap.put(JWT_FILTER_NAME, new JwtFilter(shiroLoginService, jwtProperties));
return filterMap; return filterMap;
} }
......
package com.jumeirah.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* 航空公司商家表
*
* @author giao
* @since 2020-10-13
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Merchant对象")
public class Merchant extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空", groups = {Update.class})
@ApiModelProperty("主键")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("商家名称")
private String name;
@ApiModelProperty("联系人手机号码")
private String phone;
@ApiModelProperty("联系人手机区号")
private String phoneArea;
@ApiModelProperty("公司头像")
private String head;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("状态,0:禁用,1:启用,2:锁定")
private Integer state;
@ApiModelProperty("逻辑删除,0:未删除,1:已删除")
@TableLogic
private Integer deleted;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("修改时间")
private Date updateTime;
@ApiModelProperty("商家开户银行")
private String rechargeBank;
@ApiModelProperty("商家开户名称")
private String rechargeName;
@ApiModelProperty("商家银行卡号")
private String rechargeBankNumber;
@ApiModelProperty("在列表展示的图片url")
private String imageListUrl;
@ApiModelProperty("公司介绍图片url")
private String imageCompanyIntroductionUrl;
@ApiModelProperty("团队介绍图片url")
private String imageTeamIntroductionUrl;
@ApiModelProperty("优势图片url")
private String imageAdvantageUrl;
@ApiModelProperty("公司介绍文字")
private String textCompanyIntroduction;
@ApiModelProperty("团队介绍文字")
private String textTeamIntroduction;
@ApiModelProperty("优势介绍文字")
private String textAdvantage;
@ApiModelProperty("航空公司名称")
private String airlineName;
}
...@@ -85,25 +85,4 @@ public class MerchantUser extends BaseEntity { ...@@ -85,25 +85,4 @@ public class MerchantUser extends BaseEntity {
@ApiModelProperty("修改时间") @ApiModelProperty("修改时间")
private Date updateTime; private Date updateTime;
@ApiModelProperty("在列表展示的图片url")
private String imageListUrl;
@ApiModelProperty("公司介绍图片url")
private String imageCompanyIntroductionUrl;
@ApiModelProperty("团队介绍图片url")
private String imageTeamIntroductionUrl;
@ApiModelProperty("优势图片url")
private String imageAdvantageUrl;
@ApiModelProperty("公司介绍文字")
private String textCompanyIntroduction;
@ApiModelProperty("团队介绍文字")
private String textTeamIntroduction;
@ApiModelProperty("优势介绍文字")
private String textAdvantage;
} }
...@@ -168,17 +168,6 @@ public class Stroke extends BaseEntity { ...@@ -168,17 +168,6 @@ public class Stroke extends BaseEntity {
@ApiModelProperty("用户充值截图证据, 传入数组") @ApiModelProperty("用户充值截图证据, 传入数组")
private String userRechargeCredentialsUrl; private String userRechargeCredentialsUrl;
@NotBlank(message = "商家开户银行不能为空")
@ApiModelProperty("商家开户银行")
private String rechargeBank;
@NotBlank(message = "商家开户名称不能为空")
@ApiModelProperty("商家开户名称")
private String rechargeName;
@NotBlank(message = "商家银行卡号")
@ApiModelProperty("商家银行卡号")
private String rechargeBankNumber;
@ApiModelProperty("备注") @ApiModelProperty("备注")
private String remark; private String remark;
......
...@@ -6,7 +6,7 @@ import lombok.AllArgsConstructor; ...@@ -6,7 +6,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
/** /**
* 付款状态,0-未付款,1-付款中,2-已付款,3-退款中,99-已退款 * 付款状态,0-未付款,1-用户已付款,待审核,2-用户已付款,审核通过,3-退款中,99-已退款
**/ **/
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
......
package com.jumeirah.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jumeirah.common.entity.Merchant;
import com.jumeirah.common.param.MerchantPageParam;
import com.jumeirah.common.vo.MerchantQueryVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.io.Serializable;
/**
* 航空公司商家表 Mapper 接口
*
* @author giao
* @since 2020-10-13
*/
@Repository
public interface MerchantMapper extends BaseMapper<Merchant> {
/**
* 根据ID获取查询对象
*
* @param id
* @return
*/
MerchantQueryVo getMerchantById(Serializable id);
/**
* 获取分页对象
*
* @param page
* @param merchantPageParam
* @return
*/
IPage<MerchantQueryVo> getMerchantPageList(@Param("page") Page page, @Param("param") MerchantPageParam merchantPageParam);
}
...@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jumeirah.common.entity.MerchantUser; import com.jumeirah.common.entity.MerchantUser;
import com.jumeirah.common.param.MerchantUserPageParam; import com.jumeirah.common.param.MerchantUserPageParam;
import com.jumeirah.common.vo.MerchantUserQueryForAppVo;
import com.jumeirah.common.vo.MerchantUserQueryVo; import com.jumeirah.common.vo.MerchantUserQueryVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -38,8 +37,4 @@ public interface MerchantUserMapper extends BaseMapper<MerchantUser> { ...@@ -38,8 +37,4 @@ public interface MerchantUserMapper extends BaseMapper<MerchantUser> {
*/ */
IPage<MerchantUserQueryVo> getMerchantUserPageList(@Param("page") Page page, @Param("param") MerchantUserPageParam merchantUserPageParam); IPage<MerchantUserQueryVo> getMerchantUserPageList(@Param("page") Page page, @Param("param") MerchantUserPageParam merchantUserPageParam);
IPage<MerchantUserQueryForAppVo> getMerchantUserForAppPageList(@Param("page") Page page, @Param("param") MerchantUserPageParam merchantUserPageParam);
} }
...@@ -39,6 +39,9 @@ public interface StrokeMapper extends BaseMapper<Stroke> { ...@@ -39,6 +39,9 @@ public interface StrokeMapper extends BaseMapper<Stroke> {
* @return * @return
*/ */
IPage<StrokeQueryVo> getStrokePageList(@Param("page") Page page, @Param("param") StrokePageParam strokePageParam, @Param("userId") Long userId); IPage<StrokeQueryVo> getStrokePageList(@Param("page") Page page, @Param("param") StrokePageParam strokePageParam, @Param("userId") Long userId);
IPage<StrokeQueryVo> getStrokePageListWithFinsh(@Param("page") Page page, @Param("param") StrokePageParam strokePageParam, @Param("userId") Long userId);
/** /**
* 商家端 获取行程分页对象 * 商家端 获取行程分页对象
......
package com.jumeirah.common.param;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <pre>
* 航空公司商家表 分页参数对象
* </pre>
*
* @author giao
* @date 2020-10-13
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "商家表分页参数")
public class MerchantPageParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L;
}
package com.jumeirah.common.service;
import com.jumeirah.common.entity.Merchant;
import com.jumeirah.common.param.MerchantPageParam;
import com.jumeirah.common.vo.MerchantQueryVo;
import io.geekidea.springbootplus.framework.common.service.BaseService;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
/**
* 航空公司商家表 服务类
*
* @author giao
* @since 2020-10-13
*/
public interface MerchantService extends BaseService<Merchant> {
/**
* 保存
*
* @param merchant
* @return
* @throws Exception
*/
boolean saveMerchant(Merchant merchant) throws Exception;
/**
* 修改
*
* @param merchant
* @return
* @throws Exception
*/
boolean updateMerchant(Merchant merchant) throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteMerchant(Long id) throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
MerchantQueryVo getMerchantById(Long id) throws Exception;
/**
* 获取分页对象
*
* @param merchantPageParam
* @return
* @throws Exception
*/
Paging<MerchantQueryVo> getMerchantPageList(MerchantPageParam merchantPageParam) throws Exception;
}
...@@ -4,7 +4,6 @@ import com.jumeirah.common.entity.MerchantUser; ...@@ -4,7 +4,6 @@ import com.jumeirah.common.entity.MerchantUser;
import com.jumeirah.common.param.LoginParam; import com.jumeirah.common.param.LoginParam;
import com.jumeirah.common.param.MerchantUserPageParam; import com.jumeirah.common.param.MerchantUserPageParam;
import com.jumeirah.common.vo.LoginSysUserTokenVo; import com.jumeirah.common.vo.LoginSysUserTokenVo;
import com.jumeirah.common.vo.MerchantUserQueryForAppVo;
import com.jumeirah.common.vo.MerchantUserQueryVo; import com.jumeirah.common.vo.MerchantUserQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.service.BaseService; import io.geekidea.springbootplus.framework.common.service.BaseService;
...@@ -78,13 +77,5 @@ public interface MerchantUserService extends BaseService<MerchantUser> { ...@@ -78,13 +77,5 @@ public interface MerchantUserService extends BaseService<MerchantUser> {
/**
* 获取分页对象
*
* @param merchantUserPageParam
* @return
* @throws Exception
*/
Paging<MerchantUserQueryForAppVo> getMerchantUserPageListForApp(MerchantUserPageParam merchantUserPageParam) throws Exception;
} }
...@@ -21,6 +21,7 @@ import io.geekidea.springbootplus.framework.core.pagination.PageInfo; ...@@ -21,6 +21,7 @@ import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.shiro.cache.AppLoginRedisService; import io.geekidea.springbootplus.framework.shiro.cache.AppLoginRedisService;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken; import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.geekidea.springbootplus.framework.shiro.jwt.realm.LoginClientTypeEnum;
import io.geekidea.springbootplus.framework.shiro.util.JwtUtil; import io.geekidea.springbootplus.framework.shiro.util.JwtUtil;
import io.geekidea.springbootplus.framework.shiro.util.SaltUtil; import io.geekidea.springbootplus.framework.shiro.util.SaltUtil;
import io.geekidea.springbootplus.framework.shiro.vo.LoginUserVo; import io.geekidea.springbootplus.framework.shiro.vo.LoginUserVo;
...@@ -115,7 +116,7 @@ public class AppUserServiceImpl extends BaseServiceImpl<AppUserMapper, AppUser> ...@@ -115,7 +116,7 @@ public class AppUserServiceImpl extends BaseServiceImpl<AppUserMapper, AppUser>
log.debug("token:{}", token); log.debug("token:{}", token);
// 创建AuthenticationToken // 创建AuthenticationToken
JwtToken jwtToken = JwtToken.build(token, appUser.getId().toString(), appUser.getId(), newSalt, expireSecond, "app"); JwtToken jwtToken = JwtToken.build(token, appUser.getId().toString(), appUser.getId(), newSalt, expireSecond, LoginClientTypeEnum.APP.getType());
boolean enableShiro = springBootPlusProperties.getShiro().isEnable(); boolean enableShiro = springBootPlusProperties.getShiro().isEnable();
if (enableShiro) { if (enableShiro) {
......
package com.jumeirah.common.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jumeirah.common.entity.Merchant;
import com.jumeirah.common.mapper.MerchantMapper;
import com.jumeirah.common.param.MerchantPageParam;
import com.jumeirah.common.service.MerchantService;
import com.jumeirah.common.vo.MerchantQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 航空公司商家表 服务实现类
*
* @author giao
* @since 2020-10-13
*/
@Slf4j
@Service
public class MerchantServiceImpl extends BaseServiceImpl<MerchantMapper, Merchant> implements MerchantService {
@Autowired
private MerchantMapper merchantMapper;
@Transactional(rollbackFor = Exception.class)
@Override
public boolean saveMerchant(Merchant merchant) throws Exception {
return super.save(merchant);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateMerchant(Merchant merchant) throws Exception {
return super.updateById(merchant);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean deleteMerchant(Long id) throws Exception {
return super.removeById(id);
}
@Override
public MerchantQueryVo getMerchantById(Long id) throws Exception {
return merchantMapper.getMerchantById(id);
}
@Override
public Paging<MerchantQueryVo> getMerchantPageList(MerchantPageParam merchantPageParam) throws Exception {
Page<MerchantQueryVo> page = new PageInfo<>(merchantPageParam, OrderItem.desc(getLambdaColumn(Merchant::getCreateTime)));
IPage<MerchantQueryVo> iPage = merchantMapper.getMerchantPageList(page, merchantPageParam);
return new Paging<MerchantQueryVo>(iPage);
}
}
...@@ -15,7 +15,6 @@ import com.jumeirah.common.service.MerchantRolePermissionService; ...@@ -15,7 +15,6 @@ import com.jumeirah.common.service.MerchantRolePermissionService;
import com.jumeirah.common.service.MerchantRoleService; import com.jumeirah.common.service.MerchantRoleService;
import com.jumeirah.common.service.MerchantUserService; import com.jumeirah.common.service.MerchantUserService;
import com.jumeirah.common.vo.LoginSysUserTokenVo; import com.jumeirah.common.vo.LoginSysUserTokenVo;
import com.jumeirah.common.vo.MerchantUserQueryForAppVo;
import com.jumeirah.common.vo.MerchantUserQueryVo; import com.jumeirah.common.vo.MerchantUserQueryVo;
import io.geekidea.springbootplus.config.properties.JwtProperties; import io.geekidea.springbootplus.config.properties.JwtProperties;
import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties; import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
...@@ -26,6 +25,7 @@ import io.geekidea.springbootplus.framework.core.pagination.PageInfo; ...@@ -26,6 +25,7 @@ import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.shiro.cache.MerchantLoginRedisService; import io.geekidea.springbootplus.framework.shiro.cache.MerchantLoginRedisService;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken; import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.geekidea.springbootplus.framework.shiro.jwt.realm.LoginClientTypeEnum;
import io.geekidea.springbootplus.framework.shiro.util.JwtTokenUtil; import io.geekidea.springbootplus.framework.shiro.util.JwtTokenUtil;
import io.geekidea.springbootplus.framework.shiro.util.JwtUtil; import io.geekidea.springbootplus.framework.shiro.util.JwtUtil;
import io.geekidea.springbootplus.framework.shiro.util.SaltUtil; import io.geekidea.springbootplus.framework.shiro.util.SaltUtil;
...@@ -157,7 +157,7 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper, ...@@ -157,7 +157,7 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper,
log.debug("token:{}", token); log.debug("token:{}", token);
// 创建AuthenticationToken // 创建AuthenticationToken
JwtToken jwtToken = JwtToken.build(token, username,merchantUser.getId(), newSalt, expireSecond, "mer"); JwtToken jwtToken = JwtToken.build(token, username,merchantUser.getId(), newSalt, expireSecond, LoginClientTypeEnum.MERCHANT.getType());
boolean enableShiro = springBootPlusProperties.getShiro().isEnable(); boolean enableShiro = springBootPlusProperties.getShiro().isEnable();
if (enableShiro) { if (enableShiro) {
...@@ -219,11 +219,5 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper, ...@@ -219,11 +219,5 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper,
return new Paging<MerchantUserQueryVo>(iPage); return new Paging<MerchantUserQueryVo>(iPage);
} }
@Override
public Paging<MerchantUserQueryForAppVo> getMerchantUserPageListForApp(MerchantUserPageParam merchantUserPageParam) throws Exception {
Page<MerchantUserQueryForAppVo> page = new PageInfo<>(merchantUserPageParam, OrderItem.desc(getLambdaColumn(MerchantUser::getCreateTime)));
IPage<MerchantUserQueryForAppVo> iPage = merchantUserMapper.getMerchantUserForAppPageList(page, merchantUserPageParam);
return new Paging<MerchantUserQueryForAppVo>(iPage);
}
} }
...@@ -52,6 +52,12 @@ public class StrokeServiceImpl extends BaseServiceImpl<StrokeMapper, Stroke> imp ...@@ -52,6 +52,12 @@ public class StrokeServiceImpl extends BaseServiceImpl<StrokeMapper, Stroke> imp
public boolean deleteStroke(Long id) throws Exception { public boolean deleteStroke(Long id) throws Exception {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal(); JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
Stroke byId = super.getById(id); Stroke byId = super.getById(id);
// 如果已删除 直接返回true
if (byId == null) {
return true;
}
// 判断该记录是否属于此用户 // 判断该记录是否属于此用户
if (!byId.getUserId().equals(jwtToken.getUserId())) { if (!byId.getUserId().equals(jwtToken.getUserId())) {
return false; return false;
...@@ -81,10 +87,18 @@ public class StrokeServiceImpl extends BaseServiceImpl<StrokeMapper, Stroke> imp ...@@ -81,10 +87,18 @@ public class StrokeServiceImpl extends BaseServiceImpl<StrokeMapper, Stroke> imp
@Override @Override
public Paging<StrokeQueryVo> getStrokePageList(StrokePageParam strokePageParam) throws Exception { public Paging<StrokeQueryVo> getStrokePageList(StrokePageParam strokePageParam) throws Exception {
Page<StrokeQueryVo> page = new PageInfo<>(strokePageParam, OrderItem.asc(getLambdaColumn(Stroke::getCreateTime))); // Page<StrokeQueryVo> page = new PageInfo<>(strokePageParam, OrderItem.asc(getLambdaColumn(Stroke::getCreateTime)));
Page<StrokeQueryVo> page = new PageInfo<>(strokePageParam, OrderItem.asc("s.create_time"));
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal(); JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
// 查询已完成 需要额外查询已取消状态
if (strokePageParam.getStatus().equals(StrokeStatusEnum.COMPLETED.getCode())){
IPage<StrokeQueryVo> iPage = strokeMapper.getStrokePageListWithFinsh(page, strokePageParam, jwtToken.getUserId());
return new Paging<StrokeQueryVo>(iPage);
}
IPage<StrokeQueryVo> iPage = strokeMapper.getStrokePageList(page, strokePageParam, jwtToken.getUserId()); IPage<StrokeQueryVo> iPage = strokeMapper.getStrokePageList(page, strokePageParam, jwtToken.getUserId());
return new Paging<StrokeQueryVo>(iPage); return new Paging<StrokeQueryVo>(iPage);
......
...@@ -22,6 +22,7 @@ import io.geekidea.springbootplus.framework.common.api.ApiCode; ...@@ -22,6 +22,7 @@ import io.geekidea.springbootplus.framework.common.api.ApiCode;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.shiro.cache.SysLoginRedisService; import io.geekidea.springbootplus.framework.shiro.cache.SysLoginRedisService;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken; import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.geekidea.springbootplus.framework.shiro.jwt.realm.LoginClientTypeEnum;
import io.geekidea.springbootplus.framework.shiro.util.JwtTokenUtil; import io.geekidea.springbootplus.framework.shiro.util.JwtTokenUtil;
import io.geekidea.springbootplus.framework.shiro.util.JwtUtil; import io.geekidea.springbootplus.framework.shiro.util.JwtUtil;
import io.geekidea.springbootplus.framework.shiro.util.SaltUtil; import io.geekidea.springbootplus.framework.shiro.util.SaltUtil;
...@@ -161,7 +162,7 @@ public class SysLoginServiceImpl implements SysLoginService { ...@@ -161,7 +162,7 @@ public class SysLoginServiceImpl implements SysLoginService {
log.debug("token:{}", token); log.debug("token:{}", token);
// 创建AuthenticationToken // 创建AuthenticationToken
JwtToken jwtToken = JwtToken.build(token, username,sysUser.getId(), newSalt, expireSecond, "sys"); JwtToken jwtToken = JwtToken.build(token, username,sysUser.getId(), newSalt, expireSecond, LoginClientTypeEnum.SYSTEM.getType());
boolean enableShiro = springBootPlusProperties.getShiro().isEnable(); boolean enableShiro = springBootPlusProperties.getShiro().isEnable();
if (enableShiro) { if (enableShiro) {
......
...@@ -6,26 +6,60 @@ import lombok.Data; ...@@ -6,26 +6,60 @@ import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <pre> * <pre>
* 商家 查询结果对象 * 航空公司商家表 查询结果对象
* </pre> * </pre>
* *
* @author wei * @author giao
* @date 2020-09-28 * @date 2020-10-13
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel(value = "MerchantUserQueryForAppVo对象") @ApiModel(value = "MerchantQueryVo对象")
public class MerchantUserQueryForAppVo implements Serializable { public class MerchantQueryVo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty("主键") @ApiModelProperty("主键")
private Long id; private Long id;
@ApiModelProperty("航空公司名称") @ApiModelProperty("商家名称")
private String airlineName; private String name;
@ApiModelProperty("联系人手机号码")
private String phone;
@ApiModelProperty("联系人手机区号")
private String phoneArea;
@ApiModelProperty("公司头像")
private String head;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("状态,0:禁用,1:启用,2:锁定")
private Integer state;
@ApiModelProperty("逻辑删除,0:未删除,1:已删除")
private Integer deleted;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("修改时间")
private Date updateTime;
@ApiModelProperty("商家开户银行")
private String rechargeBank;
@ApiModelProperty("商家开户名称")
private String rechargeName;
@ApiModelProperty("商家银行卡号")
private String rechargeBankNumber;
@ApiModelProperty("在列表展示的图片url") @ApiModelProperty("在列表展示的图片url")
private String imageListUrl; private String imageListUrl;
...@@ -47,4 +81,7 @@ public class MerchantUserQueryForAppVo implements Serializable { ...@@ -47,4 +81,7 @@ public class MerchantUserQueryForAppVo implements Serializable {
@ApiModelProperty("优势介绍文字") @ApiModelProperty("优势介绍文字")
private String textAdvantage; private String textAdvantage;
@ApiModelProperty("航空公司名称")
private String airlineName;
} }
\ No newline at end of file
...@@ -76,25 +76,4 @@ public class MerchantUserQueryVo implements Serializable { ...@@ -76,25 +76,4 @@ public class MerchantUserQueryVo implements Serializable {
@ApiModelProperty("修改时间") @ApiModelProperty("修改时间")
private Timestamp updateTime; private Timestamp updateTime;
@ApiModelProperty("在列表展示的图片url")
private String imageListUrl;
@ApiModelProperty("公司介绍图片url")
private String imageCompanyIntroductionUrl;
@ApiModelProperty("团队介绍图片url")
private String imageTeamIntroductionUrl;
@ApiModelProperty("优势图片url")
private String imageAdvantageUrl;
@ApiModelProperty("公司介绍文字")
private String textCompanyIntroduction;
@ApiModelProperty("团队介绍文字")
private String textTeamIntroduction;
@ApiModelProperty("优势介绍文字")
private String textAdvantage;
} }
\ No newline at end of file
...@@ -46,7 +46,7 @@ public class StrokeQueryVo implements Serializable { ...@@ -46,7 +46,7 @@ public class StrokeQueryVo implements Serializable {
@ApiModelProperty("行程类型,0-单程,1-往返行程,2-货运,3-医疗") @ApiModelProperty("行程类型,0-单程,1-往返行程,2-货运,3-医疗")
private Integer type; private Integer type;
@ApiModelProperty("状态,0-审核中,1-进行中,2-已完成,99-取消") @ApiModelProperty("付款状态,0-未付款,1-用户已付款,待审核,2-用户已付款,审核通过,3-退款中,99-已退款")
private Integer status; private Integer status;
@ApiModelProperty("价格") @ApiModelProperty("价格")
......
<?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.jumeirah.common.mapper.MerchantMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, name, phone, phone_area, head, remark, state, deleted, create_time, update_time, recharge_bank, recharge_name, recharge_bank_number, image_list_url, image_company_introduction_url, image_team_introduction_url, image_advantage_url, text_company_introduction, text_team_introduction, text_advantage, airline_name
</sql>
<select id="getMerchantById" resultType="com.jumeirah.common.vo.MerchantQueryVo">
select
<include refid="Base_Column_List"/>
from merchant where id = #{id}
</select>
<select id="getMerchantPageList" parameterType="com.jumeirah.common.param.MerchantPageParam"
resultType="com.jumeirah.common.vo.MerchantQueryVo">
select
<include refid="Base_Column_List"/>
from merchant
</select>
</mapper>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
user_id, user_id,
mu.username AS merchantName, mu.username AS merchantName,
outset_airport_name,arrive_airport_name,arrive_plain_type_id,back_outset_airport_name,back_arrive_airport_name, outset_airport_name,arrive_airport_name,arrive_plain_type_id,back_outset_airport_name,back_arrive_airport_name,
payment_status,audit_status,recharge_bank,recharge_name,recharge_bank_number payment_status,audit_status,user_recharge_bank,user_recharge_name,user_recharge_bank_number
</sql> </sql>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, city_outset_id, deleted, city_outset_name, city_arrive_id, city_arrive_name, people_mun, plain_type_id, outset_time, return_time, type, status, create_time, update_time, goods_name, goods_size, goods_weight, disease_name, instruments, medical_persons, remarks, money, user_id id, city_outset_id, deleted, city_outset_name, city_arrive_id, city_arrive_name, people_mun, plain_type_id, outset_time, return_time, type, status, create_time, update_time, goods_name, goods_size, goods_weight, disease_name, instruments, medical_persons, remarks, money, user_id
,outset_airport_name,arrive_airport_name,arrive_plain_type_id,back_outset_airport_name,back_arrive_airport_name,payment_status,audit_status, user_recharge_money,user_recharge_bank,user_recharge_name, ,outset_airport_name,arrive_airport_name,arrive_plain_type_id,back_outset_airport_name,back_arrive_airport_name,payment_status,audit_status, user_recharge_money,user_recharge_bank,user_recharge_name,
user_recharge_bank_number,user_recharge_credentials_url,recharge_bank,recharge_name,recharge_bank_number user_recharge_bank_number,user_recharge_credentials_url
</sql> </sql>
<select id="getStrokeById" resultType="com.jumeirah.common.vo.StrokeDetailVo"> <select id="getStrokeById" resultType="com.jumeirah.common.vo.StrokeDetailVo">
...@@ -52,6 +52,23 @@ ...@@ -52,6 +52,23 @@
and s.`status` = #{param.status} and s.`status` = #{param.status}
</if> </if>
</where> </where>
</select>
<!-- 已完成订单-->
<select id="getStrokePageListWithFinsh" parameterType="com.jumeirah.common.param.StrokePageParam"
resultType="com.jumeirah.common.vo.StrokeQueryVo">
select
<include refid="Page_Column_List"/>
from stroke s
INNER JOIN merchant_user mu ON mu.id = s.mc_id
<where>
and s.user_id = #{userId}
and s.deleted = 0
and s.`status` = #{param.status}
or s.`status` = 99
</where>
</select> </select>
<select id="getMcStrokePageList" parameterType="com.jumeirah.common.param.McStrokePageParam" <select id="getMcStrokePageList" parameterType="com.jumeirah.common.param.McStrokePageParam"
resultType="com.jumeirah.common.vo.McStrokeQueryVo"> resultType="com.jumeirah.common.vo.McStrokeQueryVo">
...@@ -79,7 +96,7 @@ ...@@ -79,7 +96,7 @@
AND CONCAT( au.surname, au.`name` ) LIKE CONCAT('%',#{mcStrokePageParam.applicant},'%') AND CONCAT( au.surname, au.`name` ) LIKE CONCAT('%',#{mcStrokePageParam.applicant},'%')
</if> </if>
</where> </where>
ORDER BY ORDER BY s.create_time DESC
</select> </select>
</mapper> </mapper>
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, username, nickname, password, salt, phone, phone_area, gender, head, remark, state, department_id, role_id, deleted, version, create_time, update_time, recharge_bank, recharge_name, recharge_bank_number, image_list_url, image_company_introduction_url, image_team_introduction_url, image_advantage_url, text_company_introduction, text_team_introduction, text_advantage,airline_name id, username, nickname, password, salt, phone, phone_area, gender, head, remark, state, department_id, role_id, deleted, version, create_time, update_time
</sql> </sql>
<select id="getMerchantUserById" resultType="com.jumeirah.common.vo.MerchantUserQueryVo"> <select id="getMerchantUserById" resultType="com.jumeirah.common.vo.MerchantUserQueryVo">
...@@ -20,12 +20,6 @@ ...@@ -20,12 +20,6 @@
from merchant_user from merchant_user
</select> </select>
<select id="getMerchantUserForAppPageList" parameterType="com.jumeirah.common.param.MerchantUserPageParam"
resultType="com.jumeirah.common.vo.MerchantUserQueryForAppVo">
select
<include refid="Base_Column_List"/>
from merchant_user
</select>
......
...@@ -44,7 +44,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -44,7 +44,7 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/sysLoginLog") @RequestMapping("/sys/sysLoginLog")
@Module("log") @Module("log")
@Api(value = "系统登录日志API", tags = {"系统登录日志"}) @Api(value = "系统登录日志API", tags = {"系统登录日志"})
public class SysLoginLogController extends BaseController { public class SysLoginLogController extends BaseController {
......
...@@ -41,7 +41,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -41,7 +41,7 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/sysOperationLog") @RequestMapping("/sys/sysOperationLog")
@Api(value = "系统操作日志API", tags = {"系统操作日志"}) @Api(value = "系统操作日志API", tags = {"系统操作日志"})
public class SysOperationLogController extends BaseController { public class SysOperationLogController extends BaseController {
......
...@@ -16,25 +16,21 @@ ...@@ -16,25 +16,21 @@
package io.geekidea.springbootplus.framework.shiro.jwt; package io.geekidea.springbootplus.framework.shiro.jwt;
import io.geekidea.springbootplus.config.constant.CommonRedisKey;
import io.geekidea.springbootplus.config.properties.JwtProperties; import io.geekidea.springbootplus.config.properties.JwtProperties;
import io.geekidea.springbootplus.framework.common.api.ApiCode; import io.geekidea.springbootplus.framework.common.api.ApiCode;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.shiro.cache.SysLoginRedisService;
import io.geekidea.springbootplus.framework.shiro.service.ShiroLoginService; import io.geekidea.springbootplus.framework.shiro.service.ShiroLoginService;
import io.geekidea.springbootplus.framework.shiro.util.JwtTokenUtil; import io.geekidea.springbootplus.framework.shiro.util.JwtTokenUtil;
import io.geekidea.springbootplus.framework.shiro.util.JwtUtil; import io.geekidea.springbootplus.framework.shiro.util.JwtUtil;
import io.geekidea.springbootplus.framework.shiro.vo.JwtTokenRedisVo; import io.geekidea.springbootplus.framework.shiro.vo.JwtTokenRedisVo;
import io.geekidea.springbootplus.framework.util.HttpServletResponseUtil; import io.geekidea.springbootplus.framework.util.HttpServletResponseUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.subject.Subject; import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.filter.authc.AuthenticatingFilter; import org.apache.shiro.web.filter.authc.AuthenticatingFilter;
import org.apache.shiro.web.util.WebUtils; import org.apache.shiro.web.util.WebUtils;
import org.springframework.data.redis.core.RedisTemplate;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
...@@ -52,15 +48,12 @@ import javax.servlet.http.HttpServletResponse; ...@@ -52,15 +48,12 @@ import javax.servlet.http.HttpServletResponse;
public class JwtFilter extends AuthenticatingFilter { public class JwtFilter extends AuthenticatingFilter {
private final ShiroLoginService shiroLoginService; private final ShiroLoginService shiroLoginService;
private final SysLoginRedisService sysLoginRedisService;
private final JwtProperties jwtProperties; private final JwtProperties jwtProperties;
private RedisTemplate redisTemplate;
public JwtFilter(ShiroLoginService shiroLoginService, SysLoginRedisService loginRedisService, JwtProperties jwtProperties, RedisTemplate redisTemplate) {
public JwtFilter(ShiroLoginService shiroLoginService, JwtProperties jwtProperties) {
this.shiroLoginService = shiroLoginService; this.shiroLoginService = shiroLoginService;
this.sysLoginRedisService = loginRedisService;
this.jwtProperties = jwtProperties; this.jwtProperties = jwtProperties;
this.redisTemplate = redisTemplate;
} }
/** /**
...@@ -83,36 +76,14 @@ public class JwtFilter extends AuthenticatingFilter { ...@@ -83,36 +76,14 @@ public class JwtFilter extends AuthenticatingFilter {
throw new AuthenticationException("JWT Token已过期,token:" + token); throw new AuthenticationException("JWT Token已过期,token:" + token);
} }
Object jwtTokenRedisVo = null; JwtTokenRedisVo jwt = shiroLoginService.getTokenInfoForRedis(token);
// 如果开启redis二次校验,或者设置为单个用户token登录,则先在redis中判断token是否存在
if (jwtProperties.isRedisCheck() || jwtProperties.isSingleLogin()) {
String tokenMd5 = DigestUtils.md5Hex(token);
jwtTokenRedisVo = redisTemplate.opsForValue().get(String.format(CommonRedisKey.LOGIN_TOKEN, tokenMd5));
// boolean redisExpired = sysLoginRedisService.exists(token);
if (jwtTokenRedisVo == null) {
throw new AuthenticationException("Redis Token不存在,token:" + token);
}
}
JwtTokenRedisVo jwt = (JwtTokenRedisVo) jwtTokenRedisVo;
if (jwt == null) {
throw new AuthenticationException("Redis Token不存在,token:" + token);
}
String username = JwtUtil.getUsername(token); String username = JwtUtil.getUsername(token);
String salt; return JwtToken.build(token, username, jwt.getUserId(), shiroLoginService.getSalt(token), jwtProperties.getExpireSecond(), jwt.getType());
if (jwtProperties.isSaltCheck()) {
salt = sysLoginRedisService.getSalt(username);
} else {
salt = jwtProperties.getSecret();
}
return JwtToken.build(token, username, jwt.getUserId(), salt, jwtProperties.getExpireSecond(), jwt.getType());
} }
/** /**
* 访问失败处理 * 访问失败处理
* *
......
...@@ -63,7 +63,7 @@ public class JwtRealmAppUser extends AuthorizingRealm { ...@@ -63,7 +63,7 @@ public class JwtRealmAppUser extends AuthorizingRealm {
// 设置角色/权限信息 // 设置角色/权限信息
JwtToken jwtToken = (JwtToken) principalCollection.getPrimaryPrincipal(); JwtToken jwtToken = (JwtToken) principalCollection.getPrimaryPrincipal();
if (!jwtToken.getType().equals("app")) { if (!jwtToken.getType().equals(LoginClientTypeEnum.APP.getType())) {
return null; return null;
} }
/* /*
......
...@@ -66,7 +66,7 @@ public class JwtRealmMerchant extends AuthorizingRealm { ...@@ -66,7 +66,7 @@ public class JwtRealmMerchant extends AuthorizingRealm {
// 设置角色/权限信息 // 设置角色/权限信息
JwtToken jwtToken = (JwtToken) principalCollection.getPrimaryPrincipal(); JwtToken jwtToken = (JwtToken) principalCollection.getPrimaryPrincipal();
if (!jwtToken.getType().equals("mer")) { if (!jwtToken.getType().equals(LoginClientTypeEnum.MERCHANT.getType())) {
return null; return null;
} }
......
...@@ -63,7 +63,7 @@ public class JwtRealmSystem extends AuthorizingRealm { ...@@ -63,7 +63,7 @@ public class JwtRealmSystem extends AuthorizingRealm {
// 设置角色/权限信息 // 设置角色/权限信息
JwtToken jwtToken = (JwtToken) principalCollection.getPrimaryPrincipal(); JwtToken jwtToken = (JwtToken) principalCollection.getPrimaryPrincipal();
if (!jwtToken.getType().equals("sys")) { if (!jwtToken.getType().equals(LoginClientTypeEnum.SYSTEM.getType())) {
return null; return null;
} }
// 获取username // 获取username
......
package io.geekidea.springbootplus.framework.shiro.jwt.realm;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 客户端类型
*/
@Getter
@AllArgsConstructor
public enum LoginClientTypeEnum {
// app
APP("app"),
// 平台
SYSTEM("sys"),
// 商户
MERCHANT("mer");
private final String type;
}
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package io.geekidea.springbootplus.framework.shiro.service; package io.geekidea.springbootplus.framework.shiro.service;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken; import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.geekidea.springbootplus.framework.shiro.vo.JwtTokenRedisVo;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -39,4 +40,20 @@ public interface ShiroLoginService { ...@@ -39,4 +40,20 @@ public interface ShiroLoginService {
*/ */
void refreshToken(JwtToken jwtToken, HttpServletResponse httpServletResponse) throws Exception; void refreshToken(JwtToken jwtToken, HttpServletResponse httpServletResponse) throws Exception;
/**
* 从redis获取token信息
*
* @param token
* @return
*/
JwtTokenRedisVo getTokenInfoForRedis(String token);
/**
* 获取盐
* @param token
* @return
*/
String getSalt(String token);
} }
...@@ -17,14 +17,16 @@ ...@@ -17,14 +17,16 @@
package io.geekidea.springbootplus.framework.shiro.service.impl; package io.geekidea.springbootplus.framework.shiro.service.impl;
import io.geekidea.springbootplus.config.constant.CommonConstant; import io.geekidea.springbootplus.config.constant.CommonConstant;
import io.geekidea.springbootplus.config.constant.CommonRedisKey;
import io.geekidea.springbootplus.config.properties.JwtProperties; import io.geekidea.springbootplus.config.properties.JwtProperties;
import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
import io.geekidea.springbootplus.framework.shiro.cache.SysLoginRedisService; import io.geekidea.springbootplus.framework.shiro.cache.SysLoginRedisService;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken; import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.geekidea.springbootplus.framework.shiro.service.ShiroLoginService; import io.geekidea.springbootplus.framework.shiro.service.ShiroLoginService;
import io.geekidea.springbootplus.framework.shiro.util.JwtTokenUtil; import io.geekidea.springbootplus.framework.shiro.util.JwtTokenUtil;
import io.geekidea.springbootplus.framework.shiro.util.JwtUtil; import io.geekidea.springbootplus.framework.shiro.util.JwtUtil;
import io.geekidea.springbootplus.framework.shiro.vo.JwtTokenRedisVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
...@@ -47,7 +49,6 @@ import java.util.Date; ...@@ -47,7 +49,6 @@ import java.util.Date;
@Service @Service
public class ShiroLoginServiceImpl implements ShiroLoginService { public class ShiroLoginServiceImpl implements ShiroLoginService {
@Lazy @Lazy
@Autowired @Autowired
private SysLoginRedisService sysLoginRedisService; private SysLoginRedisService sysLoginRedisService;
...@@ -58,10 +59,6 @@ public class ShiroLoginServiceImpl implements ShiroLoginService { ...@@ -58,10 +59,6 @@ public class ShiroLoginServiceImpl implements ShiroLoginService {
@Lazy @Lazy
@Autowired @Autowired
private SpringBootPlusProperties springBootPlusProperties;
@Lazy
@Autowired
private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
...@@ -103,7 +100,7 @@ public class ShiroLoginServiceImpl implements ShiroLoginService { ...@@ -103,7 +100,7 @@ public class ShiroLoginServiceImpl implements ShiroLoginService {
// 生成新token字符串 // 生成新token字符串
String newToken = JwtUtil.generateToken(username, salt, Duration.ofSeconds(expireSecond)); String newToken = JwtUtil.generateToken(username, salt, Duration.ofSeconds(expireSecond));
// 生成新JwtToken对象 // 生成新JwtToken对象
JwtToken newJwtToken = JwtToken.build(newToken, username,jwtToken.getUserId(), salt, expireSecond, jwtToken.getType()); JwtToken newJwtToken = JwtToken.build(newToken, username, jwtToken.getUserId(), salt, expireSecond, jwtToken.getType());
// 更新redis缓存 // 更新redis缓存
sysLoginRedisService.refreshLoginInfo(token, username, newJwtToken); sysLoginRedisService.refreshLoginInfo(token, username, newJwtToken);
log.debug("刷新token成功,原token:{},新token:{}", token, newToken); log.debug("刷新token成功,原token:{},新token:{}", token, newToken);
...@@ -112,4 +109,30 @@ public class ShiroLoginServiceImpl implements ShiroLoginService { ...@@ -112,4 +109,30 @@ public class ShiroLoginServiceImpl implements ShiroLoginService {
httpServletResponse.setStatus(CommonConstant.JWT_REFRESH_TOKEN_CODE); httpServletResponse.setStatus(CommonConstant.JWT_REFRESH_TOKEN_CODE);
httpServletResponse.setHeader(JwtTokenUtil.getTokenName(), newToken); httpServletResponse.setHeader(JwtTokenUtil.getTokenName(), newToken);
} }
@Override
public JwtTokenRedisVo getTokenInfoForRedis(String token) {
Object jwtTokenRedisVo = null;
// 如果开启redis二次校验,或者设置为单个用户token登录,则先在redis中判断token是否存在
if (jwtProperties.isRedisCheck() || jwtProperties.isSingleLogin()) {
String tokenMd5 = DigestUtils.md5Hex(token);
jwtTokenRedisVo = redisTemplate.opsForValue().get(String.format(CommonRedisKey.LOGIN_TOKEN, tokenMd5));
// boolean redisExpired = sysLoginRedisService.exists(token); // 判断是否存在
if (jwtTokenRedisVo == null) {
throw new AuthenticationException("Redis Token不存在,token:" + token);
}
}
return (JwtTokenRedisVo) jwtTokenRedisVo;
}
@Override
public String getSalt(String token) {
String username = JwtUtil.getUsername(token);
if (jwtProperties.isSaltCheck()) {
return sysLoginRedisService.getSalt(username);
} else {
return jwtProperties.getSecret();
}
}
} }
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