package com.zy.asrs.controller;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.zy.asrs.entity.BasArm;
|
import com.zy.asrs.service.BasArmService;
|
import com.core.annotations.ManagerAuth;
|
import com.core.common.BaseRes;
|
import com.core.common.Cools;
|
import com.core.common.R;
|
import com.zy.common.web.BaseController;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.*;
|
|
@RestController
|
public class BasArmController extends BaseController {
|
|
@Autowired
|
private BasArmService basArmService;
|
|
@RequestMapping(value = "/basArm/{id}/auth")
|
@ManagerAuth
|
public R get(@PathVariable("id") String id) {
|
return R.ok(basArmService.selectById(String.valueOf(id)));
|
}
|
|
@RequestMapping(value = "/basArm/add/auth")
|
@ManagerAuth
|
public R add(BasArm basArm) {
|
basArmService.insert(basArm);
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/basArm/update/auth")
|
@ManagerAuth
|
public R update(BasArm basArm){
|
if (Cools.isEmpty(basArm) || null==basArm.getId()){
|
return R.error();
|
}
|
basArmService.updateById(basArm);
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/basArm/delete/auth")
|
@ManagerAuth
|
public R delete(@RequestParam(value="ids[]") Long[] ids){
|
for (Long id : ids){
|
basArmService.deleteById(id);
|
}
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/basArmQuery/auth")
|
@ManagerAuth
|
public R query(String condition) {
|
EntityWrapper<BasArm> wrapper = new EntityWrapper<>();
|
wrapper.like("id", condition);
|
Page<BasArm> page = basArmService.selectPage(new Page<>(0, 10), wrapper);
|
List<Map<String, Object>> result = new ArrayList<>();
|
for (BasArm basArm : page.getRecords()){
|
Map<String, Object> map = new HashMap<>();
|
map.put("id", basArm.getId());
|
map.put("value", basArm.getId());
|
result.add(map);
|
}
|
return R.ok(result);
|
}
|
|
@RequestMapping(value = "/basArm/check/column/auth")
|
@ManagerAuth
|
public R query(@RequestBody JSONObject param) {
|
Wrapper<BasArm> wrapper = new EntityWrapper<BasArm>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
|
if (null != basArmService.selectOne(wrapper)){
|
return R.parse(BaseRes.REPEAT).add(getComment(BasArm.class, String.valueOf(param.get("key"))));
|
}
|
return R.ok();
|
}
|
|
}
|