前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >基于SSM实现仿知乎微信小程序分享

基于SSM实现仿知乎微信小程序分享

作者头像
大头猿
发布2022-10-27 11:18:10
3560
发布2022-10-27 11:18:10
举报
文章被收录于专栏:大头猿大头猿

技术点

  • 开发语言:Java
  • 框架:ssm框架
  • JDK版本:JDK1.8
  • 服务器:tomcat8.5
  • 数据库:mysql 5.7(请一定使用5.×版本数据库,尽量使用5.7)
  • 数据库工具:Navicat16
  • 开发软件:eclipse或者idea都可以
  • Maven包:Maven3.3.9

系统功能介绍

(1)用户管理功能。主要实现了仿知乎微信小程序的用户管理功能。

(2)标签管理功能。主要实现了仿知乎微信小程序的标签管理功能。

(3)今日热闻管理功能。主要实现了仿知乎微信小程序的今日热闻管理功能。

(4)问答模式管理功能。主要实现了仿知乎微信小程序的问答模式管理功能。

(5)文件管理功能。主要实现了仿知乎微信小程序的文件管理功能。

截图演示

主要代码逻辑

代码语言:javascript
复制
/**
 * 通用接口
 */
@RestController
public class CommonController{
 @Autowired
 private CommonService commonService;
 
 @Autowired
 private ConfigService configService;
 
 private static AipFace client = null;
 
 private static String BAIDU_DITU_AK = null;
 
 @RequestMapping("/location")
 public R location(String lng,String lat) {
  if(BAIDU_DITU_AK==null) {
   BAIDU_DITU_AK = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "baidu_ditu_ak")).getValue();
   if(BAIDU_DITU_AK==null) {
    return R.error("请在配置管理中正确配置baidu_ditu_ak");
   }
  }
  Map<String, String> map = BaiduUtil.getCityByLonLat(BAIDU_DITU_AK, lng, lat);
  return R.ok().put("data", map);
 }
 
 /**
  * 人脸比对
  * 
  * @param face1 人脸1
  * @param face2 人脸2
  * @return
  */
 @RequestMapping("/matchFace")
 public R matchFace(String face1, String face2,HttpServletRequest request) {
  if(client==null) {
   /*String AppID = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "AppID")).getValue();*/
   String APIKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "APIKey")).getValue();
   String SecretKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "SecretKey")).getValue();
   String token = BaiduUtil.getAuth(APIKey, SecretKey);
   if(token==null) {
    return R.error("请在配置管理中正确配置APIKey和SecretKey");
   }
   client = new AipFace(null, APIKey, SecretKey);
   client.setConnectionTimeoutInMillis(2000);
   client.setSocketTimeoutInMillis(60000);
  }
  JSONObject res = null;
  try {
   File file1 = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+face1);
   File file2 = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+face2);
   String img1 = Base64Util.encode(FileUtil.FileToByte(file1));
   String img2 = Base64Util.encode(FileUtil.FileToByte(file2));
   MatchRequest req1 = new MatchRequest(img1, "BASE64");
   MatchRequest req2 = new MatchRequest(img2, "BASE64");
   ArrayList<MatchRequest> requests = new ArrayList<MatchRequest>();
   requests.add(req1);
   requests.add(req2);
   res = client.match(requests);
   System.out.println(res.get("result"));
  } catch (FileNotFoundException e) {
   e.printStackTrace();
   return R.error("文件不存在");
  } catch (IOException e) {
   e.printStackTrace();
  } 
  return R.ok().put("data", com.alibaba.fastjson.JSONObject.parse(res.get("result").toString()));
 }
    
 /**
  * 获取table表中的column列表(联动接口)
  * @param table
  * @param column
  * @return
  */
 @IgnoreAuth
 @RequestMapping("/option/{tableName}/{columnName}")
 public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,String level,String parent) {
  Map<String, Object> params = new HashMap<String, Object>();
  params.put("table", tableName);
  params.put("column", columnName);
  if(StringUtils.isNotBlank(level)) {
   params.put("level", level);
  }
  if(StringUtils.isNotBlank(parent)) {
   params.put("parent", parent);
  }
  List<String> data = commonService.getOption(params);
  return R.ok().put("data", data);
 }

下载地址

下载地址

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2022-10-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 大头猿 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 技术点
  • 系统功能介绍
  • 截图演示
  • 主要代码逻辑
  • 下载地址
相关产品与服务
云开发 CloudBase
云开发(Tencent CloudBase,TCB)是腾讯云提供的云原生一体化开发环境和工具平台,为200万+企业和开发者提供高可用、自动弹性扩缩的后端云服务,可用于云端一体化开发多种端应用(小程序、公众号、Web 应用等),避免了应用开发过程中繁琐的服务器搭建及运维,开发者可以专注于业务逻辑的实现,开发门槛更低,效率更高。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档