Commit d1ce2bf1 by jscat

nyx: oss上传功能

更新: 在回调函数中新增addT_post的功能,新增一条信息发布
parent 36d84cb5
package cn.com.fun.nyxkey.api.config; package cn.com.fun.nyxkey.api.config;
package cn.com.fun.nyxkey.api.config; package cn.com.fun.nyxkey.api.config;
import java.io.Serializable;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.checkerframework.checker.units.qual.C;
import org.springframework.context.annotation.Configuration;
import sun.reflect.ConstructorAccessor;
import sun.reflect.FieldAccessor;
import sun.reflect.ReflectionFactory;
public enum DatabaseType { public enum DatabaseType {
} }
\ No newline at end of file
package cn.com.fun.nyxkey.api.repository; package cn.com.fun.nyxkey.api.repository;
...@@ -36,6 +36,7 @@ public interface Rockwell_keyMapper { ...@@ -36,6 +36,7 @@ public interface Rockwell_keyMapper {
/* post api */ /* post api */
List<Rockwell_keyV_post_info> getV_post_info(Rockwell_keyT_postQuery rockwell_keyT_postQuery); List<Rockwell_keyV_post_info> getV_post_info(Rockwell_keyT_postQuery rockwell_keyT_postQuery);
void addT_post(Rockwell_keyT_post rockwell_keyT_post);
/* area api */ /* area api */
List<Rockwell_keyV_area_total> getCityList(); List<Rockwell_keyV_area_total> getCityList();
......
package cn.com.fun.nyxkey.api.service; package cn.com.fun.nyxkey.api.service;
...@@ -6,6 +6,7 @@ import cn.com.fun.nyxkey.api.domain.*; ...@@ -6,6 +6,7 @@ import cn.com.fun.nyxkey.api.domain.*;
import cn.com.fun.nyxkey.api.domain.query.*; import cn.com.fun.nyxkey.api.domain.query.*;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import java.io.UnsupportedEncodingException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -14,6 +15,7 @@ import java.util.List; ...@@ -14,6 +15,7 @@ import java.util.List;
*/ */
public interface Rockwell_keyService { public interface Rockwell_keyService {
// t_quiz相关的函数
JSONResult Rockwell_keyServiceGetT_quizWithPage(String strQuestionName, int pageNum, int pageCount); JSONResult Rockwell_keyServiceGetT_quizWithPage(String strQuestionName, int pageNum, int pageCount);
JSONResult Rockwell_keyServiceGetT_quizRand(); JSONResult Rockwell_keyServiceGetT_quizRand();
JSONResult Rockwell_keyServiceGetT_matchLike(); JSONResult Rockwell_keyServiceGetT_matchLike();
...@@ -42,6 +44,11 @@ public interface Rockwell_keyService { ...@@ -42,6 +44,11 @@ public interface Rockwell_keyService {
/* post api */ /* post api */
JSONResult Rockwell_keyServiceGetV_post_info(String tag, String title, String top, int pageNum, int pageCount); JSONResult Rockwell_keyServiceGetV_post_info(String tag, String title, String top, int pageNum, int pageCount);
/* todo 添加新增pos功能
* 数据流 小程序客户端 -> 阿里云oss -> callback回应用服务器 -> AddT_post
* */
int Rockwell_keyServiceAddT_post(String userId, String noteImage, String tag, String title, String content) throws UnsupportedEncodingException;
/* member pos api */ /* member pos api */
JSONResult Rockwell_keyServiceGetCityList(); JSONResult Rockwell_keyServiceGetCityList();
......
package cn.com.fun.nyxkey.api.service.impl; package cn.com.fun.nyxkey.api.service.impl;
...@@ -9,15 +9,19 @@ import cn.com.fun.nyxkey.api.domain.query.*; ...@@ -9,15 +9,19 @@ import cn.com.fun.nyxkey.api.domain.query.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.K; import org.checkerframework.checker.units.qual.K;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.mortbay.util.UrlEncoded;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -33,6 +37,12 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService { ...@@ -33,6 +37,12 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService {
@Autowired @Autowired
private Rockwell_keyMapper rockwell_keyMapper; private Rockwell_keyMapper rockwell_keyMapper;
@Value("${aliyun.oss.endpoint}")
private String aliyunOssEndpoint;
@Value("${aliyun.oss.bucket}")
private String aliyunOssBucket;
/* /*
接口api: main use 题目热搜 接口api: main use 题目热搜
*/ */
...@@ -288,6 +298,30 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService { ...@@ -288,6 +298,30 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService {
JSONResult jsonResult = new JSONResult(totalCount, listRockwell_keyV_post_info); JSONResult jsonResult = new JSONResult(totalCount, listRockwell_keyV_post_info);
return jsonResult; return jsonResult;
} }
// 新增post
/*
post_id, user_id, tag, note_image, title, content, create_datetime, update_datetime
*/
public int Rockwell_keyServiceAddT_post(String userId, String noteImage, String tag, String title, String content) throws UnsupportedEncodingException {
LOGGER.debug("find Rockwell_keyServiceAddT_post");
System.out.println("find Rockwell_keyServiceAddT_post");
String endpoint = aliyunOssEndpoint; // 请填写您的 endpoint
String bucket = aliyunOssBucket; // 请填写您的 bucketname
String host = "http://" + bucket + "." + endpoint + "/"; // host的格式为 bucketname.endpoint
Rockwell_keyT_post rockwell_keyT_post = new Rockwell_keyT_post();
rockwell_keyT_post.setPostId("pid_"+UUID.randomUUID().toString());
rockwell_keyT_post.setUserId(userId);
rockwell_keyT_post.setTag(URLDecoder.decode(tag, "UTF-8"));
rockwell_keyT_post.setNoteImage(host+noteImage);
rockwell_keyT_post.setTitle(URLDecoder.decode(title, "UTF-8"));
rockwell_keyT_post.setContent(URLDecoder.decode(content, "UTF-8"));
rockwell_keyT_post.setCreateDatetime(new Date());
rockwell_keyT_post.setUpdateDatetime(new Date());
System.out.println(rockwell_keyT_post);
rockwell_keyMapper.addT_post(rockwell_keyT_post);
return 0;
}
/* member pos api */ /* member pos api */
public JSONResult Rockwell_keyServiceGetCityList() public JSONResult Rockwell_keyServiceGetCityList()
......
package cn.com.fun.nyxkey.api.web.controller; package cn.com.fun.nyxkey.api.web.controller;
...@@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.UnsupportedEncodingException;
/** /**
* Created by jscat on 2020-04-21. * Created by jscat on 2020-04-21.
* *
...@@ -33,6 +35,9 @@ public class OssApiController { ...@@ -33,6 +35,9 @@ public class OssApiController {
@Autowired @Autowired
private Rockwell_ossService ossService; private Rockwell_ossService ossService;
@Autowired
private Rockwell_keyService keyService;
// 3.0 oss getToken api // 3.0 oss getToken api
@ApiOperation(value="获取阿里云oss token", notes="获取阿里云oss token") @ApiOperation(value="获取阿里云oss token", notes="获取阿里云oss token")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -55,7 +60,7 @@ public class OssApiController { ...@@ -55,7 +60,7 @@ public class OssApiController {
// 前端请求传Json对象的字符串则后端使用@RequestBody。 // 前端请求传Json对象的字符串则后端使用@RequestBody。
@RequestMapping(value = "/nyx/oss/callback", method = RequestMethod.POST) @RequestMapping(value = "/nyx/oss/callback", method = RequestMethod.POST)
@ResponseBody @ResponseBody
public JSONObject callback( public JSONObject callback (
@RequestParam(value = "filename", required = false, defaultValue = "0") String filename, @RequestParam(value = "filename", required = false, defaultValue = "0") String filename,
@RequestParam(value = "size", required = false, defaultValue = "0") String size, @RequestParam(value = "size", required = false, defaultValue = "0") String size,
@RequestParam(value = "height", required = false, defaultValue = "0") String height, @RequestParam(value = "height", required = false, defaultValue = "0") String height,
...@@ -64,9 +69,10 @@ public class OssApiController { ...@@ -64,9 +69,10 @@ public class OssApiController {
@RequestParam(value = "title", required = false, defaultValue = "0") String title, @RequestParam(value = "title", required = false, defaultValue = "0") String title,
@RequestParam(value = "content", required = false, defaultValue = "0") String content, @RequestParam(value = "content", required = false, defaultValue = "0") String content,
@RequestParam(value = "category", required = false, defaultValue = "0") String category @RequestParam(value = "category", required = false, defaultValue = "0") String category
){ ) throws UnsupportedEncodingException {
System.out.println("===callback_\n"); System.out.println("===callback_\n");
System.out.println("===filename: "+filename+"&tag="+tag+"&title="+title+"&content="+content+"&category="+category); System.out.println("===filename: "+filename+"&tag="+tag+"&title="+title+"&content="+content+"&category="+category);
keyService.Rockwell_keyServiceAddT_post("uid_123",filename, tag, title, content);
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("Status","OK"); result.put("Status","OK");
return result; return result;
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
...@@ -255,6 +255,11 @@ limitations under the License. ...@@ -255,6 +255,11 @@ limitations under the License.
</if> </if>
</select> </select>
<!-- 添加一条post信息 -->
<insert id="addT_post" parameterType="cn.com.fun.nyxkey.api.domain.Rockwell_keyT_post">
insert into tbl_post(post_id, user_id, tag, note_image, title, content, create_datetime, update_datetime)
values (#{postId}, #{userId}, #{tag} , #{noteImage}, #{title}, #{content}, #{createDatetime}, #{updateDatetime})
</insert>
<!-- post api 4.1 从 view_post_info 获取 post信息 <!-- post api 4.1 从 view_post_info 获取 post信息
--> -->
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论