Forráskód Böngészése

添加用户场景编辑接口

wuweihao 2 éve
szülő
commit
a0094a2de6

+ 24 - 0
gis_domain/src/main/java/com/gis/domain/po/ClientEntity.java

@@ -0,0 +1,24 @@
+package com.gis.domain.po;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+/**
+ * 场景可编辑表
+ */
+@Data
+@Entity
+@Table(name = "tb_client")
+public class ClientEntity extends BaseEntity implements Serializable {
+
+
+    private static final long serialVersionUID = 1146551448810703871L;
+
+    @ApiModelProperty(value = "场景码")
+    private String code;
+
+}

+ 20 - 0
gis_mapper/src/main/java/com/gis/mapper/ClientMapper.java

@@ -0,0 +1,20 @@
+package com.gis.mapper;
+
+
+import com.gis.domain.po.ClientEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+import org.springframework.stereotype.Component;
+
+
+@Component
+@Mapper
+public interface ClientMapper extends IBaseMapper<ClientEntity, Long> {
+
+    @Select("select * from tb_client where rec_status='A' and code=#{code} limit 1")
+    ClientEntity findByCode(String code);
+
+    @Update("update tb_client set rec_status='I', update_time = NOW() where code=#{code}")
+    void remove(String code);
+}

+ 19 - 0
gis_service/src/main/java/com/gis/service/ClientService.java

@@ -0,0 +1,19 @@
+package com.gis.service;
+
+
+import com.gis.common.util.Result;
+import com.gis.domain.po.ClientEntity;
+
+
+/**
+ * Created by owen on 2020/3/11 0011 16:14
+ */
+public interface ClientService extends IBaseService<ClientEntity, Long> {
+
+
+    Result saveCode(String code);
+
+    ClientEntity findByCode(String code);
+
+    Result remove(String sceneCode);
+}

+ 57 - 0
gis_service/src/main/java/com/gis/service/impl/ClientServiceImpl.java

@@ -0,0 +1,57 @@
+package com.gis.service.impl;
+
+import com.gis.common.exception.BaseRuntimeException;
+import com.gis.common.util.Result;
+import com.gis.domain.po.ClientEntity;
+import com.gis.mapper.ClientMapper;
+import com.gis.mapper.IBaseMapper;
+import com.gis.service.ClientService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+
+/**
+ * Created by owen on 2020/3/11 0011 16:16
+ */
+@Slf4j
+@Service
+public class ClientServiceImpl extends IBaseServiceImpl<ClientEntity, Long> implements ClientService {
+
+    @Autowired
+    private ClientMapper entityMapper;
+
+    @Override
+    public IBaseMapper<ClientEntity, Long> getBaseMapper() {
+        return this.entityMapper;
+    }
+
+
+    @Override
+    public Result saveCode(String code) {
+
+        BaseRuntimeException.isBlank(code, null, "场景码不能为空");
+        ClientEntity entity = this.findByCode(code);
+        BaseRuntimeException.isTrue(entity!=null, null, "此场景已存在");
+
+        entity = new ClientEntity();
+        entity.setCode(code);
+        this.save(entity);
+        return Result.success(entity);
+    }
+
+    @Override
+    public ClientEntity findByCode(String code) {
+        return entityMapper.findByCode(code);
+    }
+
+    @Override
+    public Result remove(String sceneCode) {
+        log.warn("sss :{}", sceneCode);
+         entityMapper.remove(sceneCode);
+         return Result.success();
+    }
+
+
+}

+ 2 - 3
gis_service/src/main/java/com/gis/service/impl/SceneServiceImpl.java

@@ -20,14 +20,13 @@ import com.gis.mapper.SceneMapper;
 import com.gis.mapper.IBaseMapper;
 import com.gis.mapper.IBaseMapper;
 import com.gis.service.SceneService;
 import com.gis.service.SceneService;
 import com.qiniu.common.QiniuException;
 import com.qiniu.common.QiniuException;
-import lombok.extern.log4j.Log4j2;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.junit.Test;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
-import javax.validation.constraints.NotBlank;
 import java.io.*;
 import java.io.*;
 import java.util.Date;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashMap;
@@ -38,7 +37,7 @@ import java.util.Set;
 /**
 /**
  * Created by owen on 2020/3/11 0011 16:16
  * Created by owen on 2020/3/11 0011 16:16
  */
  */
-@Log4j2
+@Slf4j
 @Service
 @Service
 public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implements SceneService {
 public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implements SceneService {
 
 

+ 34 - 0
gis_web/src/main/java/com/gis/web/controller/ClientController.java

@@ -0,0 +1,34 @@
+package com.gis.web.controller;
+
+import com.gis.common.util.Result;
+import com.gis.service.ClientService;
+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 2022/10/24 0024 18:02
+ */
+
+@Api(tags = "客户场景管理")
+@RestController
+@RequestMapping("api/client")
+public class ClientController {
+
+    @Autowired
+    ClientService clientService;
+
+    @ApiOperation("添加场景")
+    @GetMapping("/save/{sceneCode}")
+    public Result saveCode(@PathVariable String sceneCode) {
+        return clientService.saveCode(sceneCode);
+    }
+
+    @ApiOperation("删除场景")
+    @GetMapping("/remove/{sceneCode}")
+    public Result remove(@PathVariable String sceneCode) {
+        return clientService.remove(sceneCode);
+    }
+
+}

+ 2 - 1
gis_web/src/main/java/com/gis/web/controller/SceneController.java

@@ -22,6 +22,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
 import lombok.extern.log4j.Log4j2;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.junit.Test;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -37,7 +38,7 @@ import java.util.*;
 /**
 /**
  * Created by owen on 2020/5/8 0008 9:54
  * Created by owen on 2020/5/8 0008 9:54
  */
  */
-@Log4j2
+@Slf4j
 @Api(tags = "大场景")
 @Api(tags = "大场景")
 @RestController
 @RestController
 @RequestMapping("manage/scene")
 @RequestMapping("manage/scene")