|
@ -18,8 +18,10 @@ import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.util.ReflectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@ -132,7 +134,8 @@ public class AdminTeamController extends BaseController {
|
|
|
try {
|
|
|
List<Doctor> members = memberService.getMembers(teamId);
|
|
|
|
|
|
return write(200, "OK", "data", new JSONArray(members));
|
|
|
return write(200, "OK", "data", new JSONArray(copyBeans(members, "id", "code", "name", "hospital",
|
|
|
"jobName", "level", "sex", "photo")));
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, e.getMessage());
|
|
@ -203,7 +206,7 @@ public class AdminTeamController extends BaseController {
|
|
|
public String getDoctorSignPatientCount(@PathVariable("team_id") long teamId) {
|
|
|
try {
|
|
|
List<Doctor> members = memberService.getMembers(teamId);
|
|
|
Map<String, Integer> counts = memberService.getMemberSigningCount(members);
|
|
|
Map<String, Integer> counts = memberService.getMemberSigningCount(teamId, members);
|
|
|
|
|
|
return write(200, "OK", "data", new JSONObject(counts));
|
|
|
} catch (Exception e) {
|
|
@ -245,4 +248,36 @@ public class AdminTeamController extends BaseController {
|
|
|
return error(-1, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private List<Map<String, Object>> copyBeans(Collection<? extends Object> beans, String...propertyNames){
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
for (Object bean : beans){
|
|
|
result.add(copyBeanProperties(bean, propertyNames));
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 复制特定属性。
|
|
|
*
|
|
|
* @param bean
|
|
|
* @param propertyNames
|
|
|
* @return
|
|
|
*/
|
|
|
private Map<String, Object> copyBeanProperties(Object bean, String...propertyNames){
|
|
|
Map<String, Object> simplifiedBean = new HashMap<>();
|
|
|
for (String propertyName : propertyNames){
|
|
|
Field field = ReflectionUtils.findField(bean.getClass(), propertyName);
|
|
|
if (field != null){
|
|
|
field.setAccessible(true);
|
|
|
Object value = ReflectionUtils.getField(field, bean);
|
|
|
simplifiedBean.put(propertyName, value == null ? "" : value);
|
|
|
} else {
|
|
|
simplifiedBean.put(propertyName, "");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return simplifiedBean;
|
|
|
}
|
|
|
}
|