-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from fqliao/feature-milestone2
add list project info for admin
- Loading branch information
Showing
37 changed files
with
437 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 37 additions & 3 deletions
40
...c/main/java/com/webank/wedpr/components/admin/controller/WedprProjectTableController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,48 @@ | ||
package com.webank.wedpr.components.admin.controller; | ||
|
||
import com.webank.wedpr.components.admin.common.Utils; | ||
import com.webank.wedpr.components.admin.request.GetWedprProjectListRequest; | ||
import com.webank.wedpr.components.admin.response.ListProjectResponse; | ||
import com.webank.wedpr.components.admin.service.WedprProjectTableService; | ||
import com.webank.wedpr.components.token.auth.model.UserToken; | ||
import com.webank.wedpr.core.utils.Constant; | ||
import com.webank.wedpr.core.utils.WeDPRResponse; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.validation.Valid; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* 前端控制器 | ||
* | ||
* @author caryliao | ||
* @since 2024-08-22 | ||
* @since 2024-09-04 | ||
*/ | ||
@RestController | ||
@RequestMapping("/admin/wedprProjectTable") | ||
public class WedprProjectTableController {} | ||
@RequestMapping( | ||
path = Constant.WEDPR_API_PREFIX + "/admin", | ||
produces = {"application/json"}) | ||
@Slf4j | ||
public class WedprProjectTableController { | ||
@Autowired private WedprProjectTableService wedprProjectTableService; | ||
|
||
@GetMapping("/listProject") | ||
public WeDPRResponse listProject( | ||
@Valid GetWedprProjectListRequest getWedprProjectListRequest, | ||
HttpServletRequest request) { | ||
try { | ||
// check user permission | ||
UserToken userToken = Utils.checkPermission(request); | ||
ListProjectResponse listProjectResponse = | ||
wedprProjectTableService.listProject(getWedprProjectListRequest); | ||
return new WeDPRResponse( | ||
Constant.WEDPR_SUCCESS, Constant.WEDPR_SUCCESS_MSG, listProjectResponse); | ||
} catch (Exception e) { | ||
log.error("listProject error", e); | ||
return new WeDPRResponse(Constant.WEDPR_FAILED, e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...n/src/main/java/com/webank/wedpr/components/admin/request/GetWedprProjectListRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.webank.wedpr.components.admin.request; | ||
|
||
import com.webank.wedpr.core.utils.Constant; | ||
import javax.validation.constraints.Max; | ||
import javax.validation.constraints.Min; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class GetWedprProjectListRequest { | ||
private String ownerAgencyName; | ||
private String projectName; | ||
private String startTime; | ||
private String endTime; | ||
private Integer pageNum = Constant.DEFAULT_PAGE_NUM; | ||
|
||
@Min(value = 5, message = "分页条数最小不能小于5") | ||
@Max(value = 10000, message = "分页条数最大不能大于10000") | ||
private Integer pageSize = Constant.DEFAULT_PAGE_SIZE; | ||
} |
12 changes: 12 additions & 0 deletions
12
...s/admin/src/main/java/com/webank/wedpr/components/admin/response/ListProjectResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.webank.wedpr.components.admin.response; | ||
|
||
import com.webank.wedpr.components.admin.entity.WedprProjectTable; | ||
import java.util.List; | ||
import lombok.Data; | ||
|
||
/** Created by caryliao on 2024/9/5 9:35 */ | ||
@Data | ||
public class ListProjectResponse { | ||
private Long total; | ||
private List<WedprProjectTable> projectList; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 42 additions & 2 deletions
44
...ain/java/com/webank/wedpr/components/admin/service/impl/WedprProjectTableServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,58 @@ | ||
package com.webank.wedpr.components.admin.service.impl; | ||
|
||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||
import com.webank.wedpr.components.admin.common.Utils; | ||
import com.webank.wedpr.components.admin.entity.WedprProjectTable; | ||
import com.webank.wedpr.components.admin.mapper.WedprProjectTableMapper; | ||
import com.webank.wedpr.components.admin.request.GetWedprProjectListRequest; | ||
import com.webank.wedpr.components.admin.response.ListProjectResponse; | ||
import com.webank.wedpr.components.admin.service.WedprProjectTableService; | ||
import java.time.LocalDateTime; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.util.StringUtils; | ||
|
||
/** | ||
* 服务实现类 | ||
* | ||
* @author caryliao | ||
* @since 2024-08-22 | ||
* @since 2024-09-04 | ||
*/ | ||
@Service | ||
public class WedprProjectTableServiceImpl | ||
extends ServiceImpl<WedprProjectTableMapper, WedprProjectTable> | ||
implements WedprProjectTableService {} | ||
implements WedprProjectTableService { | ||
|
||
@Override | ||
public ListProjectResponse listProject(GetWedprProjectListRequest request) { | ||
LambdaQueryWrapper<WedprProjectTable> lambdaQueryWrapper = new LambdaQueryWrapper<>(); | ||
String ownerAgencyName = request.getOwnerAgencyName(); | ||
String projectName = request.getProjectName(); | ||
String startTimeStr = request.getStartTime(); | ||
String endTimeStr = request.getEndTime(); | ||
Integer pageNum = request.getPageNum(); | ||
Integer pageSize = request.getPageSize(); | ||
if (!StringUtils.isEmpty(ownerAgencyName)) { | ||
lambdaQueryWrapper.like(WedprProjectTable::getOwnerAgency, ownerAgencyName); | ||
} | ||
if (!StringUtils.isEmpty(projectName)) { | ||
lambdaQueryWrapper.like(WedprProjectTable::getName, projectName); | ||
} | ||
if (!StringUtils.isEmpty(startTimeStr)) { | ||
LocalDateTime startTime = Utils.getLocalDateTime(startTimeStr); | ||
lambdaQueryWrapper.ge(WedprProjectTable::getCreateTime, startTime); | ||
} | ||
if (!StringUtils.isEmpty(endTimeStr)) { | ||
LocalDateTime endTime = Utils.getLocalDateTime(endTimeStr); | ||
lambdaQueryWrapper.le(WedprProjectTable::getCreateTime, endTime); | ||
} | ||
lambdaQueryWrapper.orderByDesc(WedprProjectTable::getLastUpdateTime); | ||
Page<WedprProjectTable> projectTablePage = new Page<>(pageNum, pageSize); | ||
Page<WedprProjectTable> page = page(projectTablePage, lambdaQueryWrapper); | ||
ListProjectResponse listProjectResponse = new ListProjectResponse(); | ||
listProjectResponse.setTotal(page.getTotal()); | ||
listProjectResponse.setProjectList(page.getRecords()); | ||
return listProjectResponse; | ||
} | ||
} |
Oops, something went wrong.