public ResponseResultDto <int> AddSongInfo(UploadSongParam song) { if (song.SingerId < 1 || string.IsNullOrWhiteSpace(song.SongName) || string.IsNullOrWhiteSpace(song.SongPath) || string.IsNullOrWhiteSpace(song.SongLength) || song.SongSize < 0) { return(new ResponseResultDto <int> { IsSuccess = false, ErrorMessage = "参数异常", Result = 0 }); } HttpRequest request = HttpContext.Current.Request; string token = request.Headers.GetValues("Access-Token").FirstOrDefault(); var result = singerSongApiRepository.AddSongInfo(song, token); //int songId = singerSongApiRepository.AddSongInfo(song,token); return(new ResponseResultDto <int> { IsSuccess = result.Item1, ErrorMessage = result.Item2, Result = result.Item3 //上传歌曲后,返回歌曲Id }); }
/// <summary> /// 上传歌曲,添加歌曲信息 /// </summary> /// <param name="song"></param> /// <returns></returns> public Tuple <bool, string, int> AddSongInfo(UploadSongParam song, string token) { SingerDetailInfoEntity user = helper.Query <SingerDetailInfoEntity>($@"select c.* from [User] a left join [UserAccessToken] b on a.Id=b.UserId left join SingerDetailInfo c on c.UserId=a.Id where b.TokenId='{token}'").FirstOrDefault(); if (user == null) { return(Tuple.Create(false, "用户还未登录", 0)); } if (user.Authentication != 3) { return(Tuple.Create(false, "音乐人未认证,无法上传歌曲", 0)); } var p = new DynamicParameters(); p.Add("@Id", dbType: DbType.Int32, direction: ParameterDirection.Output); var result = helper.Execute($@"insert into SongBook (SongName,SingerName,SingerId, SongLength,CopyrightFilePath,SongPath,SongSize,UploadTime,AuditStatus,Status,ExpirationTime) values ('{song.SongName}','{song.SingerName}',{song.SingerId},'{song.SongLength}', '{song.CopyrightFilePath}','{song.SongPath}',{song.SongSize},'{DateTime.Now}',{0},{1},'2100-01-01'); SELECT @Id=SCOPE_IDENTITY()", p); helper.Execute($@"insert into SongOptDetail (SongId,AuditTimes,AuditStatus,Note,OptType,OptTime) values ({song.Id},{0},{0},'音乐人上传歌曲',{1},'{DateTime.Now}')"); var tt = p.Get <int>("@Id"); return(Tuple.Create(true, "", tt)); }
/// <summary> /// 更新歌曲信息 /// </summary> /// <param name="song"></param> /// <returns></returns> public bool UpdateSongInfo(UploadSongParam song) { string sql = $@"update SongBook set SongName='{song.SongName}',SongLength='{song.SongLength}', CopyrightFilePath='{song.CopyrightFilePath}',SongPath='{song.SongPath}',SongSize={song.SongSize} where Id={song.Id}; insert into SongOptDetail (SongId,AuditTimes,AuditStatus,Note,OptType,OptTime) values ({song.Id},{0},{0},'音乐人修改歌曲信息',{3},'{DateTime.Now}')"; var result = helper.Execute(sql); return(result > 0 ? true : false); }
public ResponseResultDto <bool> UpdateSongInfo(UploadSongParam song) { if (song.Id < 1 || song.SingerId < 1 || string.IsNullOrWhiteSpace(song.SongName) || string.IsNullOrWhiteSpace(song.SongPath) || string.IsNullOrWhiteSpace(song.SongLength) || song.SongSize < 0) { return(new ResponseResultDto <bool> { IsSuccess = false, ErrorMessage = "参数异常", Result = false }); } var result = singerSongApiRepository.UpdateSongInfo(song); return(new ResponseResultDto <bool> { IsSuccess = result, ErrorMessage = string.Empty, Result = result }); }