@@ -32,12 +32,12 @@ | |||
<scope>test</scope> | |||
</dependency> | |||
<!--mybatis-plus 起始依赖 --> | |||
<dependency> | |||
<groupId>com.baomidou</groupId> | |||
<artifactId>mybatis-plus-boot-starter</artifactId> | |||
<version>3.2.0</version> | |||
<version>3.5.1</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>cn.hutool</groupId> | |||
<artifactId>hutool-core</artifactId> |
@@ -0,0 +1,36 @@ | |||
package com.tuoheng.config; | |||
import com.baomidou.mybatisplus.annotation.DbType; | |||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; | |||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; | |||
import org.springframework.context.annotation.Bean; | |||
import org.springframework.context.annotation.Configuration; | |||
@Configuration | |||
public class MybatisPlusConfig { | |||
/** | |||
* 插件注册 | |||
* | |||
* @param paginationInnerInterceptor 分页插件 | |||
* @return MybatisPlus拦截器 | |||
*/ | |||
@Bean | |||
public MybatisPlusInterceptor mybatisPlusInterceptor(PaginationInnerInterceptor paginationInnerInterceptor) { | |||
MybatisPlusInterceptor mp = new MybatisPlusInterceptor(); | |||
mp.addInnerInterceptor(paginationInnerInterceptor); | |||
return mp; | |||
} | |||
//分页插件 | |||
@Bean | |||
public PaginationInnerInterceptor paginationInnerInterceptor() { | |||
PaginationInnerInterceptor pii = new PaginationInnerInterceptor(); | |||
pii.setMaxLimit(20L); | |||
pii.setDbType(DbType.MYSQL); | |||
//当超过最大页数时不会报错 | |||
pii.setOverflow(true); | |||
return pii; | |||
} | |||
} |
@@ -11,5 +11,9 @@ public class HhzUrlConstant { | |||
* 创建租户 | |||
*/ | |||
public static String CREATE_TENANT = "/oidcTenant/add"; | |||
/** | |||
* 编辑租户 | |||
*/ | |||
public static String UPDATE_TENANT = "/oidcTenant/edit"; | |||
} |
@@ -49,4 +49,16 @@ public class TenantController { | |||
return clientUserSevice.findTenants(query); | |||
} | |||
/** | |||
* 更新业务租户信息及密码接口 | |||
* @param dto | |||
* @param loginUser | |||
* @return | |||
*/ | |||
@PostMapping("/edit") | |||
public JsonResult edit(@RequestBody OidcTenantDto dto,@CurrentUser LoginUser loginUser){ | |||
return clientUserSevice.editTenant(dto,loginUser); | |||
} | |||
} |
@@ -23,5 +23,6 @@ public interface TenantMapper { | |||
TTenant getByCode(@Param("code") String code); | |||
List<TenantPo> findList(@Param("query") TenantQuery query); | |||
IPage<TenantPo> findList(@Param("page") IPage<TenantVo> page, @Param("query") TenantQuery query); | |||
} |
@@ -35,4 +35,6 @@ public interface ClientUserSevice { | |||
JsonResult findTenants(TenantQuery query); | |||
JsonResult editTenant(OidcTenantDto dto, LoginUser loginUser); | |||
} |
@@ -1,5 +1,6 @@ | |||
package com.tuoheng.service.impl; | |||
import cn.hutool.core.convert.Convert; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
@@ -255,14 +256,11 @@ public class ClientUserServiceImpl implements ClientUserSevice { | |||
return JsonResult.error("分页参数不能为空"); | |||
} | |||
//开启分页 | |||
PageHelper.startPage(query.getPage(),query.getLimit()); | |||
List<TenantPo> tenantList = tenantMapper.findList(query); | |||
List<TenantVo> list = new ArrayList<>(); | |||
for (TenantPo tenantPo : tenantList) { | |||
TenantVo vo = new TenantVo(); | |||
vo.setCode(tenantPo.getCode()); | |||
vo.setName(tenantPo.getName()); | |||
Long userId = tenantPo.getUserId(); | |||
IPage<TenantVo> page = new Page<>(query.getPage(), query.getLimit()); | |||
IPage<TenantPo> pageData = tenantMapper.findList(page,query); | |||
pageData.convert(x -> { | |||
TenantVo vo = Convert.convert(TenantVo.class, x); | |||
Long userId = x.getUserId(); | |||
List<AuthoritiesPo> poList = authoritiesMapper.selectByUserId(userId); | |||
UserPo userPo = clientUserMapper.selectByUserId(userId); | |||
if (null != userPo) { | |||
@@ -278,13 +276,24 @@ public class ClientUserServiceImpl implements ClientUserSevice { | |||
businessSystemVoList.add(businessSystemVo); | |||
} | |||
vo.setList(businessSystemVoList); | |||
list.add(vo); | |||
} | |||
PageInfo<TenantVo> tenantVoPageInfo = new PageInfo<>(list); | |||
//添加总条数 | |||
tenantVoPageInfo.setTotal(list.size()); | |||
return vo; | |||
}); | |||
return JsonResult.success(pageData); | |||
} | |||
/** | |||
* 更新业务平台租户的相关基本信息 | |||
* | |||
* @param dto | |||
* @param loginUser | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult editTenant(OidcTenantDto dto, LoginUser loginUser) { | |||
return JsonResult.success(tenantVoPageInfo); | |||
//TODO | |||
return null; | |||
} | |||