From 0c29adcf7692ad992c70ff1207d7d098a635535c Mon Sep 17 00:00:00 2001
From: lizijie <lzjiiie@163.com>
Date: Thu, 10 Feb 2022 13:25:15 +0800
Subject: [PATCH] 服务范围列表条件查询接口
---
screen-api/src/main/java/com/moral/api/service/impl/SupervisionServiceImpl.java | 42 +++++++++++++++++++++++++++++++++++-------
1 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/SupervisionServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/SupervisionServiceImpl.java
index aed072d..7057c08 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/SupervisionServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/SupervisionServiceImpl.java
@@ -1,19 +1,24 @@
package com.moral.api.service.impl;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.moral.api.entity.Supervision;
+import com.moral.api.entity.SysArea;
import com.moral.api.mapper.SupervisionMapper;
import com.moral.api.service.SupervisionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.moral.api.service.SysAreaService;
import com.moral.constant.Constants;
import com.moral.constant.ResponseCodeEnum;
import com.moral.util.FileUtils;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
@@ -36,17 +41,22 @@
* @since 2022-01-12
*/
@Service
+@Slf4j
public class SupervisionServiceImpl extends ServiceImpl<SupervisionMapper, Supervision> implements SupervisionService {
@Autowired
private SupervisionMapper supervisionMapper;
+ @Autowired
+ private SysAreaService sysAreaService;
+
@Override
+ @Transactional
public Map<String, Object> add(MultipartFile[] files, Supervision supervision) {
//������jar���������������
- ApplicationHome h = new ApplicationHome(getClass());
+ ApplicationHome applicationHome = new ApplicationHome(getClass());
//���jar������������������������������upload������������������������������������
- String path = h.getSource().getParentFile().toString() + "/static/img";
+ String path = applicationHome.getSource().getParentFile().toString() + "/static/img";
Map<String, Object> result = new HashMap<>();
@@ -110,22 +120,39 @@
supervisionMapper.selectPage(supervisionPage, queryWrapper);
List<Supervision> supervisions = supervisionPage.getRecords();
+ //������������������
+ List<Map<String, Object>> item = new ArrayList<>();
+ QueryWrapper<SysArea> sysAreaQueryWrapper = new QueryWrapper<>();
+ sysAreaQueryWrapper.eq("area_code", cityCode);
+ SysArea one = sysAreaService.getOne(sysAreaQueryWrapper);
+ String cityName = one.getAreaName();
+ for (Supervision supervision : supervisions) {
+ Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(supervision), Map.class);
+ map.remove("isDelete");
+ map.remove("createTime");
+ map.remove("updateTime");
+ map.put("cityName", cityName);
+ item.add(map);
+ }
Map<String, Object> result = new LinkedHashMap<>();
result.put("total", supervisionPage.getTotal());
result.put("totalPage", supervisionPage.getPages());
result.put("current", supervisionPage.getCurrent());
result.put("pageSize", supervisionPage.getSize());
- result.put("item", supervisions);
+ result.put("item", item);
return result;
}
@Override
+ @Transactional
public Map<String, Object> updateSupervision(MultipartFile[] files, Supervision supervision) {
- String path = this.getClass().getClassLoader()
- .getResource("").getFile() + "static/img";
+ //������jar���������������
+ ApplicationHome applicationHome = new ApplicationHome(getClass());
+ //���jar������������������������������upload������������������������������������
+ String path = applicationHome.getSource().getParentFile().toString() + "/static/img";
Map<String, Object> result = new HashMap<>();
@@ -163,6 +190,7 @@
}
@Override
+ @Transactional
public void deleteSupervision(Integer supervisionId) {
QueryWrapper<Supervision> queryWrapper = new QueryWrapper<>();
queryWrapper.select("id", "images").eq("id", supervisionId);
@@ -176,8 +204,8 @@
//���������������������������������������
- String path = this.getClass().getClassLoader()
- .getResource("").getFile() + "static/img";
+ ApplicationHome applicationHome = new ApplicationHome(getClass());
+ String path = applicationHome.getSource().getParentFile().toString() + "/static/img";
for (String image : images) {
String realPath = path + File.separator + image;
File file = new File(realPath);
--
Gitblit v1.8.0