Merge pull request #126 from qiaozhanwei/dev-20190415

api token update and  add tenant code check
This commit is contained in:
乔占卫 2019-04-24 15:48:26 +08:00 committed by GitHub
commit 40216b3446
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 12 deletions

View File

@ -58,15 +58,16 @@ public class AccessTokenService extends BaseService {
public Map<String, Object> queryAccessTokenList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Map<String, Object> result = new HashMap<>(5);
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM, Constants.STATUS)) {
return result;
}
Integer count = accessTokenMapper.countAccessTokenPaging(searchVal);
PageInfo<AccessToken> pageInfo = new PageInfo<>(pageNo, pageSize);
List<AccessToken> accessTokenList = accessTokenMapper.queryAccessTokenPaging(searchVal, pageInfo.getStart(), pageSize);
Integer count;
List<AccessToken> accessTokenList;
if (loginUser.getUserType() == UserType.ADMIN_USER){
count = accessTokenMapper.countAccessTokenPaging(0,searchVal);
accessTokenList = accessTokenMapper.queryAccessTokenPaging(0,searchVal, pageInfo.getStart(), pageSize);
}else {
count = accessTokenMapper.countAccessTokenPaging(loginUser.getId(),searchVal);
accessTokenList = accessTokenMapper.queryAccessTokenPaging(loginUser.getId(),searchVal, pageInfo.getStart(), pageSize);
}
pageInfo.setTotalCount(count);
pageInfo.setLists(accessTokenList);

View File

@ -80,6 +80,10 @@ public class TenantService extends BaseService{
Tenant tenant = new Tenant();
Date now = new Date();
if (!tenantCode.matches("^[0-9a-zA-Z_.]{1,}$") || tenantCode.startsWith("-")){
putMsg(result, Status.VERIFY_TENANT_CODE_ERROR);
return result;
}
tenant.setTenantCode(tenantCode);
tenant.setTenantName(tenantName);
tenant.setQueueId(queueId);

View File

@ -74,7 +74,8 @@ public interface AccessTokenMapper {
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
})
@SelectProvider(type = AccessTokenMapperProvider.class, method = "queryAccessTokenPaging")
List<AccessToken> queryAccessTokenPaging(@Param("searchVal") String searchVal,
List<AccessToken> queryAccessTokenPaging(@Param("userId") Integer userId,
@Param("searchVal") String searchVal,
@Param("offset") Integer offset,
@Param("pageSize") Integer pageSize);
@ -84,5 +85,6 @@ public interface AccessTokenMapper {
* @return
*/
@SelectProvider(type = AccessTokenMapperProvider.class, method = "countAccessTokenPaging")
Integer countAccessTokenPaging(@Param("searchVal") String searchVal);
Integer countAccessTokenPaging(@Param("userId") Integer userId
,@Param("searchVal") String searchVal);
}

View File

@ -97,6 +97,9 @@ public class AccessTokenMapperProvider {
FROM(TABLE_NAME + " t,t_escheduler_user u");
Object searchVal = parameter.get("searchVal");
WHERE("u.id = t.user_id");
if(parameter.get("userId") != null && (int)parameter.get("userId") != 0){
WHERE(" u.id = #{userId}");
}
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
WHERE(" u.user_name like concat('%', #{searchVal}, '%')");
}
@ -115,6 +118,9 @@ public class AccessTokenMapperProvider {
FROM(TABLE_NAME + " t,t_escheduler_user u");
Object searchVal = parameter.get("searchVal");
WHERE("u.id = t.user_id");
if(parameter.get("userId") != null && (int)parameter.get("userId") != 0){
WHERE(" u.id = #{userId}");
}
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
WHERE(" u.user_name like concat('%', #{searchVal}, '%') ");
}

View File

@ -51,10 +51,10 @@ public class AccessTokenMapperTest {
@Test
public void testListPaging(){
Integer count = accessTokenMapper.countAccessTokenPaging("");
Integer count = accessTokenMapper.countAccessTokenPaging(1,"");
Assert.assertEquals(count, (Integer) 5);
List<AccessToken> accessTokenList = accessTokenMapper.queryAccessTokenPaging("", 0, 2);
List<AccessToken> accessTokenList = accessTokenMapper.queryAccessTokenPaging(1,"", 0, 2);
Assert.assertEquals(accessTokenList.size(), 5);
}