瀏覽代碼

写了一个提交blob的测试demo

cr7118@sina.cn 3 年之前
父節點
當前提交
a8f5a8fe04

+ 43 - 0
application-facade/src/main/java/com/factory/controller/web/TestBlobController.java

@@ -0,0 +1,43 @@
+package com.factory.controller.web;
+
+import com.factory.web.service.impl.TestEntry;
+import com.factory.web.service.impl.TestServiceImpl;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.nio.charset.StandardCharsets;
+
+
+@Api(tags = "本特勒 - blob测试")
+@RestController
+@RequestMapping("/benteler/testblob")
+public class TestBlobController {
+
+    @Autowired
+    private TestServiceImpl testService;
+
+
+    @GetMapping("/addIniPlan")
+    @ApiOperation(value = "testItem")
+    public void addIniPlan(HttpServletRequest request) {
+       TestEntry testEntry=TestEntry.builder().bentelerPlanId(Long.parseLong("1"))
+               .titleContent("test.asgajsd".getBytes(StandardCharsets.UTF_8)).build();
+        testService.save(testEntry);
+        System.out.println("11111111111111111111111111111111111111111");
+    }
+
+    @GetMapping("/getIniPlan")
+    public void getIniPlan(HttpServletRequest request) {
+        Long versionId = Long.valueOf(2);
+        TestEntry pp= testService.getById(versionId);
+        pp.setTitleContentStr(new String(pp.getTitleContent(),StandardCharsets.UTF_8));
+        System.out.println(pp.getTitleContentStr());
+    }
+
+
+}

+ 25 - 0
application-facade/src/main/java/com/factory/web/mapper/test/TestMapper.java

@@ -0,0 +1,25 @@
+package com.factory.web.mapper.test;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.factory.web.service.impl.TestEntry;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Result;
+import org.apache.ibatis.annotations.Results;
+
+import java.io.Serializable;
+
+@Mapper
+
+public interface TestMapper extends BaseMapper<TestEntry> {
+
+//    @Results({
+//            @Result(id = true,column = "id",property = "id"),
+//            @Result(column = "benteler_plan_id",property = "benteler_plan_id"),
+//            @Result(column = "title_content",property = "title_content_str")
+//    })
+//    int insert(T entity);
+
+//    TestEntry selectById(Serializable id);
+}
+
+

+ 29 - 0
application-facade/src/main/java/com/factory/web/service/impl/TestEntry.java

@@ -0,0 +1,29 @@
+package com.factory.web.service.impl;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.ibatis.annotations.Result;
+import org.apache.ibatis.annotations.Results;
+
+@Data
+@TableName("onsite_title_blob")
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class TestEntry {
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    private Long bentelerPlanId;
+
+    private byte[] titleContent;
+    @TableField(exist = false)
+    private String titleContentStr;
+}

+ 11 - 0
application-facade/src/main/java/com/factory/web/service/impl/TestServiceImpl.java

@@ -0,0 +1,11 @@
+package com.factory.web.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.factory.web.mapper.test.TestMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class TestServiceImpl extends ServiceImpl<TestMapper,TestEntry> {
+}