| package com.xcong.excoin.modules.helpCenter.controller;  | 
|   | 
| import java.io.IOException;  | 
| import java.util.HashMap;  | 
| import java.util.Map;  | 
|   | 
| import javax.validation.Valid;  | 
| import javax.validation.constraints.NotNull;  | 
|   | 
| import org.springframework.validation.annotation.Validated;  | 
| import org.springframework.web.bind.annotation.GetMapping;  | 
| import org.springframework.web.bind.annotation.PathVariable;  | 
| import org.springframework.web.bind.annotation.PostMapping;  | 
| import org.springframework.web.bind.annotation.RequestBody;  | 
| import org.springframework.web.bind.annotation.RequestMapping;  | 
| import org.springframework.web.bind.annotation.RestController;  | 
| import org.springframework.web.multipart.MultipartFile;  | 
|   | 
| import com.xcong.excoin.common.annotation.ControllerEndpoint;  | 
| import com.xcong.excoin.common.controller.BaseController;  | 
| import com.xcong.excoin.common.entity.FebsResponse;  | 
| import com.xcong.excoin.common.entity.QueryRequest;  | 
| import com.xcong.excoin.common.utils.OssUtils;  | 
| import com.xcong.excoin.modules.helpCenter.entity.HelpCenterArticleEntity;  | 
| import com.xcong.excoin.modules.helpCenter.entity.HelpCenterNoticeEntity;  | 
| import com.xcong.excoin.modules.helpCenter.entity.HelpCenterTypeEntity;  | 
| import com.xcong.excoin.modules.helpCenter.service.HelpCenterService;  | 
| import sun.misc.BASE64Encoder;  | 
|   | 
| import cn.hutool.core.util.IdUtil;  | 
| import lombok.RequiredArgsConstructor;  | 
| import lombok.extern.slf4j.Slf4j;  | 
|   | 
| @Slf4j  | 
| @Validated  | 
| @RestController  | 
| @RequiredArgsConstructor  | 
| @RequestMapping(value = "/helpCenter")  | 
| public class HelpCenterController extends BaseController {  | 
|       | 
|     private final HelpCenterService helpCenterService;  | 
|       | 
|     /**  | 
|      * 帮助中心---类型---删除  | 
|      * @param id  | 
|      * @return  | 
|      */  | 
|     @GetMapping("helpCenterTypeDelete/{id}")  | 
|     @ControllerEndpoint(operation = "删除", exceptionMessage = "删除失败")  | 
|     public FebsResponse helpCenterTypeDelete(@NotNull(message = "{required}") @PathVariable Long id) {  | 
|         return helpCenterService.helpCenterTypeDelete(id);  | 
|     }  | 
|       | 
|     /**  | 
|      * 帮助中心---类型---新增  | 
|      */  | 
|     @PostMapping("helpCenterTypeAdds")  | 
|     @ControllerEndpoint(operation = " 帮助中心---类型---新增", exceptionMessage = "新增失败")  | 
|     public FebsResponse helpCenterTypeAdds(@Valid HelpCenterTypeEntity helpCenterTypeEntity) {  | 
|         helpCenterService.helpCenterTypeAdds(helpCenterTypeEntity);  | 
|         return new FebsResponse().success();  | 
|     }  | 
|       | 
|     /**  | 
|      *  帮助中心---类型---列表  | 
|      * @return  | 
|      */  | 
|     @GetMapping("getHelpCenterTypeList")  | 
|     public FebsResponse getHelpCenterTypeList(HelpCenterTypeEntity helpCenterTypeEntity, QueryRequest request) {  | 
|         Map<String, Object> data = getDataTable(helpCenterService.findHelpCenterTypeListInPage(helpCenterTypeEntity, request));  | 
|         return new FebsResponse().success().data(data);  | 
|     }  | 
|       | 
|     /**  | 
|      *  帮助中心---列表  | 
|      * @return  | 
|      */  | 
|     @GetMapping("getHelpCenterList")  | 
|     public FebsResponse getHelpCenterList(HelpCenterNoticeEntity helpCenterNoticeEntity, QueryRequest request) {  | 
|         Map<String, Object> data = getDataTable(helpCenterService.findHelpCenterListInPage(helpCenterNoticeEntity, request));  | 
|         return new FebsResponse().success().data(data);  | 
|     }  | 
|       | 
|     /**  | 
|      * 帮助中心---删除公告  | 
|      * @param id  | 
|      * @return  | 
|      */  | 
|     @GetMapping("helpCenterDelete/{id}")  | 
|     @ControllerEndpoint(operation = "删除公告", exceptionMessage = "删除失败")  | 
|     public FebsResponse helpCenterDelete(@NotNull(message = "{required}") @PathVariable Long id) {  | 
|         return helpCenterService.helpCenterDelete(id);  | 
|     }  | 
|       | 
|     /**  | 
|      * 帮助中心---新增  | 
|      */  | 
|     @PostMapping("helpCenterAdds")  | 
|     @ControllerEndpoint(operation = " 帮助中心---新增", exceptionMessage = "新增失败")  | 
|     public FebsResponse helpCenterAdds(@Valid HelpCenterNoticeEntity helpCenterNoticeEntity) {  | 
|         helpCenterService.helpCenterAdds(helpCenterNoticeEntity);  | 
|         return new FebsResponse().success();  | 
|     }  | 
|       | 
|     /**  | 
|      * 帮助中心---中文确认  | 
|      * @return  | 
|      */  | 
|     @PostMapping("helpCenterConfirm")  | 
|     @ControllerEndpoint(operation = "帮助中心---确认", exceptionMessage = "设置失败")  | 
|     public FebsResponse helpCenterConfirm(@Valid HelpCenterArticleEntity helpCenterArticleEntity) {  | 
|         return helpCenterService.helpCenterConfirm(helpCenterArticleEntity);  | 
|     }  | 
|       | 
|     /**  | 
|      * 帮助中心---英文确认  | 
|      * @return  | 
|      */  | 
|     @PostMapping("helpCenterUsConfirm")  | 
|     @ControllerEndpoint(operation = "帮助中心---确认", exceptionMessage = "设置失败")  | 
|     public FebsResponse helpCenterUsConfirm(@Valid HelpCenterArticleEntity helpCenterArticleEntity) {  | 
|         return helpCenterService.helpCenterUsConfirm(helpCenterArticleEntity);  | 
|     }  | 
|       | 
|     /**  | 
|      *  帮助中心---图片上传  | 
|      * @param uploadDto  | 
|      * @return  | 
|      */  | 
|     @PostMapping(value = "/uploadFileBase64")  | 
|     @ControllerEndpoint(operation = "帮助中心---图片上传", exceptionMessage = "上传失败")  | 
|     public Map<String,Object> uploadFileBase64(@RequestBody @Validated MultipartFile file) {  | 
|         if (file.isEmpty()) {  | 
|             new FebsResponse().message("上传文件为空");  | 
|         }  | 
|           | 
|         //文件加密  | 
|         BASE64Encoder base64Encoder =new BASE64Encoder();  | 
|         String base64EncoderImg = null;  | 
|         try {  | 
|             base64EncoderImg = base64Encoder.encode(file.getBytes());  | 
|         } catch (IOException e) {  | 
|             e.printStackTrace();  | 
|         }  | 
|   | 
|         String imageFuffix = ".jpg";  | 
|         String imageNames = System.currentTimeMillis() + IdUtil.simpleUUID() + imageFuffix;  | 
|         String imageName = "uploadeFile/image/" + imageNames;  | 
|         OssUtils.uploadFileWithBase64(base64EncoderImg, imageName);  | 
|             String bucket_name ="https://excoin.oss-cn-hangzhou.aliyuncs.com";  | 
|             String url = bucket_name + "/" + imageName;  | 
|               | 
|             Map<String,Object> map = new HashMap<String,Object>();  | 
|             Map<String,Object> map2 = new HashMap<String,Object>();  | 
|             map.put("code",0);//0表示成功,1失败  | 
|             map.put("msg","上传成功");//提示消息  | 
|             map.put("data",map2);  | 
|             map2.put("src",url);//图片url  | 
|             map2.put("title",imageNames);//图片名称,这个会显示在输入框里  | 
|             return map;  | 
|     }  | 
|       | 
|       | 
|   | 
| }  |