Skip to content

Commit

Permalink
Merge pull request alibaba#550 from sjssj/feature_complete_craftsman_…
Browse files Browse the repository at this point in the history
…samples

optimize craftsman sample
  • Loading branch information
significantfrank authored Nov 26, 2024
2 parents bda5047 + 2684639 commit 09ce216
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.alibaba.craftsman.command;

import com.alibaba.cola.dto.Response;
import com.alibaba.craftsman.domain.gateway.MetricGateway;
import com.alibaba.craftsman.dto.MetricDeleteCmd;
import com.alibaba.craftsman.gatewayimpl.database.MetricMapper;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
Expand All @@ -17,12 +17,12 @@
public class MetricDeleteCmdExe{

@Resource
private MetricMapper metricMapper;
private MetricGateway metricGateway;

public Response execute(MetricDeleteCmd cmd) {

metricMapper.delete(cmd.getMetricId(), cmd.getOperater());
metricGateway.delete(cmd.getMetricId(), cmd.getOperater());

return Response.buildSuccess();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ public interface MetricGateway {
List<SubMetric> listByTechInfluence(String userId);
BugMetric getBugMetric(String userId);
AppMetric getAppMetric(String userId);
void delete(String id, String operator);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.alibaba.craftsman.gatewayimpl;

import com.alibaba.craftsman.common.event.DomainEventPublisher;
import com.alibaba.craftsman.convertor.MetricConvertor;
import com.alibaba.craftsman.domain.gateway.MetricGateway;
import com.alibaba.craftsman.domain.metrics.MainMetricType;
import com.alibaba.craftsman.domain.metrics.MetricItem;
Expand All @@ -19,7 +20,6 @@
import com.alibaba.craftsman.gatewayimpl.rpc.BugMetricMapper;
import com.alibaba.craftsman.gatewayimpl.rpc.dataobject.AppMetricDO;
import com.alibaba.craftsman.gatewayimpl.rpc.dataobject.BugMetricDO;
import com.alibaba.craftsman.convertor.MetricConvertor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -51,6 +51,7 @@ public class MetricGatewayImpl implements MetricGateway {
private DomainEventPublisher domainEventPublisher;


@Override
public void save(MetricItem metricItem){
MetricDO metricDO = MetricConvertor.toDataObject(metricItem);

Expand All @@ -64,6 +65,7 @@ public void save(MetricItem metricItem){
domainEventPublisher.publish(metricItemCreatedEvent);
}

@Override
public List<SubMetric> listByTechContribution(String userId){
List<MetricDO> metricDOList = metricMapper.listByMainMetric(userId, MainMetricType.TECH_CONTRIBUTION.getMetricCode());
RefactoringMetric refactoringMetric = new RefactoringMetric();
Expand Down Expand Up @@ -92,6 +94,7 @@ public List<SubMetric> listByTechContribution(String userId){
return subMetricList;
}

@Override
public List<SubMetric> listByTechInfluence(String userId){
List<MetricDO> metricDOList = metricMapper.listByMainMetric(userId, MainMetricType.TECH_INFLUENCE.getMetricCode());
ATAMetric ataMetric = new ATAMetric();
Expand Down Expand Up @@ -124,6 +127,7 @@ public List<SubMetric> listByTechInfluence(String userId){
return subMetricList;
}

@Override
public BugMetric getBugMetric(String userId){
BugMetricDO bugMetricDO = bugMetricMapper.getByUserId(userId);
BugMetricItem bugMetricItem = new BugMetricItem(bugMetricDO.getBugCount(), bugMetricDO.getCheckInCodeCount());
Expand All @@ -132,6 +136,7 @@ public BugMetric getBugMetric(String userId){
return bugMetric;
}

@Override
public AppMetric getAppMetric(String userId){
List<AppMetricDO> appMetricDOList = appMetricMapper.listByUserId(userId);
AppMetric appMetric = new AppMetric();
Expand All @@ -142,4 +147,9 @@ public AppMetric getAppMetric(String userId){
});
return appMetric;
}

@Override
public void delete(String id, String operator) {
metricMapper.delete(id, operator);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ public class UserProfileGatewayImpl implements UserProfileGateway {
private UserProfileMapper userProfileMapper;


@Override
public void create(UserProfile userProfile) {
userProfileMapper.create(UserProfileConvertor.toDataObjectForCreate(userProfile));
}

@Override
public void update(UserProfile userProfile) {
userProfileMapper.update(UserProfileConvertor.toDataObjectForUpdate(userProfile));
}

@Override
public UserProfile getByUserId(String userId) {
UserProfileDO userProfileDO = userProfileMapper.getByUserId(userId);
if (userProfileDO == null) {
Expand Down

0 comments on commit 09ce216

Please sign in to comment.