完成管理员登陆接口的测试

This commit is contained in:
YunaiV 2020-07-04 17:13:57 +08:00
parent bedaaf0999
commit c1ca5f7dc5
10 changed files with 27 additions and 25 deletions

View File

@ -16,7 +16,7 @@ spring:
dubbo:
# Spring Cloud Alibaba Dubbo 专属配置
cloud:
subscribed-services: 'user-service, system-service' # 设置订阅的应用列表,默认为 * 订阅所有应用
subscribed-services: 'system-service' # 设置订阅的应用列表,默认为 * 订阅所有应用
# Dubbo 服务消费者的配置
consumer:
timeout: 10000

View File

@ -6,13 +6,14 @@ import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
/**
* 管理员校验密码 DTO
*/
@Data
@Accessors(chain = true)
public class AdminVerifyPasswordDTO {
public class AdminVerifyPasswordDTO implements Serializable {
/**
* 用户名

View File

@ -4,12 +4,14 @@ import cn.iocoder.mall.systemservice.enums.admin.AdminStatusEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 管理员 DO
*/
@Data
@Accessors(chain = true)
public class AdminVO {
public class AdminVO implements Serializable {
/**
* 管理员编号

View File

@ -1 +0,0 @@
package cn.iocoder.mall.systemservice.dal.mysql.dataobject;

View File

@ -1,20 +1,20 @@
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import cn.iocoder.mall.system.biz.dataobject.account.AccountDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin.AdminDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* {@link AccountDO} {@link RoleDO} 的关联表
* {@link AdminDO} {@link RoleDO} 的关联表
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("account_role")
public class AccountRoleDO extends DeletableDO {
@TableName("permission_admin_role")
public class AdminRoleDO extends DeletableDO {
/**
* 编号
@ -23,7 +23,7 @@ public class AccountRoleDO extends DeletableDO {
/**
* 账号编号
*
* 关联 {@link AccountDO#getId()}
* 关联 {@link AdminDO#getId()}
*/
private Integer accountId;
/**

View File

@ -1,7 +1,7 @@
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import cn.iocoder.mall.system.biz.enums.authorization.ResourceTypeEnum;
import cn.iocoder.mall.systemservice.enums.permission.ResourceTypeEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -13,7 +13,7 @@ import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "resource")
@TableName(value = "permission_resource")
public class ResourceDO extends DeletableDO {
/**

View File

@ -1,8 +1,8 @@
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import cn.iocoder.mall.system.biz.enums.authorization.RoleCodeEnum;
import cn.iocoder.mall.system.biz.enums.authorization.RoleTypeEnum;
import cn.iocoder.mall.systemservice.enums.permission.RoleCodeEnum;
import cn.iocoder.mall.systemservice.enums.permission.RoleTypeEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -14,7 +14,7 @@ import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("role")
@TableName("permission_role")
public class RoleDO extends DeletableDO {
/**

View File

@ -12,7 +12,7 @@ import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("role_resource")
@TableName("permission_role_resource")
public class RoleResourceDO extends DeletableDO {
/**

View File

@ -1,6 +1,6 @@
package cn.iocoder.mall.systemservice.dal.mysql.mapper.permission;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.AccountRoleDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.AdminRoleDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
@ -10,22 +10,22 @@ import java.util.Collection;
import java.util.List;
@Repository
public interface AccountRoleMapper extends BaseMapper<AccountRoleDO> {
public interface AccountRoleMapper extends BaseMapper<AdminRoleDO> {
default List<AccountRoleDO> selectByAccountId(Integer accountId) {
return selectList(new QueryWrapper<AccountRoleDO>().eq("account_id", accountId));
default List<AdminRoleDO> selectByAccountId(Integer accountId) {
return selectList(new QueryWrapper<AdminRoleDO>().eq("account_id", accountId));
}
default List<AccountRoleDO> selectListByAccountIds(Collection<Integer> accountIds) {
return selectList(new QueryWrapper<AccountRoleDO>().in("account_id", accountIds));
default List<AdminRoleDO> selectListByAccountIds(Collection<Integer> accountIds) {
return selectList(new QueryWrapper<AdminRoleDO>().in("account_id", accountIds));
}
default int deleteByAccountId(Integer accountId) {
return delete(new QueryWrapper<AccountRoleDO>().eq("account_id", accountId));
return delete(new QueryWrapper<AdminRoleDO>().eq("account_id", accountId));
}
default int deleteByRoleId(Integer roleId) {
return delete(new QueryWrapper<AccountRoleDO>().eq("role_id", roleId));
return delete(new QueryWrapper<AdminRoleDO>().eq("role_id", roleId));
}
/**
@ -33,6 +33,6 @@ public interface AccountRoleMapper extends BaseMapper<AccountRoleDO> {
*
* @param accountRoleDOs 数组
*/
int insertList(@Param("accountRoleDOs") List<AccountRoleDO> accountRoleDOs);
int insertList(@Param("accountRoleDOs") List<AdminRoleDO> accountRoleDOs);
}

View File

@ -24,7 +24,7 @@ public class AdminService {
}
// 校验密码是否正确
String encodedPassword = DigestUtils.bcrypt(password, adminDO.getPasswordSalt());
if (encodedPassword.equals(adminDO.getPassword())) {
if (!encodedPassword.equals(adminDO.getPassword())) {
// TODO 需要补充密码错误上限
throw ServiceExceptionUtil.exception(SystemErrorCodeEnum.ADMIN_PASSWORD_ERROR);
}