门户端应用管理优化

pull/57/head^2
Friday 2023-09-25 11:27:51 +00:00 committed by smallbun
parent a094605649
commit 9a5c6d68d6
6 changed files with 21 additions and 16 deletions

View File

@ -15,11 +15,12 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cn.topiam.employee.portal.pojo.query;
package cn.topiam.employee.common.entity.app.query;
import java.io.Serial;
import java.io.Serializable;
import io.swagger.v3.oas.annotations.Parameter;
import org.springdoc.core.annotations.ParameterObject;
import lombok.Data;
@ -39,14 +40,17 @@ public class GetAppListQuery implements Serializable {
@Serial
private static final long serialVersionUID = -4981513177967939516L;
/**
* name
*
*/
@Parameter(description = "应用名称")
private String name;
/**
* groupId
* ID
*/
@Parameter(description = "应用分组ID")
private Long groupId;
}

View File

@ -19,6 +19,7 @@ package cn.topiam.employee.common.repository.app;
import java.util.List;
import cn.topiam.employee.common.entity.app.query.GetAppListQuery;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@ -37,12 +38,12 @@ public interface AppRepositoryCustomized {
*
*
*
* @param name {@link String}
* @param userId {@link Long}
* @param query {@link GetAppListQuery}
* @param pageable {@link Pageable}
* @return {@link List}
*/
Page<AppEntity> getAppList(Long userId, String name, Long groupId, Pageable pageable);
Page<AppEntity> getAppList(Long userId, GetAppListQuery query, Pageable pageable);
/**
*

View File

@ -22,6 +22,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import cn.topiam.employee.common.entity.app.query.GetAppListQuery;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
@ -56,13 +57,13 @@ public class AppRepositoryCustomizedImpl implements AppRepositoryCustomized {
/**
*
*
* @param name {@link String}
* @param userId {@link Long}
* @param query {@link query}
* @param pageable {@link String}
* @return {@link List}
*/
@Override
public Page<AppEntity> getAppList(Long userId, String name, Long groupId, Pageable pageable) {
public Page<AppEntity> getAppList(Long userId, GetAppListQuery query, Pageable pageable) {
List<Object> paramList = Lists.newArrayList();
//当前用户加入的用户组Id
List<Long> groupIdList = userGroupMemberRepository.findByUserId(userId).stream()
@ -89,12 +90,12 @@ public class AppRepositoryCustomizedImpl implements AppRepositoryCustomized {
AND (app_acce.subject_id IN (:subjectIds) OR app.authorization_type = 'all_access')
""");
//用户名
if (StringUtils.isNoneBlank(name)) {
builder.append(" AND app.name_ like '%").append(name).append("%'");
if (StringUtils.isNoneBlank(query.getName())) {
builder.append(" AND app.name_ like '%").append(query.getName()).append("%'");
}
//分组id
if (null!=groupId) {
builder.append(" AND ass.group_id = ").append(groupId);
if (Objects.nonNull(query.getGroupId())) {
builder.append(" AND ass.group_id = ").append(query.getGroupId());
}
//@formatter:on
String sql = builder.toString();

View File

@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.topiam.employee.common.entity.app.query.AppGroupQuery;
import cn.topiam.employee.portal.pojo.query.GetAppListQuery;
import cn.topiam.employee.common.entity.app.query.GetAppListQuery;
import cn.topiam.employee.portal.pojo.result.AppGroupListResult;
import cn.topiam.employee.portal.pojo.result.GetAppListResult;
import cn.topiam.employee.portal.service.AppService;

View File

@ -20,7 +20,7 @@ package cn.topiam.employee.portal.service;
import java.util.List;
import cn.topiam.employee.common.entity.app.query.AppGroupQuery;
import cn.topiam.employee.portal.pojo.query.GetAppListQuery;
import cn.topiam.employee.common.entity.app.query.GetAppListQuery;
import cn.topiam.employee.portal.pojo.result.AppGroupListResult;
import cn.topiam.employee.portal.pojo.result.GetAppListResult;
import cn.topiam.employee.support.repository.page.domain.Page;

View File

@ -29,7 +29,7 @@ import cn.topiam.employee.common.repository.app.AppGroupRepository;
import cn.topiam.employee.common.repository.app.AppRepository;
import cn.topiam.employee.portal.converter.AppConverter;
import cn.topiam.employee.portal.converter.AppGroupConverter;
import cn.topiam.employee.portal.pojo.query.GetAppListQuery;
import cn.topiam.employee.common.entity.app.query.GetAppListQuery;
import cn.topiam.employee.portal.pojo.result.AppGroupListResult;
import cn.topiam.employee.portal.pojo.result.GetAppListResult;
import cn.topiam.employee.portal.service.AppService;
@ -56,8 +56,7 @@ public class AppServiceImpl implements AppService {
public Page<GetAppListResult> getAppList(GetAppListQuery query, PageModel pageModel) {
Long userId = Long.valueOf(SecurityUtils.getCurrentUserId());
org.springframework.data.domain.Page<AppEntity> list = appRepository.getAppList(userId,
query.getName(), query.getGroupId(),
QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize()));
query, QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize()));
return appConverter.entityConvertToAppListResult(list);
}