|
@@ -1,14 +1,16 @@
|
|
|
package com.gyee.backconfig.controller;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.gyee.backconfig.config.R;
|
|
|
import com.gyee.backconfig.model.auto.ProBasicCompany;
|
|
|
import com.gyee.backconfig.service.auto.IProBasicCompanyService;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import com.gyee.common.model.StringUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -24,10 +26,102 @@ public class ProBasicCompanyController {
|
|
|
@Resource
|
|
|
private IProBasicCompanyService proBasicCompanyService;
|
|
|
|
|
|
- @GetMapping(value = "/companys")
|
|
|
- public List<ProBasicCompany> list(){
|
|
|
- List<ProBasicCompany> list = proBasicCompanyService.list();
|
|
|
- return list;
|
|
|
+ /**
|
|
|
+ * 查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @param name
|
|
|
+ * @param aname
|
|
|
+ * @param pageNum
|
|
|
+ * @param pageSize
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/listByPage")
|
|
|
+ public R findList(@RequestParam(value = "id", required = false) String id,
|
|
|
+ @RequestParam(value = "name", required = false) String name,
|
|
|
+ @RequestParam(value = "aname", required = false) String aname,
|
|
|
+ @RequestParam(value = "pageNum", required = true) String pageNum,
|
|
|
+ @RequestParam(value = "pageSize", required = true) String pageSize) {
|
|
|
+ IPage<ProBasicCompany> list = proBasicCompanyService.list(id, name, aname, pageNum, pageSize);
|
|
|
+ if (null != list) {
|
|
|
+ return R.ok().data(list);
|
|
|
+ } else {
|
|
|
+ return R.error().data("查询失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/companys/{id}")
|
|
|
+ public R findOne(@PathVariable("id") String id) {
|
|
|
+ QueryWrapper<ProBasicCompany> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("id", id);
|
|
|
+ ProBasicCompany companys = proBasicCompanyService.getOne(qw);
|
|
|
+ if (StringUtils.isNotNull(companys)) {
|
|
|
+ return R.ok().data(companys);
|
|
|
+ } else {
|
|
|
+ return R.error().data("查询失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 插入(批量)
|
|
|
+ *
|
|
|
+ * @param company
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/add-companys")
|
|
|
+ public R addAll(@RequestBody ProBasicCompany company) {
|
|
|
+
|
|
|
+ boolean b = proBasicCompanyService.saveOrUpdate(company);
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("保存失败!");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @DeleteMapping(value = "/remove-companys/{ids}")
|
|
|
+ public R deleteAll(@PathVariable("ids") String ids) {
|
|
|
+ String[] strings = ids.split(",");
|
|
|
+
|
|
|
+ boolean b = proBasicCompanyService.removeByIds(Arrays.asList(strings));
|
|
|
+
|
|
|
+
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("删除失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量修改
|
|
|
+ *
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PutMapping(value = "/companys")
|
|
|
+ public R update(@RequestBody List<ProBasicCompany> list) {
|
|
|
+ boolean b = proBasicCompanyService.updateBatchById(list);
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("更新失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|