• 基于springboot二手交易平台


    开发工具:IDEA

    服务器:Tomcat9.0, jdk1.8

    项目构建:maven

    数据库:mysql5.7

    系统分前后台,非前后端分离

    前端技术:vue.js+elementUI等框架实现

    服务端技术:springboot+mybatis-plus

    项目功能描述:

    系统主要分为三个角色:用户、卖家、管理员

    用户功能:登录、注册、首页、个人中心、订单管理、商品求购管理、我的收藏

    卖家功能:登录、注册、首页、个人中心、商品信息管理、订单管理

    管理员功能:登录、首页、个人中心、用户管理、卖家管理、商品分类管理、订单管理、商品求购管理、管理员管理、留言板管理、系统管理

     前台截图:

     

     

     

     

     

     

     

    买家截图:

     

     

     

     

     

    卖家管理:

     

     

     

     

    管理员截图:

     

     

     

     

     

     

     

     

     

     

     

     

     

    1. package com.controller;
    2. import java.io.File;
    3. import java.io.FileNotFoundException;
    4. import java.io.IOException;
    5. import java.text.SimpleDateFormat;
    6. import java.util.ArrayList;
    7. import java.util.Calendar;
    8. import java.util.Date;
    9. import java.util.HashMap;
    10. import java.util.List;
    11. import java.util.Map;
    12. import org.apache.commons.lang3.StringUtils;
    13. import org.json.JSONObject;
    14. import org.springframework.beans.factory.annotation.Autowired;
    15. import org.springframework.util.ResourceUtils;
    16. import org.springframework.web.bind.annotation.PathVariable;
    17. import org.springframework.web.bind.annotation.RequestBody;
    18. import org.springframework.web.bind.annotation.RequestMapping;
    19. import org.springframework.web.bind.annotation.RequestParam;
    20. import org.springframework.web.bind.annotation.RestController;
    21. import com.annotation.IgnoreAuth;
    22. import com.baidu.aip.face.AipFace;
    23. import com.baidu.aip.face.MatchRequest;
    24. import com.baidu.aip.util.Base64Util;
    25. import com.baomidou.mybatisplus.mapper.EntityWrapper;
    26. import com.baomidou.mybatisplus.mapper.Wrapper;
    27. import com.entity.ConfigEntity;
    28. import com.service.CommonService;
    29. import com.service.ConfigService;
    30. import com.utils.BaiduUtil;
    31. import com.utils.FileUtil;
    32. import com.utils.R;
    33. /**
    34. * 通用接口
    35. */
    36. @RestController
    37. public class CommonController{
    38. @Autowired
    39. private CommonService commonService;
    40. @Autowired
    41. private ConfigService configService;
    42. private static AipFace client = null;
    43. private static String BAIDU_DITU_AK = null;
    44. @RequestMapping("/location")
    45. public R location(String lng,String lat) {
    46. if(BAIDU_DITU_AK==null) {
    47. BAIDU_DITU_AK = configService.selectOne(new EntityWrapper().eq("name", "baidu_ditu_ak")).getValue();
    48. if(BAIDU_DITU_AK==null) {
    49. return R.error("请在配置管理中正确配置baidu_ditu_ak");
    50. }
    51. }
    52. Map map = BaiduUtil.getCityByLonLat(BAIDU_DITU_AK, lng, lat);
    53. return R.ok().put("data", map);
    54. }
    55. /**
    56. * 人脸比对
    57. *
    58. * @param face1 人脸1
    59. * @param face2 人脸2
    60. * @return
    61. */
    62. @RequestMapping("/matchFace")
    63. public R matchFace(String face1, String face2) {
    64. if(client==null) {
    65. /*String AppID = configService.selectOne(new EntityWrapper().eq("name", "AppID")).getValue();*/
    66. String APIKey = configService.selectOne(new EntityWrapper().eq("name", "APIKey")).getValue();
    67. String SecretKey = configService.selectOne(new EntityWrapper().eq("name", "SecretKey")).getValue();
    68. String token = BaiduUtil.getAuth(APIKey, SecretKey);
    69. if(token==null) {
    70. return R.error("请在配置管理中正确配置APIKey和SecretKey");
    71. }
    72. client = new AipFace(null, APIKey, SecretKey);
    73. client.setConnectionTimeoutInMillis(2000);
    74. client.setSocketTimeoutInMillis(60000);
    75. }
    76. JSONObject res = null;
    77. try {
    78. File file1 = new File(ResourceUtils.getFile("classpath:static/upload").getAbsolutePath()+"/"+face1);
    79. File file2 = new File(ResourceUtils.getFile("classpath:static/upload").getAbsolutePath()+"/"+face2);
    80. String img1 = Base64Util.encode(FileUtil.FileToByte(file1));
    81. String img2 = Base64Util.encode(FileUtil.FileToByte(file2));
    82. MatchRequest req1 = new MatchRequest(img1, "BASE64");
    83. MatchRequest req2 = new MatchRequest(img2, "BASE64");
    84. ArrayList requests = new ArrayList();
    85. requests.add(req1);
    86. requests.add(req2);
    87. res = client.match(requests);
    88. System.out.println(res.get("result"));
    89. } catch (FileNotFoundException e) {
    90. e.printStackTrace();
    91. return R.error("文件不存在");
    92. } catch (IOException e) {
    93. e.printStackTrace();
    94. }
    95. return R.ok().put("data", com.alibaba.fastjson.JSONObject.parse(res.get("result").toString()));
    96. }
    97. /**
    98. * 获取table表中的column列表(联动接口)
    99. * @param table
    100. * @param column
    101. * @return
    102. */
    103. @IgnoreAuth
    104. @RequestMapping("/option/{tableName}/{columnName}")
    105. public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,String level,String parent) {
    106. Map params = new HashMap();
    107. params.put("table", tableName);
    108. params.put("column", columnName);
    109. if(StringUtils.isNotBlank(level)) {
    110. params.put("level", level);
    111. }
    112. if(StringUtils.isNotBlank(parent)) {
    113. params.put("parent", parent);
    114. }
    115. List data = commonService.getOption(params);
    116. return R.ok().put("data", data);
    117. }
    118. /**
    119. * 根据table中的column获取单条记录
    120. * @param table
    121. * @param column
    122. * @return
    123. */
    124. @IgnoreAuth
    125. @RequestMapping("/follow/{tableName}/{columnName}")
    126. public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, @RequestParam String columnValue) {
    127. Map params = new HashMap();
    128. params.put("table", tableName);
    129. params.put("column", columnName);
    130. params.put("columnValue", columnValue);
    131. Map result = commonService.getFollowByOption(params);
    132. return R.ok().put("data", result);
    133. }
    134. /**
    135. * 修改table表的sfsh状态
    136. * @param table
    137. * @param map
    138. * @return
    139. */
    140. @RequestMapping("/sh/{tableName}")
    141. public R sh(@PathVariable("tableName") String tableName, @RequestBody Map map) {
    142. map.put("table", tableName);
    143. commonService.sh(map);
    144. return R.ok();
    145. }
    146. /**
    147. * 获取需要提醒的记录数
    148. * @param tableName
    149. * @param columnName
    150. * @param type 1:数字 2:日期
    151. * @param map
    152. * @return
    153. */
    154. @IgnoreAuth
    155. @RequestMapping("/remind/{tableName}/{columnName}/{type}")
    156. public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
    157. @PathVariable("type") String type,@RequestParam Map map) {
    158. map.put("table", tableName);
    159. map.put("column", columnName);
    160. map.put("type", type);
    161. if(type.equals("2")) {
    162. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    163. Calendar c = Calendar.getInstance();
    164. Date remindStartDate = null;
    165. Date remindEndDate = null;
    166. if(map.get("remindstart")!=null) {
    167. Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
    168. c.setTime(new Date());
    169. c.add(Calendar.DAY_OF_MONTH,remindStart);
    170. remindStartDate = c.getTime();
    171. map.put("remindstart", sdf.format(remindStartDate));
    172. }
    173. if(map.get("remindend")!=null) {
    174. Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
    175. c.setTime(new Date());
    176. c.add(Calendar.DAY_OF_MONTH,remindEnd);
    177. remindEndDate = c.getTime();
    178. map.put("remindend", sdf.format(remindEndDate));
    179. }
    180. }
    181. int count = commonService.remindCount(map);
    182. return R.ok().put("count", count);
    183. }
    184. /**
    185. * 单列求和
    186. */
    187. @IgnoreAuth
    188. @RequestMapping("/cal/{tableName}/{columnName}")
    189. public R cal(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) {
    190. Map params = new HashMap();
    191. params.put("table", tableName);
    192. params.put("column", columnName);
    193. Map result = commonService.selectCal(params);
    194. return R.ok().put("data", result);
    195. }
    196. /**
    197. * 分组统计
    198. */
    199. @IgnoreAuth
    200. @RequestMapping("/group/{tableName}/{columnName}")
    201. public R group(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) {
    202. Map params = new HashMap();
    203. params.put("table", tableName);
    204. params.put("column", columnName);
    205. List> result = commonService.selectGroup(params);
    206. return R.ok().put("data", result);
    207. }
    208. /**
    209. * (按值统计)
    210. */
    211. @IgnoreAuth
    212. @RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}")
    213. public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName) {
    214. Map params = new HashMap();
    215. params.put("table", tableName);
    216. params.put("xColumn", xColumnName);
    217. params.put("yColumn", yColumnName);
    218. List> result = commonService.selectValue(params);
    219. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    220. for(Map m : result) {
    221. for(String k : m.keySet()) {
    222. if(m.get(k) instanceof Date) {
    223. m.put(k, sdf.format((Date)m.get(k)));
    224. }
    225. }
    226. }
    227. return R.ok().put("data", result);
    228. }
    229. }

     

    package com.controller;
    
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Calendar;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Date;
    import java.util.List;
    import javax.servlet.http.HttpServletRequest;
    
    import com.utils.ValidatorUtils;
    import org.apache.commons.lang3.StringUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestBody;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.RestController;
    import com.baomidou.mybatisplus.mapper.EntityWrapper;
    import com.baomidou.mybatisplus.mapper.Wrapper;
    import com.annotation.IgnoreAuth;
    
    import com.entity.DiscussshangpinxinxiEntity;
    import com.entity.view.DiscussshangpinxinxiView;
    
    import com.service.DiscussshangpinxinxiService;
    import com.service.TokenService;
    import com.utils.PageUtils;
    import com.utils.R;
    import com.utils.MD5Util;
    import com.utils.MPUtil;
    import com.utils.CommonUtil;
    
    
    /**
     * 商品信息评论表
     * 后端接口
     * @author 
     * @email 
     * @date 2021-02-22 15:46:58
     */
    @RestController
    @RequestMapping("/discussshangpinxinxi")
    public class DiscussshangpinxinxiController {
        @Autowired
        private DiscussshangpinxinxiService discussshangpinxinxiService;
        
    
    
        /**
         * 后端列表
         */
        @RequestMapping("/page")
        public R page(@RequestParam Map params,DiscussshangpinxinxiEntity discussshangpinxinxi, HttpServletRequest request){
            EntityWrapper ew = new EntityWrapper();
          PageUtils page = discussshangpinxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discussshangpinxinxi), params), params));
    
            return R.ok().put("data", page);
        }
        
        /**
         * 前端列表
         */
       @IgnoreAuth
        @RequestMapping("/list")
        public R list(@RequestParam Map params,DiscussshangpinxinxiEntity discussshangpinxinxi, HttpServletRequest request){
            EntityWrapper ew = new EntityWrapper();
          PageUtils page = discussshangpinxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discussshangpinxinxi), params), params));
            return R.ok().put("data", page);
        }
    
       /**
         * 列表
         */
        @RequestMapping("/lists")
        public R list( DiscussshangpinxinxiEntity discussshangpinxinxi){
               EntityWrapper ew = new EntityWrapper();
           ew.allEq(MPUtil.allEQMapPre( discussshangpinxinxi, "discussshangpinxinxi")); 
            return R.ok().put("data", discussshangpinxinxiService.selectListView(ew));
        }
    
        /**
         * 查询
         */
        @RequestMapping("/query")
        public R query(DiscussshangpinxinxiEntity discussshangpinxinxi){
            EntityWrapper< DiscussshangpinxinxiEntity> ew = new EntityWrapper< DiscussshangpinxinxiEntity>();
          ew.allEq(MPUtil.allEQMapPre( discussshangpinxinxi, "discussshangpinxinxi")); 
          DiscussshangpinxinxiView discussshangpinxinxiView =  discussshangpinxinxiService.selectView(ew);
          return R.ok("查询商品信息评论表成功").put("data", discussshangpinxinxiView);
        }
       
        /**
         * 后端详情
         */
        @RequestMapping("/info/{id}")
        public R info(@PathVariable("id") Long id){
            DiscussshangpinxinxiEntity discussshangpinxinxi = discussshangpinxinxiService.selectById(id);
            return R.ok().put("data", discussshangpinxinxi);
        }
    
        /**
         * 前端详情
         */
        @RequestMapping("/detail/{id}")
        public R detail(@PathVariable("id") Long id){
            DiscussshangpinxinxiEntity discussshangpinxinxi = discussshangpinxinxiService.selectById(id);
            return R.ok().put("data", discussshangpinxinxi);
        }
        
    
    
    
        /**
         * 后端保存
         */
        @RequestMapping("/save")
        public R save(@RequestBody DiscussshangpinxinxiEntity discussshangpinxinxi, HttpServletRequest request){
           discussshangpinxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
           //ValidatorUtils.validateEntity(discussshangpinxinxi);
            discussshangpinxinxiService.insert(discussshangpinxinxi);
            return R.ok();
        }
        
        /**
         * 前端保存
         */
        @RequestMapping("/add")
        public R add(@RequestBody DiscussshangpinxinxiEntity discussshangpinxinxi, HttpServletRequest request){
           discussshangpinxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
           //ValidatorUtils.validateEntity(discussshangpinxinxi);
            discussshangpinxinxiService.insert(discussshangpinxinxi);
            return R.ok();
        }
    
        /**
         * 修改
         */
        @RequestMapping("/update")
        public R update(@RequestBody DiscussshangpinxinxiEntity discussshangpinxinxi, HttpServletRequest request){
            //ValidatorUtils.validateEntity(discussshangpinxinxi);
            discussshangpinxinxiService.updateById(discussshangpinxinxi);//全部更新
            return R.ok();
        }
        
    
        /**
         * 删除
         */
        @RequestMapping("/delete")
        public R delete(@RequestBody Long[] ids){
            discussshangpinxinxiService.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 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 wrapper = new EntityWrapper();
          if(map.get("remindstart")!=null) {
             wrapper.ge(columnName, map.get("remindstart"));
          }
          if(map.get("remindend")!=null) {
             wrapper.le(columnName, map.get("remindend"));
          }
    
    
          int count = discussshangpinxinxiService.selectCount(wrapper);
          return R.ok().put("count", count);
       }
       
    
    
    }
    
  • 相关阅读:
    MIT6.824-lab3A-Key/value service without snapshots(基本的KV服务)
    TSA优化算法——模仿航海过程中外套的喷气推进和蜂群行为(Matlab代码实现)
    蓝桥杯集训·每日一题2024 (差分)
    web前端期末大作业:基于HTML+CSS+JavaScript奥迪企业bootstrap响应式网站
    极简工作流「GitHub 热点速览」
    jQuery+AJXA+PHP动态获取数据实现新闻网页下拉加载功能(1+X Web前端开发中级 例题)
    记一次进程阻塞诊断
    【JavaScript复习十】数组入门知识
    C++11delete与default
    C++学习笔记(三十一)
  • 原文地址:https://blog.csdn.net/weixin_42899150/article/details/127813864