Browse Source

[Fix-5518]: The user definition count interface, projectId change to projectCode (#5839)

* fix: the data analysis state count interface, projectId change to projectCode

* fix: the data analysis state count interface, projectId change to projectCode

* fix checkstyle

* fix checkstyle

* fix: the process state count page use "projectCode"

* fix: English comments

* fix: the user definition count interface, projectId change to projectCode

* fix comment

Co-authored-by: wen-hemin <wenhemin@apache.com>
2.0.7-release
wen-hemin 3 years ago committed by GitHub
parent
commit
90a9a7283c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java
  2. 4
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataAnalysisService.java
  3. 31
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java
  4. 2
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataAnalysisControllerTest.java
  5. 9
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java
  6. 8
      dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/index/_source/defineUserCount.vue
  7. 10
      dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/index/index.vue
  8. 2
      dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/list/_source/list.vue
  9. 2
      dolphinscheduler-ui/src/js/conf/home/router/index.js

10
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java

@ -118,21 +118,21 @@ public class DataAnalysisController extends BaseController {
* statistics the process definition quantities of certain person
*
* @param loginUser login user
* @param projectId project id
* @return definition count in project id
* @param projectCode project code
* @return definition count in project code
*/
@ApiOperation(value = "countDefinitionByUser", notes = "COUNT_PROCESS_DEFINITION_BY_USER_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectId", value = "PROJECT_ID", dataType = "Int", example = "100")
@ApiImplicitParam(name = "projectCode", value = "PROJECT_CODE", dataType = "Long", example = "100")
})
@GetMapping(value = "/define-user-count")
@ResponseStatus(HttpStatus.OK)
@ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result countDefinitionByUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "projectId", required = false, defaultValue = "0") int projectId) {
@RequestParam(value = "projectCode", required = false, defaultValue = "0") long projectCode) {
Map<String, Object> result = dataAnalysisService.countDefinitionByUser(loginUser, projectId);
Map<String, Object> result = dataAnalysisService.countDefinitionByUser(loginUser, projectCode);
return returnDataList(result);
}

4
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataAnalysisService.java

@ -52,10 +52,10 @@ public interface DataAnalysisService {
* statistics the process definition quantities of certain person
*
* @param loginUser login user
* @param projectId project id
* @param projectCode project code
* @return definition count data
*/
Map<String, Object> countDefinitionByUser(User loginUser, int projectId);
Map<String, Object> countDefinitionByUser(User loginUser, long projectCode);
/**
* statistical command status data

31
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java

@ -132,10 +132,14 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
private Map<String, Object> countStateByProject(User loginUser, long projectCode, String startDate, String endDate
, TriFunction<Date, Date, Long[], List<ExecuteStatusCount>> instanceStateCounter) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, project.getName());
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
Map<String, Object> result = new HashMap<>();
if (projectCode != 0) {
Project project = projectMapper.queryByCode(projectCode);
result = projectService.checkProjectAndAuth(loginUser, project, project.getName());
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
}
Date start = null;
@ -167,18 +171,23 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
* statistics the process definition quantities of certain person
*
* @param loginUser login user
* @param projectId project id
* @param projectCode project code
* @return definition count data
*/
@Override
public Map<String, Object> countDefinitionByUser(User loginUser, int projectId) {
public Map<String, Object> countDefinitionByUser(User loginUser, long projectCode) {
Map<String, Object> result = new HashMap<>();
boolean checkProject = checkProject(loginUser, projectId, result);
if (!checkProject) {
return result;
if (projectCode != 0) {
Project project = projectMapper.queryByCode(projectCode);
result = projectService.checkProjectAndAuth(loginUser, project, project.getName());
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
}
Long[] projectCodeArray = projectId == 0 ? getProjectCodesArrays(loginUser)
: new Long[] { projectMapper.selectById(projectId).getCode() };
Long[] projectCodeArray = projectCode == 0 ? getProjectCodesArrays(loginUser)
: new Long[] { projectCode };
List<DefinitionGroupByUser> defineGroupByUsers = processDefinitionMapper.countDefinitionGroupByUser(
loginUser.getId(), projectCodeArray, isAdmin(loginUser));

2
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataAnalysisControllerTest.java

@ -92,7 +92,7 @@ public class DataAnalysisControllerTest extends AbstractControllerTest {
@Test
public void testCountDefinitionByUser() throws Exception {
PowerMockito.when(projectMapper.selectById(Mockito.any())).thenReturn(getProject("test"));
PowerMockito.when(projectMapper.queryByCode(Mockito.any())).thenReturn(getProject("test"));
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("projectId","16");

9
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java

@ -237,10 +237,15 @@ public class DataAnalysisServiceTest {
@Test
public void testCountDefinitionByUser() {
Mockito.when(projectMapper.selectById(Mockito.any())).thenReturn(getProject("test"));
Mockito.when(projectMapper.queryByCode(Mockito.any())).thenReturn(getProject("test"));
Map<String, Object> result = new HashMap<>();
putMsg(result, Status.SUCCESS, null);
Mockito.when(projectService.checkProjectAndAuth(any(), any(), any())).thenReturn(result);
Mockito.when(processDefinitionMapper.countDefinitionGroupByUser(Mockito.anyInt(), Mockito.any(Long[].class),
Mockito.anyBoolean())).thenReturn(new ArrayList<DefinitionGroupByUser>());
Map<String, Object> result = dataAnalysisServiceImpl.countDefinitionByUser(user, 0);
result = dataAnalysisServiceImpl.countDefinitionByUser(user, 0);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}

8
dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/index/_source/defineUserCount.vue

@ -38,11 +38,11 @@
return {
isSpin: true,
msg: true,
parameter: { projectId: 0 }
parameter: { projectCode: 0 }
}
},
props: {
projectId: Number
projectCode: Number
},
methods: {
...mapActions('projects', ['getDefineUserCount']),
@ -57,7 +57,7 @@
const myChart = Chart.bar('#process-definition-bar', this.defineUserList, {})
myChart.echart.setOption(bar)
// Jump not allowed on home page
if (this.projectId) {
if (this.projectCode) {
myChart.echart.on('click', e => {
this.$router.push({
name: 'projects-definition-list',
@ -71,7 +71,7 @@
},
created () {
this.isSpin = true
this.parameter.projectId = this.projectId
this.parameter.projectCode = this.projectCode
this.getDefineUserCount(this.parameter).then(res => {
this.msg = res.data.count > 0
this.defineUserList = []

10
dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/index/index.vue

@ -56,7 +56,7 @@
<span>{{$t('Process Definition Statistics')}}</span>
</div>
<div>
<m-define-user-count :project-id="searchParams.projectId">
<m-define-user-count :project-code="searchParams.projectCode">
</m-define-user-count>
</div>
</div>
@ -71,7 +71,6 @@
import mDefineUserCount from './_source/defineUserCount'
import mTaskStatusCount from './_source/taskStatusCount'
import mProcessStateCount from './_source/processStateCount'
import localStore from '@/module/util/localStorage'
import mListConstruction from '@/module/components/listConstruction/listConstruction'
export default {
@ -79,7 +78,6 @@
data () {
return {
searchParams: {
projectId: null,
projectCode: null,
startDate: '',
endDate: ''
@ -87,9 +85,6 @@
dataTime: []
}
},
props: {
id: Number
},
methods: {
_datepicker (val) {
this.searchParams.startDate = val[0]
@ -97,8 +92,7 @@
}
},
created () {
this.searchParams.projectId = this.id === 0 ? 0 : localStore.getItem('projectId')
this.searchParams.projectCode = this.id === 0 ? 0 : localStore.getItem('projectCode')
this.searchParams.projectCode = this.$route.params.projectCode == null ? 0 : this.$route.params.projectCode
this.dataTime[0] = dayjs().format('YYYY-MM-DD 00:00:00')
this.dataTime[1] = dayjs().format('YYYY-MM-DD HH:mm:ss')
this.searchParams.startDate = this.dataTime[0]

2
dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/list/_source/list.vue

@ -97,7 +97,7 @@
localStore.setItem('projectId', item.id)
localStore.setItem('projectCode', item.code)
localStore.setItem('projectName', item.name)
this.$router.push({ path: `/projects/${item.id}/index` })
this.$router.push({ path: `/projects/${item.code}/index` })
},
/**
* Delete Project

2
dolphinscheduler-ui/src/js/conf/home/router/index.js

@ -83,7 +83,7 @@ const router = new Router({
}
},
{
path: '/projects/:projectId/index',
path: '/projects/:projectCode/index',
name: 'projects-index',
component: resolve => require(['../pages/projects/pages/index/index'], resolve),
meta: {

Loading…
Cancel
Save