Commit 58c5ec62 by lpx

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

parents 7b31fc0f 99db8fdd
package com.jumeirah.api.merchant.controller; package com.jumeirah.api.merchant.controller;
import com.jumeirah.common.entity.MerchantUser;
import com.jumeirah.common.param.MerchantLoginParam; import com.jumeirah.common.param.MerchantLoginParam;
import com.jumeirah.common.param.MerchantUserPageParam;
import com.jumeirah.common.service.MerchantService; import com.jumeirah.common.service.MerchantService;
import com.jumeirah.common.service.MerchantUserService; import com.jumeirah.common.service.MerchantUserService;
import com.jumeirah.common.vo.LoginMerUserTokenVo; import com.jumeirah.common.vo.LoginMerUserTokenVo;
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;
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.Module; import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.annotation.OperationLogIgnore; import io.geekidea.springbootplus.framework.log.annotation.OperationLogIgnore;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
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.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; 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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -48,60 +38,60 @@ public class MerchantUserController extends BaseController { ...@@ -48,60 +38,60 @@ public class MerchantUserController extends BaseController {
@Autowired @Autowired
private MerchantService merchantService; 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);
} // }
@PostMapping("/login") @PostMapping("/login")
@OperationLogIgnore @OperationLogIgnore
......
package com.jumeirah.api.merchant.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jumeirah.api.merchant.entity.param.MerchantUserAddParam;
import com.jumeirah.api.merchant.entity.param.MerchantUserUpdateParam;
import com.jumeirah.common.entity.MerchantUser;
import com.jumeirah.common.service.MerchantUserService;
import com.jumeirah.common.vo.MerchantUserQueryVo;
import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
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.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.geekidea.springbootplus.framework.shiro.util.SaltUtil;
import io.geekidea.springbootplus.framework.util.PasswordUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
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;
import java.util.List;
/**
* 商家用户 控制器
*
* @author wei
* @since 2020-09-27
*/
@Slf4j
@RestController
@RequestMapping("/merchant/user/manager")
@Module("${cfg.module}")
@Api(value = "商家账户管理API", tags = {"商家账户管理"})
public class MerchantUserManagerController extends BaseController {
@Autowired
private MerchantUserService merchantUserService;
@Autowired
private SpringBootPlusProperties springBootPlusProperties;
/**
* 添加商家用户
*/
@PostMapping("/add")
@OperationLog(name = "添加商家用户", type = OperationLogType.ADD)
@ApiOperation(value = "添加商家用户", response = ApiResult.class)
public ApiResult<Boolean> addMerchantUser(@Validated(Add.class) @RequestBody MerchantUserAddParam merchantUserAddParam) throws Exception {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
MerchantUser merchantUser = new MerchantUser();
BeanUtils.copyProperties(merchantUserAddParam, merchantUser);
merchantUser.setMcId(jwtToken.getMcId());
// 生成盐值
String salt = null;
String password = merchantUserAddParam.getPassword();
// 如果密码为空,则设置默认密码
if (StringUtils.isBlank(password)) {
salt = springBootPlusProperties.getLoginInitSalt();
password = springBootPlusProperties.getLoginInitPassword();
} else {
salt = SaltUtil.generateSalt();
}
// 密码加密
merchantUser.setSalt(salt);
merchantUser.setPassword(PasswordUtil.encrypt(password, salt));
merchantUser.setIsAdmin(0);
boolean flag = merchantUserService.saveMerchantUser(merchantUser);
return ApiResult.result(flag);
}
/**
* 修改商家用户
*/
@PostMapping("/update")
@OperationLog(name = "修改商家用户", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改商家用户", response = ApiResult.class)
public ApiResult<Boolean> updateMerchantUser(@Validated(Update.class) @RequestBody MerchantUserUpdateParam merchantUserUpdateParam) throws Exception {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
MerchantUser sysUser = new MerchantUser().setUsername(merchantUserUpdateParam.getUsername());
MerchantUser one = merchantUserService.getOne(new QueryWrapper<MerchantUser>(sysUser));
MerchantUser merchantUser = new MerchantUser();
BeanUtils.copyProperties(merchantUserUpdateParam, merchantUser);
merchantUser.setMcId(jwtToken.getMcId());
merchantUser.setId(one.getId());
// 生成盐值
String salt = null;
String password = merchantUserUpdateParam.getPassword();
// 如果密码为空,则设置默认密码
if (StringUtils.isBlank(password)) {
salt = springBootPlusProperties.getLoginInitSalt();
password = springBootPlusProperties.getLoginInitPassword();
} else {
salt = SaltUtil.generateSalt();
}
// 密码加密
merchantUser.setSalt(salt);
merchantUser.setPassword(PasswordUtil.encrypt(password, salt));
boolean flag = merchantUserService.updateMerchantUser(merchantUser);
return ApiResult.result(flag);
}
/**
* 删除商家用户
*/
@PostMapping("/delete/{id}")
@OperationLog(name = "删除商家用户", type = OperationLogType.DELETE)
@ApiOperation(value = "删除商家用户", response = ApiResult.class)
public ApiResult<Boolean> deleteMerchantUser(@PathVariable("id") Long id) throws Exception {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
boolean flag = merchantUserService.deleteMerchantUser(id);
return ApiResult.result(flag);
}
/**
* 获取商家用户详情
*/
@GetMapping("/info/{id}")
@OperationLog(name = "商家用户详情", type = OperationLogType.INFO)
@ApiOperation(value = "商家用户详情", response = MerchantUserQueryVo.class)
public ApiResult<MerchantUserQueryVo> getMerchantUser(@PathVariable("id") Long id) throws Exception {
MerchantUserQueryVo merchantUserQueryVo = merchantUserService.getMerchantUserById(id);
return ApiResult.ok(merchantUserQueryVo);
}
/**
* 商家用户分页列表
*/
@PostMapping("/getPageList")
@OperationLog(name = "商家用户分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "商家用户分页列表")
public ApiResult<List<MerchantUserQueryVo>> getMerchantUserPageList() throws Exception {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
List<MerchantUserQueryVo> merchantUserListByMcId = merchantUserService.getMerchantUserListByMcId(jwtToken.getMcId());
return ApiResult.ok(merchantUserListByMcId);
}
}
package com.jumeirah.api.merchant.controller; package com.jumeirah.api.merchant.controller;
import com.jumeirah.common.entity.MerchantUserPermission; import com.jumeirah.common.param.MerchantUserPermissionDetailVo;
import com.jumeirah.common.param.MerchantUserPermissionPageParam;
import com.jumeirah.common.param.MerchantUserPermissionQueryVo; import com.jumeirah.common.param.MerchantUserPermissionQueryVo;
import com.jumeirah.common.service.MerchantUserPermissionService; import com.jumeirah.common.service.MerchantUserPermissionService;
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.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.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType; import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
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.springframework.beans.factory.annotation.Autowired; 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.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.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* 商家用户权限关系 控制器 * 商家用户权限关系 控制器
* *
...@@ -39,59 +35,94 @@ public class MerchantUserPermissionController extends BaseController { ...@@ -39,59 +35,94 @@ public class MerchantUserPermissionController extends BaseController {
private MerchantUserPermissionService merchantUserPermissionService; private MerchantUserPermissionService merchantUserPermissionService;
/** /**
* 添加商家用户权限关系 * 查询商家用户权限详情
*/ */
@PostMapping("/add") @PostMapping("/update/{id}")
@OperationLog(name = "添加商家用户权限关系", type = OperationLogType.ADD) @OperationLog(name = "修改商家用户权限", type = OperationLogType.INFO)
@ApiOperation(value = "添加商家用户权限关系") @ApiOperation(value = "修改商家用户权限")
public ApiResult<Boolean> addMerchantUserPermission(@Validated(Add.class) @RequestBody MerchantUserPermission merchantUserPermission) throws Exception { public ApiResult<MerchantUserPermissionQueryVo> update(@PathVariable("id") Long id) throws Exception {
boolean flag = merchantUserPermissionService.saveMerchantUserPermission(merchantUserPermission); MerchantUserPermissionQueryVo merchantUserPermissionQueryVo = merchantUserPermissionService.getMerchantUserPermissionById(id);
return ApiResult.result(flag); return ApiResult.ok(merchantUserPermissionQueryVo);
} }
/** /**
* 修改商家用户权限关系 * 查询某商家用户权限列表
*/ */
@PostMapping("/update") @GetMapping("/get/{userId}")
@OperationLog(name = "修改商家用户权限关系", type = OperationLogType.UPDATE) @OperationLog(name = "查询某商家用户权限列表", type = OperationLogType.INFO)
@ApiOperation(value = "修改商家用户权限关系") @ApiOperation(value = "查询某商家用户权限列表")
public ApiResult<Boolean> updateMerchantUserPermission(@Validated(Update.class) @RequestBody MerchantUserPermission merchantUserPermission) throws Exception { public ApiResult<List<MerchantUserPermissionDetailVo>> get(@PathVariable("userId") Long userId) throws Exception {
boolean flag = merchantUserPermissionService.updateMerchantUserPermission(merchantUserPermission); List<MerchantUserPermissionDetailVo> merchantUserPermissionByUserId = merchantUserPermissionService.getMerchantUserPermissionByUserId(userId);
return ApiResult.result(flag); return ApiResult.ok(merchantUserPermissionByUserId);
} }
/**
* 删除商家用户权限关系
*/
@PostMapping("/delete/{id}")
@OperationLog(name = "删除商家用户权限关系", type = OperationLogType.DELETE)
@ApiOperation(value = "删除商家用户权限关系")
public ApiResult<Boolean> deleteMerchantUserPermission(@PathVariable("id") Long id) throws Exception {
boolean flag = merchantUserPermissionService.deleteMerchantUserPermission(id);
return ApiResult.result(flag);
}
/** //
* 获取商家用户权限关系详情 // /**
*/ // *查询商家用户权限详情
@GetMapping("/info/{id}") // */
@OperationLog(name = "商家用户权限关系详情", type = OperationLogType.INFO) // @GetMapping("/info/{id}")
@ApiOperation(value = "商家用户权限关系详情") // @OperationLog(name = "商家用户权限关系详情", type = OperationLogType.INFO)
public ApiResult<MerchantUserPermissionQueryVo> getMerchantUserPermission(@PathVariable("id") Long id) throws Exception { // @ApiOperation(value = "商家用户权限关系详情")
MerchantUserPermissionQueryVo merchantUserPermissionQueryVo = merchantUserPermissionService.getMerchantUserPermissionById(id); // public ApiResult<MerchantUserPermissionQueryVo> getMerchantUserPermission(@PathVariable("id") Long id) throws Exception {
return ApiResult.ok(merchantUserPermissionQueryVo); // MerchantUserPermissionQueryVo merchantUserPermissionQueryVo = merchantUserPermissionService.getMerchantUserPermissionById(id);
} // return ApiResult.ok(merchantUserPermissionQueryVo);
// }
/** // /**
* 商家用户权限关系分页列表 // * 添加商家用户权限关系
*/ // */
@PostMapping("/getPageList") // @PostMapping("/add")
@OperationLog(name = "商家用户权限关系分页列表", type = OperationLogType.PAGE) // @OperationLog(name = "添加商家用户权限关系", type = OperationLogType.ADD)
@ApiOperation(value = "商家用户权限关系分页列表") // @ApiOperation(value = "添加商家用户权限关系")
public ApiResult<Paging<MerchantUserPermissionQueryVo>> getMerchantUserPermissionPageList(@Validated @RequestBody MerchantUserPermissionPageParam merchantUserPermissionPageParam) throws Exception { // public ApiResult<Boolean> addMerchantUserPermission(@Validated(Add.class) @RequestBody MerchantUserPermission merchantUserPermission) throws Exception {
Paging<MerchantUserPermissionQueryVo> paging = merchantUserPermissionService.getMerchantUserPermissionPageList(merchantUserPermissionPageParam); // boolean flag = merchantUserPermissionService.saveMerchantUserPermission(merchantUserPermission);
return ApiResult.ok(paging); // return ApiResult.result(flag);
} // }
//
// /**
// * 修改商家用户权限关系
// */
// @PostMapping("/update")
// @OperationLog(name = "修改商家用户权限关系", type = OperationLogType.UPDATE)
// @ApiOperation(value = "修改商家用户权限关系")
// public ApiResult<Boolean> updateMerchantUserPermission(@Validated(Update.class) @RequestBody MerchantUserPermission merchantUserPermission) throws Exception {
// boolean flag = merchantUserPermissionService.updateMerchantUserPermission(merchantUserPermission);
// return ApiResult.result(flag);
// }
//
// /**
// * 删除商家用户权限关系
// */
// @PostMapping("/delete/{id}")
// @OperationLog(name = "删除商家用户权限关系", type = OperationLogType.DELETE)
// @ApiOperation(value = "删除商家用户权限关系")
// public ApiResult<Boolean> deleteMerchantUserPermission(@PathVariable("id") Long id) throws Exception {
// boolean flag = merchantUserPermissionService.deleteMerchantUserPermission(id);
// return ApiResult.result(flag);
// }
//
// /**
// * 获取商家用户权限关系详情
// */
// @GetMapping("/info/{id}")
// @OperationLog(name = "商家用户权限关系详情", type = OperationLogType.INFO)
// @ApiOperation(value = "商家用户权限关系详情")
// public ApiResult<MerchantUserPermissionQueryVo> getMerchantUserPermission(@PathVariable("id") Long id) throws Exception {
// MerchantUserPermissionQueryVo merchantUserPermissionQueryVo = merchantUserPermissionService.getMerchantUserPermissionById(id);
// return ApiResult.ok(merchantUserPermissionQueryVo);
// }
//
// /**
// * 商家用户权限关系分页列表
// */
// @PostMapping("/getPageList")
// @OperationLog(name = "商家用户权限关系分页列表", type = OperationLogType.PAGE)
// @ApiOperation(value = "商家用户权限关系分页列表")
// public ApiResult<Paging<MerchantUserPermissionQueryVo>> getMerchantUserPermissionPageList(@Validated @RequestBody MerchantUserPermissionPageParam merchantUserPermissionPageParam) throws Exception {
// Paging<MerchantUserPermissionQueryVo> paging = merchantUserPermissionService.getMerchantUserPermissionPageList(merchantUserPermissionPageParam);
// return ApiResult.ok(paging);
// }
} }
package com.jumeirah.api.merchant.entity.param;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
/**
* 商家
*
* @author wei
* @since 2020-09-28
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "MerchantUserAddParam对象")
public class MerchantUserAddParam extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotBlank(message = "账号不能为空")
@ApiModelProperty("账号")
private String username;
@NotBlank(message = "密码不能为空")
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("职位")
private String position;
}
package com.jumeirah.api.merchant.entity.param;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
/**
* 商家
*
* @author wei
* @since 2020-09-28
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "MerchantUserUpdateParam对象")
public class MerchantUserUpdateParam extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("用户名")
private String username;
@NotBlank(message = "密码不能为空")
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("职位")
private String position;
}
...@@ -66,8 +66,8 @@ public class MerchantUser extends BaseEntity { ...@@ -66,8 +66,8 @@ public class MerchantUser extends BaseEntity {
@ApiModelProperty("头像") @ApiModelProperty("头像")
private String head; private String head;
@ApiModelProperty("备注") @ApiModelProperty("职位")
private String remark; private String position;
@ApiModelProperty("状态,0:禁用,1:启用,2:锁定") @ApiModelProperty("状态,0:禁用,1:启用,2:锁定")
private Integer state; private Integer state;
......
...@@ -46,8 +46,8 @@ public class MerchantUserPermission extends BaseEntity { ...@@ -46,8 +46,8 @@ public class MerchantUserPermission extends BaseEntity {
@ApiModelProperty("备注") @ApiModelProperty("备注")
private String remark; private String remark;
@ApiModelProperty("职位名称") // @ApiModelProperty("职位名称")
private String positionName; // private String positionName;
@ApiModelProperty("版本") @ApiModelProperty("版本")
@Version @Version
......
...@@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* 商家 Mapper 接口 * 商家 Mapper 接口
...@@ -37,4 +38,6 @@ public interface MerchantUserMapper extends BaseMapper<MerchantUser> { ...@@ -37,4 +38,6 @@ 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);
List<MerchantUserQueryVo> getMerchantUserListByMcId(Serializable id);
} }
...@@ -4,12 +4,14 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -4,12 +4,14 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; 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.MerchantUserPermission; import com.jumeirah.common.entity.MerchantUserPermission;
import com.jumeirah.common.param.MerchantUserPermissionDetailVo;
import com.jumeirah.common.param.MerchantUserPermissionPageParam; import com.jumeirah.common.param.MerchantUserPermissionPageParam;
import com.jumeirah.common.param.MerchantUserPermissionQueryVo; import com.jumeirah.common.param.MerchantUserPermissionQueryVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
...@@ -29,6 +31,8 @@ public interface MerchantUserPermissionMapper extends BaseMapper<MerchantUserPer ...@@ -29,6 +31,8 @@ public interface MerchantUserPermissionMapper extends BaseMapper<MerchantUserPer
*/ */
Set<String> getPermissionCodesByUserId(@Param("userId") Long userId); Set<String> getPermissionCodesByUserId(@Param("userId") Long userId);
List<MerchantUserPermissionDetailVo> getMerchantUserPermissionByUserId(Long userId);
/** /**
* 根据ID获取查询对象 * 根据ID获取查询对象
* *
......
package com.jumeirah.common.param; package com.jumeirah.common.param;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
/** /**
* <pre> * <pre>
......
package com.jumeirah.common.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* <pre>
* 商家用户权限关系 查询结果对象
* </pre>
*
* @author giao
* @date 2020-10-19
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "MerchantUserPermissionDetailVo对象")
public class MerchantUserPermissionDetailVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("权限id")
private Long permissionId;
@ApiModelProperty("权限code")
private String permissionCode;
@ApiModelProperty("权限中文名")
private String permissionName;
@ApiModelProperty("0:没有该权限,1:有该权限")
private Integer isHasPermission;
}
\ No newline at end of file
...@@ -37,9 +37,6 @@ public class MerchantUserPermissionQueryVo implements Serializable { ...@@ -37,9 +37,6 @@ public class MerchantUserPermissionQueryVo implements Serializable {
@ApiModelProperty("备注") @ApiModelProperty("备注")
private String remark; private String remark;
@ApiModelProperty("职位名称")
private String positionName;
@ApiModelProperty("版本") @ApiModelProperty("版本")
private Integer version; private Integer version;
......
package com.jumeirah.common.service; package com.jumeirah.common.service;
import com.jumeirah.common.entity.MerchantUserPermission; import com.jumeirah.common.entity.MerchantUserPermission;
import com.jumeirah.common.param.MerchantUserPermissionDetailVo;
import com.jumeirah.common.param.MerchantUserPermissionPageParam; import com.jumeirah.common.param.MerchantUserPermissionPageParam;
import com.jumeirah.common.param.MerchantUserPermissionQueryVo; import com.jumeirah.common.param.MerchantUserPermissionQueryVo;
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 java.util.List;
import java.util.Set; import java.util.Set;
/** /**
...@@ -62,6 +64,16 @@ public interface MerchantUserPermissionService extends BaseService<MerchantUserP ...@@ -62,6 +64,16 @@ public interface MerchantUserPermissionService extends BaseService<MerchantUserP
MerchantUserPermissionQueryVo getMerchantUserPermissionById(Long id) throws Exception; MerchantUserPermissionQueryVo getMerchantUserPermissionById(Long id) throws Exception;
/** /**
* 根据user获取查询对象
*
* @param userId
* @return
* @throws Exception
*/
List<MerchantUserPermissionDetailVo> getMerchantUserPermissionByUserId(Long userId) throws Exception;
/**
* 获取分页对象 * 获取分页对象
* *
* @param merchantUserPermissionPageParam * @param merchantUserPermissionPageParam
......
...@@ -9,6 +9,8 @@ import io.geekidea.springbootplus.framework.common.api.ApiResult; ...@@ -9,6 +9,8 @@ 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 java.util.List;
/** /**
* 商家 服务类 * 商家 服务类
* *
...@@ -75,6 +77,7 @@ public interface MerchantUserService extends BaseService<MerchantUser> { ...@@ -75,6 +77,7 @@ public interface MerchantUserService extends BaseService<MerchantUser> {
*/ */
Paging<MerchantUserQueryVo> getMerchantUserPageList(MerchantUserPageParam merchantUserPageParam) throws Exception; Paging<MerchantUserQueryVo> getMerchantUserPageList(MerchantUserPageParam merchantUserPageParam) throws Exception;
List<MerchantUserQueryVo> getMerchantUserListByMcId(Long mcId) throws Exception;
......
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem; ...@@ -5,6 +5,7 @@ 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.entity.MerchantUserPermission; import com.jumeirah.common.entity.MerchantUserPermission;
import com.jumeirah.common.mapper.MerchantUserPermissionMapper; import com.jumeirah.common.mapper.MerchantUserPermissionMapper;
import com.jumeirah.common.param.MerchantUserPermissionDetailVo;
import com.jumeirah.common.param.MerchantUserPermissionPageParam; import com.jumeirah.common.param.MerchantUserPermissionPageParam;
import com.jumeirah.common.param.MerchantUserPermissionQueryVo; import com.jumeirah.common.param.MerchantUserPermissionQueryVo;
import com.jumeirah.common.service.MerchantUserPermissionService; import com.jumeirah.common.service.MerchantUserPermissionService;
...@@ -16,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -16,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
...@@ -60,6 +62,11 @@ public class MerchantUserPermissionServiceImpl extends BaseServiceImpl<MerchantU ...@@ -60,6 +62,11 @@ public class MerchantUserPermissionServiceImpl extends BaseServiceImpl<MerchantU
} }
@Override @Override
public List<MerchantUserPermissionDetailVo> getMerchantUserPermissionByUserId(Long userId) throws Exception {
return merchantUserPermissionMapper.getMerchantUserPermissionByUserId(userId);
}
@Override
public Paging<MerchantUserPermissionQueryVo> getMerchantUserPermissionPageList(MerchantUserPermissionPageParam merchantUserPermissionPageParam) throws Exception { public Paging<MerchantUserPermissionQueryVo> getMerchantUserPermissionPageList(MerchantUserPermissionPageParam merchantUserPermissionPageParam) throws Exception {
Page<MerchantUserPermissionQueryVo> page = new PageInfo<>(merchantUserPermissionPageParam, OrderItem.desc(getLambdaColumn(MerchantUserPermission::getCreateTime))); Page<MerchantUserPermissionQueryVo> page = new PageInfo<>(merchantUserPermissionPageParam, OrderItem.desc(getLambdaColumn(MerchantUserPermission::getCreateTime)));
IPage<MerchantUserPermissionQueryVo> iPage = merchantUserPermissionMapper.getMerchantUserPermissionPageList(page, merchantUserPermissionPageParam); IPage<MerchantUserPermissionQueryVo> iPage = merchantUserPermissionMapper.getMerchantUserPermissionPageList(page, merchantUserPermissionPageParam);
......
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.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;
...@@ -7,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -7,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jumeirah.common.convert.UserConvert; import com.jumeirah.common.convert.UserConvert;
import com.jumeirah.common.entity.MerchantPermission; import com.jumeirah.common.entity.MerchantPermission;
import com.jumeirah.common.entity.MerchantUser; import com.jumeirah.common.entity.MerchantUser;
import com.jumeirah.common.entity.MerchantUserPermission;
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.MerchantLoginParam; import com.jumeirah.common.param.MerchantLoginParam;
...@@ -149,6 +149,22 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper, ...@@ -149,6 +149,22 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper,
permissionCodes.add(merchantPermission.getCode()); permissionCodes.add(merchantPermission.getCode());
} }
loginSysUserVo.setPermissionCodes(permissionCodes); loginSysUserVo.setPermissionCodes(permissionCodes);
// 查询全部权限
List<MerchantPermission> list = merchantPermissionService.list();
// 删除该用户所有权限
merchantUserPermissionService.remove(new QueryWrapper<MerchantUserPermission>()
.lambda().eq(MerchantUserPermission::getUserId, merchantUser.getId()));
// 给管理管设置全部权限
for (MerchantPermission merchantPermission : list) {
MerchantUserPermission merchantUserPermission = new MerchantUserPermission();
merchantUserPermission.setUserId(merchantUser.getId());
merchantUserPermission.setPermissionId(merchantPermission.getId());
merchantUserPermission.setState(0);
merchantUserPermissionService.save(merchantUserPermission);
}
} else { } else {
Set<String> permissionCodes = merchantUserPermissionService.getPermissionCodesByUserId(merchantUser.getId()); Set<String> permissionCodes = merchantUserPermissionService.getPermissionCodesByUserId(merchantUser.getId());
loginSysUserVo.setPermissionCodes(permissionCodes); loginSysUserVo.setPermissionCodes(permissionCodes);
...@@ -187,6 +203,7 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper, ...@@ -187,6 +203,7 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper,
LoginMerUserTokenVo loginSysUserTokenVo = new LoginMerUserTokenVo(); LoginMerUserTokenVo loginSysUserTokenVo = new LoginMerUserTokenVo();
loginSysUserTokenVo.setToken(token); loginSysUserTokenVo.setToken(token);
loginSysUserTokenVo.setLoginSysUserVo(loginSysUserVo); loginSysUserTokenVo.setLoginSysUserVo(loginSysUserVo);
loginSysUserTokenVo.setIsAdmin(merchantUser.getIsAdmin());
return ApiResult.ok(loginSysUserTokenVo); return ApiResult.ok(loginSysUserTokenVo);
} }
...@@ -250,8 +267,13 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper, ...@@ -250,8 +267,13 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper,
public Paging<MerchantUserQueryVo> getMerchantUserPageList(MerchantUserPageParam merchantUserPageParam) throws Exception { public Paging<MerchantUserQueryVo> getMerchantUserPageList(MerchantUserPageParam merchantUserPageParam) throws Exception {
Page<MerchantUserQueryVo> page = new PageInfo<>(merchantUserPageParam, OrderItem.desc(getLambdaColumn(MerchantUser::getCreateTime))); Page<MerchantUserQueryVo> page = new PageInfo<>(merchantUserPageParam, OrderItem.desc(getLambdaColumn(MerchantUser::getCreateTime)));
IPage<MerchantUserQueryVo> iPage = merchantUserMapper.getMerchantUserPageList(page, merchantUserPageParam); IPage<MerchantUserQueryVo> iPage = merchantUserMapper.getMerchantUserPageList(page, merchantUserPageParam);
return new Paging<MerchantUserQueryVo>(iPage); return new Paging<>(iPage);
} }
@Override
public List<MerchantUserQueryVo> getMerchantUserListByMcId(Long mcId) throws Exception {
return merchantUserMapper.getMerchantUserListByMcId(mcId);
}
} }
...@@ -37,6 +37,9 @@ public class LoginMerUserTokenVo implements LoginToken { ...@@ -37,6 +37,9 @@ public class LoginMerUserTokenVo implements LoginToken {
@ApiModelProperty("token") @ApiModelProperty("token")
private String token; private String token;
@ApiModelProperty("是否为管理员,0:普通,1:超级管理员")
private Integer isAdmin;
/** /**
* 登录用户对象 * 登录用户对象
*/ */
......
...@@ -27,53 +27,16 @@ public class MerchantUserQueryVo implements Serializable { ...@@ -27,53 +27,16 @@ public class MerchantUserQueryVo implements Serializable {
@ApiModelProperty("用户名") @ApiModelProperty("用户名")
private String username; private String username;
//
// @ApiModelProperty("密码")
// private String password;
@ApiModelProperty("昵称") @ApiModelProperty("职位")
private String nickname; private String position;
@ApiModelProperty("航空公司名称") @ApiModelProperty("是否为管理员,0:普通,1:超级管理员")
private String airlineName; private Integer isAdmin;
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("盐值")
private String salt;
@ApiModelProperty("手机号码")
private String phone;
@ApiModelProperty("手机区号")
private String phoneArea;
@ApiModelProperty("性别,0:女,1:男,默认1")
private Integer gender;
@ApiModelProperty("头像")
private String head;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("状态,0:禁用,1:启用,2:锁定")
private Integer state;
@ApiModelProperty("部门id")
private Long departmentId;
@ApiModelProperty("角色id")
private Long roleId;
@ApiModelProperty("逻辑删除,0:未删除,1:已删除")
private Integer deleted;
@ApiModelProperty("版本")
private Integer version;
@ApiModelProperty("创建时间") @ApiModelProperty("创建时间")
private Timestamp createTime; private Timestamp createTime;
@ApiModelProperty("修改时间")
private Timestamp updateTime;
} }
\ No newline at end of file
...@@ -3,20 +3,38 @@ ...@@ -3,20 +3,38 @@
<mapper namespace="com.jumeirah.common.mapper.MerchantUserPermissionMapper"> <mapper namespace="com.jumeirah.common.mapper.MerchantUserPermissionMapper">
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, user_id, permission_id, state, remark, version, create_time, update_time
id, user_id, permission_id, state, remark, position_name, version, create_time, update_time
</sql> </sql>
<select id="getPermissionCodesByUserId" resultType="java.lang.String"> <select id="getPermissionCodesByUserId" resultType="java.lang.String">
SELECT
mp.CODE
FROM
merchant_user_permission mup
INNER JOIN merchant_permission mp ON mp.id = mup.permission_id
WHERE
mup.user_id = #{userId}
</select>
<select id="getMerchantUserPermissionByUserId"
resultType="com.jumeirah.common.param.MerchantUserPermissionDetailVo">
SELECT
mp.id AS permissionId,
mp.name as permissionName,
mp.code as permissionCode,
CASE
WHEN ISNULL( mup.id ) THEN
0 ELSE 1
END AS isHasPermission
FROM
merchant_permission mp
LEFT JOIN ( SELECT mup.id, mup.permission_id FROM merchant_user_permission mup WHERE mup.user_id = #{userId} ) AS mup ON mup.permission_id = mp.id
SELECT
mp.CODE
FROM
merchant_user_permission mup
INNER JOIN merchant_permission mp ON mp.id = mup.permission_id
WHERE
mup.user_id = #{userId}
</select> </select>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
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 id,mc_id,is_admin, username, nickname, password, salt, phone, phone_area, gender, head, position, 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,7 +20,14 @@ ...@@ -20,7 +20,14 @@
from merchant_user from merchant_user
</select> </select>
<select id="getMerchantUserListByMcId" parameterType="com.jumeirah.common.param.MerchantUserPageParam"
resultType="com.jumeirah.common.vo.MerchantUserQueryVo">
select
id,mc_id,is_admin, username, nickname, phone, phone_area, gender, head, position, state, role_id, create_time, update_time
from merchant_user
where mc_id = #{id}
and deleted=0
</select>
</mapper> </mapper>
...@@ -43,7 +43,7 @@ public class JwtToken implements HostAuthenticationToken { ...@@ -43,7 +43,7 @@ public class JwtToken implements HostAuthenticationToken {
private String type; private String type;
/** /**
* mcId * 商家mcId
*/ */
private Long mcId; private Long mcId;
......
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