完善c端接口

This commit is contained in:
menxipeng
2025-07-22 22:10:50 +08:00
parent 2fdda69c61
commit 6fecee904b
17 changed files with 128 additions and 98 deletions

View File

@@ -1,6 +1,9 @@
package com.ruoyi.system.config;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.constant.AliKeyConfig;
import com.ruoyi.common.core.domain.UmResp;
import com.ruoyi.common.enums.DeviceTypeEnum;
import com.ruoyi.common.utils.uuid.UUID;
import org.apache.commons.codec.binary.Base64;
@@ -12,6 +15,8 @@ import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.crypto.Mac;
@@ -23,28 +28,29 @@ import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
@Component
public class UmengConfig {
private static final Logger log = LoggerFactory.getLogger(UmengConfig.class);
public static CloseableHttpResponse send(String token,String deviceTypeUp){
//String umAppkey = null;
//if (deviceTypeUp.equals(DeviceTypeEnum.ANDROID.name())){
// umAppkey = AliKeyConfig.UMApp_Android_Key;
//}else if (deviceTypeUp.equals(DeviceTypeEnum.IOS.name())){
// umAppkey = AliKeyConfig.UMApp_IOS_Key;
//}
////687b2df479267e0210b79b6f
//String appKey = AliKeyConfig.UMApp_AliKey;
//String appSecret = AliKeyConfig.UMApp_AliSecret;
public UmResp send(String token,String deviceTypeUp){
String umAppkey = null;
if (deviceTypeUp.equals(DeviceTypeEnum.ANDROID.name())){
umAppkey = AliKeyConfig.UMApp_Android_Key;
}else if (deviceTypeUp.equals(DeviceTypeEnum.IOS.name())){
umAppkey = AliKeyConfig.UMApp_IOS_Key;
}
//687b2df479267e0210b79b6f
String umAppkey = "687b2e1679267e0210b79b70";
String appKey = "204918113";
String appSecret = "v4UrIhhLZlo0adpmevyCfvThGFbrRer0";
String appKey = AliKeyConfig.UMApp_AliKey;
String appSecret = AliKeyConfig.UMApp_AliSecret;
// if (deviceTypeUp.equals(DeviceTypeEnum.ANDROID.name())){
//
// }
// //687b2df479267e0210b79b6f
// String umAppkey = "687b2e1679267e0210b79b70";
// String appKey = "204918113";
// String appSecret = "v4UrIhhLZlo0adpmevyCfvThGFbrRer0";
// 下面的url要和阿里云云市场购买的商品对应
String url = "https://verify5.market.alicloudapi.com/api/v1/mobile/info?appkey=" + umAppkey;
HttpPost httpPost = new HttpPost(url);
@@ -90,8 +96,11 @@ public class UmengConfig {
*/
CloseableHttpClient httpclient = HttpClients.createDefault();
try {
log.info("发送数据:{}",httpPost);
CloseableHttpResponse response = httpclient.execute(httpPost);
return response;
String respStr = EntityUtils.toString(response.getEntity());
log.info("返回数据:{}",respStr);
return JSONUtil.toBean(respStr, UmResp.class);
} catch (Exception e) {
e.printStackTrace();
}
@@ -101,12 +110,16 @@ public class UmengConfig {
public static void main(String[] args) throws IOException {
System.out.println(DeviceTypeEnum.ANDROID.name());
// CloseableHttpResponse sss = send("1234");
// String reponseContent = EntityUtils.toString(sss.getEntity());
// System.out.println(reponseContent);
// System.out.println(sss.getStatusLine().getReasonPhrase());
public static void main(String[] args) {
// System.out.println(DeviceTypeEnum.ANDROID.name());
// UmResp sss1 = send("eyJvIjoiaU9TIiwiayI6ImJNSGJwMktVdjhVaE5zOW1wQWhwYlwvWCtVRTlqcnZKeXhjb091N3BDdVlqcHNEc2RKM3A2M0pJZ056U0JrdlY5UlFPSHo3U25ZMmNcL3ZpbUI3ZHN2THFwQXlkbmRJeDB4NHhLSytFR2pvVEF4eU1oUnpUVHlrNHYzZThCSjNIajJOamJoK0VPdUtRTXV3N2pnS0dIdHJoT3FJRFF4QXJ0NisrUTI1ODhhQWdEVnp5TUVZdmxpTFhKeDUwS1wvZWI5VjdSb1VoNkMzc2E5Mm1xcHI1S3FxMm9KZHk3THoyYkVPQUVnM1hvWHJWVlwvcmtOMFluV1AyMVBZb0xrVFgxXC84TWZhVXZ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wvcVVSMGRJN25HbER4U1wvWEFFbWNHU0wxcDllczN0U0lsVUIrbHNcL3luWWZFNWNicDIwRE9NV3ZcL0xLa0I2cXA5RkVtaXV6eDY2MWYzZE9hZnk2WUJ2V2dsQnljU05TSkdDNkpYeTZnWHEwR1wvNE9XTkRPdjFhakIxMnhGRk9PK1dhbUVKcG9Takxic0FFV0V5eEtDb3pXaU9meG0ydEJ0bHdoM2hwXC9Vb3RyRCtIbkY2Z1NOOGtCblVtYnJRU3FzYUdsM2g3WDZSZUREbXdRSmMzSzY0QkxNcCJ9", "ios");
// String sss;
//
// sss = "{\"success\":true,\"data\":{\"mobile\":\"18518753918\",\"score\":null,\"activeScore\":null,\"aesEncryptKey\":null},\"code\":2001,\"message\":\"gain mobile's result success\",\"requestId\":\"0E87E249-42A0-42C0-94D3-7424D45E571E\"}\n";
//
// UmResp ss = JSONUtil.toBean(sss, UmResp.class);
// System.out.println(ss);
}
private static String getSignString(HttpPost httpPost) {

View File

@@ -37,7 +37,7 @@ public interface IMusicInfoService
* @param musicInfo 音乐信息
* @return 结果
*/
public int insertMusicInfo(MusicInfo musicInfo, MultipartFile img,MultipartFile music);
public int insertMusicInfo(MusicInfo musicInfo);
/**
* 修改音乐信息

View File

@@ -1,6 +1,9 @@
package com.ruoyi.system.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import com.ruoyi.common.core.domain.UmResp;
import com.ruoyi.common.core.domain.entity.ActivityInfo;
import com.ruoyi.common.core.domain.entity.ShopUser;
import com.ruoyi.common.core.domain.entity.ShopUserResq;
@@ -46,12 +49,13 @@ public class CShopUserServiceImpl implements ShopUserService {
}
case "2":
// 验证码
String code = redisCache.getCacheObject("sms_code:"+shopUser.getPhone());
//String code = redisCache.getCacheObject("sms_code:"+shopUser.getPhone());
// TODO:写死
code="9527";
String code="9527";
String reqCode = shopUser.getCode();
if (code != null && code.equals(reqCode)){
// 登录
shopUser.setUsername(shopUser.getPhone());
return loginAndRegis(shopUser);
}else {
ShopUser msg = new ShopUser();
@@ -60,10 +64,15 @@ public class CShopUserServiceImpl implements ShopUserService {
}
case "3":
// 一键 todo 完善功能
String uMtoken = shopUser.getUMtoken();
String uMtoken = shopUser.getToken();
String deviceType = shopUser.getDeviceType();
String deviceTypeUp = deviceType.toUpperCase();
umengConfig.send(uMtoken,deviceTypeUp);
UmResp resp = umengConfig.send(uMtoken, deviceTypeUp);
if (resp != null && resp.isSuccess()){
String phone = (String) resp.getData().get("mobile");
shopUser.setPhone(phone);
return loginAndRegis(shopUser);
}
break;
}
return null;
@@ -113,12 +122,15 @@ public class CShopUserServiceImpl implements ShopUserService {
public ShopUser loginAndRegis(ShopUserResq shopUser) {
ShopUser member = shopUserMapper.selectShopUserByPhone(shopUser.getPhone());
if (StringUtils.isNull(member)) {
if (shopUser.getPhone() != null && StringUtils.isNull(member)) {
// 走注册在登录
member = new ShopUser();
member.setUserId(IdUtil.getSnowflakeNextId());
member.setUsername(shopUser.getPhone());
member.setPhone(shopUser.getPhone());
member.setStatus(1L);
member.setVip(2L);
member.setRegisterTime(new Date());
member.setPassword(IdUtil.fastUUID());
member.setUsername(shopUser.getUsername());
member.setDeviceId(shopUser.getDeviceId());

View File

@@ -74,21 +74,14 @@ public class MusicInfoServiceImpl implements IMusicInfoService
* @return 结果
*/
@Override
public int insertMusicInfo(MusicInfo musicInfo, MultipartFile img, MultipartFile music)
public int insertMusicInfo(MusicInfo musicInfo)
{
musicInfo.setCreateTime(DateUtils.getNowDate());
musicInfo.setMusicId(IdUtil.getSnowflakeNextId());
try {
String imgAddr = AliConfig.ossUp("musicImg/" , img.getOriginalFilename(), img.getInputStream());
String musicAddr = AliConfig.ossUp("musicFile/" , music.getOriginalFilename(), music.getInputStream());
musicInfo.setMusicAddr(musicAddr);
musicInfo.setImgAddr(imgAddr);
musicInfo.setMusicType(MusicType.ORDINARY.getMusicType());
musicInfo.setCreator(SecurityUtils.getUsername());
musicInfo.setShelf(2L);
} catch (IOException e) {
throw new RuntimeException(e);
}
musicInfo.setMusicType(MusicType.ORDINARY.getMusicType());
musicInfo.setCreator(SecurityUtils.getUsername());
musicInfo.setShelf(2L);
return musicInfoMapper.insertMusicInfo(musicInfo);
}

View File

@@ -20,10 +20,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="isDel" column="is_del" />
<result property="label" column="label" />
<result property="fileType" column="file_type"/>
</resultMap>
<sql id="selectMusicInfoVo">
select id, music_id, name, author, vip, shelf, img_addr, music_addr, music_type, creator, modify, create_time, update_time, is_del, label from music_info
select id, music_id, name, author, vip, shelf, img_addr, music_addr, music_type, creator, modify, create_time, update_time, is_del, label,file_type from music_info
</sql>
<select id="selectMusicInfoList" parameterType="MusicInfo" resultMap="MusicInfoResult">
@@ -66,6 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time,</if>
<if test="isDel != null">is_del,</if>
<if test="label != null">label,</if>
<if test="fileType != null">file_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="musicId != null">#{musicId},</if>
@@ -82,6 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">#{updateTime},</if>
<if test="isDel != null">#{isDel},</if>
<if test="label != null">#{label},</if>
<if test="fileType != null">#{fileType},</if>
</trim>
</insert>
@@ -102,6 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="label != null">label = #{label},</if>
<if test="fileType != null">file_type = #{fileType},</if>
</trim>
where id = #{id}
</update>