Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
83c9d74cdf
|
@ -1,8 +1,9 @@
|
|||
apply plugin: 'org.springframework.boot'
|
||||
|
||||
dependencies {
|
||||
compile project(":diboot-core")
|
||||
// compile project(":diboot-core")
|
||||
|
||||
compile("com.diboot:diboot-core-spring-boot-starter:2.0.3")
|
||||
compile("org.apache.shiro:shiro-spring:1.4.1")
|
||||
compile("org.aspectj:aspectjweaver")
|
||||
compile("com.auth0:java-jwt:3.4.1",
|
||||
|
@ -10,4 +11,19 @@ dependencies {
|
|||
|
||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
resources {
|
||||
srcDirs "src/main/java"
|
||||
include '**/*.xml'
|
||||
include '**/*.dtd'
|
||||
include '**/*.class'
|
||||
}
|
||||
resources {
|
||||
srcDirs "src/main/resources"
|
||||
include '**'
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,8 @@ import com.diboot.core.mapper.BaseCrudMapper;
|
|||
import com.diboot.shiro.entity.UserRole;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户角色Mapper
|
||||
* @author Yangzhao
|
||||
|
@ -19,6 +21,6 @@ public interface UserRoleMapper extends BaseCrudMapper<UserRole> {
|
|||
* @param wrapper
|
||||
* @return
|
||||
*/
|
||||
int deletePhysics(@Param("ew") Wrapper<UserRole> wrapper);
|
||||
int deletePhysics(@Param("ew")Map<String, Object> criteria);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,13 +2,22 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "./mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.diboot.shiro.mapper.UserRoleMapper">
|
||||
|
||||
<delete id="deletePhysics" parameterType="com.baomidou.mybatisplus.core.conditions.Wrapper">
|
||||
<delete id="deletePhysics" parameterType="java.util.Map">
|
||||
DELETE
|
||||
FROM user_role
|
||||
<where>
|
||||
<choose>
|
||||
<when test="ew != null">
|
||||
#{ew.expression.sqlSegment}
|
||||
is_deleted=0
|
||||
<if test="ew.userId">
|
||||
AND user_id = #{ew.userId}
|
||||
</if>
|
||||
<if test="ew.roleId">
|
||||
AND role_id = #{ew.roleId}
|
||||
</if>
|
||||
<if test="ew.userType">
|
||||
AND user_type = #{ew.userType}
|
||||
</if>
|
||||
</when>
|
||||
<otherwise>
|
||||
is_deleted=1
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.diboot.shiro.entity.UserRole;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户角色Service
|
||||
|
@ -26,10 +27,10 @@ public interface UserRoleService extends BaseService<UserRole> {
|
|||
boolean createOrUpdateOrDeleteEntities(Collection<UserRole> entityList, int batchSize);
|
||||
|
||||
/**
|
||||
* 根据条件物理删除
|
||||
* @param wrapper
|
||||
* 根据条件物理删除 必传选项(userId、userType、roleId)
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
boolean deletePhysics(Wrapper<UserRole> wrapper);
|
||||
boolean deletePhysics(Map<String, Object> criteria);
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,9 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -117,11 +119,12 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
|||
throw new ShiroCustomException(Status.FAIL_VALIDATION, "删除用户失败!");
|
||||
}
|
||||
//删除账户绑定的角色信息
|
||||
LambdaQueryWrapper<UserRole> queryWrapper = Wrappers.<UserRole>lambdaQuery()
|
||||
.eq(UserRole::getUserId, id)
|
||||
.eq(UserRole::getUserType, iUserType.getType());
|
||||
Map<String, Object> criteria = new HashMap(){{
|
||||
put("userId", id);
|
||||
put("userType", iUserType.getType());
|
||||
}};
|
||||
|
||||
if (userRoleService.deleteEntities(queryWrapper)) {
|
||||
if (userRoleService.deletePhysics(criteria)) {
|
||||
throw new ShiroCustomException(Status.FAIL_VALIDATION, "删除用户失败!");
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -20,6 +20,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
|
@ -59,7 +61,12 @@ public class UserRoleServiceImpl extends BaseServiceImpl<UserRoleMapper, UserRol
|
|||
}
|
||||
//此处物理删除
|
||||
else if (entity.isDeleted()){
|
||||
deletePhysics(queryWrapper);
|
||||
Map<String, Object> criteria = new HashMap(){{
|
||||
put("roleId", entity.getRoleId());
|
||||
put("userId", entity.getUserId());
|
||||
put("userType", entity.getUserType());
|
||||
}};
|
||||
deletePhysics(criteria);
|
||||
}
|
||||
//更新数据
|
||||
else {
|
||||
|
@ -78,8 +85,8 @@ public class UserRoleServiceImpl extends BaseServiceImpl<UserRoleMapper, UserRol
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePhysics(Wrapper<UserRole> wrapper) {
|
||||
return getBaseMapper().deletePhysics(wrapper) > 0;
|
||||
public boolean deletePhysics(Map<String, Object> criteria) {
|
||||
return getBaseMapper().deletePhysics(criteria) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue