123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- package com.huimv.video.controller;
- import com.huimv.video.domain.PastureArea;
- import com.huimv.video.result.Result;
- import com.huimv.video.service.PastureAreaService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.CrossOrigin;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.List;
- /**
- * @Project : huimv.shiwan
- * @Package : com.huimv.video.controller
- * @Description : TODO
- * @Author : yuxuexuan
- * @Create : 2021/3/4 0007 10:34
- **/
- @CrossOrigin
- @RestController
- @RequestMapping("/pastureArea")
- public class PastureAreaController {
- @Autowired
- private PastureAreaService pastureAreaService;
- @RequestMapping("/add")
- private Result addArea(PastureArea pastureArea){
- try {
- if (pastureArea.getParentId() != null){
- pastureAreaService.save(pastureArea);
- return new Result(10000,"添加成功");
- }else {
- return new Result(10002,"请选择父级ID");
- }
- }catch (Exception e){
- return new Result(10001,"添加失败");
- }
- }
- @RequestMapping("/update")
- private Result updateArea(PastureArea pastureArea){
- try {
- if (pastureArea.getId()==0){
- return new Result(10002,"请选择修改数据");
- }
- if (pastureArea.getParentId() != null){
- pastureAreaService.update(pastureArea);
- return new Result(10000,"修改成功");
- }else {
- return new Result(10002,"请选择父级ID");
- }
- }catch (Exception e){
- return new Result(10001,"修改失败");
- }
- }
- @RequestMapping("/delete")
- private Result deleteArea(@RequestParam(required = false)List<Integer> ids){
- // try {
- pastureAreaService.delete(ids);
- return new Result(10000,"删除成功");
- // }catch (Exception e){
- // return new Result(10001,"删除失败");
- // }
- }
- @RequestMapping("/findAll")
- private Result findAll(Integer userId){
- try {
- List list = pastureAreaService.findAll(userId);
- if (list == null){
- return new Result(10000,"暂时没有数据");
- }
- return new Result(10000,"查询成功",list);
- }catch (Exception e){
- return new Result(10001,"查询失败");
- }
- }
- @RequestMapping("/findById")
- private Result findById(Integer id){
- try {
- PastureArea pastureArea = pastureAreaService.findById(id);
- return new Result(10000,"设置成功",pastureArea);
- }catch (Exception e){
- return new Result(10001,"设置失败");
- }
- }
- @RequestMapping("/findAllByAttention")
- private Result findAllByAttention(){
- try {
- List list = pastureAreaService.findAllByAttention();
- return new Result(10000,"查询成功",list);
- }catch (Exception e){
- return new Result(10001,"查询失败");
- }
- }
- @RequestMapping("/updateAttention")
- private Result updateAttention(Integer id,Integer attention){
- try {
- pastureAreaService.updateAttention(id,attention);
- if (attention == 0){
- return new Result(10000,"取消关注成功");
- }
- return new Result(10000,"关注成功");
- }catch (Exception e){
- return new Result(10001,"关注失败");
- }
- }
- }
|