pull/56/head
shao1121353141 1 year ago
parent 5cd5513f2e
commit 17649b6bc8

@ -15,7 +15,7 @@
* 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;

@ -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);
/**
*

@ -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 (Objects.nonNull(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();

@ -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;

@ -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;

@ -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);
}

Loading…
Cancel
Save