Commit 5a15f8b2 by lpx

Merge branch 'master' of http://119.28.51.83/hewei/Jumeirah into dev/lanpingxiong

parents 0cc1c4bc a1573ab5
...@@ -2,9 +2,11 @@ package com.jumeirah.api.merchant.controller; ...@@ -2,9 +2,11 @@ package com.jumeirah.api.merchant.controller;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog; import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles; import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -19,13 +21,15 @@ import java.io.IOException; ...@@ -19,13 +21,15 @@ import java.io.IOException;
@Slf4j @Slf4j
@Api(value = "Hello World2", tags = {"商户Hello World2"}) @Api(value = "Hello World2", tags = {"商户Hello World2"})
@RestController @RestController
@RequestMapping("/merchant/") @RequestMapping("/merchant/hello")
public class MerchantHelloWorldController { public class MerchantHelloWorldController {
@GetMapping(value = "/world") @GetMapping(value = "/world")
@OperationLog(name = "helloWorld") @OperationLog(name = "helloWorld")
@ApiOperation(value = "Hello World", response = String.class) @ApiOperation(value = "Hello World", response = String.class)
public ApiResult<String> helloWorld() throws IOException { public ApiResult<String> helloWorld() throws IOException {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
log.debug("Hello World...app"); log.debug("Hello World...app");
return ApiResult.ok("Hello World app merchant"); return ApiResult.ok("Hello World app merchant");
} }
...@@ -34,6 +38,8 @@ public class MerchantHelloWorldController { ...@@ -34,6 +38,8 @@ public class MerchantHelloWorldController {
@OperationLog(name = "needRole") @OperationLog(name = "needRole")
@ApiOperation(value = "needRole", response = String.class) @ApiOperation(value = "needRole", response = String.class)
public ApiResult<String> needRole() throws IOException { public ApiResult<String> needRole() throws IOException {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
log.debug("Hello World...app"); log.debug("Hello World...app");
return ApiResult.ok("Hello World app"); return ApiResult.ok("Hello World app");
} }
...@@ -41,8 +47,10 @@ public class MerchantHelloWorldController { ...@@ -41,8 +47,10 @@ public class MerchantHelloWorldController {
@GetMapping(value = "/needRoleAdmin") @GetMapping(value = "/needRoleAdmin")
@OperationLog(name = "needRoleAdmin") @OperationLog(name = "needRoleAdmin")
@ApiOperation(value = "needRoleAdmin", response = String.class) @ApiOperation(value = "needRoleAdmin", response = String.class)
@RequiresPermissions("mer:admin") @RequiresPermissions("merchant:admin")
public ApiResult<String> needRoleAdmin() throws IOException { public ApiResult<String> needRoleAdmin() throws IOException {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
log.debug("Hello World...app"); log.debug("Hello World...app");
return ApiResult.ok("Hello World needRoleAdmin"); return ApiResult.ok("Hello World needRoleAdmin");
} }
...@@ -50,8 +58,10 @@ public class MerchantHelloWorldController { ...@@ -50,8 +58,10 @@ public class MerchantHelloWorldController {
@GetMapping(value = "/needRoleAll") @GetMapping(value = "/needRoleAll")
@OperationLog(name = "needRoleAll") @OperationLog(name = "needRoleAll")
@ApiOperation(value = "needRoleAll", response = String.class) @ApiOperation(value = "needRoleAll", response = String.class)
@RequiresRoles("app:all") @RequiresRoles("merchant:all")
public ApiResult<String> needRoleAll() throws IOException { public ApiResult<String> needRoleAll() throws IOException {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
log.debug("Hello World...app"); log.debug("Hello World...app");
return ApiResult.ok("Hello World needRoleAll"); return ApiResult.ok("Hello World needRoleAll");
} }
...@@ -60,6 +70,8 @@ public class MerchantHelloWorldController { ...@@ -60,6 +70,8 @@ public class MerchantHelloWorldController {
@OperationLog(name = "noRole") @OperationLog(name = "noRole")
@ApiOperation(value = "noRole", response = String.class) @ApiOperation(value = "noRole", response = String.class)
public ApiResult<String> noRole() throws IOException { public ApiResult<String> noRole() throws IOException {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
log.debug("Hello World...app"); log.debug("Hello World...app");
return ApiResult.ok("Hello World app noRole"); return ApiResult.ok("Hello World app noRole");
} }
......
...@@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/merchantPermission") @RequestMapping("/merchant/permission")
@Module("${cfg.module}") @Module("${cfg.module}")
@Api(value = "商家权限API", tags = {"商家权限"}) @Api(value = "商家权限API", tags = {"商家权限"})
public class MerchantPermissionController extends BaseController { public class MerchantPermissionController extends BaseController {
......
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jumeirah.api.merchant.controller;
import com.jumeirah.common.param.RegisterParam;
import com.jumeirah.common.service.SysRegisterService;
import com.jumeirah.common.vo.LoginSysUserTokenVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLogIgnore;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
/**
* 注册控制器
*
* @author geekidea
* @date 2019-09-28
* @since 1.3.0.RELEASE
**/
@Slf4j
@RestController
@Module("system")
@Api(value = "商户注册API", tags = {"商户注册"})
@RequestMapping("/merchant/")
public class MerchantRegisterController {
@Autowired
private SysRegisterService registerService;
@PostMapping("/register")
@OperationLogIgnore
@ApiOperation(value = "注册", notes = "商户注册", response = LoginSysUserTokenVo.class)
public ApiResult<LoginSysUserTokenVo> register(@Validated @RequestBody RegisterParam registerParam, HttpServletResponse response, @RequestHeader(required = false) String language) throws Exception {
return registerService.register(registerParam, response, language);
}
}
...@@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/merchantRole") @RequestMapping("/merchant/role")
@Module("${cfg.module}") @Module("${cfg.module}")
@Api(value = "商家角色API", tags = {"商家角色"}) @Api(value = "商家角色API", tags = {"商家角色"})
public class MerchantRoleController extends BaseController { public class MerchantRoleController extends BaseController {
......
...@@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/merchantRolePermission") @RequestMapping("/merchant/rolePermission")
@Module("${cfg.module}") @Module("${cfg.module}")
@Api(value = "商家角色权限关系API", tags = {"商家角色权限关系"}) @Api(value = "商家角色权限关系API", tags = {"商家角色权限关系"})
public class MerchantRolePermissionController extends BaseController { public class MerchantRolePermissionController extends BaseController {
......
package com.jumeirah.api.merchant.controller; package com.jumeirah.api.merchant.controller;
import com.jumeirah.api.merchant.service.MerchantSmsService; import com.jumeirah.common.service.impl.MerchantSmsService;
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.log.annotation.OperationLog; import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
...@@ -23,8 +23,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -23,8 +23,8 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j @Slf4j
@RestController @RestController
//@Module("api-app") //@Module("api-app")
@Api(value = "短信验证码", tags = {"APP短信验证码相关"}) @Api(value = "短信验证码", tags = {"APP短信验证码相关"},hidden = true)
@RequestMapping("/app/sms/") @RequestMapping("/merchant/sms/")
public class MerchantSmsController extends BaseController { public class MerchantSmsController extends BaseController {
@Autowired @Autowired
......
package com.jumeirah.api.merchant.controller; package com.jumeirah.api.merchant.controller;
import com.jumeirah.common.entity.MerchantUser; import com.jumeirah.common.entity.MerchantUser;
import com.jumeirah.common.param.LoginParam; import com.jumeirah.common.param.MerchantLoginParam;
import com.jumeirah.common.param.MerchantUserPageParam; import com.jumeirah.common.param.MerchantUserPageParam;
import com.jumeirah.common.service.MerchantService;
import com.jumeirah.common.service.MerchantUserService; import com.jumeirah.common.service.MerchantUserService;
import com.jumeirah.common.vo.LoginSysUserTokenVo; import com.jumeirah.common.vo.LoginMerUserTokenVo;
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.controller.BaseController; import io.geekidea.springbootplus.framework.common.controller.BaseController;
...@@ -24,78 +25,79 @@ import org.springframework.web.bind.annotation.GetMapping; ...@@ -24,78 +25,79 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
/** /**
* 商家 控制器 * 商家用户 控制器
* *
* @author wei * @author wei
* @since 2020-09-27 * @since 2020-09-27
*/ */
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/merchantUser") @RequestMapping("/merchant/user")
@Module("${cfg.module}") @Module("${cfg.module}")
@Api(value = "商家API", tags = {"商家"}) @Api(value = "商家用户API", tags = {"商家用户表"})
public class MerchantUserController extends BaseController { public class MerchantUserController extends BaseController {
@Autowired @Autowired
private MerchantUserService merchantUserService; private MerchantUserService merchantUserService;
@Autowired
private MerchantService merchantService;
/** /**
* 添加商家 * 添加商家用户
*/ */
@PostMapping("/add") @PostMapping("/add")
@OperationLog(name = "添加商家", type = OperationLogType.ADD) @OperationLog(name = "添加商家用户", type = OperationLogType.ADD)
@ApiOperation(value = "添加商家", response = ApiResult.class) @ApiOperation(value = "添加商家用户", response = ApiResult.class)
public ApiResult<Boolean> addMerchantUser(@Validated(Add.class) @RequestBody MerchantUser merchantUser) throws Exception { public ApiResult<Boolean> addMerchantUser(@Validated(Add.class) @RequestBody MerchantUser merchantUser) throws Exception {
boolean flag = merchantUserService.saveMerchantUser(merchantUser); boolean flag = merchantUserService.saveMerchantUser(merchantUser);
return ApiResult.result(flag); return ApiResult.result(flag);
} }
/** /**
* 修改商家 * 修改商家用户
*/ */
@PostMapping("/update") @PostMapping("/update")
@OperationLog(name = "修改商家", type = OperationLogType.UPDATE) @OperationLog(name = "修改商家用户", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改商家", response = ApiResult.class) @ApiOperation(value = "修改商家用户", response = ApiResult.class)
public ApiResult<Boolean> updateMerchantUser(@Validated(Update.class) @RequestBody MerchantUser merchantUser) throws Exception { public ApiResult<Boolean> updateMerchantUser(@Validated(Update.class) @RequestBody MerchantUser merchantUser) throws Exception {
boolean flag = merchantUserService.updateMerchantUser(merchantUser); boolean flag = merchantUserService.updateMerchantUser(merchantUser);
return ApiResult.result(flag); return ApiResult.result(flag);
} }
/** /**
* 删除商家 * 删除商家用户
*/ */
@PostMapping("/delete/{id}") @PostMapping("/delete/{id}")
@OperationLog(name = "删除商家", type = OperationLogType.DELETE) @OperationLog(name = "删除商家用户", type = OperationLogType.DELETE)
@ApiOperation(value = "删除商家", response = ApiResult.class) @ApiOperation(value = "删除商家用户", response = ApiResult.class)
public ApiResult<Boolean> deleteMerchantUser(@PathVariable("id") Long id) throws Exception { public ApiResult<Boolean> deleteMerchantUser(@PathVariable("id") Long id) throws Exception {
boolean flag = merchantUserService.deleteMerchantUser(id); boolean flag = merchantUserService.deleteMerchantUser(id);
return ApiResult.result(flag); return ApiResult.result(flag);
} }
/** /**
* 获取商家详情 * 获取商家用户详情
*/ */
@GetMapping("/info/{id}") @GetMapping("/info/{id}")
@OperationLog(name = "商家详情", type = OperationLogType.INFO) @OperationLog(name = "商家用户详情", type = OperationLogType.INFO)
@ApiOperation(value = "商家详情", response = MerchantUserQueryVo.class) @ApiOperation(value = "商家用户详情", response = MerchantUserQueryVo.class)
public ApiResult<MerchantUserQueryVo> getMerchantUser(@PathVariable("id") Long id) throws Exception { public ApiResult<MerchantUserQueryVo> getMerchantUser(@PathVariable("id") Long id) throws Exception {
MerchantUserQueryVo merchantUserQueryVo = merchantUserService.getMerchantUserById(id); MerchantUserQueryVo merchantUserQueryVo = merchantUserService.getMerchantUserById(id);
return ApiResult.ok(merchantUserQueryVo); return ApiResult.ok(merchantUserQueryVo);
} }
/** /**
* 商家分页列表 * 商家用户分页列表
*/ */
@PostMapping("/getPageList") @PostMapping("/getPageList")
@OperationLog(name = "商家分页列表", type = OperationLogType.PAGE) @OperationLog(name = "商家用户分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "商家分页列表", response = MerchantUserQueryVo.class) @ApiOperation(value = "商家用户分页列表", response = MerchantUserQueryVo.class)
public ApiResult<Paging<MerchantUserQueryVo>> getMerchantUserPageList(@Validated @RequestBody MerchantUserPageParam merchantUserPageParam) throws Exception { public ApiResult<Paging<MerchantUserQueryVo>> getMerchantUserPageList(@Validated @RequestBody MerchantUserPageParam merchantUserPageParam) throws Exception {
Paging<MerchantUserQueryVo> paging = merchantUserService.getMerchantUserPageList(merchantUserPageParam); Paging<MerchantUserQueryVo> paging = merchantUserService.getMerchantUserPageList(merchantUserPageParam);
return ApiResult.ok(paging); return ApiResult.ok(paging);
...@@ -103,17 +105,16 @@ public class MerchantUserController extends BaseController { ...@@ -103,17 +105,16 @@ public class MerchantUserController extends BaseController {
@PostMapping("/login") @PostMapping("/login")
@OperationLogIgnore @OperationLogIgnore
@ApiOperation(value = "登录", notes = "商家登录", response = LoginSysUserTokenVo.class) @ApiOperation(value = "登录", notes = "商家用户登录")
public ApiResult<LoginSysUserTokenVo> login(@Validated @RequestBody LoginParam loginParam, HttpServletResponse response, @RequestHeader(required = false) String language) throws Exception { public ApiResult<LoginMerUserTokenVo> login(@Validated @RequestBody MerchantLoginParam merchantLoginParam, HttpServletResponse response) throws Exception {
return merchantUserService.login(loginParam, response, language); return merchantUserService.login(merchantLoginParam);
} }
// @PostMapping("/register")
@PostMapping("/register") // @OperationLogIgnore
@OperationLogIgnore // @ApiOperation(value = "注册", notes = "商家注册")
@ApiOperation(value = "注册", notes = "商家注册", response = LoginSysUserTokenVo.class) // public ApiResult<Boolean> register(@Validated @RequestBody MerchantRegisterParam merchantRegisterParam, HttpServletResponse response) throws Exception {
public ApiResult<LoginSysUserTokenVo> register(@Validated @RequestBody LoginParam loginParam, HttpServletResponse response, @RequestHeader(required = false) String language) throws Exception { // return merchantUserService.register(merchantRegisterParam);
return merchantUserService.login(loginParam, response, language); // }
}
} }
...@@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/sys/merchant") @RequestMapping("/sys/merchant")
@Api(value = "航空公司商家表API", tags = {"航空公司商家表"}) @Api(value = "航空公司商家表API", tags = {"航空公司商家表"})
public class MerchantController extends BaseController { public class MerchantForSysController extends BaseController {
@Autowired @Autowired
private MerchantService merchantService; private MerchantService merchantService;
......
...@@ -29,9 +29,9 @@ import org.mapstruct.factory.Mappers; ...@@ -29,9 +29,9 @@ import org.mapstruct.factory.Mappers;
* @date 2019-10-05 * @date 2019-10-05
**/ **/
@Mapper @Mapper
public interface SysUserConvert { public interface UserConvert {
SysUserConvert INSTANCE = Mappers.getMapper(SysUserConvert.class); UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);
/** /**
* 系统用户实体对象转换成登录用户VO对象 * 系统用户实体对象转换成登录用户VO对象
......
...@@ -18,7 +18,7 @@ import java.util.Date; ...@@ -18,7 +18,7 @@ import java.util.Date;
* 航空公司商家表 * 航空公司商家表
* *
* @author giao * @author giao
* @since 2020-10-13 * @since 2020-10-16
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
...@@ -72,6 +72,14 @@ public class Merchant extends BaseEntity { ...@@ -72,6 +72,14 @@ public class Merchant extends BaseEntity {
@ApiModelProperty("在列表展示的图片url") @ApiModelProperty("在列表展示的图片url")
private String imageListUrl; private String imageListUrl;
@NotNull(message = "在列表展示的图片高度不能为空")
@ApiModelProperty("在列表展示的图片高度")
private Long imageListHeight;
@NotNull(message = "在列表展示的图片宽度不能为空")
@ApiModelProperty("在列表展示的图片宽度")
private Long imageListWidth;
@ApiModelProperty("公司介绍图片url") @ApiModelProperty("公司介绍图片url")
private String imageCompanyIntroductionUrl; private String imageCompanyIntroductionUrl;
...@@ -93,9 +101,16 @@ public class Merchant extends BaseEntity { ...@@ -93,9 +101,16 @@ public class Merchant extends BaseEntity {
@ApiModelProperty("航空公司名称") @ApiModelProperty("航空公司名称")
private String airlineName; private String airlineName;
@ApiModelProperty("列表图片高") @ApiModelProperty("公司所在地址")
private Long imageListHeight; private String location;
@ApiModelProperty("列表图片宽")
private Long imageListWidth; @ApiModelProperty("邮箱")
private String email;
@ApiModelProperty("营业执照图片url")
private String imageBusinessLicenseUrl;
@ApiModelProperty("审核注册状态 0未审核,1审核成功")
private Integer auditRegisterStatus;
} }
...@@ -24,7 +24,7 @@ import java.util.Date; ...@@ -24,7 +24,7 @@ import java.util.Date;
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel(value = "MerchantUser对象") @ApiModel(value = "MerchantUser对象")
public class MerchantUser extends BaseEntity { public class MerchantUser extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -34,6 +34,13 @@ public class MerchantUser extends BaseEntity { ...@@ -34,6 +34,13 @@ public class MerchantUser extends BaseEntity {
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Long id; private Long id;
@NotNull(message = "商家id不能为空")
@ApiModelProperty("商家id")
private Long mcId;
@ApiModelProperty("是否为管理员,0:普通,1:超级管理员")
private Integer isAdmin;
@ApiModelProperty("用户名") @ApiModelProperty("用户名")
private String username; private String username;
......
...@@ -15,7 +15,7 @@ import java.io.Serializable; ...@@ -15,7 +15,7 @@ import java.io.Serializable;
* 航空公司商家表 Mapper 接口 * 航空公司商家表 Mapper 接口
* *
* @author giao * @author giao
* @since 2020-10-13 * @since 2020-10-16
*/ */
@Repository @Repository
public interface MerchantMapper extends BaseMapper<Merchant> { public interface MerchantMapper extends BaseMapper<Merchant> {
......
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jumeirah.common.param;
import io.geekidea.springbootplus.framework.shiro.service.LoginUsername;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 登录参数
*
* @author geekidea
* @date 2019-05-15
**/
@Data
@ApiModel("登录参数")
public class MerchantLoginParam implements LoginUsername {
private static final long serialVersionUID = 2854217576695117356L;
@NotBlank(message = "请输入账号")
@ApiModelProperty(value = "账号", example = "zhuomeiya")
private String username;
@NotBlank(message = "请输入密码")
@ApiModelProperty(value = "密码", example = "123456")
private String password;
}
...@@ -12,12 +12,12 @@ import lombok.experimental.Accessors; ...@@ -12,12 +12,12 @@ import lombok.experimental.Accessors;
* </pre> * </pre>
* *
* @author giao * @author giao
* @date 2020-10-13 * @date 2020-10-16
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel(value = "商家表分页参数") @ApiModel(value = "航空公司商家表分页参数")
public class MerchantPageParam extends BasePageOrderParam { public class MerchantPageParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jumeirah.common.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 注册参数
*
* @author geekidea
* @date 2019-05-15
**/
@Data
@ApiModel("注册参数")
public class MerchantRegisterParam implements Serializable {
private static final long serialVersionUID = 2854217576695117357L;
@NotBlank(message = "请输入密码")
@ApiModelProperty(value = "密码", example = "123456")
private String password;
@NotBlank(message = "参数不能为空")
@ApiModelProperty("验证码")
private String smsCode;
@ApiModelProperty("商家名称")
@NotBlank(message = "参数不能为空")
private String name;
@ApiModelProperty("联系人手机号码")
@NotBlank(message = "请输入手机号")
private String phone;
@ApiModelProperty("联系人手机区号")
private String phoneArea;
@ApiModelProperty("公司所在地址")
private String location;
@ApiModelProperty("邮箱")
private String email;
@ApiModelProperty("营业执照图片url, 为多张可以传入数组")
private String imageBusinessLicenseUrl;
}
...@@ -10,7 +10,7 @@ import io.geekidea.springbootplus.framework.core.pagination.Paging; ...@@ -10,7 +10,7 @@ import io.geekidea.springbootplus.framework.core.pagination.Paging;
* 航空公司商家表 服务类 * 航空公司商家表 服务类
* *
* @author giao * @author giao
* @since 2020-10-13 * @since 2020-10-16
*/ */
public interface MerchantService extends BaseService<Merchant> { public interface MerchantService extends BaseService<Merchant> {
......
package com.jumeirah.common.service; package com.jumeirah.common.service;
import com.jumeirah.common.entity.MerchantUser; import com.jumeirah.common.entity.MerchantUser;
import com.jumeirah.common.param.LoginParam; import com.jumeirah.common.param.MerchantLoginParam;
import com.jumeirah.common.param.MerchantRegisterParam;
import com.jumeirah.common.param.MerchantUserPageParam; import com.jumeirah.common.param.MerchantUserPageParam;
import com.jumeirah.common.vo.LoginSysUserTokenVo; import com.jumeirah.common.vo.LoginMerUserTokenVo;
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;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.Paging;
import javax.servlet.http.HttpServletResponse;
/** /**
* 商家 服务类 * 商家 服务类
* *
...@@ -32,11 +31,13 @@ public interface MerchantUserService extends BaseService<MerchantUser> { ...@@ -32,11 +31,13 @@ public interface MerchantUserService extends BaseService<MerchantUser> {
/** /**
* 登录 * 登录
* *
* @param loginParam
* @return * @return
* @throws Exception * @throws Exception
*/ */
ApiResult<LoginSysUserTokenVo> login(LoginParam loginParam, HttpServletResponse response, String language) throws Exception; ApiResult<LoginMerUserTokenVo> login(MerchantLoginParam merchantLoginParam) throws Exception;
ApiResult<Boolean> register(MerchantRegisterParam merchantRegisterParam) throws Exception;
/** /**
......
...@@ -116,7 +116,7 @@ public class AppUserServiceImpl extends BaseServiceImpl<AppUserMapper, AppUser> ...@@ -116,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, LoginClientTypeEnum.APP.getType()); JwtToken jwtToken = JwtToken.build(token, appUser.getId().toString(), appUser.getId(), newSalt, expireSecond, LoginClientTypeEnum.APP.getType(), null);
boolean enableShiro = springBootPlusProperties.getShiro().isEnable(); boolean enableShiro = springBootPlusProperties.getShiro().isEnable();
if (enableShiro) { if (enableShiro) {
......
package com.jumeirah.common.service.impl; 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.MerchantRole; import com.jumeirah.common.entity.MerchantRole;
import com.jumeirah.common.mapper.MerchantRoleMapper; import com.jumeirah.common.mapper.MerchantRoleMapper;
import com.jumeirah.common.param.MerchantRolePageParam;
import com.jumeirah.common.service.MerchantRoleService; import com.jumeirah.common.service.MerchantRoleService;
import com.jumeirah.common.param.MerchantRolePageParam; import com.jumeirah.common.vo.MerchantRoleQueryVo;
import com.jumeirah.common.vo.MerchantRoleQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl; import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo; import io.geekidea.springbootplus.framework.core.pagination.Paging;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 商家角色 服务实现类 * 商家角色 服务实现类
......
...@@ -20,7 +20,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -20,7 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
* 航空公司商家表 服务实现类 * 航空公司商家表 服务实现类
* *
* @author giao * @author giao
* @since 2020-10-13 * @since 2020-10-16
*/ */
@Slf4j @Slf4j
@Service @Service
......
package com.jumeirah.api.merchant.service; package com.jumeirah.common.service.impl;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
......
package com.jumeirah.api.merchant.service; package com.jumeirah.common.service.impl;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
......
...@@ -4,17 +4,20 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -4,17 +4,20 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jumeirah.common.convert.SysUserConvert; import com.jumeirah.common.convert.UserConvert;
import com.jumeirah.common.entity.Merchant;
import com.jumeirah.common.entity.MerchantRole; import com.jumeirah.common.entity.MerchantRole;
import com.jumeirah.common.entity.MerchantUser; import com.jumeirah.common.entity.MerchantUser;
import com.jumeirah.common.enums.StateEnum; import com.jumeirah.common.enums.StateEnum;
import com.jumeirah.common.mapper.MerchantUserMapper; import com.jumeirah.common.mapper.MerchantUserMapper;
import com.jumeirah.common.param.LoginParam; import com.jumeirah.common.param.MerchantLoginParam;
import com.jumeirah.common.param.MerchantRegisterParam;
import com.jumeirah.common.param.MerchantUserPageParam; import com.jumeirah.common.param.MerchantUserPageParam;
import com.jumeirah.common.service.MerchantRolePermissionService; import com.jumeirah.common.service.MerchantRolePermissionService;
import com.jumeirah.common.service.MerchantRoleService; import com.jumeirah.common.service.MerchantRoleService;
import com.jumeirah.common.service.MerchantService;
import com.jumeirah.common.service.MerchantUserService; import com.jumeirah.common.service.MerchantUserService;
import com.jumeirah.common.vo.LoginSysUserTokenVo; import com.jumeirah.common.vo.LoginMerUserTokenVo;
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,7 +29,6 @@ import io.geekidea.springbootplus.framework.core.pagination.Paging; ...@@ -26,7 +29,6 @@ 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.jwt.realm.LoginClientTypeEnum;
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;
import io.geekidea.springbootplus.framework.shiro.vo.LoginUserVo; import io.geekidea.springbootplus.framework.shiro.vo.LoginUserVo;
...@@ -35,13 +37,13 @@ import lombok.extern.slf4j.Slf4j; ...@@ -35,13 +37,13 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.subject.Subject; import org.apache.shiro.subject.Subject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.time.Duration; import java.time.Duration;
import java.util.Set; import java.util.Set;
...@@ -77,56 +79,47 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper, ...@@ -77,56 +79,47 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper,
private MerchantRoleService merchantRoleService; private MerchantRoleService merchantRoleService;
@Autowired @Autowired
private MerchantService merchantService;
@Autowired
private MerchantSmsService merchantSmsService;
@Autowired
private MerchantRolePermissionService merchantRolePermissionService; private MerchantRolePermissionService merchantRolePermissionService;
public MerchantUser getSysUserByUsername(String username) throws Exception { public MerchantUser getMerUserByUsername(String username) throws Exception {
MerchantUser sysUser = new MerchantUser().setUsername(username); MerchantUser sysUser = new MerchantUser().setUsername(username);
return merchantUserMapper.selectOne(new QueryWrapper<MerchantUser>(sysUser)); return merchantUserMapper.selectOne(new QueryWrapper<MerchantUser>(sysUser));
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public ApiResult<LoginSysUserTokenVo> login(LoginParam loginParam, HttpServletResponse response, String language) throws Exception { public ApiResult<LoginMerUserTokenVo> login(MerchantLoginParam merchantLoginParam) throws Exception {
// // 校验验证码 String username = merchantLoginParam.getUsername();
// checkVerifyCode(loginParam.getVerifyToken(), loginParam.getCode());
String username = loginParam.getUsername();
// 从数据库中获取登录用户信息 // 从数据库中获取登录用户信息
MerchantUser merchantUser = getSysUserByUsername(username); MerchantUser merchantUser = getMerUserByUsername(username);
if (merchantUser == null) { if (merchantUser == null) {
log.error("登录失败,用户名或密码错误merchantLoginParam:{}", merchantLoginParam);
log.error("登录失败,loginParam:{}", loginParam); return ApiResult.result(ApiCode.PWD_OR_USERNAME_ERROR, null);
// throw new AuthenticationException("用户名或密码错误");
return ApiResult.fail(ApiCode.PWD_OR_USERNAME_ERROR, language);
} }
if (StateEnum.DISABLE.getCode().equals(merchantUser.getState())) { if (StateEnum.DISABLE.getCode().equals(merchantUser.getState())) {
throw new AuthenticationException("账号已禁用"); log.error("登录失败,禁用:{}", merchantLoginParam);
return ApiResult.result(ApiCode.LOGIN_EXCEPTION, null);
} }
// 实际项目中,前端传过来的密码应先加密 // 实际项目中,前端传过来的密码应先加密
// 原始密码明文:123456 // 原始密码明文:123456
// 原始密码前端加密:sha256(123456) // 原始密码前端加密:sha256(123456)
// 后台加密规则:sha256(sha256(123456) + salt) // 后台加密规则:sha256(sha256(123456) + salt)
String encryptPassword = PasswordUtil.encrypt(loginParam.getPassword(), merchantUser.getSalt()); String encryptPassword = PasswordUtil.encrypt(merchantLoginParam.getPassword(), merchantUser.getSalt());
if (!encryptPassword.equals(merchantUser.getPassword())) { if (!encryptPassword.equals(merchantUser.getPassword())) {
return ApiResult.fail(ApiCode.PWD_OR_USERNAME_ERROR, language); return ApiResult.result(ApiCode.PWD_OR_USERNAME_ERROR, null);
} }
// 将系统用户对象转换成登录用户对象 // 将系统用户对象转换成登录用户对象
LoginUserVo loginSysUserVo = SysUserConvert.INSTANCE.merchantUserToLoginSysUserVo(merchantUser); LoginUserVo loginSysUserVo = UserConvert.INSTANCE.merchantUserToLoginSysUserVo(merchantUser);
// // 获取部门
// SysDepartment sysDepartment = sysDepartmentService.getById(merchantUser.getDepartmentId());
// if (sysDepartment == null) {
// throw new AuthenticationException("部门不存在");
// }
// if (!StateEnum.ENABLE.getCode().equals(sysDepartment.getState())) {
// throw new AuthenticationException("部门已禁用");
// }
// loginSysUserVo.setDepartmentId(sysDepartment.getId())
// .setDepartmentName(sysDepartment.getName());
// 获取当前用户角色 // 获取当前用户角色
Long roleId = merchantUser.getRoleId(); Long roleId = merchantUser.getRoleId();
...@@ -143,9 +136,6 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper, ...@@ -143,9 +136,6 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper,
// 获取当前用户权限 // 获取当前用户权限
Set<String> permissionCodes = merchantRolePermissionService.getPermissionCodesByRoleId(roleId); Set<String> permissionCodes = merchantRolePermissionService.getPermissionCodesByRoleId(roleId);
// if (CollectionUtils.isEmpty(permissionCodes)) {
// throw new AuthenticationException("权限列表不能为空");
// }
loginSysUserVo.setPermissionCodes(permissionCodes); loginSysUserVo.setPermissionCodes(permissionCodes);
// 获取数据库中保存的盐值 // 获取数据库中保存的盐值
...@@ -157,7 +147,7 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper, ...@@ -157,7 +147,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, LoginClientTypeEnum.MERCHANT.getType()); JwtToken jwtToken = JwtToken.build(token, username, merchantUser.getId(), newSalt, expireSecond, LoginClientTypeEnum.MERCHANT.getType(),merchantUser.getMcId());
boolean enableShiro = springBootPlusProperties.getShiro().isEnable(); boolean enableShiro = springBootPlusProperties.getShiro().isEnable();
if (enableShiro) { if (enableShiro) {
...@@ -178,16 +168,44 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper, ...@@ -178,16 +168,44 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper,
redisTemplate.opsForValue().set(tokenSha256, loginSysUserVo, 1, TimeUnit.DAYS);*/ redisTemplate.opsForValue().set(tokenSha256, loginSysUserVo, 1, TimeUnit.DAYS);*/
// 返回token和登录用户信息对象 // 返回token和登录用户信息对象
LoginSysUserTokenVo loginSysUserTokenVo = new LoginSysUserTokenVo(); LoginMerUserTokenVo loginSysUserTokenVo = new LoginMerUserTokenVo();
loginSysUserTokenVo.setToken(token); loginSysUserTokenVo.setToken(token);
loginSysUserTokenVo.setLoginSysUserVo(loginSysUserVo); loginSysUserTokenVo.setLoginSysUserVo(loginSysUserVo);
// 设置token响应头
response.setHeader(JwtTokenUtil.getTokenName(), loginSysUserTokenVo.getToken());
return ApiResult.ok(loginSysUserTokenVo); return ApiResult.ok(loginSysUserTokenVo);
} }
@Override
public ApiResult<Boolean> register(MerchantRegisterParam merchantRegisterPram) throws Exception {
// 校验验证码
boolean equalsRegisterCode = merchantSmsService.equalsRegisterCode(merchantRegisterPram.getPhoneArea(), merchantRegisterPram.getPhone(), merchantRegisterPram.getSmsCode());
if (!equalsRegisterCode) {
return ApiResult.fail(ApiCode.SMS_CODE_ERROR);
}
// 删除已使用的验证码
merchantSmsService.deleteRegisterCode(merchantRegisterPram.getPhoneArea(), merchantRegisterPram.getPhone());
// 判断是否已经注册
// if (appUserService.hasUserByPhoneNumer(loginParam.getPhoneArea(), loginParam.getPhone())) {
// // 如果已经注册直接走登陆的代码
// return appUserService.login(loginParam, language, true);
// }
// 没注册则先保存到数据库
Merchant merchant = new Merchant();
BeanUtils.copyProperties(merchantRegisterPram, merchant);
merchant.setAuditRegisterStatus(0);
merchant.setState(1);
boolean isDbOk = merchantService.saveMerchant(merchant);
if (!isDbOk) {
return ApiResult.fail(ApiCode.SPRING_BOOT_PLUS_EXCEPTION);
}
// 创建一个该公司默认的管理员账号
return ApiResult.ok();
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
package com.jumeirah.common.service.impl; package com.jumeirah.common.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jumeirah.common.convert.SysUserConvert; import com.jumeirah.common.convert.UserConvert;
import com.jumeirah.common.entity.SysDepartment; import com.jumeirah.common.entity.SysDepartment;
import com.jumeirah.common.entity.SysRole; import com.jumeirah.common.entity.SysRole;
import com.jumeirah.common.entity.SysUser; import com.jumeirah.common.entity.SysUser;
...@@ -120,7 +120,7 @@ public class SysLoginServiceImpl implements SysLoginService { ...@@ -120,7 +120,7 @@ public class SysLoginServiceImpl implements SysLoginService {
} }
// 将系统用户对象转换成登录用户对象 // 将系统用户对象转换成登录用户对象
LoginUserVo loginSysUserVo = SysUserConvert.INSTANCE.sysUserToLoginSysUserVo(sysUser); LoginUserVo loginSysUserVo = UserConvert.INSTANCE.sysUserToLoginSysUserVo(sysUser);
// 获取部门 // 获取部门
SysDepartment sysDepartment = sysDepartmentService.getById(sysUser.getDepartmentId()); SysDepartment sysDepartment = sysDepartmentService.getById(sysUser.getDepartmentId());
...@@ -162,7 +162,7 @@ public class SysLoginServiceImpl implements SysLoginService { ...@@ -162,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, LoginClientTypeEnum.SYSTEM.getType()); JwtToken jwtToken = JwtToken.build(token, username,sysUser.getId(), newSalt, expireSecond, LoginClientTypeEnum.SYSTEM.getType(),null);
boolean enableShiro = springBootPlusProperties.getShiro().isEnable(); boolean enableShiro = springBootPlusProperties.getShiro().isEnable();
if (enableShiro) { if (enableShiro) {
......
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jumeirah.common.vo;
import io.geekidea.springbootplus.framework.shiro.service.LoginToken;
import io.geekidea.springbootplus.framework.shiro.vo.LoginUserVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* @author geekidea
* @date 2019-10-26
**/
@Data
@Accessors(chain = true)
@ApiModel("登录用户信息TokenVO")
public class LoginMerUserTokenVo implements LoginToken {
private static final long serialVersionUID = -2138450422989081056L;
@ApiModelProperty("token")
private String token;
/**
* 登录用户对象
*/
private LoginUserVo loginSysUserVo;
}
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
from business_plain bp from business_plain bp
INNER JOIN merchant m ON bp.mc_id=m.id INNER JOIN merchant m ON bp.mc_id=m.id
where bp.business_type=#{param.type} where bp.business_type=#{param.type}
AND m.state=1 and m.audit_register_status=1
</select> </select>
</mapper> </mapper>
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
from charter_introduction ci from charter_introduction ci
INNER JOIN merchant m ON ci.mc_id=m.id INNER JOIN merchant m ON ci.mc_id=m.id
where ci.type = #{param.type} where ci.type = #{param.type}
AND m.state=1 and m.audit_register_status=1
</select> </select>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <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,image_list_height,image_list_width id, name, phone, phone_area, head, remark, state, deleted, create_time, update_time, recharge_bank, recharge_name, recharge_bank_number, image_list_url, image_list_height, image_list_width, image_company_introduction_url, image_team_introduction_url, image_advantage_url, text_company_introduction, text_team_introduction, text_advantage, airline_name, location, email, image_business_license_url, audit_register_status
</sql> </sql>
<select id="getMerchantById" resultType="com.jumeirah.common.vo.MerchantQueryVo"> <select id="getMerchantById" resultType="com.jumeirah.common.vo.MerchantQueryVo">
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from merchant from merchant
<where>
state=1 and audit_register_status=1
</where>
</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 id,mc_id,is_admin, 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">
......
...@@ -2,7 +2,7 @@ spring-boot-plus: ...@@ -2,7 +2,7 @@ spring-boot-plus:
# 是否启用ansi控制台输出有颜色的字体,local环境建议开启,服务器环境设置为false # 是否启用ansi控制台输出有颜色的字体,local环境建议开启,服务器环境设置为false
enable-ansi: false enable-ansi: false
# 当前环境服务IP地址 # 当前环境服务IP地址
server-ip: 47.105.159.10 server-ip: 47.99.47.225
# 文件上传下载配置 # 文件上传下载配置
upload-path: /opt/upload/ upload-path: /opt/upload/
# AOP配置 # AOP配置
...@@ -15,15 +15,15 @@ spring-boot-plus: ...@@ -15,15 +15,15 @@ spring-boot-plus:
spring: spring:
datasource: datasource:
url: jdbc:mysql://mysql57:3306/Jumeirah?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true url: jdbc:mysql://47.99.47.225:3306/Jumeirah?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
username: root username: root
password: 123 password: temple123456
# Redis配置 # Redis配置
redis: redis:
database: 0 database: 0
host: redis6 host: 127.0.0.1
password: password: temple123456
port: 6379 port: 6379
# 打印SQL语句和结果集,本地开发环境可开启,线上注释掉 # 打印SQL语句和结果集,本地开发环境可开启,线上注释掉
......
...@@ -185,8 +185,8 @@ spring-boot-plus: ...@@ -185,8 +185,8 @@ spring-boot-plus:
# 排除登录 注册 登出 # 排除登录 注册 登出
- /app/user/registerOrLogin,/app/user/login - /app/user/registerOrLogin,/app/user/login
- /sys/login,/sys/logout,/sys/register - /sys/login,/sys/logout,/sys/register
- /merchantUser/login - /merchant/user/login,/merchant/user/register
- /app/sms/registerOrLoginCode - /app/sms/registerOrLoginCode,/merchant/sms/registerCode
# 排除静态资源 # 排除静态资源
- /static/**,/templates/** - /static/**,/templates/**
# 排除Swagger # 排除Swagger
...@@ -195,7 +195,7 @@ spring-boot-plus: ...@@ -195,7 +195,7 @@ spring-boot-plus:
# - /actuator/** # - /actuator/**
- # 排除首页 - # 排除首页
- /,/index.html - /,/index.html
- /app/noRole - /app/noRole,/merchant/hello/world
# 航空公司介绍分页列表 # 航空公司介绍分页列表
- /app/airline/getPageList - /app/airline/getPageList
# 公务机出售托管表分页列表 # 公务机出售托管表分页列表
...@@ -282,7 +282,7 @@ spring: ...@@ -282,7 +282,7 @@ spring:
elideSetAutoCommits: true elideSetAutoCommits: true
maintainTimeStats: false maintainTimeStats: false
hikari: hikari:
minimum-idle: 10 minimum-idle: 5
maximum-pool-size: 20 maximum-pool-size: 20
idle-timeout: 10000 idle-timeout: 10000
max-lifetime: 1800000 max-lifetime: 1800000
......
...@@ -42,11 +42,11 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService ...@@ -42,11 +42,11 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService
* username:num * username:num
*/ */
@Override @Override
public void cacheLoginInfo(JwtToken jwtToken, LoginUserVo loginSysUserVo) { public void cacheLoginInfo(JwtToken jwtToken, LoginUserVo loginUserVo) {
if (jwtToken == null) { if (jwtToken == null) {
throw new IllegalArgumentException("jwtToken不能为空"); throw new IllegalArgumentException("jwtToken不能为空");
} }
if (loginSysUserVo == null) { if (loginUserVo == null) {
throw new IllegalArgumentException("loginSysUserVo不能为空"); throw new IllegalArgumentException("loginSysUserVo不能为空");
} }
// token // token
...@@ -54,20 +54,20 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService ...@@ -54,20 +54,20 @@ public class MerchantLoginRedisServiceImpl implements MerchantLoginRedisService
// 盐值 // 盐值
String salt = jwtToken.getSalt(); String salt = jwtToken.getSalt();
// 登录用户名称 // 登录用户名称
String username = loginSysUserVo.getUsername(); String username = loginUserVo.getUsername();
// token md5值 // token md5值
String tokenMd5 = DigestUtils.md5Hex(token); String tokenMd5 = DigestUtils.md5Hex(token);
// Redis缓存JWT Token信息 // Redis缓存JWT Token信息
JwtTokenRedisVo jwtTokenRedisVo = ShiroMapstructConvert.INSTANCE.jwtTokenToJwtTokenRedisVo(jwtToken); JwtTokenRedisVo jwtTokenRedisVo = ShiroMapstructConvert.INSTANCE.jwtTokenToJwtTokenRedisVo(jwtToken);
jwtTokenRedisVo.setUserId(loginSysUserVo.getId()); jwtTokenRedisVo.setUserId(loginUserVo.getId());
jwtTokenRedisVo.setMcId(jwtToken.getMcId());
// 用户客户端信息 // 用户客户端信息
ClientInfo clientInfo = ClientInfoUtil.get(HttpServletRequestUtil.getRequest()); ClientInfo clientInfo = ClientInfoUtil.get(HttpServletRequestUtil.getRequest());
// Redis缓存登录用户信息 // Redis缓存登录用户信息
// 将LoginSysUserVo对象复制到LoginSysUserRedisVo,使用mapstruct进行对象属性复制 // 将LoginSysUserVo对象复制到LoginSysUserRedisVo,使用mapstruct进行对象属性复制
LoginUserRedisVo loginSysUserRedisVo = LoginSysUserVoConvert.INSTANCE.voToRedisVo(loginSysUserVo); LoginUserRedisVo loginSysUserRedisVo = LoginSysUserVoConvert.INSTANCE.voToRedisVo(loginUserVo);
loginSysUserRedisVo.setSalt(salt); loginSysUserRedisVo.setSalt(salt);
loginSysUserRedisVo.setClientInfo(clientInfo); loginSysUserRedisVo.setClientInfo(clientInfo);
......
...@@ -80,7 +80,7 @@ public class JwtFilter extends AuthenticatingFilter { ...@@ -80,7 +80,7 @@ public class JwtFilter extends AuthenticatingFilter {
String username = JwtUtil.getUsername(token); String username = JwtUtil.getUsername(token);
return JwtToken.build(token, username, jwt.getUserId(), shiroLoginService.getSalt(token), jwtProperties.getExpireSecond(), jwt.getType()); return JwtToken.build(token, username, jwt.getUserId(), shiroLoginService.getSalt(token), jwtProperties.getExpireSecond(), jwt.getType(),jwt.getMcId());
} }
......
...@@ -37,9 +37,17 @@ import java.util.Date; ...@@ -37,9 +37,17 @@ import java.util.Date;
public class JwtToken implements HostAuthenticationToken { public class JwtToken implements HostAuthenticationToken {
private static final long serialVersionUID = 5101247566043093405L; private static final long serialVersionUID = 5101247566043093405L;
/**
* 客户端类型
*/
private String type; private String type;
/** /**
* mcId
*/
private Long mcId;
/**
* 登录ip * 登录ip
*/ */
private String host; private String host;
...@@ -78,7 +86,7 @@ public class JwtToken implements HostAuthenticationToken { ...@@ -78,7 +86,7 @@ public class JwtToken implements HostAuthenticationToken {
private String credentials; private String credentials;
public static JwtToken build(String token, String username,Long userId, String salt, long expireSecond, String type) { public static JwtToken build(String token, String username,Long userId, String salt, long expireSecond, String type,Long mcId) {
DecodedJWT decodedJwt = JwtUtil.getJwtInfo(token); DecodedJWT decodedJwt = JwtUtil.getJwtInfo(token);
Date createDate = decodedJwt.getIssuedAt(); Date createDate = decodedJwt.getIssuedAt();
Date expireDate = decodedJwt.getExpiresAt(); Date expireDate = decodedJwt.getExpiresAt();
...@@ -91,7 +99,8 @@ public class JwtToken implements HostAuthenticationToken { ...@@ -91,7 +99,8 @@ public class JwtToken implements HostAuthenticationToken {
.setType(type) .setType(type)
.setCreateDate(createDate) .setCreateDate(createDate)
.setExpireSecond(expireSecond) .setExpireSecond(expireSecond)
.setExpireDate(expireDate); .setExpireDate(expireDate)
.setMcId(mcId);
} }
......
...@@ -100,7 +100,7 @@ public class ShiroLoginServiceImpl implements ShiroLoginService { ...@@ -100,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(), null);
// 更新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);
......
...@@ -33,9 +33,16 @@ import java.util.Date; ...@@ -33,9 +33,16 @@ import java.util.Date;
public class JwtTokenRedisVo implements Serializable { public class JwtTokenRedisVo implements Serializable {
private static final long serialVersionUID = 1831633309466775223L; private static final long serialVersionUID = 1831633309466775223L;
/**
* 客户端类型
*/
private String type; private String type;
/** /**
* mcId
*/
private Long mcId;
/**
* 登录ip * 登录ip
*/ */
private String host; private String host;
......
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