|
@@ -1,19 +1,20 @@
|
|
package com.charging.chargingparking.modules.backController;
|
|
package com.charging.chargingparking.modules.backController;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
-import com.charging.chargingparking.dto.AddParkingMember;
|
|
|
|
import com.charging.chargingparking.dto.MessageResult;
|
|
import com.charging.chargingparking.dto.MessageResult;
|
|
|
|
+import com.charging.chargingparking.dto.PojoUtils;
|
|
import com.charging.chargingparking.entity.ParkingInfo;
|
|
import com.charging.chargingparking.entity.ParkingInfo;
|
|
-import com.charging.chargingparking.modules.vo.ParkingInfoVo;
|
|
|
|
|
|
+import com.charging.chargingparking.modules.common.dto.Sort;
|
|
import com.charging.chargingparking.service.ParkingInfoService;
|
|
import com.charging.chargingparking.service.ParkingInfoService;
|
|
|
|
+import com.github.pagehelper.Page;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.validation.BindingResult;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import javax.validation.Valid;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author 墨鱼_mo
|
|
* @author 墨鱼_mo
|
|
@@ -24,20 +25,204 @@ import java.util.List;
|
|
@RequestMapping("/backParkingInfo")
|
|
@RequestMapping("/backParkingInfo")
|
|
public class ParkingInfoController {
|
|
public class ParkingInfoController {
|
|
|
|
|
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private ParkingInfoService parkingInfoService;
|
|
private ParkingInfoService parkingInfoService;
|
|
|
|
|
|
- @PostMapping("parkingInfoList")
|
|
|
|
- public MessageResult<Object> parkingInfoList(String parkingName,@RequestParam Integer pageSize,@RequestParam Integer pageIndex) {
|
|
|
|
|
|
+ @ApiOperation(value="创建空记录")
|
|
|
|
+ @GetMapping("create")
|
|
|
|
+ public MessageResult<ParkingInfo> create(){
|
|
|
|
+ MessageResult<ParkingInfo> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ ParkingInfo parkingInfo = new ParkingInfo();
|
|
|
|
+
|
|
|
|
+ msgResult.setData(parkingInfo);
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="添加信息")
|
|
|
|
+ @PostMapping("add")
|
|
|
|
+ public MessageResult<ParkingInfo> add(@RequestBody ParkingInfo parkingInfo,@RequestAttribute String subject){
|
|
|
|
+ MessageResult<ParkingInfo> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ parkingInfo.setId(UUID.randomUUID().toString());
|
|
|
|
+ parkingInfo.setDelFlag(false);
|
|
|
|
+ parkingInfo.setCreateTime(new Date());
|
|
|
|
+
|
|
|
|
+ int affectCount = parkingInfoService.insert(parkingInfo);
|
|
|
|
+
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(parkingInfo);
|
|
|
|
+ } else {
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage("数据库添加失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex){
|
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="获取信息")
|
|
|
|
+ @GetMapping("edit/{id}")
|
|
|
|
+ public MessageResult<ParkingInfo> edit(@PathVariable("id") String id){
|
|
|
|
+ MessageResult<ParkingInfo> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ ParkingInfo parkingInfo = parkingInfoService.get(id);
|
|
|
|
+
|
|
|
|
+ if (parkingInfo != null) {
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(parkingInfo);
|
|
|
|
+ } else {
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage("数据库不存在该记录!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex){
|
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="更新用户")
|
|
|
|
+ @PostMapping("update")
|
|
|
|
+ public MessageResult<ParkingInfo> update(@RequestBody ParkingInfo parkingInfo,@RequestAttribute String subject){
|
|
|
|
+ MessageResult<ParkingInfo> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ parkingInfo.setUpdateBy(subject);
|
|
|
|
+ parkingInfo.setUpdateTime(new Date());
|
|
|
|
+
|
|
|
|
+ int affectCount = parkingInfoService.update(parkingInfo);
|
|
|
|
+
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(parkingInfo);
|
|
|
|
+ } else {
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage("数据库更新失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex){
|
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="删除")
|
|
|
|
+ @PostMapping("delete/{id}")
|
|
|
|
+ public MessageResult<Integer> delete(@PathVariable("id") String id,@RequestAttribute String subject){
|
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ ParkingInfo parkingInfo = parkingInfoService.get(id);
|
|
|
|
+ parkingInfo.setDelFlag(true);
|
|
|
|
+ parkingInfo.setUpdateBy(subject);
|
|
|
|
+ parkingInfo.setUpdateTime(new Date());
|
|
|
|
+
|
|
|
|
+ int affectCount = parkingInfoService.update(parkingInfo);
|
|
|
|
+
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(affectCount);
|
|
|
|
+ } else {
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage("删除失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex){
|
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="批量删除")
|
|
|
|
+ @PostMapping("batchDelete")
|
|
|
|
+ public MessageResult<Integer> batchDelete(@RequestBody List<String> idList, @RequestAttribute String subject){
|
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
|
|
- MessageResult<Object> messageResult = new MessageResult<>();
|
|
|
|
|
|
+ try {
|
|
|
|
+ int affectCount = 0;
|
|
|
|
+
|
|
|
|
+ for (String id : idList) {
|
|
|
|
+ ParkingInfo parkingInfo = parkingInfoService.get(id);
|
|
|
|
+ parkingInfo.setDelFlag(true);
|
|
|
|
+ parkingInfo.setUpdateBy(subject);
|
|
|
|
+ parkingInfo.setUpdateTime(new Date());
|
|
|
|
+
|
|
|
|
+ affectCount += parkingInfoService.update(parkingInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(affectCount);
|
|
|
|
+ } else {
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage("删除失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex){
|
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="停车场列表")
|
|
|
|
+ @RequestMapping(value = "parkingInfoList",method = RequestMethod.POST)
|
|
|
|
+ public MessageResult<Map> parkingInfoList(
|
|
|
|
+ String parkingName,
|
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
|
+ @RequestParam(value="field",defaultValue="create_time") String field,
|
|
|
|
+ @RequestParam(value="direction",defaultValue="desc") String direction,
|
|
|
|
+ @RequestAttribute String subject){
|
|
|
|
+
|
|
|
|
+ //当前用户ID
|
|
|
|
+ System.out.println(subject);
|
|
|
|
+
|
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
|
|
|
try{
|
|
try{
|
|
- QueryWrapper<ParkingInfo> parkingInfoQueryWrapper = new QueryWrapper<>();
|
|
|
|
- parkingInfoQueryWrapper.like("parking_name",parkingName);
|
|
|
|
- Page<ParkingInfo> page = parkingInfoService.page(new Page<>(pageIndex,pageSize),parkingInfoQueryWrapper);
|
|
|
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
|
+ sortList.add(new Sort(field,direction));
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotEmpty(parkingName)) {
|
|
|
|
+ searchParams.put("parkingName","%" + parkingName + "%");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Page<ParkingInfo> page = parkingInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
|
|
|
- messageResult.setData(page);
|
|
|
|
|
|
+ messageResult.setData(PojoUtils.pageWrapper(page));
|
|
messageResult.setResult(true);
|
|
messageResult.setResult(true);
|
|
|
|
|
|
}catch (Exception ex){
|
|
}catch (Exception ex){
|