Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
|
bd728480a9 |
|
@ -2,6 +2,7 @@ package org.jeecg;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
|
@ -18,6 +19,7 @@ import java.net.UnknownHostException;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
//@MapperScan("org.jeecg.cool.music.mapper")
|
||||||
//@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})
|
//@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})
|
||||||
public class JeecgSystemApplication extends SpringBootServletInitializer {
|
public class JeecgSystemApplication extends SpringBootServletInitializer {
|
||||||
|
|
||||||
|
@ -41,4 +43,4 @@ public class JeecgSystemApplication extends SpringBootServletInitializer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package org.jeecg.modules.cool.music.controller;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.sf.json.JSONArray;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.modules.cool.music.service.MusicService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Api(tags = "流行音乐分析平台")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/cool/music")
|
||||||
|
@Slf4j
|
||||||
|
public class DashboardController {
|
||||||
|
@Autowired
|
||||||
|
MusicService musicService;
|
||||||
|
|
||||||
|
@GetMapping("/getRanking")
|
||||||
|
public Result<JSONArray> getRanking() throws InterruptedException {
|
||||||
|
|
||||||
|
Thread.sleep(2000);
|
||||||
|
|
||||||
|
return musicService.getRanking();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package org.jeecg.modules.cool.music.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("comment_list")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@ApiModel(value="音乐评论排行榜对象", description="流行音乐分析")
|
||||||
|
public class Ranking {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
/**主键*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "歌手")
|
||||||
|
private String singer;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "评论数")
|
||||||
|
private Integer comment;
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.jeecg.modules.cool.music.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.jeecg.modules.cool.music.entity.Ranking;
|
||||||
|
|
||||||
|
|
||||||
|
public interface MusicMapper extends BaseMapper<Ranking> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="org.jeecg.modules.cool.music.mapper.MusicMapper">
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.jeecg.modules.cool.music.service;
|
||||||
|
|
||||||
|
import net.sf.json.JSONArray;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public interface MusicService {
|
||||||
|
|
||||||
|
public Result<JSONArray> getRanking();
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package org.jeecg.modules.cool.music.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import net.sf.json.JSONArray;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
import org.apache.commons.math3.genetics.RandomKey;
|
||||||
|
import org.apache.poi.ss.formula.functions.Rank;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.modules.cool.music.entity.Ranking;
|
||||||
|
import org.jeecg.modules.cool.music.mapper.MusicMapper;
|
||||||
|
import org.jeecg.modules.cool.music.service.MusicService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MusicServiceImpl extends ServiceImpl<MusicMapper, Ranking> implements MusicService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MusicMapper musicMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<JSONArray> getRanking() {
|
||||||
|
ComparatorList comparatorList = new ComparatorList();
|
||||||
|
List<Ranking> rankings = musicMapper.selectList(null);
|
||||||
|
JSONArray result = new JSONArray();
|
||||||
|
System.out.println(rankings);
|
||||||
|
Collections.sort(rankings, comparatorList);
|
||||||
|
for (Ranking ranking : rankings) {
|
||||||
|
System.out.println("\n\n\n\n\n" + ranking);
|
||||||
|
JSONObject object = new JSONObject();
|
||||||
|
object.put("comment", ranking.getComment());
|
||||||
|
object.put("singer", ranking.getSinger());
|
||||||
|
object.put("songName", ranking.getName());
|
||||||
|
result.add(object);
|
||||||
|
}
|
||||||
|
UpdateWrapper<Ranking> updateWrapper = new UpdateWrapper<>();
|
||||||
|
updateWrapper.setSql("comment=comment- FLOOR( RAND()*100 )");
|
||||||
|
musicMapper.update(null,updateWrapper);
|
||||||
|
|
||||||
|
return Result.OK(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ComparatorList implements Comparator<Ranking> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(Ranking o1, Ranking o2) {
|
||||||
|
return o1.getComment() > o2.getComment() ? 1 : -1;
|
||||||
|
}
|
||||||
|
}
|
|
@ -160,7 +160,7 @@ spring:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/jeecg-boot2?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://127.0.0.1:3306/jeecg-boot2?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: ob666666
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
# 多数据源配置
|
# 多数据源配置
|
||||||
#multi-datasource1:
|
#multi-datasource1:
|
||||||
|
@ -239,7 +239,7 @@ jeecg:
|
||||||
#大屏报表参数设置
|
#大屏报表参数设置
|
||||||
jmreport:
|
jmreport:
|
||||||
#多租户模式,默认值为空(created:按照创建人隔离、tenant:按照租户隔离) (v1.6.2+ 新增)
|
#多租户模式,默认值为空(created:按照创建人隔离、tenant:按照租户隔离) (v1.6.2+ 新增)
|
||||||
saasMode:
|
saasMode:
|
||||||
# 平台上线安全配置(v1.6.2+ 新增)
|
# 平台上线安全配置(v1.6.2+ 新增)
|
||||||
firewall:
|
firewall:
|
||||||
# 数据源安全 (开启后,不允许使用平台数据源、SQL解析加签并且不允许查询数据库)
|
# 数据源安全 (开启后,不允许使用平台数据源、SQL解析加签并且不允许查询数据库)
|
||||||
|
|
Loading…
Reference in New Issue