com.ajaxjs.website.section.TreeLikeController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ajaxjs-framework2 Show documentation
Show all versions of ajaxjs-framework2 Show documentation
AJAXJS aims to full-stack, not only the server-side framework,
but also integrates the front-end library. It's written in HTML5 + Java, a successor to the JVM platform, efficient, secure, stable, cross-platform and many other advantages, but it abandoned the traditional enterprise architecture brought about by the large and bloated,
emphasizing the lightweight, and fast, very suitable for the Internet fast application.
The newest version!
package com.ajaxjs.website.section;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ajaxjs.framework.BaseController;
import com.ajaxjs.framework.filter.DataBaseFilter;
/**
*
* 控制器
*/
@Controller
@RequestMapping("/admin/entity/tree-like")
public class TreeLikeController extends BaseController {
@Autowired
private TreeLikeService service;
@GetMapping
public String page(ModelMap mv) {
prepareData(mv, service);
return "entity/tree-like";
}
@ResponseBody
@GetMapping(value = "json", produces = JSON)
@DataBaseFilter
public String json(ModelMap mv) {
return toJson(service.getAllChildren());
}
@ResponseBody
@DataBaseFilter
@GetMapping(value = ID_INFO, produces = JSON)
public String list(@PathVariable(ID) int pid) {
return toJson(service.getAllChildren(pid));
}
@ResponseBody
@DataBaseFilter
@GetMapping(value = "getListAndSubByParentId/" + ID_INFO, produces = JSON)
public String getListAndSubByParentId(@PathVariable(ID) int pid) {
return toJson(service.getAllChildren(pid));
}
@ResponseBody
@DataBaseFilter
@PostMapping(produces = JSON)
public String create(TreeNode entity) {
return create(service, entity);
}
@ResponseBody
@DataBaseFilter
@PutMapping(value = ID_INFO, produces = JSON)
public String update(@PathVariable(ID) Long id, TreeNode entity) {
return update(service, id, entity);
}
@ResponseBody
@DataBaseFilter
@DeleteMapping(value = ID_INFO, produces = JSON)
public String delete(@PathVariable(ID) Long id) {
return delete(service, id, new TreeNode());
}
}