change 4 anni fa
parent
commit
5093611fcf

+ 2 - 1
zhongzheng-api/src/main/java/com/zhongzheng/controller/base/UserProfileStampController.java

@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -76,7 +77,7 @@ public class UserProfileStampController extends BaseController {
 
     @ApiOperation("导出盖章word")
     @PostMapping("/addWord")
-    public AjaxResult<Void> addWord(@RequestBody UserProfileAddBo bo) {
+    public AjaxResult<Void> addWord(@RequestBody UserProfileAddBo bo) throws IOException {
         ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
         bo.setUserId(loginUser.getUser().getUserId());
         String s = iUserProfileService.addWord(bo);

+ 4 - 0
zhongzheng-system/pom.xml

@@ -27,6 +27,10 @@
             <groupId>com.github.xiaoymin</groupId>
             <artifactId>knife4j-spring-boot-starter</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+        </dependency>
 
     </dependencies>
 

+ 3 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/IUserProfileService.java

@@ -7,6 +7,8 @@ import com.zhongzheng.modules.base.bo.UserProfileAddBo;
 import com.zhongzheng.modules.base.bo.UserProfileEditBo;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.util.Collection;
 import java.util.List;
 
@@ -50,7 +52,7 @@ public interface IUserProfileService extends IService<UserProfile> {
 	 */
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
 
-	String addWord(UserProfileAddBo bo);
+	String addWord(UserProfileAddBo bo) throws IOException;
 
 	UserProfileVo getInfo(UserProfileQueryBo bo);
 

+ 23 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/impl/UserProfileServiceImpl.java

@@ -11,10 +11,15 @@ import cn.hutool.poi.word.Word07Writer;
 import com.alibaba.fastjson.JSONObject;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.SecurityUtils;
+import com.zhongzheng.modules.alioss.bo.OssRequest;
+import com.zhongzheng.modules.alioss.service.impl.OssServiceImpl;
 import com.zhongzheng.modules.base.bo.UserProfileFit;
+import org.apache.http.entity.ContentType;
 import org.apache.poi.xwpf.usermodel.BreakType;
 import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -27,6 +32,7 @@ import com.zhongzheng.modules.base.domain.UserProfile;
 import com.zhongzheng.modules.base.mapper.UserProfileMapper;
 import com.zhongzheng.modules.base.vo.UserProfileVo;
 import com.zhongzheng.modules.base.service.IUserProfileService;
+import org.springframework.web.multipart.MultipartFile;
 import sun.misc.BASE64Encoder;
 
 import java.awt.*;
@@ -49,6 +55,12 @@ public class UserProfileServiceImpl extends ServiceImpl<UserProfileMapper, UserP
     @Value("${aliyun.oss.endpoint}")
     private String ALIYUN_OSS_ENDPOINT;
 
+    @Value("${zhongzheng.profile}")
+    private String ZHONGZHENG_PROFILE;
+
+    @Autowired()
+    private OssServiceImpl ossService;
+
     @Override
     public UserProfileVo queryById(Long id){
         UserProfileQueryBo userProfileQueryBo = new UserProfileQueryBo();
@@ -135,7 +147,7 @@ public class UserProfileServiceImpl extends ServiceImpl<UserProfileMapper, UserP
     }
 
     @Override
-    public String addWord(UserProfileAddBo bo) {
+    public String addWord(UserProfileAddBo bo) throws IOException {
         UserProfileQueryBo userProfileQueryBo = new UserProfileQueryBo();
         userProfileQueryBo.setUserId(bo.getUserId());
         userProfileQueryBo.setGoodsId(bo.getGoodsId());
@@ -164,10 +176,17 @@ public class UserProfileServiceImpl extends ServiceImpl<UserProfileMapper, UserP
         bindingMap.put("d", 1);
         bindingMap.put("time", JSONObject.parseObject(String.valueOf(maps.get("graduation_time")), UserProfileFit.class).getValue());
         bindingMap.put("year", JSONObject.parseObject(String.valueOf(maps.get("working_years")), UserProfileFit.class).getValue());
+        File touch = FileUtil.touch(ZHONGZHENG_PROFILE+"word.docx");
         //最终渲染出来的样子
-        template.render(bindingMap);
-
-        return "11";
+        template.render(bindingMap,touch);
+        OssRequest ossRequest = new OssRequest();
+        FileInputStream fileInputStream = new FileInputStream(touch);
+        MultipartFile multipartFile = new MockMultipartFile(touch.getName(), touch.getName(),
+                ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);
+        ossRequest.setFile((MultipartFile) touch);
+        ossRequest.setImageStatus(6);
+        String upload = ossService.upload(ossRequest);
+        return upload;
     }
 
     @Override

+ 1 - 1
zhongzheng-system/src/main/resources/mapper/modules/base/UserProfileMapper.xml

@@ -153,7 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM
         user_profile up
         where 1=1
-        and up.current_status = 0
+        and up.current_status = 2
         <if test="typeStatus != null and typeStatus !='' ">
             and up.type_status = #{typeStatus}
         </if>