一,系统演示
二,系统的简介
开发语言:Java
框架:ssm
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7(一定要5.7版本)
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
系统实现的主要功能
(1)用户管理。主要实现了仿知乎微信小程序的用户管理功能。
(2)标签管理。主要实现了仿知乎微信小程序的标签管理功能。
(3)今日热闻管理。主要实现了仿知乎微信小程序的今日热闻管理功能。
(4)问答模式管理。主要实现了仿知乎微信小程序的问答模式管理功能。
(5)文件管理。主要实现了仿知乎微信小程序的文件管理功能。
三,核心代码展示
@RestController @RequestMapping("/biaoqianleixing") public class BiaoqianleixingController { @Autowired private BiaoqianleixingService biaoqianleixingService; /** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,BiaoqianleixingEntity biaoqianleixing, HttpServletRequest request){ EntityWrapper<BiaoqianleixingEntity> ew = new EntityWrapper<BiaoqianleixingEntity>(); PageUtils page = biaoqianleixingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, biaoqianleixing), params), params)); return R.ok().put("data", page); } /** * 前端列表 */ @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,BiaoqianleixingEntity biaoqianleixing, HttpServletRequest request){ EntityWrapper<BiaoqianleixingEntity> ew = new EntityWrapper<BiaoqianleixingEntity>(); PageUtils page = biaoqianleixingService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, biaoqianleixing), params), params)); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/lists") public R list( BiaoqianleixingEntity biaoqianleixing){ EntityWrapper<BiaoqianleixingEntity> ew = new EntityWrapper<BiaoqianleixingEntity>(); ew.allEq(MPUtil.allEQMapPre( biaoqianleixing, "biaoqianleixing")); return R.ok().put("data", biaoqianleixingService.selectListView(ew)); } /** * 查询 */ @RequestMapping("/query") public R query(BiaoqianleixingEntity biaoqianleixing){ EntityWrapper< BiaoqianleixingEntity> ew = new EntityWrapper< BiaoqianleixingEntity>(); ew.allEq(MPUtil.allEQMapPre( biaoqianleixing, "biaoqianleixing")); BiaoqianleixingView biaoqianleixingView = biaoqianleixingService.selectView(ew); return R.ok("查询标签类型成功").put("data", biaoqianleixingView); } /** * 后端详情 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ BiaoqianleixingEntity biaoqianleixing = biaoqianleixingService.selectById(id); return R.ok().put("data", biaoqianleixing); } /** * 前端详情 */ @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ BiaoqianleixingEntity biaoqianleixing = biaoqianleixingService.selectById(id); return R.ok().put("data", biaoqianleixing); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody BiaoqianleixingEntity biaoqianleixing, HttpServletRequest request){ biaoqianleixing.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(biaoqianleixing); biaoqianleixingService.insert(biaoqianleixing); return R.ok(); } /** * 前端保存 */ @RequestMapping("/add") public R add(@RequestBody BiaoqianleixingEntity biaoqianleixing, HttpServletRequest request){ biaoqianleixing.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(biaoqianleixing); biaoqianleixingService.insert(biaoqianleixing); return R.ok(); } /** * 修改 */ @RequestMapping("/update") public R update(@RequestBody BiaoqianleixingEntity biaoqianleixing, HttpServletRequest request){ //ValidatorUtils.validateEntity(biaoqianleixing); biaoqianleixingService.updateById(biaoqianleixing);//全部更新 return R.ok(); } /** * 删除 */ @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ biaoqianleixingService.deleteBatchIds(Arrays.asList(ids)); return R.ok(); } /** * 提醒接口 */ @RequestMapping("/remind/{columnName}/{type}") public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, @PathVariable("type") String type,@RequestParam Map<String, Object> map) { map.put("column", columnName); map.put("type", type); if(type.equals("2")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); Date remindStartDate = null; Date remindEndDate = null; if(map.get("remindstart")!=null) { Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindStart); remindStartDate = c.getTime(); map.put("remindstart", sdf.format(remindStartDate)); } if(map.get("remindend")!=null) { Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindEnd); remindEndDate = c.getTime(); map.put("remindend", sdf.format(remindEndDate)); } } Wrapper<BiaoqianleixingEntity> wrapper = new EntityWrapper<BiaoqianleixingEntity>(); if(map.get("remindstart")!=null) { wrapper.ge(columnName, map.get("remindstart")); } if(map.get("remindend")!=null) { wrapper.le(columnName, map.get("remindend")); } int count = biaoqianleixingService.selectCount(wrapper); return R.ok().put("count", count); }
/** * 通用接口 */ @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); }