|
@@ -1,15 +1,19 @@
|
|
|
package com.gyee.backconfig.controller;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.gyee.backconfig.config.R;
|
|
|
import com.gyee.backconfig.model.auto.Companys;
|
|
|
import com.gyee.backconfig.service.BackConfigService;
|
|
|
+import com.gyee.backconfig.service.auto.ICompanysService;
|
|
|
import com.gyee.backconfig.vo.Companysvo;
|
|
|
import com.gyee.common.model.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -23,36 +27,66 @@ import javax.annotation.Resource;
|
|
|
@RequestMapping("//companys")
|
|
|
public class CompanysController {
|
|
|
@Resource
|
|
|
- private BackConfigService backConfigService;
|
|
|
-
|
|
|
- @GetMapping("/listByPage")
|
|
|
- @ResponseBody
|
|
|
- @CrossOrigin(origins = "*", maxAge = 3600)
|
|
|
- public R ListByPage(
|
|
|
- @RequestParam(value = "pagenum", required = true) Integer pageNum,
|
|
|
- @RequestParam(value = "pagesize", required = true) Integer pageSize,
|
|
|
- @RequestParam(value = "id", required = false) String id,
|
|
|
- @RequestParam(value = "name", required = false) String name,
|
|
|
- @RequestParam(value = "rid", required = false) String rid) {
|
|
|
- Companysvo vo = new Companysvo();
|
|
|
- setVOTemplate(pageSize, pageNum, id,name,rid,vo);
|
|
|
- Page<Companys> CompanysPage = backConfigService.CompanysBypage(vo);
|
|
|
- if (StringUtils.isNotNull(CompanysPage)) {
|
|
|
- return R.ok().data(CompanysPage);
|
|
|
- } else {
|
|
|
- return R.error().message("访问失败");
|
|
|
+ private ICompanysService companysService;
|
|
|
+
|
|
|
+ @GetMapping(value = "/companys")
|
|
|
+ public R findList(@RequestParam(value = "id",required = true) String id,
|
|
|
+ @RequestParam(value = "name",required = true) String name,
|
|
|
+ @RequestParam(value = "pageNum",required = true) String pageNum,
|
|
|
+ @RequestParam(value = "pageSize",required = true) String pageSize){
|
|
|
+ List<Companys> list = companysService.list(id,name,pageNum,pageSize);
|
|
|
+ if (StringUtils.isNotEmpty(list)){
|
|
|
+ return R.ok(list.size()).data(list);
|
|
|
+ }else {
|
|
|
+ return R.error().data("查询失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/companys/{id}")
|
|
|
+ public R findOne(@PathVariable("id") String id){
|
|
|
+ QueryWrapper<Companys> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("id",id);
|
|
|
+ Companys companys = companysService.getOne(qw);
|
|
|
+ if (StringUtils.isNotNull(companys)){
|
|
|
+ return R.ok().data(companys);
|
|
|
+ }else {
|
|
|
+ return R.error().data("查询失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(value = "/companys")
|
|
|
+ public R addAll(@RequestBody List<Companys> list){
|
|
|
+ boolean b = companysService.saveBatch(list);
|
|
|
+ if (b){
|
|
|
+ return R.ok().data(b);
|
|
|
+ }else {
|
|
|
+ return R.error().data("保存失败!");
|
|
|
}
|
|
|
}
|
|
|
- private void setVOTemplate(@RequestParam(value = "pagenum", required = true) Integer pageNum,
|
|
|
- @RequestParam(value = "pagesize", required = true) Integer pageSize,
|
|
|
- @RequestParam(value = "id", required = false) String id,
|
|
|
- @RequestParam(value = "rid", required = false) String rid,
|
|
|
- @RequestParam(value = "name", required = false) String name,Companysvo vo){
|
|
|
- vo.setId(id);
|
|
|
- vo.setName(name);
|
|
|
- vo.setPageSize(pageSize);
|
|
|
- vo.setRid(rid);
|
|
|
- vo.setCurrent(pageNum);
|
|
|
|
|
|
+ @DeleteMapping(value = "/companys/{ids}")
|
|
|
+ public R deleteAll(@PathVariable("ids") String ids){
|
|
|
+ String[] strings = ids.split(",");
|
|
|
+ boolean b = companysService.removeByIds(Arrays.asList(strings));
|
|
|
+ if (b){
|
|
|
+ return R.ok().data(b);
|
|
|
+ }else {
|
|
|
+ return R.error().data("删除失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping(value = "/companys")
|
|
|
+ public R update(@RequestBody List<Companys> list){
|
|
|
+ boolean b = companysService.updateBatchById(list);
|
|
|
+ if (b){
|
|
|
+ return R.ok().data(b);
|
|
|
+ }else {
|
|
|
+ return R.error().data("更新失败!");
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|