Browse Source

注意表的编码是否一致

wuweihao 4 năm trước cách đây
mục cha
commit
00354f88b2

+ 4 - 1
gis_domain/src/main/java/com/gis/domain/dto/GoodsDto.java

@@ -31,7 +31,10 @@ public class GoodsDto {
     @ApiModelProperty(value = "文件地址")
     private String filePath;
 
-    @NotBlank(message = "展区不能为空")
+    @ApiModelProperty(value = "文件名称")
+    private String fileName;
+
+    @NotNull(message = "展区不能为空")
     @ApiModelProperty(value = "展区id", required = true)
     private Long zoneId;
 

+ 3 - 0
gis_domain/src/main/java/com/gis/domain/dto/GoodsPageDto.java

@@ -12,6 +12,9 @@ public class GoodsPageDto extends PageDateDto{
     @ApiModelProperty(value = "类型")
     private String type;
 
+    @ApiModelProperty(value = "展区id")
+    private Long zoneId;
+
 
 
 

+ 23 - 0
gis_domain/src/main/java/com/gis/domain/dto/ZoneDto.java

@@ -0,0 +1,23 @@
+package com.gis.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * Created by owen on 2020/5/28 0028 16:36
+ */
+@Data
+public class ZoneDto {
+
+    @ApiModelProperty(value = "id, 修改时必须传,新增忽略", required = true)
+    private Long id;
+
+
+    @NotBlank(message = "标题不能为空")
+    @ApiModelProperty(value = "标题", required = true)
+    private String name;
+
+}

+ 3 - 0
gis_domain/src/main/java/com/gis/domain/po/GoodsEntity.java

@@ -25,6 +25,9 @@ public class GoodsEntity extends BaseEntity {
     @ApiModelProperty(value = "文件地址")
     private String filePath;
 
+    @ApiModelProperty(value = "文件地址")
+    private String fileName;
+
     @ApiModelProperty(value = "展区id")
     private Long zoneId;
 

+ 20 - 2
gis_mapper/src/main/java/com/gis/mapper/provider/GoodsProvider.java

@@ -3,6 +3,7 @@ package com.gis.mapper.provider;
 import com.gis.domain.dto.GoodsPageDto;
 import lombok.extern.log4j.Log4j2;
 import org.apache.commons.lang3.StringUtils;
+import org.junit.Test;
 
 
 /**
@@ -18,15 +19,21 @@ public class GoodsProvider {
 
         if (StringUtils.isNotBlank(param.getStartTime()) && StringUtils.isNotBlank(param.getEndTime())) {
 
-            sql.append(" and z.create_time >= ").append("'").append(param.getStartTime()).append("'");
-            sql.append(" and z.create_time <= ").append("'").append(param.getEndTime()).append("'");
+            sql.append(" and create_time >= ").append("'").append(param.getStartTime()).append("'");
+            sql.append(" and create_time <= ").append("'").append(param.getEndTime()).append("'");
         }
 
         String searchKey = param.getSearchKey();
         if (!StringUtils.isAllBlank(searchKey)) {
+            searchKey = StringUtils.trim(searchKey);
             sql.append(" and ( name like '%").append(searchKey).append("%' )");
         }
 
+        Long zoneId = param.getZoneId();
+        if (zoneId != null) {
+            sql.append(" and  zone_id = ").append(zoneId);
+        }
+
         String type = param.getType();
         if (StringUtils.isNotBlank(type)) {
             sql.append(" and type = '").append(type).append("'");
@@ -37,4 +44,15 @@ public class GoodsProvider {
         log.info("sql: {}", sql.toString());
         return sql.toString();
     }
+
+    @Test
+    public void test(){
+        System.out.println(StringUtils.trim("  ssss  aa  cc"));
+        System.out.println(StringUtils.trimToEmpty("  ssss  aa cc"));
+        System.out.println(StringUtils.trimToNull("  ssss  aa cc"));
+
+    }
 }
+
+
+

+ 1 - 0
gis_mapper/src/main/java/com/gis/mapper/provider/LogProvider.java

@@ -24,6 +24,7 @@ public class LogProvider {
 
         String searchKey = param.getSearchKey();
         if(!StringUtils.isAllBlank(searchKey)){
+            searchKey = StringUtils.trim(searchKey);
             sql.append(" and (( u.user_name like '%").append(searchKey).append("%' )");
             sql.append(" or ( z.description like '%").append(searchKey).append("%' )");
             sql.append(" or ( z.type like '%").append(searchKey).append("%' ))");

+ 1 - 0
gis_mapper/src/main/java/com/gis/mapper/provider/SceneProvider.java

@@ -20,6 +20,7 @@ public class SceneProvider {
 
         String searchKey = param.getSearchKey();
         if(!StringUtils.isAllBlank(searchKey)){
+            searchKey = StringUtils.trim(searchKey);
             sql.append(" and ( scene_title like '%").append(searchKey).append("%' )");
         }
 

+ 14 - 1
gis_service/src/main/java/com/gis/service/impl/GoodsServiceImpl.java

@@ -23,7 +23,9 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Date;
+import java.util.HashMap;
 
 
 /**
@@ -77,10 +79,18 @@ public class GoodsServiceImpl extends IBaseServiceImpl<GoodsEntity, Long> implem
             return Result.failure("上传文件格式有误, 请重新上传");
         }
 
+        // 判断后缀名,需要包含这以下四个
+        String [] typeCheck = {"video","model","img","thumb"};
+        if (!Arrays.asList(typeCheck).contains(type)) {
+            return Result.failure("非法类型");
+        }
+
         // 文件目录
         String newName = "";
         String fileName = file.getOriginalFilename();
         String suffix = StringUtils.substringAfterLast(fileName, ".");
+
+
         // 视频、模型使用原名存储(中文转拼音)
         if ("video".equals(type) || "model".equals(type)) {
             newName = RegexUtil.getPinyinName(fileName);
@@ -96,7 +106,10 @@ public class GoodsServiceImpl extends IBaseServiceImpl<GoodsEntity, Long> implem
             e.printStackTrace();
         }
         urlPath = "/data/" + urlPath;
-        return Result.success((Object)urlPath);
+        HashMap<String, Object> result = new HashMap<>();
+        result.put("fileName", fileName);
+        result.put("filePath", urlPath);
+        return Result.success(result);
     }
 
 

+ 7 - 6
gis_service/src/main/java/com/gis/service/impl/SceneServiceImpl.java

@@ -322,13 +322,14 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
      * 无值: link = "/edit-backstage/hot_online/index.html?m=" + key
      */
     private String getLink(JSONObject param, String key){
-        JSONObject infoAttribute = param.getJSONObject("infoAttribute");
+//        JSONObject infoAttribute = param.getJSONObject("infoAttribute");
         // m_title可能会没有这个属性key, 需要判断
-        JSONArray m_title = infoAttribute.getJSONArray("m_title");
-        String url  = "/edit-backstage/hot_online/index.html#/?m=" + key;
-        if (m_title != null && m_title.size() > 0){
-            url  = "/edit-backstage/hot_online1/index.html#/?m=" + key;
-        }
+//        JSONArray m_title = infoAttribute.getJSONArray("m_title");
+//        String url  = "/edit-backstage/hot_online/index.html#/?m=" + key;
+//        if (m_title != null && m_title.size() > 0){
+//            url  = "/edit-backstage/hot_online1/index.html#/?m=" + key;
+//        }
+        String url  = "/edit-backstage/hot_online1/index.html#/?m=" + key;
         return url;
     }
 

+ 4 - 3
gis_web/src/main/java/com/gis/web/controller/SceneController.java

@@ -124,14 +124,15 @@ public class SceneController extends BaseController {
         // 转小写
         pinyinName =  StringUtils.lowerCase(pinyinName);
 
-        String path = entity.getPath();
-        String basePath = configConstant.serverBasePath + path;
+
+
+        String basePath = configConstant.serverBasePath + sceneCode;
         String savePath = basePath + "/edit/" + pinyinName;
         log.info("文件保存位置:" + savePath);
         FileUtil.writeFromStream(file.getInputStream(), savePath);
 
 
-        Object urlPath =  path + "/edit/" + pinyinName;
+        Object urlPath =  entity.getPath() + "/edit/" + pinyinName;
 
         log.info("文件写入成功: {}", urlPath);
 

+ 32 - 29
gis_web/src/main/java/com/gis/web/controller/SysUserController.java

@@ -3,15 +3,18 @@ package com.gis.web.controller;
 
 import com.gis.common.util.PasswordUtils;
 import com.gis.common.util.Result;
+import com.gis.domain.dto.UserDto;
 import com.gis.domain.po.SysUserEntity;
 import com.gis.domain.dto.PasswordRequest;
 import com.gis.service.SysUserService;
 import com.gis.service.aop.WebControllerLog;
+import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
 import org.apache.shiro.authz.annotation.Logical;
 import org.apache.shiro.authz.annotation.RequiresRoles;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.transaction.annotation.Transactional;
@@ -49,34 +52,34 @@ public class SysUserController extends BaseController {
 //        return Result.success(page);
 //    }
 
-//    @WebControllerLog(description = "用户管理-修改用户")
-//    @ApiOperation("新增/修改用户信息")
-//    @PostMapping("save")
-//    public Result save(@Valid @RequestBody UserDto param) {
-//
-//        SysUserEntity entity = null;
-//        if (param.getId() == null) {
-//            entity = userService.findByUserName(param.getUserName());
-//            if (entity != null) {
-//                return Result.failure("身份证号已存在");
-//            }
-//            entity = new SysUserEntity();
-//            BeanUtils.copyProperties(param, entity);
-//            entity.setPassword(PasswordUtils.encrypt(param.getUserName(), "123456", PasswordUtils.getStaticSalt()));
-//            userService.save(entity);
-//        } else {
-//            entity = userService.findById(param.getId());
-//            if (entity == null) {
-//                log.error("用户不存在: {}", param.getId());
-//                return Result.failure("用户不存在");
-//            }
-//            BeanUtils.copyProperties(param, entity);
-//            entity.setUpdateTime(new Date());
-//            userService.update(entity);
-//        }
-//
-//        return Result.success();
-//    }
+    @WebControllerLog(description = "用户管理-修改用户")
+    @ApiOperation("新增/修改用户信息")
+    @PostMapping("save")
+    public Result save(@Valid @RequestBody UserDto param) {
+
+        SysUserEntity entity = null;
+        if (param.getId() == null) {
+            entity = userService.findByUserName(param.getUserName());
+            if (entity != null) {
+                return Result.failure("身份证号已存在");
+            }
+            entity = new SysUserEntity();
+            BeanUtils.copyProperties(param, entity);
+            entity.setPassword(PasswordUtils.encrypt(param.getUserName(), "123456", PasswordUtils.getStaticSalt()));
+            userService.save(entity);
+        } else {
+            entity = userService.findById(param.getId());
+            if (entity == null) {
+                log.error("用户不存在: {}", param.getId());
+                return Result.failure("用户不存在");
+            }
+            BeanUtils.copyProperties(param, entity);
+            entity.setUpdateTime(new Date());
+            userService.update(entity);
+        }
+
+        return Result.success();
+    }
 
 
     @ApiOperation("查询用户信息")
@@ -91,7 +94,7 @@ public class SysUserController extends BaseController {
         return Result.success(user);
     }
 
-    @WebControllerLog(description = "用户管理-修改密码")
+    @WebControllerLog(description = "用户管理-修改密码", addDb = true)
     @ApiOperation("修改密码")
     @PostMapping("updatePwd")
     public Result updatePwd(@Valid @RequestBody PasswordRequest param) {

+ 39 - 0
gis_web/src/main/java/com/gis/web/controller/WebController.java

@@ -0,0 +1,39 @@
+package com.gis.web.controller;
+
+import com.gis.common.util.Result;
+import com.gis.domain.dto.GoodsPageDto;
+import com.gis.domain.po.GoodsEntity;
+import com.gis.domain.po.ZoneEntity;
+import com.gis.service.GoodsService;
+import com.gis.service.ZoneService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * Created by owen on 2021/5/18 0018 14:50
+ */
+@Api(tags = "展示页")
+@RestController
+@RequestMapping("api/web")
+public class WebController {
+
+    @Autowired
+    private ZoneService zoneService;
+
+    @Autowired
+    private GoodsService goodsService;
+
+    @ApiOperation("展区列表")
+    @GetMapping("zoneList")
+    public Result<ZoneEntity> list() {
+        return Result.success(zoneService.findAll());
+    }
+
+    @ApiOperation("文物列表")
+    @PostMapping("goodsList")
+    public Result<GoodsEntity> list(@RequestBody GoodsPageDto param) {
+        return goodsService.search(param);
+    }
+}

+ 6 - 3
gis_web/src/main/java/com/gis/web/controller/ZoneController.java

@@ -1,6 +1,7 @@
 package com.gis.web.controller;
 
 import com.gis.common.util.Result;
+import com.gis.domain.dto.ZoneDto;
 import com.gis.domain.po.ZoneEntity;
 import com.gis.service.ZoneService;
 import com.gis.service.aop.WebControllerLog;
@@ -9,6 +10,7 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
 import java.util.Date;
 
 /**
@@ -32,13 +34,14 @@ public class ZoneController extends BaseController {
 
     @WebControllerLog(description = "展区管理-编辑", addDb = true)
     @ApiOperation("编辑")
-    @GetMapping("edit/{id}/{name}")
-    public Result edit(@PathVariable Long id, @PathVariable String name) {
+    @PostMapping("edit")
+    public Result edit(@Valid @RequestBody ZoneDto param) {
+        Long id = param.getId();
         ZoneEntity entity = zoneService.findById(id);
         if (entity == null){
             return Result.failure("对象不存在:" + id);
         }
-        entity.setName(name);
+        entity.setName(param.getName());
         entity.setUpdateTime(new Date());
         zoneService.update(entity);