Skip to content

Commit

Permalink
Add some administrator functions
Browse files Browse the repository at this point in the history
These features are not perfect.
  • Loading branch information
KADGang committed Jun 7, 2022
1 parent 3ce5858 commit 947eb7a
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ protected void configure(HttpSecurity http) throws Exception {
.and()
.formLogin()
.loginProcessingUrl("/admin/login")
// .loginPage("/login") //TODO:实现自定义登录
.permitAll();
.permitAll()
.and()
.csrf().disable();//TODO:尝试在qiusheng-terminal中加入csrf防护
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public interface ChartDao {
Integer findSidByCid(@Param("cid") int cid);
void uploadChartMsg(Chart chart);
void updateChart(Chart chart);
int deleteChart(@Param("cid") int cid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public interface EventDao {
String findCidListByEid(@Param("eid") int eid);
void addEvent(Event event);
void updateEvent(Event event);
int deleteEvent(@Param("eid") int eid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ public interface SongDao {
void updateSong(Song song);
void updateLengthBySid(@Param("sid") int sid, @Param("length") int length);
void updateSongMD5PathBySid(Song song);
int deleteSong(@Param("sid") int sid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,21 @@ public DownloadResult chartDownload(@RequestParam(required = false) int cid) {
return new DownloadResult(0, items, chart.getSid(), chart.getCid());
}

@PostMapping("/admin/store/deleteChart")
@ResponseBody
public int deleteChart(@RequestParam int cid) {
int deleteCode = chartDao.deleteChart(cid);
//TODO:添加删除铺面文件的选项与逻辑

if (deleteCode == 0) {
log.info("删除谱面(cid: " + cid + ")时出错,可能原因为数据库中并未存在该谱面");
return 1;
} else
log.info("成功删除谱面(cid: " + cid + ")");

return 0;
}

//返回代码类
@Data
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,15 @@ public void addEvent(@RequestBody(required = false) Event event) {
public void updateEvent(@RequestBody(required = false) Event event) {
eventDao.updateEvent(event);
}

@PostMapping("/admin/event/delete")
@ResponseBody
public void deleteEvent(@RequestParam(required = false) int eid) {
int deleteCode = eventDao.deleteEvent(eid);

if (deleteCode == 0)
log.info("删除活动(eid: " + eid + ")时出错,可能原因为数据库中并未存在该事件");
else
log.info("成功删除活动(eid: " + eid + ")");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,21 @@ public ListResult<SongResult> storePromote(@RequestParam(required = false) Integ
return new ListResult<>(1,false,0, result);
}


@PostMapping("/admin/store/deleteSong")
@ResponseBody
public int deleteSong(@RequestParam int sid) {
//TODO:添加删除歌曲以下所有铺面文件的选项与逻辑


int deleteCode = songDao.deleteSong(sid);

if (deleteCode == 0) {
log.info("删除谱面(cid: " + sid + ")时出错,可能原因为数据库中并未存在该谱面");
return 1;
} else
log.info("成功删除谱面(cid: " + sid + ")");

return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.extern.slf4j.Slf4j;
import org.pockettech.qiusheng.dao.AdminDao;
import org.pockettech.qiusheng.entity.userrole.Admin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
Expand Down
4 changes: 4 additions & 0 deletions qiusheng-core/src/main/resources/mapping/ChartMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,9 @@
type = #{type},size = #{size},c_mode = #{c_mode},c_md5 = ifnull(#{c_md5},c_md5),c_file_path = #{c_file_path}
where cid = #{cid}
</update>

<delete id="deleteChart" parameterType="java.lang.Integer">
delete from chart where cid = #{cid}
</delete>
</mapper>

4 changes: 4 additions & 0 deletions qiusheng-core/src/main/resources/mapping/EventMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@
start = #{start}, end = #{end}, cover = #{cover}, active = #{active}, cid_list = #{cid_list}
where eid = #{eid}
</update>

<delete id="deleteEvent" parameterType="java.lang.Integer">
delete from events where eid = #{eid}
</delete>
</mapper>

4 changes: 4 additions & 0 deletions qiusheng-core/src/main/resources/mapping/SongMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,9 @@
<update id="updateImgMD5PathBySid" parameterType="org.pockettech.qiusheng.entity.data.Song">
update song set img_md5 = #{img_md5}, img_file_path = #{img_file_path} where sid = #{sid}
</update>

<delete id="deleteSong" parameterType="java.lang.Integer">
delete from song where sid = #{sid}
</delete>
</mapper>

0 comments on commit 947eb7a

Please sign in to comment.