|
|
|
@ -8,13 +8,20 @@ import com.luoo.music.pojo.ArtistAlbum;
|
|
|
|
|
import com.luoo.music.pojo.ArtistRepresentative;
|
|
|
|
|
import com.luoo.music.pojo.SongInfo;
|
|
|
|
|
import dto.PmsProduct;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
import util.IdWorker;
|
|
|
|
|
|
|
|
|
|
import java.beans.BeanInfo;
|
|
|
|
|
import java.beans.IntrospectionException;
|
|
|
|
|
import java.beans.Introspector;
|
|
|
|
|
import java.beans.PropertyDescriptor;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author: yawei.huang
|
|
|
|
@ -24,6 +31,7 @@ import java.util.List;
|
|
|
|
|
* @Filename: ArtistRepresentativeService
|
|
|
|
|
* @Describe:
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
public class ArtistRepresentativeService {
|
|
|
|
|
|
|
|
|
@ -64,15 +72,16 @@ public class ArtistRepresentativeService {
|
|
|
|
|
case 1:
|
|
|
|
|
// 专辑
|
|
|
|
|
ArtistAlbum artistAlbum = artistAlbumDao.findById(representative.getRepresentativeId()).get();
|
|
|
|
|
representative.setArtistAlbum(artistAlbum);
|
|
|
|
|
artistRepresentative.setArtistAlbum(artistAlbum);
|
|
|
|
|
case 2:
|
|
|
|
|
// 歌曲
|
|
|
|
|
SongInfo songInfo = songInfoDao.findById(representative.getRepresentativeId()).get();
|
|
|
|
|
representative.setSongInfo(songInfo);
|
|
|
|
|
artistRepresentative.setSongInfo(songInfo);
|
|
|
|
|
case 3:
|
|
|
|
|
// 商品
|
|
|
|
|
PmsProduct pmsProduct = restTemplate.getForObject(mallConfig.getProductUrl(), PmsProduct.class);
|
|
|
|
|
representative.setPmsProduct(pmsProduct);
|
|
|
|
|
PmsProduct pmsProduct = restTemplate.getForObject(mallConfig.getProductUrl().replace("{id}", representative.getRepresentativeId()), PmsProduct.class);
|
|
|
|
|
artistRepresentative.setPmsProduct(pmsProduct);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
@ -82,6 +91,39 @@ public class ArtistRepresentativeService {
|
|
|
|
|
return artistRepresentative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Object convertToObject(Class clazz, Map<String, Object> map) throws
|
|
|
|
|
IntrospectionException, InstantiationException, IllegalAccessException {
|
|
|
|
|
BeanInfo bi = Introspector.getBeanInfo(clazz);
|
|
|
|
|
|
|
|
|
|
Object obj = clazz.newInstance();
|
|
|
|
|
|
|
|
|
|
PropertyDescriptor[] pds = bi.getPropertyDescriptors();
|
|
|
|
|
|
|
|
|
|
String pName;
|
|
|
|
|
for (PropertyDescriptor pd : pds) {
|
|
|
|
|
pName = pd.getName();
|
|
|
|
|
if (map.containsKey(pName)) {
|
|
|
|
|
try {
|
|
|
|
|
if (pd.getPropertyType().getName().equals("java.lang.Long")) {
|
|
|
|
|
if(StringUtils.isNotEmpty(map.get(pName).toString())){
|
|
|
|
|
pd.getWriteMethod().invoke(obj, Long.parseLong(map.get(pName).toString()));
|
|
|
|
|
}
|
|
|
|
|
// else{
|
|
|
|
|
// pd.getWriteMethod().invoke(obj, map.get(pName));
|
|
|
|
|
// }
|
|
|
|
|
} else {
|
|
|
|
|
pd.getWriteMethod().invoke(obj, map.get(pName));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置代表作
|
|
|
|
|
*
|
|
|
|
|