diff --git a/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/AttController.java b/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/AttController.java index 06daf19..eb3db18 100644 --- a/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/AttController.java +++ b/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/AttController.java @@ -1,6 +1,7 @@ package com.xiaoshuai.c202201020323.smallcourse.controller; import com.xiaoshuai.c202201020323.smallcourse.model.Att; +import com.xiaoshuai.c202201020323.smallcourse.model.Result; import com.xiaoshuai.c202201020323.smallcourse.service.IAttService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; @@ -11,7 +12,7 @@ import java.util.List; /** *

- * 前端控制器 + * 前端控制器 *

* * @author xiao @@ -23,10 +24,31 @@ public class AttController { @Autowired public IAttService attService; + @ResponseBody @RequestMapping("/att") - public List att(){ - List list = attService.list(); - return list; + public Result att() { + List list = attService.list(); + return Result.ok().put("data", list); + } + + @ResponseBody + @RequestMapping("/editAtt") + public Result editAtt(Att att) { + boolean edit = attService.saveOrUpdate(att); + if (edit) { + return Result.ok("修改成功"); + } + return Result.error("修改失败"); + } + + @ResponseBody + @RequestMapping("/delAtt") + public Result delAtt(Integer id) { + boolean del = attService.removeById(id); + if (del) { + return Result.ok("删除成功"); + } + return Result.error("删除失败"); } } diff --git a/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/FindController.java b/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/FindController.java index 4f84d82..c415dc2 100644 --- a/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/FindController.java +++ b/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/FindController.java @@ -1,5 +1,6 @@ package com.xiaoshuai.c202201020323.smallcourse.controller; +import com.xiaoshuai.c202201020323.smallcourse.model.Result; import com.xiaoshuai.c202201020323.smallcourse.service.IFindService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; @@ -10,7 +11,7 @@ import java.util.List; /** *

- * 前端控制器 + * 前端控制器 *

* * @author xiao @@ -21,10 +22,31 @@ import java.util.List; public class FindController { @Autowired public IFindService findService; + @ResponseBody @RequestMapping("/find") - public List find(){ - List list = findService.list(); - return list; + public Result find() { + List list = findService.list(); + return Result.ok().put("data", list); + } + + @ResponseBody + @RequestMapping("/editFind") + public Result editFind(com.xiaoshuai.c202201020323.smallcourse.model.Find find) { + boolean edit = findService.saveOrUpdate(find); + if (edit) { + return Result.ok(); + } + return Result.error(); + } + + @ResponseBody + @RequestMapping("/delFind") + public Result delFind(Integer id) { + boolean del = findService.removeById(id); + if (del) { + return Result.ok(); + } + return Result.error(); } } diff --git a/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/ModelController.java b/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/ModelController.java index acab136..70d839e 100644 --- a/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/ModelController.java +++ b/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/ModelController.java @@ -1,6 +1,7 @@ package com.xiaoshuai.c202201020323.smallcourse.controller; import com.xiaoshuai.c202201020323.smallcourse.model.Model; +import com.xiaoshuai.c202201020323.smallcourse.model.Result; import com.xiaoshuai.c202201020323.smallcourse.service.IModelService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; @@ -11,7 +12,7 @@ import java.util.List; /** *

- * 前端控制器 + * 前端控制器 *

* * @author xiao @@ -22,10 +23,31 @@ import java.util.List; public class ModelController { @Autowired public IModelService modelService; + @ResponseBody @RequestMapping("/model") - public List model(){ - List list = modelService.list(); - return list; + public Result model() { + List list = modelService.list(); + return Result.ok().put("data", list); + } + + @ResponseBody + @RequestMapping("/editModel") + public Result editModel(Model model) { + boolean edit = modelService.saveOrUpdate(model); + if (edit) { + return Result.ok("修改成功"); + } + return Result.error("修改失败"); + } + + @ResponseBody + @RequestMapping("/delModel") + public Result delModel(Integer id) { + boolean del = modelService.removeById(id); + if (del) { + return Result.ok("删除成功"); + } + return Result.error("删除失败"); } } diff --git a/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/MyselfCityController.java b/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/MyselfCityController.java index aef6780..2e48014 100644 --- a/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/MyselfCityController.java +++ b/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/MyselfCityController.java @@ -1,5 +1,7 @@ package com.xiaoshuai.c202201020323.smallcourse.controller; +import com.xiaoshuai.c202201020323.smallcourse.model.MyselfCity; +import com.xiaoshuai.c202201020323.smallcourse.model.Result; import com.xiaoshuai.c202201020323.smallcourse.service.IMyselfCityService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; @@ -10,7 +12,7 @@ import java.util.List; /** *

- * 前端控制器 + * 前端控制器 *

* * @author xiao @@ -21,10 +23,31 @@ import java.util.List; public class MyselfCityController { @Autowired public IMyselfCityService myselfCityService; + @ResponseBody @RequestMapping("/myselfCity") - public List myselfCity(){ - List list = myselfCityService.list(); - return list; + public Result myselfCity() { + List list = myselfCityService.list(); + return Result.ok().put("data", list); + } + + @ResponseBody + @RequestMapping("/editMyselfCity") + public Result editMyselfCity(MyselfCity myselfCity) { + boolean edit = myselfCityService.saveOrUpdate(myselfCity); + if (edit) { + return Result.ok("修改成功"); + } + return Result.error("修改失败"); + } + + @ResponseBody + @RequestMapping("/delMyselfCity") + public Result delMyselfCity(Integer id) { + boolean del = myselfCityService.removeById(id); + if (del) { + return Result.ok("删除成功"); + } + return Result.error("删除失败"); } } diff --git a/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/SchoolController.java b/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/SchoolController.java index 215a9ba..55f2259 100644 --- a/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/SchoolController.java +++ b/smallCourse/src/main/java/com/xiaoshuai/c202201020323/smallcourse/controller/SchoolController.java @@ -1,5 +1,6 @@ package com.xiaoshuai.c202201020323.smallcourse.controller; +import com.xiaoshuai.c202201020323.smallcourse.model.Result; import com.xiaoshuai.c202201020323.smallcourse.model.School; import com.xiaoshuai.c202201020323.smallcourse.service.ISchoolService; import org.springframework.beans.factory.annotation.Autowired; @@ -11,7 +12,7 @@ import java.util.List; /** *

- * 前端控制器 + * 前端控制器 *

* * @author xiao @@ -22,10 +23,33 @@ import java.util.List; public class SchoolController { @Autowired public ISchoolService schoolService; + @ResponseBody @RequestMapping("/school") - public List school(){ - List list = schoolService.list(); - return list; + public Result school() { + List list = schoolService.list(); + return Result.ok().put("data", list); + } + + @ResponseBody + @RequestMapping("/editSchool") + public Result editSchool(School school) { + boolean edit = schoolService.saveOrUpdate(school); + if (edit) { + return Result.ok(); + } else { + return Result.error(); + } + } + + @ResponseBody + @RequestMapping("/delSchool") + public Result delSchool(Integer id) { + boolean del = schoolService.removeById(id); + if (del) { + return Result.ok(); + } else { + return Result.error(); + } } }