完善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

@@ -36,7 +36,7 @@ public class ActivityInfoController extends BaseController
/**
* 查询【请填写功能名称】列表
*/
@PreAuthorize("@ss.hasPermi('system:info:list')")
// @PreAuthorize("@ss.hasPermi('system:info:list')")
@GetMapping("/list")
public TableDataInfo list(ActivityInfo activityInfo)
{
@@ -74,20 +74,14 @@ public class ActivityInfoController extends BaseController
// @PreAuthorize("@ss.hasPermi('system:info:add')")
// @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
@PostMapping("/addActivity")
public AjaxResult add(
@RequestParam("name") String name,
@RequestParam("content") String content,
@RequestParam("startTime") String startTime,
@RequestParam("endTime") String endTime,
@RequestParam("file") MultipartFile file
) throws IOException {
ActivityInfo activityInfo = new ActivityInfo();
String imgAddr = AliConfig.ossUp("config/" , Objects.requireNonNull(file.getOriginalFilename()), file.getInputStream());
activityInfo.setImg("");
activityInfo.setName(name);
activityInfo.setContent(content);
activityInfo.setStartTime(DateUtil.parseDateTime(startTime));
activityInfo.setEndTime(DateUtil.parseDateTime(endTime));
public AjaxResult add(@RequestBody ActivityInfo activityInfo) throws IOException {
// ActivityInfo activityInfo = new ActivityInfo();
// String imgAddr = AliConfig.ossUp("config/" , Objects.requireNonNull(file.getOriginalFilename()), file.getInputStream());
// activityInfo.setImg("");
// activityInfo.setName(name);
// activityInfo.setContent(content);
// activityInfo.setStartTime(DateUtil.parseDateTime(startTime));
// activityInfo.setEndTime(DateUtil.parseDateTime(endTime));
return toAjax(activityInfoService.insertActivityInfo(activityInfo));
}

View File

@@ -3,7 +3,6 @@ package com.ruoyi.web.controller.back;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.BannerInfo;
import com.ruoyi.common.core.domain.entity.MusicInfo;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
@@ -12,7 +11,6 @@ import com.ruoyi.system.service.IMusicInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@@ -122,26 +120,7 @@ public class MusicInfoController extends BaseController
//@PreAuthorize("@ss.hasPermi('system:info:add')")
//@Log(title = "音乐信息", businessType = BusinessType.INSERT)
@PostMapping("/addMusic")
public AjaxResult add(
@RequestParam("name") String name,
@RequestParam("author") String author,
@RequestParam("vip") long vip,
@RequestParam("label") String label,
@RequestParam("img") MultipartFile img,
@RequestParam("music") MultipartFile music
) {
// 1. 处理文件上传
if (music != null && !music.isEmpty()) {
// 保存文件逻辑
// String url = fileService.save(file);
// bannerInfo.setImageUrl(url);
}
// 2. 保存bannerInfo
MusicInfo musicInfo = new MusicInfo();
musicInfo.setName(name);
musicInfo.setAuthor(author);
musicInfo.setVip(vip);
musicInfo.setLabel(label);
return toAjax(musicInfoService.insertMusicInfo(musicInfo,img,music));
public AjaxResult add(@RequestBody MusicInfo musicInfo) {
return toAjax(musicInfoService.insertMusicInfo(musicInfo));
}
}

View File

@@ -31,7 +31,7 @@ public class MusicSceneController extends BaseController
/**
* 查询【请填写功能名称】列表
*/
@PreAuthorize("@ss.hasPermi('system:scene:list')")
// @PreAuthorize("@ss.hasPermi('system:scene:list')")
@GetMapping("/list")
public TableDataInfo list(MusicScene musicScene)
{

View File

@@ -47,8 +47,8 @@ public class ClientShopUserController {
{
AjaxResult ajax = AjaxResult.success();
ShopUser shopUser = shopUserService.login(userResq);
if (shopUser.getMsg() != null){
return AjaxResult.error(shopUser.getMsg());
if (shopUser == null || shopUser.getMsg() != null){
return new AjaxResult(999,"登录失败");
}else {
// 生成令牌
String token = loginService.shopUserLogin(shopUser.getUsername(), shopUser.getPassword());

View File

@@ -0,0 +1,31 @@
package com.ruoyi.common.core.domain;
import lombok.Data;
import java.util.Map;
@Data
public class UmResp {
//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"
private boolean success;
private Map<String,Object> data;
private String code;
private String message;
private String requestId;
}

View File

@@ -74,4 +74,6 @@ public class MusicInfo extends BaseEntity
private MusicSceneRelate musicScene;
private String fileType;
}

View File

@@ -19,11 +19,13 @@ public class ShopUserResq {
private Long userId;
private String uMtoken;
private String uMTk;
private String code;
private String deviceType;
private String deviceId;
private String token;
}

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("eyJvIjoiaU9TIiwiayI6ImJNSGJwMktVdjhVaE5zOW1wQWhwYlwvWCtVRTlqcnZKeXhjb091N3BDdVlqcHNEc2RKM3A2M0pJZ056U0JrdlY5Ul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QRzdPcGN2bXhuSkF4bTJYNTFkQUZtaTdsSjZuZlc0MlJSNDRZWDBtMlhkczAwY3hZa2s5Q29zeVdWVUdGUkVDMjdjUUFURU9PMWp2TzdlMHEwOTRLZjdnaEx2UFJadlo2bFIxSUxmTTJxeWlQc0V5dmRiSUJyaG1yVEtJOWdqRW5Qc3U2dEZPc1RiZ0oxaVwvNGZBRFBKWDhOczF1Ym9taVl2KzZnVGsyNzlZTmQ3WU9OT21mMzlTOG05RktrNEN3Uk1QT1wvcVVSMGRJN25HbER4U1wvWEFFbWNHU0wxcDllczN0U0lsVUIrbHNcL3luWWZFNWNicDIwRE9NV3ZcL0xLa0I2cXA5RkVtaXV6eDY2MWYzZE9hZnk2WUJ2V2dsQnljU05TSkdDNkpYeTZnWHEwR1wvNE9XTkRPdjFhakIxMnhGRk9PK1dhbUVKcG9Takxic0FFV0V5eEtDb3pXaU9meG0ydEJ0bHdoM2hwXC9Vb3RyRCtIbkY2Z1NOOGtCblVtYnJRU3FzYUdsM2g3WDZSZUREbXdRSmMzSzY0QkxNcCJ9", "ios");
// String sss;
//
// sss = "{\"success\":true,\"data\":{\"mobile\":\"18518753918\",\"score\":null,\"activeScore\":null,\"aesEncryptKey\":null},\"code\":2001,\"message\":\"gain mobile&#39;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);
}
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>

View File

@@ -3,7 +3,7 @@ import request from '@/utils/request'
// 查询会员记录列表
export function listMember(query) {
return request({
url: '/back/member/list',
url: '/back/user/list',
method: 'get',
params: query
})

View File

@@ -3,7 +3,7 @@ import request from '@/utils/request'
// 查询普通歌曲列表
export function listNormalSong(query) {
return request({
url: '/back/normal/list',
url: '/back/music/list',
method: 'get',
params: query
})

View File

@@ -3,7 +3,7 @@ import request from '@/utils/request'
// 查询混音歌曲列表
export function listRemixSong(query) {
return request({
url: '/back/remix/list',
url: '/back/music/list',
method: 'get',
params: query
})

View File

@@ -125,10 +125,10 @@
<!-- 添加或修改普通歌曲对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="音乐名称" prop="musicName" required>
<el-form-item label="音乐名称" prop="name" required>
<el-input v-model="form.musicName" placeholder="请输入音乐名称" />
</el-form-item>
<el-form-item label="制作人" prop="producer" required>
<el-form-item label="制作人" prop="author" required>
<el-input v-model="form.producer" placeholder="请输入制作人" />
</el-form-item>
<el-form-item label="文件类型" prop="fileType" required>

View File

@@ -9,7 +9,7 @@ const CompressionPlugin = require('compression-webpack-plugin')
const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题
const baseUrl = 'http://60.205.107.210:8080' // 后端接口
const baseUrl = 'http://localhost:8080' // 后端接口
const port = process.env.port || process.env.npm_config_port || 80 // 端口