You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.7 KiB
65 lines
1.7 KiB
package web.controller;
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import db.AbstractModel;
|
|
import db.DBAction;
|
|
import db.model.bilibili.DataModel;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import web.service.DataService;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.io.IOException;
|
|
import java.util.EnumSet;
|
|
|
|
@Controller
|
|
@RequestMapping("/data")
|
|
public class DataController extends TableController<DataModel,DataService> {
|
|
|
|
|
|
private static JsonNode jsonNode;
|
|
|
|
static {
|
|
try {
|
|
jsonNode = new ObjectMapper().readTree(DataController.class.getResourceAsStream("/region.json"));
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
;
|
|
|
|
@Resource
|
|
private DataService dataService;
|
|
|
|
@RequestMapping
|
|
public <T extends AbstractModel> String find(Model model, DataModel queryCommand){
|
|
model.addAttribute("regionJson",jsonNode.toString());
|
|
return super.find(model,queryCommand,0,10);
|
|
}
|
|
|
|
@RequestMapping("start/{size}")
|
|
public void start(@PathVariable Integer size){
|
|
stop();
|
|
dataService.start(size);
|
|
}
|
|
|
|
@RequestMapping("stop")
|
|
public void stop(){
|
|
dataService.stop();
|
|
}
|
|
|
|
@Override
|
|
@Autowired
|
|
protected void setService(DataService service) {
|
|
this.service=service;
|
|
}
|
|
|
|
@Override
|
|
public boolean checkAction(DBAction action) {
|
|
return !EnumSet.of(DBAction.D).contains(action);
|
|
}
|
|
}
|
|
|