├── limage └── 1.png ├── image ├── 图片1.png ├── 图片10.png ├── 图片11.png ├── 图片12.png ├── 图片2.png ├── 图片3.png ├── 图片4.png ├── 图片5.png ├── 图片6.png ├── 图片7.png ├── 图片8.png └── 图片9.png ├── src ├── main │ ├── resources │ │ ├── mapper │ │ │ ├── ConfigDao.xml │ │ │ ├── UserDao.xml │ │ │ ├── TokenDao.xml │ │ │ ├── StoreupDao.xml │ │ │ ├── WodehaoyouDao.xml │ │ │ ├── YonghuDao.xml │ │ │ ├── DefaultuserDao.xml │ │ │ ├── DiscussmeishijianshangDao.xml │ │ │ ├── CommonDao.xml │ │ │ └── MeishijianshangDao.xml │ │ └── application.yml │ └── java │ │ └── com │ │ ├── dao │ │ ├── ConfigDao.java │ │ ├── UserDao.java │ │ ├── TokenDao.java │ │ ├── CommonDao.java │ │ ├── YonghuDao.java │ │ ├── StoreupDao.java │ │ ├── WodehaoyouDao.java │ │ ├── DefaultuserDao.java │ │ ├── MeishijianshangDao.java │ │ └── DiscussmeishijianshangDao.java │ │ ├── annotation │ │ ├── IgnoreAuth.java │ │ ├── LoginUser.java │ │ └── APPLoginUser.java │ │ ├── service │ │ ├── ConfigService.java │ │ ├── CommonService.java │ │ ├── UserService.java │ │ ├── TokenService.java │ │ ├── impl │ │ │ ├── ConfigServiceImpl.java │ │ │ ├── CommonServiceImpl.java │ │ │ ├── UserServiceImpl.java │ │ │ ├── YonghuServiceImpl.java │ │ │ ├── StoreupServiceImpl.java │ │ │ ├── WodehaoyouServiceImpl.java │ │ │ ├── DefaultuserServiceImpl.java │ │ │ ├── MeishijianshangServiceImpl.java │ │ │ ├── DiscussmeishijianshangServiceImpl.java │ │ │ └── TokenServiceImpl.java │ │ ├── YonghuService.java │ │ ├── StoreupService.java │ │ ├── WodehaoyouService.java │ │ ├── DefaultuserService.java │ │ ├── MeishijianshangService.java │ │ └── DiscussmeishijianshangService.java │ │ ├── utils │ │ ├── MD5Util.java │ │ ├── CommonUtil.java │ │ ├── FileUtil.java │ │ ├── JQPageInfo.java │ │ ├── R.java │ │ ├── SQLFilter.java │ │ ├── HttpClientUtils.java │ │ ├── ValidatorUtils.java │ │ ├── SpringContextUtils.java │ │ ├── PageUtils.java │ │ ├── Query.java │ │ ├── BaiduUtil.java │ │ └── MPUtil.java │ │ ├── config │ │ ├── MybatisPlusConfig.java │ │ └── InterceptorConfig.java │ │ ├── SpringbootSchemaApplication.java │ │ ├── entity │ │ ├── view │ │ │ ├── YonghuView.java │ │ │ ├── StoreupView.java │ │ │ ├── WodehaoyouView.java │ │ │ ├── DefaultuserView.java │ │ │ ├── MeishijianshangView.java │ │ │ └── DiscussmeishijianshangView.java │ │ ├── EIException.java │ │ ├── ConfigEntity.java │ │ ├── UserEntity.java │ │ ├── vo │ │ │ ├── WodehaoyouVO.java │ │ │ ├── StoreupVO.java │ │ │ ├── DiscussmeishijianshangVO.java │ │ │ ├── YonghuVO.java │ │ │ ├── DefaultuserVO.java │ │ │ └── MeishijianshangVO.java │ │ ├── model │ │ │ ├── WodehaoyouModel.java │ │ │ ├── StoreupModel.java │ │ │ ├── DiscussmeishijianshangModel.java │ │ │ ├── YonghuModel.java │ │ │ ├── DefaultuserModel.java │ │ │ └── MeishijianshangModel.java │ │ ├── TokenEntity.java │ │ ├── WodehaoyouEntity.java │ │ ├── StoreupEntity.java │ │ ├── DiscussmeishijianshangEntity.java │ │ ├── YonghuEntity.java │ │ ├── DefaultuserEntity.java │ │ └── MeishijianshangEntity.java │ │ ├── controller │ │ ├── ConfigController.java │ │ ├── FileController.java │ │ ├── UserController.java │ │ ├── StoreupController.java │ │ ├── DiscussmeishijianshangController.java │ │ ├── WodehaoyouController.java │ │ └── CommonController.java │ │ └── interceptor │ │ └── AuthorizationInterceptor.java └── test │ └── java │ └── com │ └── SpringbootSchemaApplicationTests.java ├── README.md └── pom.xml /limage/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No302Exploration-and-Sharing-Platform-for-Campus-Surrounding-Cuisine/HEAD/limage/1.png -------------------------------------------------------------------------------- /image/图片1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No302Exploration-and-Sharing-Platform-for-Campus-Surrounding-Cuisine/HEAD/image/图片1.png -------------------------------------------------------------------------------- /image/图片10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No302Exploration-and-Sharing-Platform-for-Campus-Surrounding-Cuisine/HEAD/image/图片10.png -------------------------------------------------------------------------------- /image/图片11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No302Exploration-and-Sharing-Platform-for-Campus-Surrounding-Cuisine/HEAD/image/图片11.png -------------------------------------------------------------------------------- /image/图片12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No302Exploration-and-Sharing-Platform-for-Campus-Surrounding-Cuisine/HEAD/image/图片12.png -------------------------------------------------------------------------------- /image/图片2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No302Exploration-and-Sharing-Platform-for-Campus-Surrounding-Cuisine/HEAD/image/图片2.png -------------------------------------------------------------------------------- /image/图片3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No302Exploration-and-Sharing-Platform-for-Campus-Surrounding-Cuisine/HEAD/image/图片3.png -------------------------------------------------------------------------------- /image/图片4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No302Exploration-and-Sharing-Platform-for-Campus-Surrounding-Cuisine/HEAD/image/图片4.png -------------------------------------------------------------------------------- /image/图片5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No302Exploration-and-Sharing-Platform-for-Campus-Surrounding-Cuisine/HEAD/image/图片5.png -------------------------------------------------------------------------------- /image/图片6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No302Exploration-and-Sharing-Platform-for-Campus-Surrounding-Cuisine/HEAD/image/图片6.png -------------------------------------------------------------------------------- /image/图片7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No302Exploration-and-Sharing-Platform-for-Campus-Surrounding-Cuisine/HEAD/image/图片7.png -------------------------------------------------------------------------------- /image/图片8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No302Exploration-and-Sharing-Platform-for-Campus-Surrounding-Cuisine/HEAD/image/图片8.png -------------------------------------------------------------------------------- /image/图片9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No302Exploration-and-Sharing-Platform-for-Campus-Surrounding-Cuisine/HEAD/image/图片9.png -------------------------------------------------------------------------------- /src/main/resources/mapper/ConfigDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/main/java/com/dao/ConfigDao.java: -------------------------------------------------------------------------------- 1 | 2 | package com.dao; 3 | 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import com.entity.ConfigEntity; 6 | 7 | /** 8 | * 配置 9 | */ 10 | public interface ConfigDao extends BaseMapper { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/annotation/IgnoreAuth.java: -------------------------------------------------------------------------------- 1 | package com.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * 忽略Token验证 7 | */ 8 | @Target(ElementType.METHOD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | public @interface IgnoreAuth { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/com/SpringbootSchemaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringbootSchemaApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/service/ConfigService.java: -------------------------------------------------------------------------------- 1 | 2 | package com.service; 3 | 4 | import java.util.Map; 5 | 6 | import com.baomidou.mybatisplus.service.IService; 7 | import com.entity.ConfigEntity; 8 | import com.utils.PageUtils; 9 | 10 | 11 | /** 12 | * 系统用户 13 | */ 14 | public interface ConfigService extends IService { 15 | PageUtils queryPage(Map params); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/utils/MD5Util.java: -------------------------------------------------------------------------------- 1 | package com.utils; 2 | 3 | import cn.hutool.crypto.digest.DigestUtil; 4 | 5 | public class MD5Util { 6 | 7 | /** 8 | * @param text明文 9 | * @param key密钥 10 | * @return 密文 11 | */ 12 | // 带秘钥加密 13 | public static String md5(String text) { 14 | // 加密后的字符串 15 | String md5str = DigestUtil.md5Hex(text); 16 | return md5str; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/annotation/LoginUser.java: -------------------------------------------------------------------------------- 1 | package com.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 登录用户信息 10 | */ 11 | @Target(ElementType.PARAMETER) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface LoginUser { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/annotation/APPLoginUser.java: -------------------------------------------------------------------------------- 1 | package com.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 登录用户信息 10 | */ 11 | @Target(ElementType.PARAMETER) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface APPLoginUser { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/resources/mapper/UserDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/mapper/TokenDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/config/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | 2 | package com.config; 3 | 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import com.baomidou.mybatisplus.mapper.MetaObjectHandler; 8 | import com.baomidou.mybatisplus.plugins.PaginationInterceptor; 9 | 10 | /** 11 | * mybatis-plus配置 12 | */ 13 | @Configuration 14 | public class MybatisPlusConfig { 15 | 16 | /** 17 | * 分页插件 18 | */ 19 | @Bean 20 | public PaginationInterceptor paginationInterceptor() { 21 | return new PaginationInterceptor(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/service/CommonService.java: -------------------------------------------------------------------------------- 1 | package com.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | public interface CommonService { 7 | List getOption(Map params); 8 | 9 | Map getFollowByOption(Map params); 10 | 11 | void sh(Map params); 12 | 13 | int remindCount(Map params); 14 | 15 | Map selectCal(Map params); 16 | 17 | List> selectGroup(Map params); 18 | 19 | List> selectValue(Map params); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | 2 | package com.dao; 3 | 4 | import java.util.List; 5 | 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import com.baomidou.mybatisplus.mapper.BaseMapper; 9 | import com.baomidou.mybatisplus.mapper.Wrapper; 10 | import com.baomidou.mybatisplus.plugins.pagination.Pagination; 11 | import com.entity.UserEntity; 12 | 13 | /** 14 | * 用户 15 | */ 16 | public interface UserDao extends BaseMapper { 17 | 18 | List selectListView(@Param("ew") Wrapper wrapper); 19 | 20 | List selectListView(Pagination page,@Param("ew") Wrapper wrapper); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/utils/CommonUtil.java: -------------------------------------------------------------------------------- 1 | package com.utils; 2 | 3 | import java.util.Random; 4 | 5 | public class CommonUtil { 6 | /** 7 | * 获取随机字符串 8 | * 9 | * @param num 10 | * @return 11 | */ 12 | public static String getRandomString(Integer num) { 13 | String base = "abcdefghijklmnopqrstuvwxyz0123456789"; 14 | Random random = new Random(); 15 | StringBuffer sb = new StringBuffer(); 16 | for (int i = 0; i < num; i++) { 17 | int number = random.nextInt(base.length()); 18 | sb.append(base.charAt(number)); 19 | } 20 | return sb.toString(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/dao/TokenDao.java: -------------------------------------------------------------------------------- 1 | 2 | package com.dao; 3 | 4 | import java.util.List; 5 | 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import com.baomidou.mybatisplus.mapper.BaseMapper; 9 | import com.baomidou.mybatisplus.mapper.Wrapper; 10 | import com.baomidou.mybatisplus.plugins.pagination.Pagination; 11 | import com.entity.TokenEntity; 12 | 13 | /** 14 | * token 15 | */ 16 | public interface TokenDao extends BaseMapper { 17 | 18 | List selectListView(@Param("ew") Wrapper wrapper); 19 | 20 | List selectListView(Pagination page,@Param("ew") Wrapper wrapper); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/service/UserService.java: -------------------------------------------------------------------------------- 1 | 2 | package com.service; 3 | 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import org.apache.ibatis.annotations.Param; 8 | 9 | import com.baomidou.mybatisplus.mapper.Wrapper; 10 | import com.baomidou.mybatisplus.service.IService; 11 | import com.entity.UserEntity; 12 | import com.utils.PageUtils; 13 | 14 | 15 | /** 16 | * 系统用户 17 | */ 18 | public interface UserService extends IService { 19 | PageUtils queryPage(Map params); 20 | 21 | List selectListView(Wrapper wrapper); 22 | 23 | PageUtils queryPage(Map params,Wrapper wrapper); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/dao/CommonDao.java: -------------------------------------------------------------------------------- 1 | 2 | package com.dao; 3 | 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | /** 8 | * 通用接口 9 | */ 10 | public interface CommonDao{ 11 | List getOption(Map params); 12 | 13 | Map getFollowByOption(Map params); 14 | 15 | List getFollowByOption2(Map params); 16 | 17 | void sh(Map params); 18 | 19 | int remindCount(Map params); 20 | 21 | Map selectCal(Map params); 22 | 23 | List> selectGroup(Map params); 24 | 25 | List> selectValue(Map params); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/utils/FileUtil.java: -------------------------------------------------------------------------------- 1 | package com.utils; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.File; 5 | import java.io.FileInputStream; 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | 9 | /** 10 | * 类说明 : 11 | */ 12 | 13 | public class FileUtil { 14 | public static byte[] FileToByte(File file) throws IOException { 15 | // 将数据转为流 16 | @SuppressWarnings("resource") 17 | InputStream content = new FileInputStream(file); 18 | ByteArrayOutputStream swapStream = new ByteArrayOutputStream(); 19 | byte[] buff = new byte[100]; 20 | int rc = 0; 21 | while ((rc = content.read(buff, 0, 100)) > 0) { 22 | swapStream.write(buff, 0, rc); 23 | } 24 | // 获得二进制数组 25 | return swapStream.toByteArray(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/service/TokenService.java: -------------------------------------------------------------------------------- 1 | 2 | package com.service; 3 | 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import com.baomidou.mybatisplus.mapper.Wrapper; 8 | import com.baomidou.mybatisplus.service.IService; 9 | import com.entity.TokenEntity; 10 | import com.utils.PageUtils; 11 | 12 | 13 | /** 14 | * token 15 | */ 16 | public interface TokenService extends IService { 17 | PageUtils queryPage(Map params); 18 | 19 | List selectListView(Wrapper wrapper); 20 | 21 | PageUtils queryPage(Map params,Wrapper wrapper); 22 | 23 | String generateToken(Long userid,String username,String tableName, String role); 24 | 25 | TokenEntity getTokenEntity(String token); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/SpringbootSchemaApplication.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.builder.SpringApplicationBuilder; 7 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 8 | 9 | @SpringBootApplication 10 | @MapperScan(basePackages = {"com.dao"}) 11 | public class SpringbootSchemaApplication extends SpringBootServletInitializer{ 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(SpringbootSchemaApplication.class, args); 15 | } 16 | 17 | @Override 18 | protected SpringApplicationBuilder configure(SpringApplicationBuilder applicationBuilder) { 19 | return applicationBuilder.sources(SpringbootSchemaApplication.class); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/entity/view/YonghuView.java: -------------------------------------------------------------------------------- 1 | package com.entity.view; 2 | 3 | import com.entity.YonghuEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import org.apache.commons.beanutils.BeanUtils; 7 | import java.lang.reflect.InvocationTargetException; 8 | 9 | import java.io.Serializable; 10 | 11 | 12 | /** 13 | * 用户 14 | * 后端返回视图实体辅助类 15 | * (通常后端关联的表或者自定义的字段需要返回使用) 16 | * @author 17 | * @email 18 | * @date 2021-03-12 20:57:00 19 | */ 20 | @TableName("yonghu") 21 | public class YonghuView extends YonghuEntity implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | public YonghuView(){ 25 | } 26 | 27 | public YonghuView(YonghuEntity yonghuEntity){ 28 | try { 29 | BeanUtils.copyProperties(this, yonghuEntity); 30 | } catch (IllegalAccessException | InvocationTargetException e) { 31 | // TODO Auto-generated catch block 32 | e.printStackTrace(); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/entity/view/StoreupView.java: -------------------------------------------------------------------------------- 1 | package com.entity.view; 2 | 3 | import com.entity.StoreupEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import org.apache.commons.beanutils.BeanUtils; 7 | import java.lang.reflect.InvocationTargetException; 8 | 9 | import java.io.Serializable; 10 | 11 | 12 | /** 13 | * 收藏表 14 | * 后端返回视图实体辅助类 15 | * (通常后端关联的表或者自定义的字段需要返回使用) 16 | * @author 17 | * @email 18 | * @date 2021-03-12 20:57:00 19 | */ 20 | @TableName("storeup") 21 | public class StoreupView extends StoreupEntity implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | public StoreupView(){ 25 | } 26 | 27 | public StoreupView(StoreupEntity storeupEntity){ 28 | try { 29 | BeanUtils.copyProperties(this, storeupEntity); 30 | } catch (IllegalAccessException | InvocationTargetException e) { 31 | // TODO Auto-generated catch block 32 | e.printStackTrace(); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/entity/view/WodehaoyouView.java: -------------------------------------------------------------------------------- 1 | package com.entity.view; 2 | 3 | import com.entity.WodehaoyouEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import org.apache.commons.beanutils.BeanUtils; 7 | import java.lang.reflect.InvocationTargetException; 8 | 9 | import java.io.Serializable; 10 | 11 | 12 | /** 13 | * 我的好友 14 | * 后端返回视图实体辅助类 15 | * (通常后端关联的表或者自定义的字段需要返回使用) 16 | * @author 17 | * @email 18 | * @date 2021-03-12 20:57:00 19 | */ 20 | @TableName("wodehaoyou") 21 | public class WodehaoyouView extends WodehaoyouEntity implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | public WodehaoyouView(){ 25 | } 26 | 27 | public WodehaoyouView(WodehaoyouEntity wodehaoyouEntity){ 28 | try { 29 | BeanUtils.copyProperties(this, wodehaoyouEntity); 30 | } catch (IllegalAccessException | InvocationTargetException e) { 31 | // TODO Auto-generated catch block 32 | e.printStackTrace(); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/utils/JQPageInfo.java: -------------------------------------------------------------------------------- 1 | package com.utils; 2 | 3 | public class JQPageInfo{ 4 | private Integer page; 5 | 6 | private Integer limit; 7 | 8 | private String sidx; 9 | 10 | private String order; 11 | 12 | private Integer offset; 13 | 14 | public Integer getPage() { 15 | return page; 16 | } 17 | 18 | public void setPage(Integer page) { 19 | this.page = page; 20 | } 21 | 22 | public Integer getLimit() { 23 | return limit; 24 | } 25 | 26 | public void setLimit(Integer limit) { 27 | this.limit = limit; 28 | } 29 | 30 | public String getSidx() { 31 | return sidx; 32 | } 33 | 34 | public void setSidx(String sidx) { 35 | this.sidx = sidx; 36 | } 37 | 38 | public String getOrder() { 39 | return order; 40 | } 41 | 42 | public void setOrder(String order) { 43 | this.order = order; 44 | } 45 | 46 | public Integer getOffset() { 47 | return offset; 48 | } 49 | 50 | public void setOffset(Integer offset) { 51 | this.offset = offset; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/entity/view/DefaultuserView.java: -------------------------------------------------------------------------------- 1 | package com.entity.view; 2 | 3 | import com.entity.DefaultuserEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import org.apache.commons.beanutils.BeanUtils; 7 | import java.lang.reflect.InvocationTargetException; 8 | 9 | import java.io.Serializable; 10 | 11 | 12 | /** 13 | * 注册用户 14 | * 后端返回视图实体辅助类 15 | * (通常后端关联的表或者自定义的字段需要返回使用) 16 | * @author 17 | * @email 18 | * @date 2021-03-12 20:57:00 19 | */ 20 | @TableName("defaultuser") 21 | public class DefaultuserView extends DefaultuserEntity implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | public DefaultuserView(){ 25 | } 26 | 27 | public DefaultuserView(DefaultuserEntity defaultuserEntity){ 28 | try { 29 | BeanUtils.copyProperties(this, defaultuserEntity); 30 | } catch (IllegalAccessException | InvocationTargetException e) { 31 | // TODO Auto-generated catch block 32 | e.printStackTrace(); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/dao/YonghuDao.java: -------------------------------------------------------------------------------- 1 | package com.dao; 2 | 3 | import com.entity.YonghuEntity; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import java.util.List; 6 | import com.baomidou.mybatisplus.mapper.Wrapper; 7 | import com.baomidou.mybatisplus.plugins.pagination.Pagination; 8 | 9 | import org.apache.ibatis.annotations.Param; 10 | import com.entity.vo.YonghuVO; 11 | import com.entity.view.YonghuView; 12 | 13 | 14 | /** 15 | * 用户 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public interface YonghuDao extends BaseMapper { 22 | 23 | List selectListVO(@Param("ew") Wrapper wrapper); 24 | 25 | YonghuVO selectVO(@Param("ew") Wrapper wrapper); 26 | 27 | List selectListView(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Pagination page,@Param("ew") Wrapper wrapper); 30 | 31 | YonghuView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/ConfigServiceImpl.java: -------------------------------------------------------------------------------- 1 | 2 | package com.service.impl; 3 | 4 | 5 | import java.util.Map; 6 | 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 10 | import com.baomidou.mybatisplus.plugins.Page; 11 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 12 | import com.dao.ConfigDao; 13 | import com.entity.ConfigEntity; 14 | import com.entity.UserEntity; 15 | import com.service.ConfigService; 16 | import com.utils.PageUtils; 17 | import com.utils.Query; 18 | 19 | 20 | /** 21 | * 系统用户 22 | */ 23 | @Service("configService") 24 | public class ConfigServiceImpl extends ServiceImpl implements ConfigService { 25 | @Override 26 | public PageUtils queryPage(Map params) { 27 | Page page = this.selectPage( 28 | new Query(params).getPage(), 29 | new EntityWrapper() 30 | ); 31 | return new PageUtils(page); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/entity/EIException.java: -------------------------------------------------------------------------------- 1 | 2 | package com.entity; 3 | 4 | /** 5 | * 自定义异常 6 | */ 7 | public class EIException extends RuntimeException { 8 | private static final long serialVersionUID = 1L; 9 | 10 | private String msg; 11 | private int code = 500; 12 | 13 | public EIException(String msg) { 14 | super(msg); 15 | this.msg = msg; 16 | } 17 | 18 | public EIException(String msg, Throwable e) { 19 | super(msg, e); 20 | this.msg = msg; 21 | } 22 | 23 | public EIException(String msg, int code) { 24 | super(msg); 25 | this.msg = msg; 26 | this.code = code; 27 | } 28 | 29 | public EIException(String msg, int code, Throwable e) { 30 | super(msg, e); 31 | this.msg = msg; 32 | this.code = code; 33 | } 34 | 35 | public String getMsg() { 36 | return msg; 37 | } 38 | 39 | public void setMsg(String msg) { 40 | this.msg = msg; 41 | } 42 | 43 | public int getCode() { 44 | return code; 45 | } 46 | 47 | public void setCode(int code) { 48 | this.code = code; 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/dao/StoreupDao.java: -------------------------------------------------------------------------------- 1 | package com.dao; 2 | 3 | import com.entity.StoreupEntity; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import java.util.List; 6 | import com.baomidou.mybatisplus.mapper.Wrapper; 7 | import com.baomidou.mybatisplus.plugins.pagination.Pagination; 8 | 9 | import org.apache.ibatis.annotations.Param; 10 | import com.entity.vo.StoreupVO; 11 | import com.entity.view.StoreupView; 12 | 13 | 14 | /** 15 | * 收藏表 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public interface StoreupDao extends BaseMapper { 22 | 23 | List selectListVO(@Param("ew") Wrapper wrapper); 24 | 25 | StoreupVO selectVO(@Param("ew") Wrapper wrapper); 26 | 27 | List selectListView(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Pagination page,@Param("ew") Wrapper wrapper); 30 | 31 | StoreupView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/utils/R.java: -------------------------------------------------------------------------------- 1 | package com.utils; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * 返回数据 8 | */ 9 | public class R extends HashMap { 10 | private static final long serialVersionUID = 1L; 11 | 12 | public R() { 13 | put("code", 0); 14 | } 15 | 16 | public static R error() { 17 | return error(500, "未知异常,请联系管理员"); 18 | } 19 | 20 | public static R error(String msg) { 21 | return error(500, msg); 22 | } 23 | 24 | public static R error(int code, String msg) { 25 | R r = new R(); 26 | r.put("code", code); 27 | r.put("msg", msg); 28 | return r; 29 | } 30 | 31 | public static R ok(String msg) { 32 | R r = new R(); 33 | r.put("msg", msg); 34 | return r; 35 | } 36 | 37 | public static R ok(Map map) { 38 | R r = new R(); 39 | r.putAll(map); 40 | return r; 41 | } 42 | 43 | public static R ok() { 44 | return new R(); 45 | } 46 | 47 | public R put(String key, Object value) { 48 | super.put(key, value); 49 | return this; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/entity/view/MeishijianshangView.java: -------------------------------------------------------------------------------- 1 | package com.entity.view; 2 | 3 | import com.entity.MeishijianshangEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import org.apache.commons.beanutils.BeanUtils; 7 | import java.lang.reflect.InvocationTargetException; 8 | 9 | import java.io.Serializable; 10 | 11 | 12 | /** 13 | * 美食鉴赏 14 | * 后端返回视图实体辅助类 15 | * (通常后端关联的表或者自定义的字段需要返回使用) 16 | * @author 17 | * @email 18 | * @date 2021-03-12 20:57:00 19 | */ 20 | @TableName("meishijianshang") 21 | public class MeishijianshangView extends MeishijianshangEntity implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | public MeishijianshangView(){ 25 | } 26 | 27 | public MeishijianshangView(MeishijianshangEntity meishijianshangEntity){ 28 | try { 29 | BeanUtils.copyProperties(this, meishijianshangEntity); 30 | } catch (IllegalAccessException | InvocationTargetException e) { 31 | // TODO Auto-generated catch block 32 | e.printStackTrace(); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/entity/ConfigEntity.java: -------------------------------------------------------------------------------- 1 | package com.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableId; 6 | import com.baomidou.mybatisplus.annotations.TableName; 7 | import com.baomidou.mybatisplus.enums.IdType; 8 | 9 | /** 10 | * 类说明 : 11 | */ 12 | @TableName("config") 13 | public class ConfigEntity implements Serializable{ 14 | private static final long serialVersionUID = 1L; 15 | 16 | @TableId(type = IdType.AUTO) 17 | private Long id; 18 | 19 | /** 20 | * key 21 | */ 22 | private String name; 23 | 24 | /** 25 | * value 26 | */ 27 | private String value; 28 | 29 | public Long getId() { 30 | return id; 31 | } 32 | 33 | public void setId(Long id) { 34 | this.id = id; 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public void setName(String name) { 42 | this.name = name; 43 | } 44 | 45 | public String getValue() { 46 | return value; 47 | } 48 | 49 | public void setValue(String value) { 50 | this.value = value; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/service/YonghuService.java: -------------------------------------------------------------------------------- 1 | package com.service; 2 | 3 | import com.baomidou.mybatisplus.mapper.Wrapper; 4 | import com.baomidou.mybatisplus.service.IService; 5 | import com.utils.PageUtils; 6 | import com.entity.YonghuEntity; 7 | import java.util.List; 8 | import java.util.Map; 9 | import com.entity.vo.YonghuVO; 10 | import org.apache.ibatis.annotations.Param; 11 | import com.entity.view.YonghuView; 12 | 13 | 14 | /** 15 | * 用户 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public interface YonghuService extends IService { 22 | 23 | PageUtils queryPage(Map params); 24 | 25 | List selectListVO(Wrapper wrapper); 26 | 27 | YonghuVO selectVO(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Wrapper wrapper); 30 | 31 | YonghuView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | PageUtils queryPage(Map params,Wrapper wrapper); 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/com/dao/WodehaoyouDao.java: -------------------------------------------------------------------------------- 1 | package com.dao; 2 | 3 | import com.entity.WodehaoyouEntity; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import java.util.List; 6 | import com.baomidou.mybatisplus.mapper.Wrapper; 7 | import com.baomidou.mybatisplus.plugins.pagination.Pagination; 8 | 9 | import org.apache.ibatis.annotations.Param; 10 | import com.entity.vo.WodehaoyouVO; 11 | import com.entity.view.WodehaoyouView; 12 | 13 | 14 | /** 15 | * 我的好友 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public interface WodehaoyouDao extends BaseMapper { 22 | 23 | List selectListVO(@Param("ew") Wrapper wrapper); 24 | 25 | WodehaoyouVO selectVO(@Param("ew") Wrapper wrapper); 26 | 27 | List selectListView(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Pagination page,@Param("ew") Wrapper wrapper); 30 | 31 | WodehaoyouView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/service/StoreupService.java: -------------------------------------------------------------------------------- 1 | package com.service; 2 | 3 | import com.baomidou.mybatisplus.mapper.Wrapper; 4 | import com.baomidou.mybatisplus.service.IService; 5 | import com.utils.PageUtils; 6 | import com.entity.StoreupEntity; 7 | import java.util.List; 8 | import java.util.Map; 9 | import com.entity.vo.StoreupVO; 10 | import org.apache.ibatis.annotations.Param; 11 | import com.entity.view.StoreupView; 12 | 13 | 14 | /** 15 | * 收藏表 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public interface StoreupService extends IService { 22 | 23 | PageUtils queryPage(Map params); 24 | 25 | List selectListVO(Wrapper wrapper); 26 | 27 | StoreupVO selectVO(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Wrapper wrapper); 30 | 31 | StoreupView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | PageUtils queryPage(Map params,Wrapper wrapper); 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/com/dao/DefaultuserDao.java: -------------------------------------------------------------------------------- 1 | package com.dao; 2 | 3 | import com.entity.DefaultuserEntity; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import java.util.List; 6 | import com.baomidou.mybatisplus.mapper.Wrapper; 7 | import com.baomidou.mybatisplus.plugins.pagination.Pagination; 8 | 9 | import org.apache.ibatis.annotations.Param; 10 | import com.entity.vo.DefaultuserVO; 11 | import com.entity.view.DefaultuserView; 12 | 13 | 14 | /** 15 | * 注册用户 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public interface DefaultuserDao extends BaseMapper { 22 | 23 | List selectListVO(@Param("ew") Wrapper wrapper); 24 | 25 | DefaultuserVO selectVO(@Param("ew") Wrapper wrapper); 26 | 27 | List selectListView(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Pagination page,@Param("ew") Wrapper wrapper); 30 | 31 | DefaultuserView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/entity/view/DiscussmeishijianshangView.java: -------------------------------------------------------------------------------- 1 | package com.entity.view; 2 | 3 | import com.entity.DiscussmeishijianshangEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import org.apache.commons.beanutils.BeanUtils; 7 | import java.lang.reflect.InvocationTargetException; 8 | 9 | import java.io.Serializable; 10 | 11 | 12 | /** 13 | * 美食鉴赏评论表 14 | * 后端返回视图实体辅助类 15 | * (通常后端关联的表或者自定义的字段需要返回使用) 16 | * @author 17 | * @email 18 | * @date 2021-03-12 20:57:00 19 | */ 20 | @TableName("discussmeishijianshang") 21 | public class DiscussmeishijianshangView extends DiscussmeishijianshangEntity implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | public DiscussmeishijianshangView(){ 25 | } 26 | 27 | public DiscussmeishijianshangView(DiscussmeishijianshangEntity discussmeishijianshangEntity){ 28 | try { 29 | BeanUtils.copyProperties(this, discussmeishijianshangEntity); 30 | } catch (IllegalAccessException | InvocationTargetException e) { 31 | // TODO Auto-generated catch block 32 | e.printStackTrace(); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/utils/SQLFilter.java: -------------------------------------------------------------------------------- 1 | 2 | package com.utils; 3 | 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | import com.entity.EIException; 7 | 8 | /** 9 | * SQL过滤 10 | */ 11 | public class SQLFilter { 12 | 13 | /** 14 | * SQL注入过滤 15 | * @param str 待验证的字符串 16 | */ 17 | public static String sqlInject(String str){ 18 | if(StringUtils.isBlank(str)){ 19 | return null; 20 | } 21 | //去掉'|"|;|\字符 22 | str = StringUtils.replace(str, "'", ""); 23 | str = StringUtils.replace(str, "\"", ""); 24 | str = StringUtils.replace(str, ";", ""); 25 | str = StringUtils.replace(str, "\\", ""); 26 | 27 | //转换成小写 28 | str = str.toLowerCase(); 29 | 30 | //非法字符 31 | String[] keywords = {"master", "truncate", "insert", "select", "delete", "update", "declare", "alter", "drop"}; 32 | 33 | //判断是否包含非法字符 34 | for(String keyword : keywords){ 35 | if(str.indexOf(keyword) != -1){ 36 | throw new EIException("包含非法字符"); 37 | } 38 | } 39 | 40 | return str; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/service/WodehaoyouService.java: -------------------------------------------------------------------------------- 1 | package com.service; 2 | 3 | import com.baomidou.mybatisplus.mapper.Wrapper; 4 | import com.baomidou.mybatisplus.service.IService; 5 | import com.utils.PageUtils; 6 | import com.entity.WodehaoyouEntity; 7 | import java.util.List; 8 | import java.util.Map; 9 | import com.entity.vo.WodehaoyouVO; 10 | import org.apache.ibatis.annotations.Param; 11 | import com.entity.view.WodehaoyouView; 12 | 13 | 14 | /** 15 | * 我的好友 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public interface WodehaoyouService extends IService { 22 | 23 | PageUtils queryPage(Map params); 24 | 25 | List selectListVO(Wrapper wrapper); 26 | 27 | WodehaoyouVO selectVO(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Wrapper wrapper); 30 | 31 | WodehaoyouView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | PageUtils queryPage(Map params,Wrapper wrapper); 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/com/service/DefaultuserService.java: -------------------------------------------------------------------------------- 1 | package com.service; 2 | 3 | import com.baomidou.mybatisplus.mapper.Wrapper; 4 | import com.baomidou.mybatisplus.service.IService; 5 | import com.utils.PageUtils; 6 | import com.entity.DefaultuserEntity; 7 | import java.util.List; 8 | import java.util.Map; 9 | import com.entity.vo.DefaultuserVO; 10 | import org.apache.ibatis.annotations.Param; 11 | import com.entity.view.DefaultuserView; 12 | 13 | 14 | /** 15 | * 注册用户 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public interface DefaultuserService extends IService { 22 | 23 | PageUtils queryPage(Map params); 24 | 25 | List selectListVO(Wrapper wrapper); 26 | 27 | DefaultuserVO selectVO(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Wrapper wrapper); 30 | 31 | DefaultuserView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | PageUtils queryPage(Map params,Wrapper wrapper); 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/com/utils/HttpClientUtils.java: -------------------------------------------------------------------------------- 1 | package com.utils; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.InputStreamReader; 5 | import java.net.HttpURLConnection; 6 | import java.net.URL; 7 | 8 | 9 | /** 10 | * HttpClient工具类 11 | */ 12 | public class HttpClientUtils { 13 | 14 | /** 15 | * @param uri 16 | * @return String 17 | * @description get请求方式 18 | * @author: long.he01 19 | */ 20 | public static String doGet(String uri) { 21 | 22 | StringBuilder result = new StringBuilder(); 23 | try { 24 | String res = ""; 25 | URL url = new URL(uri); 26 | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 27 | BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8")); 28 | String line; 29 | while ((line = in.readLine()) != null) { 30 | res += line+"\n"; 31 | } 32 | in.close(); 33 | return res; 34 | }catch (Exception e) { 35 | e.printStackTrace(); 36 | return null; 37 | } 38 | 39 | } 40 | 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/main/java/com/dao/MeishijianshangDao.java: -------------------------------------------------------------------------------- 1 | package com.dao; 2 | 3 | import com.entity.MeishijianshangEntity; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import java.util.List; 6 | import com.baomidou.mybatisplus.mapper.Wrapper; 7 | import com.baomidou.mybatisplus.plugins.pagination.Pagination; 8 | 9 | import org.apache.ibatis.annotations.Param; 10 | import com.entity.vo.MeishijianshangVO; 11 | import com.entity.view.MeishijianshangView; 12 | 13 | 14 | /** 15 | * 美食鉴赏 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public interface MeishijianshangDao extends BaseMapper { 22 | 23 | List selectListVO(@Param("ew") Wrapper wrapper); 24 | 25 | MeishijianshangVO selectVO(@Param("ew") Wrapper wrapper); 26 | 27 | List selectListView(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Pagination page,@Param("ew") Wrapper wrapper); 30 | 31 | MeishijianshangView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/utils/ValidatorUtils.java: -------------------------------------------------------------------------------- 1 | 2 | package com.utils; 3 | 4 | 5 | import java.util.Set; 6 | 7 | import javax.validation.ConstraintViolation; 8 | import javax.validation.Validation; 9 | import javax.validation.Validator; 10 | 11 | import com.entity.EIException; 12 | 13 | /** 14 | * hibernate-validator校验工具类 15 | */ 16 | public class ValidatorUtils { 17 | private static Validator validator; 18 | 19 | static { 20 | validator = Validation.buildDefaultValidatorFactory().getValidator(); 21 | } 22 | 23 | /** 24 | * 校验对象 25 | * @param object 待校验对象 26 | * @param groups 待校验的组 27 | * @throws EIException 校验不通过,则报EIException异常 28 | */ 29 | public static void validateEntity(Object object, Class... groups) 30 | throws EIException { 31 | Set> constraintViolations = validator.validate(object, groups); 32 | if (!constraintViolations.isEmpty()) { 33 | ConstraintViolation constraint = (ConstraintViolation)constraintViolations.iterator().next(); 34 | throw new EIException(constraint.getMessage()); 35 | } 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/service/MeishijianshangService.java: -------------------------------------------------------------------------------- 1 | package com.service; 2 | 3 | import com.baomidou.mybatisplus.mapper.Wrapper; 4 | import com.baomidou.mybatisplus.service.IService; 5 | import com.utils.PageUtils; 6 | import com.entity.MeishijianshangEntity; 7 | import java.util.List; 8 | import java.util.Map; 9 | import com.entity.vo.MeishijianshangVO; 10 | import org.apache.ibatis.annotations.Param; 11 | import com.entity.view.MeishijianshangView; 12 | 13 | 14 | /** 15 | * 美食鉴赏 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public interface MeishijianshangService extends IService { 22 | 23 | PageUtils queryPage(Map params); 24 | 25 | List selectListVO(Wrapper wrapper); 26 | 27 | MeishijianshangVO selectVO(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Wrapper wrapper); 30 | 31 | MeishijianshangView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | PageUtils queryPage(Map params,Wrapper wrapper); 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/com/dao/DiscussmeishijianshangDao.java: -------------------------------------------------------------------------------- 1 | package com.dao; 2 | 3 | import com.entity.DiscussmeishijianshangEntity; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import java.util.List; 6 | import com.baomidou.mybatisplus.mapper.Wrapper; 7 | import com.baomidou.mybatisplus.plugins.pagination.Pagination; 8 | 9 | import org.apache.ibatis.annotations.Param; 10 | import com.entity.vo.DiscussmeishijianshangVO; 11 | import com.entity.view.DiscussmeishijianshangView; 12 | 13 | 14 | /** 15 | * 美食鉴赏评论表 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public interface DiscussmeishijianshangDao extends BaseMapper { 22 | 23 | List selectListVO(@Param("ew") Wrapper wrapper); 24 | 25 | DiscussmeishijianshangVO selectVO(@Param("ew") Wrapper wrapper); 26 | 27 | List selectListView(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Pagination page,@Param("ew") Wrapper wrapper); 30 | 31 | DiscussmeishijianshangView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/utils/SpringContextUtils.java: -------------------------------------------------------------------------------- 1 | 2 | package com.utils; 3 | 4 | import org.springframework.beans.BeansException; 5 | import org.springframework.context.ApplicationContext; 6 | import org.springframework.context.ApplicationContextAware; 7 | import org.springframework.stereotype.Component; 8 | 9 | 10 | /** 11 | * Spring Context 工具类 12 | */ 13 | @Component 14 | public class SpringContextUtils implements ApplicationContextAware { 15 | public static ApplicationContext applicationContext; 16 | 17 | @Override 18 | public void setApplicationContext(ApplicationContext applicationContext) 19 | throws BeansException { 20 | SpringContextUtils.applicationContext = applicationContext; 21 | } 22 | 23 | public static Object getBean(String name) { 24 | return applicationContext.getBean(name); 25 | } 26 | 27 | public static T getBean(String name, Class requiredType) { 28 | return applicationContext.getBean(name, requiredType); 29 | } 30 | 31 | public static boolean containsBean(String name) { 32 | return applicationContext.containsBean(name); 33 | } 34 | 35 | public static boolean isSingleton(String name) { 36 | return applicationContext.isSingleton(name); 37 | } 38 | 39 | public static Class getType(String name) { 40 | return applicationContext.getType(name); 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /src/main/java/com/service/DiscussmeishijianshangService.java: -------------------------------------------------------------------------------- 1 | package com.service; 2 | 3 | import com.baomidou.mybatisplus.mapper.Wrapper; 4 | import com.baomidou.mybatisplus.service.IService; 5 | import com.utils.PageUtils; 6 | import com.entity.DiscussmeishijianshangEntity; 7 | import java.util.List; 8 | import java.util.Map; 9 | import com.entity.vo.DiscussmeishijianshangVO; 10 | import org.apache.ibatis.annotations.Param; 11 | import com.entity.view.DiscussmeishijianshangView; 12 | 13 | 14 | /** 15 | * 美食鉴赏评论表 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public interface DiscussmeishijianshangService extends IService { 22 | 23 | PageUtils queryPage(Map params); 24 | 25 | List selectListVO(Wrapper wrapper); 26 | 27 | DiscussmeishijianshangVO selectVO(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Wrapper wrapper); 30 | 31 | DiscussmeishijianshangView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | PageUtils queryPage(Map params,Wrapper wrapper); 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/main/resources/mapper/StoreupDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 20 | 21 | 26 | 27 | 33 | 34 | 38 | 39 | -------------------------------------------------------------------------------- /src/main/resources/mapper/WodehaoyouDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 19 | 20 | 25 | 26 | 32 | 33 | 37 | 38 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/CommonServiceImpl.java: -------------------------------------------------------------------------------- 1 | 2 | package com.service.impl; 3 | 4 | 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | import com.dao.CommonDao; 12 | import com.service.CommonService; 13 | 14 | 15 | /** 16 | * 系统用户 17 | */ 18 | @Service("commonService") 19 | public class CommonServiceImpl implements CommonService { 20 | 21 | @Autowired 22 | private CommonDao commonDao; 23 | 24 | @Override 25 | public List getOption(Map params) { 26 | return commonDao.getOption(params); 27 | } 28 | 29 | @Override 30 | public Map getFollowByOption(Map params) { 31 | return commonDao.getFollowByOption(params); 32 | } 33 | 34 | @Override 35 | public void sh(Map params) { 36 | commonDao.sh(params); 37 | } 38 | 39 | @Override 40 | public int remindCount(Map params) { 41 | return commonDao.remindCount(params); 42 | } 43 | 44 | @Override 45 | public Map selectCal(Map params) { 46 | return commonDao.selectCal(params); 47 | } 48 | 49 | @Override 50 | public List> selectGroup(Map params) { 51 | return commonDao.selectGroup(params); 52 | } 53 | 54 | @Override 55 | public List> selectValue(Map params) { 56 | return commonDao.selectValue(params); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/entity/UserEntity.java: -------------------------------------------------------------------------------- 1 | package com.entity; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | import com.baomidou.mybatisplus.annotations.TableId; 7 | import com.baomidou.mybatisplus.annotations.TableName; 8 | import com.baomidou.mybatisplus.enums.IdType; 9 | 10 | /** 11 | * 用户 12 | */ 13 | @TableName("users") 14 | public class UserEntity implements Serializable { 15 | private static final long serialVersionUID = 1L; 16 | 17 | @TableId(type = IdType.AUTO) 18 | private Long id; 19 | 20 | /** 21 | * 用户账号 22 | */ 23 | private String username; 24 | 25 | /** 26 | * 密码 27 | */ 28 | private String password; 29 | 30 | /** 31 | * 用户类型 32 | */ 33 | private String role; 34 | 35 | private Date addtime; 36 | 37 | public String getUsername() { 38 | return username; 39 | } 40 | 41 | public void setUsername(String username) { 42 | this.username = username; 43 | } 44 | 45 | public String getPassword() { 46 | return password; 47 | } 48 | 49 | public void setPassword(String password) { 50 | this.password = password; 51 | } 52 | 53 | public String getRole() { 54 | return role; 55 | } 56 | 57 | public void setRole(String role) { 58 | this.role = role; 59 | } 60 | 61 | public Date getAddtime() { 62 | return addtime; 63 | } 64 | 65 | public void setAddtime(Date addtime) { 66 | this.addtime = addtime; 67 | } 68 | 69 | public Long getId() { 70 | return id; 71 | } 72 | 73 | public void setId(Long id) { 74 | this.id = id; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/resources/mapper/YonghuDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 22 | 23 | 28 | 29 | 35 | 36 | 40 | 41 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | 2 | package com.service.impl; 3 | 4 | 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.springframework.stereotype.Service; 9 | 10 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 11 | import com.baomidou.mybatisplus.mapper.Wrapper; 12 | import com.baomidou.mybatisplus.plugins.Page; 13 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 14 | import com.dao.UserDao; 15 | import com.entity.UserEntity; 16 | import com.service.UserService; 17 | import com.utils.PageUtils; 18 | import com.utils.Query; 19 | 20 | 21 | /** 22 | * 系统用户 23 | */ 24 | @Service("userService") 25 | public class UserServiceImpl extends ServiceImpl implements UserService { 26 | 27 | @Override 28 | public PageUtils queryPage(Map params) { 29 | Page page = this.selectPage( 30 | new Query(params).getPage(), 31 | new EntityWrapper() 32 | ); 33 | return new PageUtils(page); 34 | } 35 | 36 | @Override 37 | public List selectListView(Wrapper wrapper) { 38 | return baseMapper.selectListView(wrapper); 39 | } 40 | 41 | @Override 42 | public PageUtils queryPage(Map params, 43 | Wrapper wrapper) { 44 | Page page =new Query(params).getPage(); 45 | page.setRecords(baseMapper.selectListView(page,wrapper)); 46 | PageUtils pageUtil = new PageUtils(page); 47 | return pageUtil; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/config/InterceptorConfig.java: -------------------------------------------------------------------------------- 1 | package com.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 6 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; 8 | 9 | import com.interceptor.AuthorizationInterceptor; 10 | 11 | @Configuration 12 | public class InterceptorConfig extends WebMvcConfigurationSupport{ 13 | 14 | @Bean 15 | public AuthorizationInterceptor getAuthorizationInterceptor() { 16 | return new AuthorizationInterceptor(); 17 | } 18 | 19 | @Override 20 | public void addInterceptors(InterceptorRegistry registry) { 21 | registry.addInterceptor(getAuthorizationInterceptor()).addPathPatterns("/**").excludePathPatterns("/static/**"); 22 | super.addInterceptors(registry); 23 | } 24 | 25 | /** 26 | * springboot 2.0配置WebMvcConfigurationSupport之后,会导致默认配置被覆盖,要访问静态资源需要重写addResourceHandlers方法 27 | */ 28 | @Override 29 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 30 | registry.addResourceHandler("/**") 31 | .addResourceLocations("classpath:/resources/") 32 | .addResourceLocations("classpath:/static/") 33 | .addResourceLocations("classpath:/admin/") 34 | .addResourceLocations("classpath:/front/") 35 | .addResourceLocations("classpath:/public/"); 36 | super.addResourceHandlers(registry); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/resources/mapper/DefaultuserDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 29 | 30 | 36 | 37 | 41 | 42 | -------------------------------------------------------------------------------- /src/main/resources/mapper/DiscussmeishijianshangDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 20 | 21 | 26 | 27 | 33 | 34 | 38 | 39 | -------------------------------------------------------------------------------- /src/main/java/com/entity/vo/WodehaoyouVO.java: -------------------------------------------------------------------------------- 1 | package com.entity.vo; 2 | 3 | import com.entity.WodehaoyouEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import java.util.Date; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import com.fasterxml.jackson.annotation.JsonFormat; 10 | import java.io.Serializable; 11 | 12 | 13 | /** 14 | * 我的好友 15 | * 手机端接口返回实体辅助类 16 | * (主要作用去除一些不必要的字段) 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public class WodehaoyouVO implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | 25 | /** 26 | * 姓名 27 | */ 28 | 29 | private String xingming; 30 | 31 | /** 32 | * 添加时间 33 | */ 34 | 35 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 36 | @DateTimeFormat 37 | private Date tianjiashijian; 38 | 39 | /** 40 | * 用户id 41 | */ 42 | 43 | private Long userid; 44 | 45 | 46 | /** 47 | * 设置:姓名 48 | */ 49 | 50 | public void setXingming(String xingming) { 51 | this.xingming = xingming; 52 | } 53 | 54 | /** 55 | * 获取:姓名 56 | */ 57 | public String getXingming() { 58 | return xingming; 59 | } 60 | 61 | 62 | /** 63 | * 设置:添加时间 64 | */ 65 | 66 | public void setTianjiashijian(Date tianjiashijian) { 67 | this.tianjiashijian = tianjiashijian; 68 | } 69 | 70 | /** 71 | * 获取:添加时间 72 | */ 73 | public Date getTianjiashijian() { 74 | return tianjiashijian; 75 | } 76 | 77 | 78 | /** 79 | * 设置:用户id 80 | */ 81 | 82 | public void setUserid(Long userid) { 83 | this.userid = userid; 84 | } 85 | 86 | /** 87 | * 获取:用户id 88 | */ 89 | public Long getUserid() { 90 | return userid; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/entity/model/WodehaoyouModel.java: -------------------------------------------------------------------------------- 1 | package com.entity.model; 2 | 3 | import com.entity.WodehaoyouEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import java.util.Date; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import com.fasterxml.jackson.annotation.JsonFormat; 10 | import java.io.Serializable; 11 | 12 | 13 | /** 14 | * 我的好友 15 | * 接收传参的实体类 16 | *(实际开发中配合移动端接口开发手动去掉些没用的字段, 后端一般用entity就够用了) 17 | * 取自ModelAndView 的model名称 18 | * @author 19 | * @email 20 | * @date 2021-03-12 20:57:00 21 | */ 22 | public class WodehaoyouModel implements Serializable { 23 | private static final long serialVersionUID = 1L; 24 | 25 | 26 | /** 27 | * 姓名 28 | */ 29 | 30 | private String xingming; 31 | 32 | /** 33 | * 添加时间 34 | */ 35 | 36 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 37 | @DateTimeFormat 38 | private Date tianjiashijian; 39 | 40 | /** 41 | * 用户id 42 | */ 43 | 44 | private Long userid; 45 | 46 | 47 | /** 48 | * 设置:姓名 49 | */ 50 | 51 | public void setXingming(String xingming) { 52 | this.xingming = xingming; 53 | } 54 | 55 | /** 56 | * 获取:姓名 57 | */ 58 | public String getXingming() { 59 | return xingming; 60 | } 61 | 62 | 63 | /** 64 | * 设置:添加时间 65 | */ 66 | 67 | public void setTianjiashijian(Date tianjiashijian) { 68 | this.tianjiashijian = tianjiashijian; 69 | } 70 | 71 | /** 72 | * 获取:添加时间 73 | */ 74 | public Date getTianjiashijian() { 75 | return tianjiashijian; 76 | } 77 | 78 | 79 | /** 80 | * 设置:用户id 81 | */ 82 | 83 | public void setUserid(Long userid) { 84 | this.userid = userid; 85 | } 86 | 87 | /** 88 | * 获取:用户id 89 | */ 90 | public Long getUserid() { 91 | return userid; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # Tomcat 2 | server: 3 | tomcat: 4 | uri-encoding: UTF-8 5 | port: 8080 6 | servlet: 7 | context-path: /springboot35l3z 8 | 9 | spring: 10 | datasource: 11 | driverClassName: com.mysql.jdbc.Driver 12 | url: jdbc:mysql://127.0.0.1:3306/springboot35l3z?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8 13 | username: root 14 | password: 123456 15 | 16 | # driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver 17 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=springboot35l3z 18 | # username: sa 19 | # password: 123456 20 | 21 | servlet: 22 | multipart: 23 | max-file-size: 10MB 24 | max-request-size: 10MB 25 | resources: 26 | static-locations: classpath:static/,file:static/ 27 | 28 | #mybatis 29 | mybatis-plus: 30 | mapper-locations: classpath*:mapper/*.xml 31 | #实体扫描,多个package用逗号或者分号分隔 32 | typeAliasesPackage: com.entity 33 | global-config: 34 | #主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID"; 35 | id-type: 1 36 | #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断" 37 | field-strategy: 2 38 | #驼峰下划线转换 39 | db-column-underline: true 40 | #刷新mapper 调试神器 41 | refresh-mapper: true 42 | #逻辑删除配置 43 | logic-delete-value: -1 44 | logic-not-delete-value: 0 45 | #自定义SQL注入器 46 | sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector 47 | configuration: 48 | map-underscore-to-camel-case: true 49 | cache-enabled: false 50 | call-setters-on-nulls: true 51 | #springboot 项目mybatis plus 设置 jdbcTypeForNull (oracle数据库需配置JdbcType.NULL, 默认是Other) 52 | jdbc-type-for-null: 'null' 53 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 54 | -------------------------------------------------------------------------------- /src/main/resources/mapper/CommonDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 19 | 20 | 21 | UPDATE ${table} set sfsh=#{sfsh} where id=#{id} 22 | 23 | 24 | 44 | 45 | 48 | 49 | 52 | 53 | 56 | 57 | -------------------------------------------------------------------------------- /src/main/java/com/entity/vo/StoreupVO.java: -------------------------------------------------------------------------------- 1 | package com.entity.vo; 2 | 3 | import com.entity.StoreupEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import java.util.Date; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import com.fasterxml.jackson.annotation.JsonFormat; 10 | import java.io.Serializable; 11 | 12 | 13 | /** 14 | * 收藏表 15 | * 手机端接口返回实体辅助类 16 | * (主要作用去除一些不必要的字段) 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public class StoreupVO implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | 25 | /** 26 | * 收藏id 27 | */ 28 | 29 | private Long refid; 30 | 31 | /** 32 | * 表名 33 | */ 34 | 35 | private String tablename; 36 | 37 | /** 38 | * 收藏名称 39 | */ 40 | 41 | private String name; 42 | 43 | /** 44 | * 收藏图片 45 | */ 46 | 47 | private String picture; 48 | 49 | 50 | /** 51 | * 设置:收藏id 52 | */ 53 | 54 | public void setRefid(Long refid) { 55 | this.refid = refid; 56 | } 57 | 58 | /** 59 | * 获取:收藏id 60 | */ 61 | public Long getRefid() { 62 | return refid; 63 | } 64 | 65 | 66 | /** 67 | * 设置:表名 68 | */ 69 | 70 | public void setTablename(String tablename) { 71 | this.tablename = tablename; 72 | } 73 | 74 | /** 75 | * 获取:表名 76 | */ 77 | public String getTablename() { 78 | return tablename; 79 | } 80 | 81 | 82 | /** 83 | * 设置:收藏名称 84 | */ 85 | 86 | public void setName(String name) { 87 | this.name = name; 88 | } 89 | 90 | /** 91 | * 获取:收藏名称 92 | */ 93 | public String getName() { 94 | return name; 95 | } 96 | 97 | 98 | /** 99 | * 设置:收藏图片 100 | */ 101 | 102 | public void setPicture(String picture) { 103 | this.picture = picture; 104 | } 105 | 106 | /** 107 | * 获取:收藏图片 108 | */ 109 | public String getPicture() { 110 | return picture; 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/YonghuServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.service.impl; 2 | 3 | import org.springframework.stereotype.Service; 4 | import java.util.Map; 5 | import java.util.List; 6 | 7 | import com.baomidou.mybatisplus.mapper.Wrapper; 8 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 9 | import com.baomidou.mybatisplus.plugins.Page; 10 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 11 | import com.utils.PageUtils; 12 | import com.utils.Query; 13 | 14 | 15 | import com.dao.YonghuDao; 16 | import com.entity.YonghuEntity; 17 | import com.service.YonghuService; 18 | import com.entity.vo.YonghuVO; 19 | import com.entity.view.YonghuView; 20 | 21 | @Service("yonghuService") 22 | public class YonghuServiceImpl extends ServiceImpl implements YonghuService { 23 | 24 | 25 | @Override 26 | public PageUtils queryPage(Map params) { 27 | Page page = this.selectPage( 28 | new Query(params).getPage(), 29 | new EntityWrapper() 30 | ); 31 | return new PageUtils(page); 32 | } 33 | 34 | @Override 35 | public PageUtils queryPage(Map params, Wrapper wrapper) { 36 | Page page =new Query(params).getPage(); 37 | page.setRecords(baseMapper.selectListView(page,wrapper)); 38 | PageUtils pageUtil = new PageUtils(page); 39 | return pageUtil; 40 | } 41 | 42 | @Override 43 | public List selectListVO(Wrapper wrapper) { 44 | return baseMapper.selectListVO(wrapper); 45 | } 46 | 47 | @Override 48 | public YonghuVO selectVO(Wrapper wrapper) { 49 | return baseMapper.selectVO(wrapper); 50 | } 51 | 52 | @Override 53 | public List selectListView(Wrapper wrapper) { 54 | return baseMapper.selectListView(wrapper); 55 | } 56 | 57 | @Override 58 | public YonghuView selectView(Wrapper wrapper) { 59 | return baseMapper.selectView(wrapper); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/entity/vo/DiscussmeishijianshangVO.java: -------------------------------------------------------------------------------- 1 | package com.entity.vo; 2 | 3 | import com.entity.DiscussmeishijianshangEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import java.util.Date; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import com.fasterxml.jackson.annotation.JsonFormat; 10 | import java.io.Serializable; 11 | 12 | 13 | /** 14 | * 美食鉴赏评论表 15 | * 手机端接口返回实体辅助类 16 | * (主要作用去除一些不必要的字段) 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public class DiscussmeishijianshangVO implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | 25 | /** 26 | * 用户id 27 | */ 28 | 29 | private Long userid; 30 | 31 | /** 32 | * 用户名 33 | */ 34 | 35 | private String nickname; 36 | 37 | /** 38 | * 评论内容 39 | */ 40 | 41 | private String content; 42 | 43 | /** 44 | * 回复内容 45 | */ 46 | 47 | private String reply; 48 | 49 | 50 | /** 51 | * 设置:用户id 52 | */ 53 | 54 | public void setUserid(Long userid) { 55 | this.userid = userid; 56 | } 57 | 58 | /** 59 | * 获取:用户id 60 | */ 61 | public Long getUserid() { 62 | return userid; 63 | } 64 | 65 | 66 | /** 67 | * 设置:用户名 68 | */ 69 | 70 | public void setNickname(String nickname) { 71 | this.nickname = nickname; 72 | } 73 | 74 | /** 75 | * 获取:用户名 76 | */ 77 | public String getNickname() { 78 | return nickname; 79 | } 80 | 81 | 82 | /** 83 | * 设置:评论内容 84 | */ 85 | 86 | public void setContent(String content) { 87 | this.content = content; 88 | } 89 | 90 | /** 91 | * 获取:评论内容 92 | */ 93 | public String getContent() { 94 | return content; 95 | } 96 | 97 | 98 | /** 99 | * 设置:回复内容 100 | */ 101 | 102 | public void setReply(String reply) { 103 | this.reply = reply; 104 | } 105 | 106 | /** 107 | * 获取:回复内容 108 | */ 109 | public String getReply() { 110 | return reply; 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/com/entity/model/StoreupModel.java: -------------------------------------------------------------------------------- 1 | package com.entity.model; 2 | 3 | import com.entity.StoreupEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import java.util.Date; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import com.fasterxml.jackson.annotation.JsonFormat; 10 | import java.io.Serializable; 11 | 12 | 13 | /** 14 | * 收藏表 15 | * 接收传参的实体类 16 | *(实际开发中配合移动端接口开发手动去掉些没用的字段, 后端一般用entity就够用了) 17 | * 取自ModelAndView 的model名称 18 | * @author 19 | * @email 20 | * @date 2021-03-12 20:57:00 21 | */ 22 | public class StoreupModel implements Serializable { 23 | private static final long serialVersionUID = 1L; 24 | 25 | 26 | /** 27 | * 收藏id 28 | */ 29 | 30 | private Long refid; 31 | 32 | /** 33 | * 表名 34 | */ 35 | 36 | private String tablename; 37 | 38 | /** 39 | * 收藏名称 40 | */ 41 | 42 | private String name; 43 | 44 | /** 45 | * 收藏图片 46 | */ 47 | 48 | private String picture; 49 | 50 | 51 | /** 52 | * 设置:收藏id 53 | */ 54 | 55 | public void setRefid(Long refid) { 56 | this.refid = refid; 57 | } 58 | 59 | /** 60 | * 获取:收藏id 61 | */ 62 | public Long getRefid() { 63 | return refid; 64 | } 65 | 66 | 67 | /** 68 | * 设置:表名 69 | */ 70 | 71 | public void setTablename(String tablename) { 72 | this.tablename = tablename; 73 | } 74 | 75 | /** 76 | * 获取:表名 77 | */ 78 | public String getTablename() { 79 | return tablename; 80 | } 81 | 82 | 83 | /** 84 | * 设置:收藏名称 85 | */ 86 | 87 | public void setName(String name) { 88 | this.name = name; 89 | } 90 | 91 | /** 92 | * 获取:收藏名称 93 | */ 94 | public String getName() { 95 | return name; 96 | } 97 | 98 | 99 | /** 100 | * 设置:收藏图片 101 | */ 102 | 103 | public void setPicture(String picture) { 104 | this.picture = picture; 105 | } 106 | 107 | /** 108 | * 获取:收藏图片 109 | */ 110 | public String getPicture() { 111 | return picture; 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/StoreupServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.service.impl; 2 | 3 | import org.springframework.stereotype.Service; 4 | import java.util.Map; 5 | import java.util.List; 6 | 7 | import com.baomidou.mybatisplus.mapper.Wrapper; 8 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 9 | import com.baomidou.mybatisplus.plugins.Page; 10 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 11 | import com.utils.PageUtils; 12 | import com.utils.Query; 13 | 14 | 15 | import com.dao.StoreupDao; 16 | import com.entity.StoreupEntity; 17 | import com.service.StoreupService; 18 | import com.entity.vo.StoreupVO; 19 | import com.entity.view.StoreupView; 20 | 21 | @Service("storeupService") 22 | public class StoreupServiceImpl extends ServiceImpl implements StoreupService { 23 | 24 | 25 | @Override 26 | public PageUtils queryPage(Map params) { 27 | Page page = this.selectPage( 28 | new Query(params).getPage(), 29 | new EntityWrapper() 30 | ); 31 | return new PageUtils(page); 32 | } 33 | 34 | @Override 35 | public PageUtils queryPage(Map params, Wrapper wrapper) { 36 | Page page =new Query(params).getPage(); 37 | page.setRecords(baseMapper.selectListView(page,wrapper)); 38 | PageUtils pageUtil = new PageUtils(page); 39 | return pageUtil; 40 | } 41 | 42 | @Override 43 | public List selectListVO(Wrapper wrapper) { 44 | return baseMapper.selectListVO(wrapper); 45 | } 46 | 47 | @Override 48 | public StoreupVO selectVO(Wrapper wrapper) { 49 | return baseMapper.selectVO(wrapper); 50 | } 51 | 52 | @Override 53 | public List selectListView(Wrapper wrapper) { 54 | return baseMapper.selectListView(wrapper); 55 | } 56 | 57 | @Override 58 | public StoreupView selectView(Wrapper wrapper) { 59 | return baseMapper.selectView(wrapper); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/entity/model/DiscussmeishijianshangModel.java: -------------------------------------------------------------------------------- 1 | package com.entity.model; 2 | 3 | import com.entity.DiscussmeishijianshangEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import java.util.Date; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import com.fasterxml.jackson.annotation.JsonFormat; 10 | import java.io.Serializable; 11 | 12 | 13 | /** 14 | * 美食鉴赏评论表 15 | * 接收传参的实体类 16 | *(实际开发中配合移动端接口开发手动去掉些没用的字段, 后端一般用entity就够用了) 17 | * 取自ModelAndView 的model名称 18 | * @author 19 | * @email 20 | * @date 2021-03-12 20:57:00 21 | */ 22 | public class DiscussmeishijianshangModel implements Serializable { 23 | private static final long serialVersionUID = 1L; 24 | 25 | 26 | /** 27 | * 用户id 28 | */ 29 | 30 | private Long userid; 31 | 32 | /** 33 | * 用户名 34 | */ 35 | 36 | private String nickname; 37 | 38 | /** 39 | * 评论内容 40 | */ 41 | 42 | private String content; 43 | 44 | /** 45 | * 回复内容 46 | */ 47 | 48 | private String reply; 49 | 50 | 51 | /** 52 | * 设置:用户id 53 | */ 54 | 55 | public void setUserid(Long userid) { 56 | this.userid = userid; 57 | } 58 | 59 | /** 60 | * 获取:用户id 61 | */ 62 | public Long getUserid() { 63 | return userid; 64 | } 65 | 66 | 67 | /** 68 | * 设置:用户名 69 | */ 70 | 71 | public void setNickname(String nickname) { 72 | this.nickname = nickname; 73 | } 74 | 75 | /** 76 | * 获取:用户名 77 | */ 78 | public String getNickname() { 79 | return nickname; 80 | } 81 | 82 | 83 | /** 84 | * 设置:评论内容 85 | */ 86 | 87 | public void setContent(String content) { 88 | this.content = content; 89 | } 90 | 91 | /** 92 | * 获取:评论内容 93 | */ 94 | public String getContent() { 95 | return content; 96 | } 97 | 98 | 99 | /** 100 | * 设置:回复内容 101 | */ 102 | 103 | public void setReply(String reply) { 104 | this.reply = reply; 105 | } 106 | 107 | /** 108 | * 获取:回复内容 109 | */ 110 | public String getReply() { 111 | return reply; 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/WodehaoyouServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.service.impl; 2 | 3 | import org.springframework.stereotype.Service; 4 | import java.util.Map; 5 | import java.util.List; 6 | 7 | import com.baomidou.mybatisplus.mapper.Wrapper; 8 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 9 | import com.baomidou.mybatisplus.plugins.Page; 10 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 11 | import com.utils.PageUtils; 12 | import com.utils.Query; 13 | 14 | 15 | import com.dao.WodehaoyouDao; 16 | import com.entity.WodehaoyouEntity; 17 | import com.service.WodehaoyouService; 18 | import com.entity.vo.WodehaoyouVO; 19 | import com.entity.view.WodehaoyouView; 20 | 21 | @Service("wodehaoyouService") 22 | public class WodehaoyouServiceImpl extends ServiceImpl implements WodehaoyouService { 23 | 24 | 25 | @Override 26 | public PageUtils queryPage(Map params) { 27 | Page page = this.selectPage( 28 | new Query(params).getPage(), 29 | new EntityWrapper() 30 | ); 31 | return new PageUtils(page); 32 | } 33 | 34 | @Override 35 | public PageUtils queryPage(Map params, Wrapper wrapper) { 36 | Page page =new Query(params).getPage(); 37 | page.setRecords(baseMapper.selectListView(page,wrapper)); 38 | PageUtils pageUtil = new PageUtils(page); 39 | return pageUtil; 40 | } 41 | 42 | @Override 43 | public List selectListVO(Wrapper wrapper) { 44 | return baseMapper.selectListVO(wrapper); 45 | } 46 | 47 | @Override 48 | public WodehaoyouVO selectVO(Wrapper wrapper) { 49 | return baseMapper.selectVO(wrapper); 50 | } 51 | 52 | @Override 53 | public List selectListView(Wrapper wrapper) { 54 | return baseMapper.selectListView(wrapper); 55 | } 56 | 57 | @Override 58 | public WodehaoyouView selectView(Wrapper wrapper) { 59 | return baseMapper.selectView(wrapper); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/DefaultuserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.service.impl; 2 | 3 | import org.springframework.stereotype.Service; 4 | import java.util.Map; 5 | import java.util.List; 6 | 7 | import com.baomidou.mybatisplus.mapper.Wrapper; 8 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 9 | import com.baomidou.mybatisplus.plugins.Page; 10 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 11 | import com.utils.PageUtils; 12 | import com.utils.Query; 13 | 14 | 15 | import com.dao.DefaultuserDao; 16 | import com.entity.DefaultuserEntity; 17 | import com.service.DefaultuserService; 18 | import com.entity.vo.DefaultuserVO; 19 | import com.entity.view.DefaultuserView; 20 | 21 | @Service("defaultuserService") 22 | public class DefaultuserServiceImpl extends ServiceImpl implements DefaultuserService { 23 | 24 | 25 | @Override 26 | public PageUtils queryPage(Map params) { 27 | Page page = this.selectPage( 28 | new Query(params).getPage(), 29 | new EntityWrapper() 30 | ); 31 | return new PageUtils(page); 32 | } 33 | 34 | @Override 35 | public PageUtils queryPage(Map params, Wrapper wrapper) { 36 | Page page =new Query(params).getPage(); 37 | page.setRecords(baseMapper.selectListView(page,wrapper)); 38 | PageUtils pageUtil = new PageUtils(page); 39 | return pageUtil; 40 | } 41 | 42 | @Override 43 | public List selectListVO(Wrapper wrapper) { 44 | return baseMapper.selectListVO(wrapper); 45 | } 46 | 47 | @Override 48 | public DefaultuserVO selectVO(Wrapper wrapper) { 49 | return baseMapper.selectVO(wrapper); 50 | } 51 | 52 | @Override 53 | public List selectListView(Wrapper wrapper) { 54 | return baseMapper.selectListView(wrapper); 55 | } 56 | 57 | @Override 58 | public DefaultuserView selectView(Wrapper wrapper) { 59 | return baseMapper.selectView(wrapper); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/resources/mapper/MeishijianshangDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 35 | 36 | 42 | 43 | 47 | 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 基于Springboot的校园周边美食探索及分享平台(程序+论文) 2 | = 3 | ### 完整代码获取地址:从戎源码网 ([https://armycodes.com/](https://armycodes.com/)) 4 | ### 作者微信:19941326836 QQ:952045282 5 | ### 承接计算机毕业设计、Java毕业设计、Python毕业设计、深度学习、机器学习 6 | ### 选题+开题报告+任务书+程序定制+安装调试+论文+答辩ppt 一条龙服务 7 | ### 所有选题地址https://github.com/nature924/allProject 8 | 9 | 一、项目介绍 10 | --- 11 | 系统包含两种角色:用户、管理员,系统分为前台和后台两大模块,主要功能如下: 12 | 13 | ### 前台首页功能模块 14 | 在校园周边美食探索及分享平台的系统首页,用户可以查看首页、美食鉴赏、我的好友、个人中心、后台管理等内容。 15 | 16 | - 用户登录与注册 17 | 在用户注册页面,填写用户名、姓名、手机、邮箱、身份证等详细内容进行注册和登录。 18 | 19 | - 美食鉴赏 20 | 在美食鉴赏页面查看发布时间、美食名称、美食类别、美食介绍、商品所在位置、推荐指数、美食照片、商品价格、用户名、姓名等信息,并进行点赞、评论,也可根据美食鉴赏名称进行搜索操作。 21 | 22 | - 个人中心 23 | 在个人中心页面,填写用户名、姓名、手机、邮箱、身份证、照片等信息进行添加、修改、删除操作。 24 | 25 | ### 用户功能模块 26 | 用户登录后可以访问校园周边美食探索及分享平台的首页、个人中心、美食鉴赏管理、我的好友管理、我的收藏管理等内容。 27 | 28 | - 个人中心 29 | 用户在个人信息页面中可以查看用户名、姓名、手机、邮箱、身份证、照片等信息,并根据需要进行查看、删除或其他操作。 30 | 31 | - 美食鉴赏管理 32 | 用户可以添加发布时间、美食名称、美食类别、美食介绍、商品所在位置、推荐指数、美食照片、商品价格、用户名、姓名等信息,并进行修改或删除操作。 33 | 34 | - 我的收藏管理 35 | 用户可以收藏美食名称、美食图片等,并进行查看或删除等操作。 36 | 37 | ### 管理员功能模块 38 | 管理员登录后,通过填写注册时输入的用户名、密码、角色进行登录。登录后可以查看首页、个人中心、用户管理、美食鉴赏管理、我的好友管理、我的收藏管理、系统管理等信息。 39 | 40 | - 个人中心 41 | 管理员在个人中心可以修改密码,填写原密码、新密码、确认密码进行修改操作。 42 | 43 | - 用户管理 44 | 在用户信息页面,管理员可以查看用户名、姓名、手机、邮箱、身份证、照片等信息,并对用户信息进行修改或删除操作。 45 | 46 | - 美食鉴赏管理 47 | 在美食鉴赏信息页面,管理员可以查看发布时间、美食名称、美食类别、美食介绍、商品所在位置、推荐指数、美食照片、商品价格、用户名、姓名等信息,并对美食鉴赏信息进行新增、修改或删除操作。 48 | 49 | - 我的好友管理 50 | 在我的好友页面,管理员可以查看用户名、姓名、添加时间等内容,并对好友进行新增、修改或删除操作。 51 | 52 | - 系统管理 53 | 在系统管理页面,管理员可以查看轮播图,进行图片上传、添加、删除、修改操作,并对整个系统进行维护。 54 | 55 | 56 | 57 | 58 | 二、项目技术 59 | --- 60 | - 编程语言:Java 61 | - 数据库:MySQL 62 | - 项目管理工具:Maven 63 | - 前端技术:VUE、HTML、Jquery、Bootstrap 64 | - 后端技术:Spring、SpringMVC、MyBatis 65 | 66 | 三、运行环境 67 | --- 68 | - 操作系统:Windows、macOS都可以 69 | - JDK版本:JDK1.8以上都可以 70 | - 开发工具:IDEA、Ecplise、Myecplise都可以 71 | - 数据库: MySQL5.7以上都可以 72 | - Tomcat:任意版本都可以 73 | - Maven:任意版本都可以 74 | 75 | 四、运行截图 76 | --- 77 | ### 论文截图: 78 | ![image/1.png](limage/1.png) 79 | 80 | ### 程序截图: 81 | ![image/1.png](image/图片1.png) 82 | ![image/1.png](image/图片2.png) 83 | ![image/1.png](image/图片3.png) 84 | ![image/1.png](image/图片4.png) 85 | ![image/1.png](image/图片5.png) 86 | ![image/1.png](image/图片6.png) 87 | ![image/1.png](image/图片7.png) 88 | ![image/1.png](image/图片8.png) 89 | ![image/1.png](image/图片9.png) 90 | 91 | 92 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/MeishijianshangServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.service.impl; 2 | 3 | import org.springframework.stereotype.Service; 4 | import java.util.Map; 5 | import java.util.List; 6 | 7 | import com.baomidou.mybatisplus.mapper.Wrapper; 8 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 9 | import com.baomidou.mybatisplus.plugins.Page; 10 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 11 | import com.utils.PageUtils; 12 | import com.utils.Query; 13 | 14 | 15 | import com.dao.MeishijianshangDao; 16 | import com.entity.MeishijianshangEntity; 17 | import com.service.MeishijianshangService; 18 | import com.entity.vo.MeishijianshangVO; 19 | import com.entity.view.MeishijianshangView; 20 | 21 | @Service("meishijianshangService") 22 | public class MeishijianshangServiceImpl extends ServiceImpl implements MeishijianshangService { 23 | 24 | 25 | @Override 26 | public PageUtils queryPage(Map params) { 27 | Page page = this.selectPage( 28 | new Query(params).getPage(), 29 | new EntityWrapper() 30 | ); 31 | return new PageUtils(page); 32 | } 33 | 34 | @Override 35 | public PageUtils queryPage(Map params, Wrapper wrapper) { 36 | Page page =new Query(params).getPage(); 37 | page.setRecords(baseMapper.selectListView(page,wrapper)); 38 | PageUtils pageUtil = new PageUtils(page); 39 | return pageUtil; 40 | } 41 | 42 | @Override 43 | public List selectListVO(Wrapper wrapper) { 44 | return baseMapper.selectListVO(wrapper); 45 | } 46 | 47 | @Override 48 | public MeishijianshangVO selectVO(Wrapper wrapper) { 49 | return baseMapper.selectVO(wrapper); 50 | } 51 | 52 | @Override 53 | public List selectListView(Wrapper wrapper) { 54 | return baseMapper.selectListView(wrapper); 55 | } 56 | 57 | @Override 58 | public MeishijianshangView selectView(Wrapper wrapper) { 59 | return baseMapper.selectView(wrapper); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/utils/PageUtils.java: -------------------------------------------------------------------------------- 1 | 2 | package com.utils; 3 | 4 | import java.io.Serializable; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import com.baomidou.mybatisplus.plugins.Page; 9 | 10 | /** 11 | * 分页工具类 12 | */ 13 | public class PageUtils implements Serializable { 14 | private static final long serialVersionUID = 1L; 15 | //总记录数 16 | private long total; 17 | //每页记录数 18 | private int pageSize; 19 | //总页数 20 | private long totalPage; 21 | //当前页数 22 | private int currPage; 23 | //列表数据 24 | private List list; 25 | 26 | /** 27 | * 分页 28 | * @param list 列表数据 29 | * @param totalCount 总记录数 30 | * @param pageSize 每页记录数 31 | * @param currPage 当前页数 32 | */ 33 | public PageUtils(List list, int totalCount, int pageSize, int currPage) { 34 | this.list = list; 35 | this.total = totalCount; 36 | this.pageSize = pageSize; 37 | this.currPage = currPage; 38 | this.totalPage = (int)Math.ceil((double)totalCount/pageSize); 39 | } 40 | 41 | /** 42 | * 分页 43 | */ 44 | public PageUtils(Page page) { 45 | this.list = page.getRecords(); 46 | this.total = page.getTotal(); 47 | this.pageSize = page.getSize(); 48 | this.currPage = page.getCurrent(); 49 | this.totalPage = page.getPages(); 50 | } 51 | 52 | /* 53 | * 空数据的分页 54 | */ 55 | public PageUtils(Map params) { 56 | Page page =new Query(params).getPage(); 57 | new PageUtils(page); 58 | } 59 | 60 | 61 | public int getPageSize() { 62 | return pageSize; 63 | } 64 | 65 | public void setPageSize(int pageSize) { 66 | this.pageSize = pageSize; 67 | } 68 | 69 | public int getCurrPage() { 70 | return currPage; 71 | } 72 | 73 | public void setCurrPage(int currPage) { 74 | this.currPage = currPage; 75 | } 76 | 77 | public List getList() { 78 | return list; 79 | } 80 | 81 | public void setList(List list) { 82 | this.list = list; 83 | } 84 | 85 | public long getTotalPage() { 86 | return totalPage; 87 | } 88 | 89 | public void setTotalPage(long totalPage) { 90 | this.totalPage = totalPage; 91 | } 92 | 93 | public long getTotal() { 94 | return total; 95 | } 96 | 97 | public void setTotal(long total) { 98 | this.total = total; 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/DiscussmeishijianshangServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.service.impl; 2 | 3 | import org.springframework.stereotype.Service; 4 | import java.util.Map; 5 | import java.util.List; 6 | 7 | import com.baomidou.mybatisplus.mapper.Wrapper; 8 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 9 | import com.baomidou.mybatisplus.plugins.Page; 10 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 11 | import com.utils.PageUtils; 12 | import com.utils.Query; 13 | 14 | 15 | import com.dao.DiscussmeishijianshangDao; 16 | import com.entity.DiscussmeishijianshangEntity; 17 | import com.service.DiscussmeishijianshangService; 18 | import com.entity.vo.DiscussmeishijianshangVO; 19 | import com.entity.view.DiscussmeishijianshangView; 20 | 21 | @Service("discussmeishijianshangService") 22 | public class DiscussmeishijianshangServiceImpl extends ServiceImpl implements DiscussmeishijianshangService { 23 | 24 | 25 | @Override 26 | public PageUtils queryPage(Map params) { 27 | Page page = this.selectPage( 28 | new Query(params).getPage(), 29 | new EntityWrapper() 30 | ); 31 | return new PageUtils(page); 32 | } 33 | 34 | @Override 35 | public PageUtils queryPage(Map params, Wrapper wrapper) { 36 | Page page =new Query(params).getPage(); 37 | page.setRecords(baseMapper.selectListView(page,wrapper)); 38 | PageUtils pageUtil = new PageUtils(page); 39 | return pageUtil; 40 | } 41 | 42 | @Override 43 | public List selectListVO(Wrapper wrapper) { 44 | return baseMapper.selectListVO(wrapper); 45 | } 46 | 47 | @Override 48 | public DiscussmeishijianshangVO selectVO(Wrapper wrapper) { 49 | return baseMapper.selectVO(wrapper); 50 | } 51 | 52 | @Override 53 | public List selectListView(Wrapper wrapper) { 54 | return baseMapper.selectListView(wrapper); 55 | } 56 | 57 | @Override 58 | public DiscussmeishijianshangView selectView(Wrapper wrapper) { 59 | return baseMapper.selectView(wrapper); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/entity/vo/YonghuVO.java: -------------------------------------------------------------------------------- 1 | package com.entity.vo; 2 | 3 | import com.entity.YonghuEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import java.util.Date; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import com.fasterxml.jackson.annotation.JsonFormat; 10 | import java.io.Serializable; 11 | 12 | 13 | /** 14 | * 用户 15 | * 手机端接口返回实体辅助类 16 | * (主要作用去除一些不必要的字段) 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public class YonghuVO implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | 25 | /** 26 | * 密码 27 | */ 28 | 29 | private String mima; 30 | 31 | /** 32 | * 姓名 33 | */ 34 | 35 | private String xingming; 36 | 37 | /** 38 | * 手机 39 | */ 40 | 41 | private String shouji; 42 | 43 | /** 44 | * 邮箱 45 | */ 46 | 47 | private String youxiang; 48 | 49 | /** 50 | * 身份证 51 | */ 52 | 53 | private String shenfenzheng; 54 | 55 | /** 56 | * 照片 57 | */ 58 | 59 | private String zhaopian; 60 | 61 | 62 | /** 63 | * 设置:密码 64 | */ 65 | 66 | public void setMima(String mima) { 67 | this.mima = mima; 68 | } 69 | 70 | /** 71 | * 获取:密码 72 | */ 73 | public String getMima() { 74 | return mima; 75 | } 76 | 77 | 78 | /** 79 | * 设置:姓名 80 | */ 81 | 82 | public void setXingming(String xingming) { 83 | this.xingming = xingming; 84 | } 85 | 86 | /** 87 | * 获取:姓名 88 | */ 89 | public String getXingming() { 90 | return xingming; 91 | } 92 | 93 | 94 | /** 95 | * 设置:手机 96 | */ 97 | 98 | public void setShouji(String shouji) { 99 | this.shouji = shouji; 100 | } 101 | 102 | /** 103 | * 获取:手机 104 | */ 105 | public String getShouji() { 106 | return shouji; 107 | } 108 | 109 | 110 | /** 111 | * 设置:邮箱 112 | */ 113 | 114 | public void setYouxiang(String youxiang) { 115 | this.youxiang = youxiang; 116 | } 117 | 118 | /** 119 | * 获取:邮箱 120 | */ 121 | public String getYouxiang() { 122 | return youxiang; 123 | } 124 | 125 | 126 | /** 127 | * 设置:身份证 128 | */ 129 | 130 | public void setShenfenzheng(String shenfenzheng) { 131 | this.shenfenzheng = shenfenzheng; 132 | } 133 | 134 | /** 135 | * 获取:身份证 136 | */ 137 | public String getShenfenzheng() { 138 | return shenfenzheng; 139 | } 140 | 141 | 142 | /** 143 | * 设置:照片 144 | */ 145 | 146 | public void setZhaopian(String zhaopian) { 147 | this.zhaopian = zhaopian; 148 | } 149 | 150 | /** 151 | * 获取:照片 152 | */ 153 | public String getZhaopian() { 154 | return zhaopian; 155 | } 156 | 157 | } 158 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/TokenServiceImpl.java: -------------------------------------------------------------------------------- 1 | 2 | package com.service.impl; 3 | 4 | 5 | import java.util.Calendar; 6 | import java.util.Date; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | import org.springframework.stereotype.Service; 11 | 12 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 13 | import com.baomidou.mybatisplus.mapper.Wrapper; 14 | import com.baomidou.mybatisplus.plugins.Page; 15 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; 16 | import com.dao.TokenDao; 17 | import com.entity.TokenEntity; 18 | import com.entity.TokenEntity; 19 | import com.service.TokenService; 20 | import com.utils.CommonUtil; 21 | import com.utils.PageUtils; 22 | import com.utils.Query; 23 | 24 | 25 | /** 26 | * token 27 | */ 28 | @Service("tokenService") 29 | public class TokenServiceImpl extends ServiceImpl implements TokenService { 30 | 31 | @Override 32 | public PageUtils queryPage(Map params) { 33 | Page page = this.selectPage( 34 | new Query(params).getPage(), 35 | new EntityWrapper() 36 | ); 37 | return new PageUtils(page); 38 | } 39 | 40 | @Override 41 | public List selectListView(Wrapper wrapper) { 42 | return baseMapper.selectListView(wrapper); 43 | } 44 | 45 | @Override 46 | public PageUtils queryPage(Map params, 47 | Wrapper wrapper) { 48 | Page page =new Query(params).getPage(); 49 | page.setRecords(baseMapper.selectListView(page,wrapper)); 50 | PageUtils pageUtil = new PageUtils(page); 51 | return pageUtil; 52 | } 53 | 54 | @Override 55 | public String generateToken(Long userid,String username, String tableName, String role) { 56 | TokenEntity tokenEntity = this.selectOne(new EntityWrapper().eq("userid", userid).eq("role", role)); 57 | String token = CommonUtil.getRandomString(32); 58 | Calendar cal = Calendar.getInstance(); 59 | cal.setTime(new Date()); 60 | cal.add(Calendar.HOUR_OF_DAY, 1); 61 | if(tokenEntity!=null) { 62 | tokenEntity.setToken(token); 63 | tokenEntity.setExpiratedtime(cal.getTime()); 64 | this.updateById(tokenEntity); 65 | } else { 66 | this.insert(new TokenEntity(userid,username, tableName, role, token, cal.getTime())); 67 | } 68 | return token; 69 | } 70 | 71 | @Override 72 | public TokenEntity getTokenEntity(String token) { 73 | TokenEntity tokenEntity = this.selectOne(new EntityWrapper().eq("token", token)); 74 | if(tokenEntity == null || tokenEntity.getExpiratedtime().getTime() extends LinkedHashMap { 15 | private static final long serialVersionUID = 1L; 16 | /** 17 | * mybatis-plus分页参数 18 | */ 19 | private Page page; 20 | /** 21 | * 当前页码 22 | */ 23 | private int currPage = 1; 24 | /** 25 | * 每页条数 26 | */ 27 | private int limit = 10; 28 | 29 | public Query(JQPageInfo pageInfo) { 30 | //分页参数 31 | if(pageInfo.getPage()!= null){ 32 | currPage = pageInfo.getPage(); 33 | } 34 | if(pageInfo.getLimit()!= null){ 35 | limit = pageInfo.getLimit(); 36 | } 37 | 38 | 39 | //防止SQL注入(因为sidx、order是通过拼接SQL实现排序的,会有SQL注入风险) 40 | String sidx = SQLFilter.sqlInject(pageInfo.getSidx()); 41 | String order = SQLFilter.sqlInject(pageInfo.getOrder()); 42 | 43 | 44 | //mybatis-plus分页 45 | this.page = new Page<>(currPage, limit); 46 | 47 | //排序 48 | if(StringUtils.isNotBlank(sidx) && StringUtils.isNotBlank(order)){ 49 | this.page.setOrderByField(sidx); 50 | this.page.setAsc("ASC".equalsIgnoreCase(order)); 51 | } 52 | } 53 | 54 | 55 | public Query(Map params){ 56 | this.putAll(params); 57 | 58 | //分页参数 59 | if(params.get("page") != null){ 60 | currPage = Integer.parseInt((String)params.get("page")); 61 | } 62 | if(params.get("limit") != null){ 63 | limit = Integer.parseInt((String)params.get("limit")); 64 | } 65 | 66 | this.put("offset", (currPage - 1) * limit); 67 | this.put("page", currPage); 68 | this.put("limit", limit); 69 | 70 | //防止SQL注入(因为sidx、order是通过拼接SQL实现排序的,会有SQL注入风险) 71 | String sidx = SQLFilter.sqlInject((String)params.get("sidx")); 72 | String order = SQLFilter.sqlInject((String)params.get("order")); 73 | this.put("sidx", sidx); 74 | this.put("order", order); 75 | 76 | //mybatis-plus分页 77 | this.page = new Page<>(currPage, limit); 78 | 79 | //排序 80 | if(StringUtils.isNotBlank(sidx) && StringUtils.isNotBlank(order)){ 81 | this.page.setOrderByField(sidx); 82 | this.page.setAsc("ASC".equalsIgnoreCase(order)); 83 | } 84 | 85 | } 86 | 87 | public Page getPage() { 88 | return page; 89 | } 90 | 91 | public int getCurrPage() { 92 | return currPage; 93 | } 94 | 95 | public int getLimit() { 96 | return limit; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/entity/vo/DefaultuserVO.java: -------------------------------------------------------------------------------- 1 | package com.entity.vo; 2 | 3 | import com.entity.DefaultuserEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import java.util.Date; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import com.fasterxml.jackson.annotation.JsonFormat; 10 | import java.io.Serializable; 11 | 12 | 13 | /** 14 | * 注册用户 15 | * 手机端接口返回实体辅助类 16 | * (主要作用去除一些不必要的字段) 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public class DefaultuserVO implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | 25 | /** 26 | * 密码 27 | */ 28 | 29 | private String mima; 30 | 31 | /** 32 | * 姓名 33 | */ 34 | 35 | private String name; 36 | 37 | /** 38 | * 性别 39 | */ 40 | 41 | private String sex; 42 | 43 | /** 44 | * 年龄 45 | */ 46 | 47 | private Integer age; 48 | 49 | /** 50 | * 电话 51 | */ 52 | 53 | private String phone; 54 | 55 | /** 56 | * 照片 57 | */ 58 | 59 | private String picture; 60 | 61 | /** 62 | * 邮箱 63 | */ 64 | 65 | private String email; 66 | 67 | 68 | /** 69 | * 设置:密码 70 | */ 71 | 72 | public void setMima(String mima) { 73 | this.mima = mima; 74 | } 75 | 76 | /** 77 | * 获取:密码 78 | */ 79 | public String getMima() { 80 | return mima; 81 | } 82 | 83 | 84 | /** 85 | * 设置:姓名 86 | */ 87 | 88 | public void setName(String name) { 89 | this.name = name; 90 | } 91 | 92 | /** 93 | * 获取:姓名 94 | */ 95 | public String getName() { 96 | return name; 97 | } 98 | 99 | 100 | /** 101 | * 设置:性别 102 | */ 103 | 104 | public void setSex(String sex) { 105 | this.sex = sex; 106 | } 107 | 108 | /** 109 | * 获取:性别 110 | */ 111 | public String getSex() { 112 | return sex; 113 | } 114 | 115 | 116 | /** 117 | * 设置:年龄 118 | */ 119 | 120 | public void setAge(Integer age) { 121 | this.age = age; 122 | } 123 | 124 | /** 125 | * 获取:年龄 126 | */ 127 | public Integer getAge() { 128 | return age; 129 | } 130 | 131 | 132 | /** 133 | * 设置:电话 134 | */ 135 | 136 | public void setPhone(String phone) { 137 | this.phone = phone; 138 | } 139 | 140 | /** 141 | * 获取:电话 142 | */ 143 | public String getPhone() { 144 | return phone; 145 | } 146 | 147 | 148 | /** 149 | * 设置:照片 150 | */ 151 | 152 | public void setPicture(String picture) { 153 | this.picture = picture; 154 | } 155 | 156 | /** 157 | * 获取:照片 158 | */ 159 | public String getPicture() { 160 | return picture; 161 | } 162 | 163 | 164 | /** 165 | * 设置:邮箱 166 | */ 167 | 168 | public void setEmail(String email) { 169 | this.email = email; 170 | } 171 | 172 | /** 173 | * 获取:邮箱 174 | */ 175 | public String getEmail() { 176 | return email; 177 | } 178 | 179 | } 180 | -------------------------------------------------------------------------------- /src/main/java/com/entity/model/DefaultuserModel.java: -------------------------------------------------------------------------------- 1 | package com.entity.model; 2 | 3 | import com.entity.DefaultuserEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import java.util.Date; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import com.fasterxml.jackson.annotation.JsonFormat; 10 | import java.io.Serializable; 11 | 12 | 13 | /** 14 | * 注册用户 15 | * 接收传参的实体类 16 | *(实际开发中配合移动端接口开发手动去掉些没用的字段, 后端一般用entity就够用了) 17 | * 取自ModelAndView 的model名称 18 | * @author 19 | * @email 20 | * @date 2021-03-12 20:57:00 21 | */ 22 | public class DefaultuserModel implements Serializable { 23 | private static final long serialVersionUID = 1L; 24 | 25 | 26 | /** 27 | * 密码 28 | */ 29 | 30 | private String mima; 31 | 32 | /** 33 | * 姓名 34 | */ 35 | 36 | private String name; 37 | 38 | /** 39 | * 性别 40 | */ 41 | 42 | private String sex; 43 | 44 | /** 45 | * 年龄 46 | */ 47 | 48 | private Integer age; 49 | 50 | /** 51 | * 电话 52 | */ 53 | 54 | private String phone; 55 | 56 | /** 57 | * 照片 58 | */ 59 | 60 | private String picture; 61 | 62 | /** 63 | * 邮箱 64 | */ 65 | 66 | private String email; 67 | 68 | 69 | /** 70 | * 设置:密码 71 | */ 72 | 73 | public void setMima(String mima) { 74 | this.mima = mima; 75 | } 76 | 77 | /** 78 | * 获取:密码 79 | */ 80 | public String getMima() { 81 | return mima; 82 | } 83 | 84 | 85 | /** 86 | * 设置:姓名 87 | */ 88 | 89 | public void setName(String name) { 90 | this.name = name; 91 | } 92 | 93 | /** 94 | * 获取:姓名 95 | */ 96 | public String getName() { 97 | return name; 98 | } 99 | 100 | 101 | /** 102 | * 设置:性别 103 | */ 104 | 105 | public void setSex(String sex) { 106 | this.sex = sex; 107 | } 108 | 109 | /** 110 | * 获取:性别 111 | */ 112 | public String getSex() { 113 | return sex; 114 | } 115 | 116 | 117 | /** 118 | * 设置:年龄 119 | */ 120 | 121 | public void setAge(Integer age) { 122 | this.age = age; 123 | } 124 | 125 | /** 126 | * 获取:年龄 127 | */ 128 | public Integer getAge() { 129 | return age; 130 | } 131 | 132 | 133 | /** 134 | * 设置:电话 135 | */ 136 | 137 | public void setPhone(String phone) { 138 | this.phone = phone; 139 | } 140 | 141 | /** 142 | * 获取:电话 143 | */ 144 | public String getPhone() { 145 | return phone; 146 | } 147 | 148 | 149 | /** 150 | * 设置:照片 151 | */ 152 | 153 | public void setPicture(String picture) { 154 | this.picture = picture; 155 | } 156 | 157 | /** 158 | * 获取:照片 159 | */ 160 | public String getPicture() { 161 | return picture; 162 | } 163 | 164 | 165 | /** 166 | * 设置:邮箱 167 | */ 168 | 169 | public void setEmail(String email) { 170 | this.email = email; 171 | } 172 | 173 | /** 174 | * 获取:邮箱 175 | */ 176 | public String getEmail() { 177 | return email; 178 | } 179 | 180 | } 181 | -------------------------------------------------------------------------------- /src/main/java/com/entity/WodehaoyouEntity.java: -------------------------------------------------------------------------------- 1 | package com.entity; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableId; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.NotEmpty; 7 | import javax.validation.constraints.NotNull; 8 | 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import java.lang.reflect.InvocationTargetException; 11 | 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | import org.springframework.format.annotation.DateTimeFormat; 17 | import com.fasterxml.jackson.annotation.JsonFormat; 18 | import org.apache.commons.beanutils.BeanUtils; 19 | import com.baomidou.mybatisplus.annotations.TableField; 20 | import com.baomidou.mybatisplus.enums.FieldFill; 21 | import com.baomidou.mybatisplus.enums.IdType; 22 | 23 | 24 | /** 25 | * 我的好友 26 | * 数据库通用操作实体类(普通增删改查) 27 | * @author 28 | * @email 29 | * @date 2021-03-12 20:57:00 30 | */ 31 | @TableName("wodehaoyou") 32 | public class WodehaoyouEntity implements Serializable { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | public WodehaoyouEntity() { 37 | 38 | } 39 | 40 | public WodehaoyouEntity(T t) { 41 | try { 42 | BeanUtils.copyProperties(this, t); 43 | } catch (IllegalAccessException | InvocationTargetException e) { 44 | // TODO Auto-generated catch block 45 | e.printStackTrace(); 46 | } 47 | } 48 | 49 | /** 50 | * 主键id 51 | */ 52 | @TableId 53 | private Long id; 54 | /** 55 | * 用户名 56 | */ 57 | 58 | private String yonghuming; 59 | 60 | /** 61 | * 姓名 62 | */ 63 | 64 | private String xingming; 65 | 66 | /** 67 | * 添加时间 68 | */ 69 | 70 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 71 | @DateTimeFormat 72 | private Date tianjiashijian; 73 | 74 | /** 75 | * 用户id 76 | */ 77 | 78 | private Long userid; 79 | 80 | 81 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 82 | @DateTimeFormat 83 | private Date addtime; 84 | 85 | public Date getAddtime() { 86 | return addtime; 87 | } 88 | public void setAddtime(Date addtime) { 89 | this.addtime = addtime; 90 | } 91 | 92 | public Long getId() { 93 | return id; 94 | } 95 | 96 | public void setId(Long id) { 97 | this.id = id; 98 | } 99 | /** 100 | * 设置:用户名 101 | */ 102 | public void setYonghuming(String yonghuming) { 103 | this.yonghuming = yonghuming; 104 | } 105 | /** 106 | * 获取:用户名 107 | */ 108 | public String getYonghuming() { 109 | return yonghuming; 110 | } 111 | /** 112 | * 设置:姓名 113 | */ 114 | public void setXingming(String xingming) { 115 | this.xingming = xingming; 116 | } 117 | /** 118 | * 获取:姓名 119 | */ 120 | public String getXingming() { 121 | return xingming; 122 | } 123 | /** 124 | * 设置:添加时间 125 | */ 126 | public void setTianjiashijian(Date tianjiashijian) { 127 | this.tianjiashijian = tianjiashijian; 128 | } 129 | /** 130 | * 获取:添加时间 131 | */ 132 | public Date getTianjiashijian() { 133 | return tianjiashijian; 134 | } 135 | /** 136 | * 设置:用户id 137 | */ 138 | public void setUserid(Long userid) { 139 | this.userid = userid; 140 | } 141 | /** 142 | * 获取:用户id 143 | */ 144 | public Long getUserid() { 145 | return userid; 146 | } 147 | 148 | } 149 | -------------------------------------------------------------------------------- /src/main/java/com/controller/ConfigController.java: -------------------------------------------------------------------------------- 1 | 2 | package com.controller; 3 | 4 | 5 | import java.util.Arrays; 6 | import java.util.Map; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestParam; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import com.annotation.IgnoreAuth; 17 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 18 | import com.entity.ConfigEntity; 19 | import com.service.ConfigService; 20 | import com.utils.PageUtils; 21 | import com.utils.R; 22 | import com.utils.ValidatorUtils; 23 | 24 | /** 25 | * 登录相关 26 | */ 27 | @RequestMapping("config") 28 | @RestController 29 | public class ConfigController{ 30 | 31 | @Autowired 32 | private ConfigService configService; 33 | 34 | /** 35 | * 列表 36 | */ 37 | @RequestMapping("/page") 38 | public R page(@RequestParam Map params,ConfigEntity config){ 39 | EntityWrapper ew = new EntityWrapper(); 40 | PageUtils page = configService.queryPage(params); 41 | return R.ok().put("data", page); 42 | } 43 | 44 | /** 45 | * 列表 46 | */ 47 | @IgnoreAuth 48 | @RequestMapping("/list") 49 | public R list(@RequestParam Map params,ConfigEntity config){ 50 | EntityWrapper ew = new EntityWrapper(); 51 | PageUtils page = configService.queryPage(params); 52 | return R.ok().put("data", page); 53 | } 54 | 55 | /** 56 | * 信息 57 | */ 58 | @RequestMapping("/info/{id}") 59 | public R info(@PathVariable("id") String id){ 60 | ConfigEntity config = configService.selectById(id); 61 | return R.ok().put("data", config); 62 | } 63 | 64 | /** 65 | * 详情 66 | */ 67 | @IgnoreAuth 68 | @RequestMapping("/detail/{id}") 69 | public R detail(@PathVariable("id") String id){ 70 | ConfigEntity config = configService.selectById(id); 71 | return R.ok().put("data", config); 72 | } 73 | 74 | /** 75 | * 根据name获取信息 76 | */ 77 | @RequestMapping("/info") 78 | public R infoByName(@RequestParam String name){ 79 | ConfigEntity config = configService.selectOne(new EntityWrapper().eq("name", "faceFile")); 80 | return R.ok().put("data", config); 81 | } 82 | 83 | /** 84 | * 保存 85 | */ 86 | @PostMapping("/save") 87 | public R save(@RequestBody ConfigEntity config){ 88 | // ValidatorUtils.validateEntity(config); 89 | configService.insert(config); 90 | return R.ok(); 91 | } 92 | 93 | /** 94 | * 修改 95 | */ 96 | @RequestMapping("/update") 97 | public R update(@RequestBody ConfigEntity config){ 98 | // ValidatorUtils.validateEntity(config); 99 | configService.updateById(config);//全部更新 100 | return R.ok(); 101 | } 102 | 103 | /** 104 | * 删除 105 | */ 106 | @RequestMapping("/delete") 107 | public R delete(@RequestBody Long[] ids){ 108 | configService.deleteBatchIds(Arrays.asList(ids)); 109 | return R.ok(); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/com/entity/StoreupEntity.java: -------------------------------------------------------------------------------- 1 | package com.entity; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableId; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.NotEmpty; 7 | import javax.validation.constraints.NotNull; 8 | 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import java.lang.reflect.InvocationTargetException; 11 | 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | import org.springframework.format.annotation.DateTimeFormat; 17 | import com.fasterxml.jackson.annotation.JsonFormat; 18 | import org.apache.commons.beanutils.BeanUtils; 19 | import com.baomidou.mybatisplus.annotations.TableField; 20 | import com.baomidou.mybatisplus.enums.FieldFill; 21 | import com.baomidou.mybatisplus.enums.IdType; 22 | 23 | 24 | /** 25 | * 收藏表 26 | * 数据库通用操作实体类(普通增删改查) 27 | * @author 28 | * @email 29 | * @date 2021-03-12 20:57:00 30 | */ 31 | @TableName("storeup") 32 | public class StoreupEntity implements Serializable { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | public StoreupEntity() { 37 | 38 | } 39 | 40 | public StoreupEntity(T t) { 41 | try { 42 | BeanUtils.copyProperties(this, t); 43 | } catch (IllegalAccessException | InvocationTargetException e) { 44 | // TODO Auto-generated catch block 45 | e.printStackTrace(); 46 | } 47 | } 48 | 49 | /** 50 | * 主键id 51 | */ 52 | @TableId 53 | private Long id; 54 | /** 55 | * 用户id 56 | */ 57 | 58 | private Long userid; 59 | 60 | /** 61 | * 收藏id 62 | */ 63 | 64 | private Long refid; 65 | 66 | /** 67 | * 表名 68 | */ 69 | 70 | private String tablename; 71 | 72 | /** 73 | * 收藏名称 74 | */ 75 | 76 | private String name; 77 | 78 | /** 79 | * 收藏图片 80 | */ 81 | 82 | private String picture; 83 | 84 | 85 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 86 | @DateTimeFormat 87 | private Date addtime; 88 | 89 | public Date getAddtime() { 90 | return addtime; 91 | } 92 | public void setAddtime(Date addtime) { 93 | this.addtime = addtime; 94 | } 95 | 96 | public Long getId() { 97 | return id; 98 | } 99 | 100 | public void setId(Long id) { 101 | this.id = id; 102 | } 103 | /** 104 | * 设置:用户id 105 | */ 106 | public void setUserid(Long userid) { 107 | this.userid = userid; 108 | } 109 | /** 110 | * 获取:用户id 111 | */ 112 | public Long getUserid() { 113 | return userid; 114 | } 115 | /** 116 | * 设置:收藏id 117 | */ 118 | public void setRefid(Long refid) { 119 | this.refid = refid; 120 | } 121 | /** 122 | * 获取:收藏id 123 | */ 124 | public Long getRefid() { 125 | return refid; 126 | } 127 | /** 128 | * 设置:表名 129 | */ 130 | public void setTablename(String tablename) { 131 | this.tablename = tablename; 132 | } 133 | /** 134 | * 获取:表名 135 | */ 136 | public String getTablename() { 137 | return tablename; 138 | } 139 | /** 140 | * 设置:收藏名称 141 | */ 142 | public void setName(String name) { 143 | this.name = name; 144 | } 145 | /** 146 | * 获取:收藏名称 147 | */ 148 | public String getName() { 149 | return name; 150 | } 151 | /** 152 | * 设置:收藏图片 153 | */ 154 | public void setPicture(String picture) { 155 | this.picture = picture; 156 | } 157 | /** 158 | * 获取:收藏图片 159 | */ 160 | public String getPicture() { 161 | return picture; 162 | } 163 | 164 | } 165 | -------------------------------------------------------------------------------- /src/main/java/com/entity/DiscussmeishijianshangEntity.java: -------------------------------------------------------------------------------- 1 | package com.entity; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableId; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.NotEmpty; 7 | import javax.validation.constraints.NotNull; 8 | 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import java.lang.reflect.InvocationTargetException; 11 | 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | import org.springframework.format.annotation.DateTimeFormat; 17 | import com.fasterxml.jackson.annotation.JsonFormat; 18 | import org.apache.commons.beanutils.BeanUtils; 19 | import com.baomidou.mybatisplus.annotations.TableField; 20 | import com.baomidou.mybatisplus.enums.FieldFill; 21 | import com.baomidou.mybatisplus.enums.IdType; 22 | 23 | 24 | /** 25 | * 美食鉴赏评论表 26 | * 数据库通用操作实体类(普通增删改查) 27 | * @author 28 | * @email 29 | * @date 2021-03-12 20:57:00 30 | */ 31 | @TableName("discussmeishijianshang") 32 | public class DiscussmeishijianshangEntity implements Serializable { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | public DiscussmeishijianshangEntity() { 37 | 38 | } 39 | 40 | public DiscussmeishijianshangEntity(T t) { 41 | try { 42 | BeanUtils.copyProperties(this, t); 43 | } catch (IllegalAccessException | InvocationTargetException e) { 44 | // TODO Auto-generated catch block 45 | e.printStackTrace(); 46 | } 47 | } 48 | 49 | /** 50 | * 主键id 51 | */ 52 | @TableId 53 | private Long id; 54 | /** 55 | * 关联表id 56 | */ 57 | 58 | private Long refid; 59 | 60 | /** 61 | * 用户id 62 | */ 63 | 64 | private Long userid; 65 | 66 | /** 67 | * 用户名 68 | */ 69 | 70 | private String nickname; 71 | 72 | /** 73 | * 评论内容 74 | */ 75 | 76 | private String content; 77 | 78 | /** 79 | * 回复内容 80 | */ 81 | 82 | private String reply; 83 | 84 | 85 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 86 | @DateTimeFormat 87 | private Date addtime; 88 | 89 | public Date getAddtime() { 90 | return addtime; 91 | } 92 | public void setAddtime(Date addtime) { 93 | this.addtime = addtime; 94 | } 95 | 96 | public Long getId() { 97 | return id; 98 | } 99 | 100 | public void setId(Long id) { 101 | this.id = id; 102 | } 103 | /** 104 | * 设置:关联表id 105 | */ 106 | public void setRefid(Long refid) { 107 | this.refid = refid; 108 | } 109 | /** 110 | * 获取:关联表id 111 | */ 112 | public Long getRefid() { 113 | return refid; 114 | } 115 | /** 116 | * 设置:用户id 117 | */ 118 | public void setUserid(Long userid) { 119 | this.userid = userid; 120 | } 121 | /** 122 | * 获取:用户id 123 | */ 124 | public Long getUserid() { 125 | return userid; 126 | } 127 | /** 128 | * 设置:用户名 129 | */ 130 | public void setNickname(String nickname) { 131 | this.nickname = nickname; 132 | } 133 | /** 134 | * 获取:用户名 135 | */ 136 | public String getNickname() { 137 | return nickname; 138 | } 139 | /** 140 | * 设置:评论内容 141 | */ 142 | public void setContent(String content) { 143 | this.content = content; 144 | } 145 | /** 146 | * 获取:评论内容 147 | */ 148 | public String getContent() { 149 | return content; 150 | } 151 | /** 152 | * 设置:回复内容 153 | */ 154 | public void setReply(String reply) { 155 | this.reply = reply; 156 | } 157 | /** 158 | * 获取:回复内容 159 | */ 160 | public String getReply() { 161 | return reply; 162 | } 163 | 164 | } 165 | -------------------------------------------------------------------------------- /src/main/java/com/interceptor/AuthorizationInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.interceptor; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import com.alibaba.fastjson.JSONObject; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Component; 14 | import org.springframework.web.method.HandlerMethod; 15 | import org.springframework.web.servlet.HandlerInterceptor; 16 | import org.springframework.web.bind.annotation.RequestMethod; 17 | import org.springframework.http.HttpStatus; 18 | 19 | import com.annotation.IgnoreAuth; 20 | import com.entity.EIException; 21 | import com.entity.TokenEntity; 22 | import com.service.TokenService; 23 | import com.utils.R; 24 | 25 | /** 26 | * 权限(Token)验证 27 | */ 28 | @Component 29 | public class AuthorizationInterceptor implements HandlerInterceptor { 30 | 31 | public static final String LOGIN_TOKEN_KEY = "Token"; 32 | 33 | @Autowired 34 | private TokenService tokenService; 35 | 36 | @Override 37 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 38 | 39 | //支持跨域请求 40 | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); 41 | response.setHeader("Access-Control-Max-Age", "3600"); 42 | response.setHeader("Access-Control-Allow-Credentials", "true"); 43 | response.setHeader("Access-Control-Allow-Headers", "x-requested-with,request-source,Token, Origin,imgType, Content-Type, cache-control,postman-token,Cookie, Accept,authorization"); 44 | response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin")); 45 | // 跨域时会首先发送一个OPTIONS请求,这里我们给OPTIONS请求直接返回正常状态 46 | if (request.getMethod().equals(RequestMethod.OPTIONS.name())) { 47 | response.setStatus(HttpStatus.OK.value()); 48 | return false; 49 | } 50 | 51 | IgnoreAuth annotation; 52 | if (handler instanceof HandlerMethod) { 53 | annotation = ((HandlerMethod) handler).getMethodAnnotation(IgnoreAuth.class); 54 | } else { 55 | return true; 56 | } 57 | 58 | //从header中获取token 59 | String token = request.getHeader(LOGIN_TOKEN_KEY); 60 | 61 | /** 62 | * 不需要验证权限的方法直接放过 63 | */ 64 | if(annotation!=null) { 65 | return true; 66 | } 67 | 68 | TokenEntity tokenEntity = null; 69 | if(StringUtils.isNotBlank(token)) { 70 | tokenEntity = tokenService.getTokenEntity(token); 71 | } 72 | 73 | if(tokenEntity != null) { 74 | request.getSession().setAttribute("userId", tokenEntity.getUserid()); 75 | request.getSession().setAttribute("role", tokenEntity.getRole()); 76 | request.getSession().setAttribute("tableName", tokenEntity.getTablename()); 77 | request.getSession().setAttribute("username", tokenEntity.getUsername()); 78 | return true; 79 | } 80 | 81 | PrintWriter writer = null; 82 | response.setCharacterEncoding("UTF-8"); 83 | response.setContentType("application/json; charset=utf-8"); 84 | try { 85 | writer = response.getWriter(); 86 | writer.print(JSONObject.toJSONString(R.error(401, "请先登录"))); 87 | } finally { 88 | if(writer != null){ 89 | writer.close(); 90 | } 91 | } 92 | // throw new EIException("请先登录", 401); 93 | return false; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/utils/BaiduUtil.java: -------------------------------------------------------------------------------- 1 | package com.utils; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.InputStreamReader; 5 | import java.net.HttpURLConnection; 6 | import java.net.URL; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | import org.json.JSONObject; 12 | 13 | 14 | /** 15 | * 类说明 : 16 | */ 17 | 18 | public class BaiduUtil { 19 | 20 | /** 21 | * 根据经纬度获得省市区信息 22 | * @param lon 纬度 23 | * @param lat 经度 24 | * @param coordtype 经纬度坐标系 25 | * @return 26 | */ 27 | public static Map getCityByLonLat(String key, String lng, String lat) { 28 | String location = lat + "," + lng; 29 | try { 30 | //拼装url 31 | String url = "http://api.map.baidu.com/reverse_geocoding/v3/?ak="+key+"&output=json&coordtype=wgs84ll&location="+location; 32 | String result = HttpClientUtils.doGet(url); 33 | JSONObject o = new JSONObject(result); 34 | Map area = new HashMap<>(); 35 | area.put("province", o.getJSONObject("result").getJSONObject("addressComponent").getString("province")); 36 | area.put("city", o.getJSONObject("result").getJSONObject("addressComponent").getString("city")); 37 | area.put("district", o.getJSONObject("result").getJSONObject("addressComponent").getString("district")); 38 | area.put("street", o.getJSONObject("result").getJSONObject("addressComponent").getString("street")); 39 | return area; 40 | }catch (Exception e) { 41 | e.printStackTrace(); 42 | } 43 | return null; 44 | } 45 | 46 | /** 47 | * 获取API访问token 48 | * 该token有一定的有效期,需要自行管理,当失效时需重新获取. 49 | * @param ak - 百度云官网获取的 API Key 50 | * @param sk - 百度云官网获取的 Securet Key 51 | * @return assess_token 52 | */ 53 | public static String getAuth(String ak, String sk) { 54 | // 获取token地址 55 | String authHost = "https://aip.baidubce.com/oauth/2.0/token?"; 56 | String getAccessTokenUrl = authHost 57 | // 1. grant_type为固定参数 58 | + "grant_type=client_credentials" 59 | // 2. 官网获取的 API Key 60 | + "&client_id=" + ak 61 | // 3. 官网获取的 Secret Key 62 | + "&client_secret=" + sk; 63 | try { 64 | URL realUrl = new URL(getAccessTokenUrl); 65 | // 打开和URL之间的连接 66 | HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection(); 67 | connection.setRequestMethod("GET"); 68 | connection.connect(); 69 | // 获取所有响应头字段 70 | Map> map = connection.getHeaderFields(); 71 | // 遍历所有的响应头字段 72 | for (String key : map.keySet()) { 73 | System.err.println(key + "--->" + map.get(key)); 74 | } 75 | // 定义 BufferedReader输入流来读取URL的响应 76 | BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); 77 | String result = ""; 78 | String line; 79 | while ((line = in.readLine()) != null) { 80 | result += line; 81 | } 82 | /** 83 | * 返回结果示例 84 | */ 85 | System.err.println("result:" + result); 86 | org.json.JSONObject jsonObject = new org.json.JSONObject(result); 87 | String access_token = jsonObject.getString("access_token"); 88 | return access_token; 89 | } catch (Exception e) { 90 | System.err.printf("获取token失败!"); 91 | e.printStackTrace(System.err); 92 | } 93 | return null; 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/controller/FileController.java: -------------------------------------------------------------------------------- 1 | package com.controller; 2 | 3 | import java.io.File; 4 | import java.io.FileNotFoundException; 5 | import java.io.IOException; 6 | import java.util.Arrays; 7 | import java.util.Date; 8 | import java.util.HashMap; 9 | import java.util.List; 10 | import java.util.Map; 11 | import java.util.Random; 12 | import java.util.UUID; 13 | 14 | import org.apache.commons.io.FileUtils; 15 | import org.apache.commons.lang3.StringUtils; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.http.HttpHeaders; 18 | import org.springframework.http.HttpStatus; 19 | import org.springframework.http.MediaType; 20 | import org.springframework.http.ResponseEntity; 21 | import org.springframework.util.ResourceUtils; 22 | import org.springframework.web.bind.annotation.PathVariable; 23 | import org.springframework.web.bind.annotation.RequestBody; 24 | import org.springframework.web.bind.annotation.RequestMapping; 25 | import org.springframework.web.bind.annotation.RequestParam; 26 | import org.springframework.web.bind.annotation.RestController; 27 | import org.springframework.web.multipart.MultipartFile; 28 | 29 | import com.annotation.IgnoreAuth; 30 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 31 | import com.entity.ConfigEntity; 32 | import com.entity.EIException; 33 | import com.service.ConfigService; 34 | import com.utils.R; 35 | 36 | /** 37 | * 上传文件映射表 38 | */ 39 | @RestController 40 | @RequestMapping("file") 41 | @SuppressWarnings({"unchecked","rawtypes"}) 42 | public class FileController{ 43 | @Autowired 44 | private ConfigService configService; 45 | /** 46 | * 上传文件 47 | */ 48 | @RequestMapping("/upload") 49 | public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception { 50 | if (file.isEmpty()) { 51 | throw new EIException("上传文件不能为空"); 52 | } 53 | String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1); 54 | File path = new File(ResourceUtils.getURL("classpath:static").getPath()); 55 | if(!path.exists()) { 56 | path = new File(""); 57 | } 58 | File upload = new File(path.getAbsolutePath(),"/upload/"); 59 | if(!upload.exists()) { 60 | upload.mkdirs(); 61 | } 62 | String fileName = new Date().getTime()+"."+fileExt; 63 | File dest = new File(upload.getAbsolutePath()+"/"+fileName); 64 | file.transferTo(dest); 65 | if(StringUtils.isNotBlank(type) && type.equals("1")) { 66 | ConfigEntity configEntity = configService.selectOne(new EntityWrapper().eq("name", "faceFile")); 67 | if(configEntity==null) { 68 | configEntity = new ConfigEntity(); 69 | configEntity.setName("faceFile"); 70 | configEntity.setValue(fileName); 71 | } else { 72 | configEntity.setValue(fileName); 73 | } 74 | configService.insertOrUpdate(configEntity); 75 | } 76 | return R.ok().put("file", fileName); 77 | } 78 | 79 | /** 80 | * 下载文件 81 | */ 82 | @IgnoreAuth 83 | @RequestMapping("/download") 84 | public ResponseEntity download(@RequestParam String fileName) { 85 | try { 86 | File path = new File(ResourceUtils.getURL("classpath:static").getPath()); 87 | if(!path.exists()) { 88 | path = new File(""); 89 | } 90 | File upload = new File(path.getAbsolutePath(),"/upload/"); 91 | if(!upload.exists()) { 92 | upload.mkdirs(); 93 | } 94 | File file = new File(upload.getAbsolutePath()+"/"+fileName); 95 | if(file.exists()){ 96 | /*if(!fileService.canRead(file, SessionManager.getSessionUser())){ 97 | getResponse().sendError(403); 98 | }*/ 99 | HttpHeaders headers = new HttpHeaders(); 100 | headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); 101 | headers.setContentDispositionFormData("attachment", fileName); 102 | return new ResponseEntity(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED); 103 | } 104 | } catch (IOException e) { 105 | e.printStackTrace(); 106 | } 107 | return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/com/entity/YonghuEntity.java: -------------------------------------------------------------------------------- 1 | package com.entity; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableId; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.NotEmpty; 7 | import javax.validation.constraints.NotNull; 8 | 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import java.lang.reflect.InvocationTargetException; 11 | 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | import org.springframework.format.annotation.DateTimeFormat; 17 | import com.fasterxml.jackson.annotation.JsonFormat; 18 | import org.apache.commons.beanutils.BeanUtils; 19 | import com.baomidou.mybatisplus.annotations.TableField; 20 | import com.baomidou.mybatisplus.enums.FieldFill; 21 | import com.baomidou.mybatisplus.enums.IdType; 22 | 23 | 24 | /** 25 | * 用户 26 | * 数据库通用操作实体类(普通增删改查) 27 | * @author 28 | * @email 29 | * @date 2021-03-12 20:57:00 30 | */ 31 | @TableName("yonghu") 32 | public class YonghuEntity implements Serializable { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | public YonghuEntity() { 37 | 38 | } 39 | 40 | public YonghuEntity(T t) { 41 | try { 42 | BeanUtils.copyProperties(this, t); 43 | } catch (IllegalAccessException | InvocationTargetException e) { 44 | // TODO Auto-generated catch block 45 | e.printStackTrace(); 46 | } 47 | } 48 | 49 | /** 50 | * 主键id 51 | */ 52 | @TableId 53 | private Long id; 54 | /** 55 | * 用户名 56 | */ 57 | 58 | private String yonghuming; 59 | 60 | /** 61 | * 密码 62 | */ 63 | 64 | private String mima; 65 | 66 | /** 67 | * 姓名 68 | */ 69 | 70 | private String xingming; 71 | 72 | /** 73 | * 手机 74 | */ 75 | 76 | private String shouji; 77 | 78 | /** 79 | * 邮箱 80 | */ 81 | 82 | private String youxiang; 83 | 84 | /** 85 | * 身份证 86 | */ 87 | 88 | private String shenfenzheng; 89 | 90 | /** 91 | * 照片 92 | */ 93 | 94 | private String zhaopian; 95 | 96 | 97 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 98 | @DateTimeFormat 99 | private Date addtime; 100 | 101 | public Date getAddtime() { 102 | return addtime; 103 | } 104 | public void setAddtime(Date addtime) { 105 | this.addtime = addtime; 106 | } 107 | 108 | public Long getId() { 109 | return id; 110 | } 111 | 112 | public void setId(Long id) { 113 | this.id = id; 114 | } 115 | /** 116 | * 设置:用户名 117 | */ 118 | public void setYonghuming(String yonghuming) { 119 | this.yonghuming = yonghuming; 120 | } 121 | /** 122 | * 获取:用户名 123 | */ 124 | public String getYonghuming() { 125 | return yonghuming; 126 | } 127 | /** 128 | * 设置:密码 129 | */ 130 | public void setMima(String mima) { 131 | this.mima = mima; 132 | } 133 | /** 134 | * 获取:密码 135 | */ 136 | public String getMima() { 137 | return mima; 138 | } 139 | /** 140 | * 设置:姓名 141 | */ 142 | public void setXingming(String xingming) { 143 | this.xingming = xingming; 144 | } 145 | /** 146 | * 获取:姓名 147 | */ 148 | public String getXingming() { 149 | return xingming; 150 | } 151 | /** 152 | * 设置:手机 153 | */ 154 | public void setShouji(String shouji) { 155 | this.shouji = shouji; 156 | } 157 | /** 158 | * 获取:手机 159 | */ 160 | public String getShouji() { 161 | return shouji; 162 | } 163 | /** 164 | * 设置:邮箱 165 | */ 166 | public void setYouxiang(String youxiang) { 167 | this.youxiang = youxiang; 168 | } 169 | /** 170 | * 获取:邮箱 171 | */ 172 | public String getYouxiang() { 173 | return youxiang; 174 | } 175 | /** 176 | * 设置:身份证 177 | */ 178 | public void setShenfenzheng(String shenfenzheng) { 179 | this.shenfenzheng = shenfenzheng; 180 | } 181 | /** 182 | * 获取:身份证 183 | */ 184 | public String getShenfenzheng() { 185 | return shenfenzheng; 186 | } 187 | /** 188 | * 设置:照片 189 | */ 190 | public void setZhaopian(String zhaopian) { 191 | this.zhaopian = zhaopian; 192 | } 193 | /** 194 | * 获取:照片 195 | */ 196 | public String getZhaopian() { 197 | return zhaopian; 198 | } 199 | 200 | } 201 | -------------------------------------------------------------------------------- /src/main/java/com/entity/DefaultuserEntity.java: -------------------------------------------------------------------------------- 1 | package com.entity; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableId; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.NotEmpty; 7 | import javax.validation.constraints.NotNull; 8 | 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import java.lang.reflect.InvocationTargetException; 11 | 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | import org.springframework.format.annotation.DateTimeFormat; 17 | import com.fasterxml.jackson.annotation.JsonFormat; 18 | import org.apache.commons.beanutils.BeanUtils; 19 | import com.baomidou.mybatisplus.annotations.TableField; 20 | import com.baomidou.mybatisplus.enums.FieldFill; 21 | import com.baomidou.mybatisplus.enums.IdType; 22 | 23 | 24 | /** 25 | * 注册用户 26 | * 数据库通用操作实体类(普通增删改查) 27 | * @author 28 | * @email 29 | * @date 2021-03-12 20:57:00 30 | */ 31 | @TableName("defaultuser") 32 | public class DefaultuserEntity implements Serializable { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | public DefaultuserEntity() { 37 | 38 | } 39 | 40 | public DefaultuserEntity(T t) { 41 | try { 42 | BeanUtils.copyProperties(this, t); 43 | } catch (IllegalAccessException | InvocationTargetException e) { 44 | // TODO Auto-generated catch block 45 | e.printStackTrace(); 46 | } 47 | } 48 | 49 | /** 50 | * 主键id 51 | */ 52 | @TableId 53 | private Long id; 54 | /** 55 | * 用户名 56 | */ 57 | 58 | private String username; 59 | 60 | /** 61 | * 密码 62 | */ 63 | 64 | private String mima; 65 | 66 | /** 67 | * 姓名 68 | */ 69 | 70 | private String name; 71 | 72 | /** 73 | * 性别 74 | */ 75 | 76 | private String sex; 77 | 78 | /** 79 | * 年龄 80 | */ 81 | 82 | private Integer age; 83 | 84 | /** 85 | * 电话 86 | */ 87 | 88 | private String phone; 89 | 90 | /** 91 | * 照片 92 | */ 93 | 94 | private String picture; 95 | 96 | /** 97 | * 邮箱 98 | */ 99 | 100 | private String email; 101 | 102 | 103 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 104 | @DateTimeFormat 105 | private Date addtime; 106 | 107 | public Date getAddtime() { 108 | return addtime; 109 | } 110 | public void setAddtime(Date addtime) { 111 | this.addtime = addtime; 112 | } 113 | 114 | public Long getId() { 115 | return id; 116 | } 117 | 118 | public void setId(Long id) { 119 | this.id = id; 120 | } 121 | /** 122 | * 设置:用户名 123 | */ 124 | public void setUsername(String username) { 125 | this.username = username; 126 | } 127 | /** 128 | * 获取:用户名 129 | */ 130 | public String getUsername() { 131 | return username; 132 | } 133 | /** 134 | * 设置:密码 135 | */ 136 | public void setMima(String mima) { 137 | this.mima = mima; 138 | } 139 | /** 140 | * 获取:密码 141 | */ 142 | public String getMima() { 143 | return mima; 144 | } 145 | /** 146 | * 设置:姓名 147 | */ 148 | public void setName(String name) { 149 | this.name = name; 150 | } 151 | /** 152 | * 获取:姓名 153 | */ 154 | public String getName() { 155 | return name; 156 | } 157 | /** 158 | * 设置:性别 159 | */ 160 | public void setSex(String sex) { 161 | this.sex = sex; 162 | } 163 | /** 164 | * 获取:性别 165 | */ 166 | public String getSex() { 167 | return sex; 168 | } 169 | /** 170 | * 设置:年龄 171 | */ 172 | public void setAge(Integer age) { 173 | this.age = age; 174 | } 175 | /** 176 | * 获取:年龄 177 | */ 178 | public Integer getAge() { 179 | return age; 180 | } 181 | /** 182 | * 设置:电话 183 | */ 184 | public void setPhone(String phone) { 185 | this.phone = phone; 186 | } 187 | /** 188 | * 获取:电话 189 | */ 190 | public String getPhone() { 191 | return phone; 192 | } 193 | /** 194 | * 设置:照片 195 | */ 196 | public void setPicture(String picture) { 197 | this.picture = picture; 198 | } 199 | /** 200 | * 获取:照片 201 | */ 202 | public String getPicture() { 203 | return picture; 204 | } 205 | /** 206 | * 设置:邮箱 207 | */ 208 | public void setEmail(String email) { 209 | this.email = email; 210 | } 211 | /** 212 | * 获取:邮箱 213 | */ 214 | public String getEmail() { 215 | return email; 216 | } 217 | 218 | } 219 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.2.RELEASE 9 | 10 | 11 | com.jlwl 12 | 13 | springboot35l3z 14 | 0.0.1-SNAPSHOT 15 | springboot-schema 16 | springboot学习框架 17 | 18 | 19 | 1.8 20 | 1.2.8 21 | 3.1.1 22 | 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-web 28 | 29 | 30 | org.mybatis.spring.boot 31 | mybatis-spring-boot-starter 32 | 2.1.1 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-jdbc 37 | 38 | 39 | 40 | mysql 41 | mysql-connector-java 42 | 43 | 44 | org.apache.shiro 45 | shiro-spring 46 | 1.3.2 47 | 48 | 49 | 50 | com.baomidou 51 | mybatis-plus 52 | 2.3 53 | 54 | 55 | com.baomidou 56 | mybatisplus-spring-boot-starter 57 | 1.0.5 58 | 59 | 60 | com.google.protobuf 61 | protobuf-java 62 | 3.10.0 63 | 64 | 65 | 66 | org.apache.commons 67 | commons-lang3 68 | 3.0 69 | 70 | 71 | 72 | javax.validation 73 | validation-api 74 | 2.0.1.Final 75 | 76 | 77 | 78 | commons-io 79 | commons-io 80 | 2.5 81 | 82 | 83 | 84 | 85 | cn.hutool 86 | hutool-all 87 | 4.0.12 88 | 89 | 90 | 91 | 92 | com.alibaba 93 | fastjson 94 | ${fastjson.version} 95 | 96 | 97 | com.microsoft.sqlserver 98 | sqljdbc4 99 | 4.0 100 | 4.0 101 | 102 | 103 | 104 | com.microsoft.sqlserver 105 | mssql-jdbc 106 | 6.2.0.jre8 107 | runtime 108 | 109 | 110 | 111 | com.baidu.aip 112 | java-sdk 113 | 4.4.1 114 | 115 | 116 | 117 | org.springframework.boot 118 | spring-boot-starter-test 119 | test 120 | 121 | 122 | org.junit.vintage 123 | junit-vintage-engine 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | org.springframework.boot 133 | spring-boot-maven-plugin 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /src/main/java/com/entity/vo/MeishijianshangVO.java: -------------------------------------------------------------------------------- 1 | package com.entity.vo; 2 | 3 | import com.entity.MeishijianshangEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import java.util.Date; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import com.fasterxml.jackson.annotation.JsonFormat; 10 | import java.io.Serializable; 11 | 12 | 13 | /** 14 | * 美食鉴赏 15 | * 手机端接口返回实体辅助类 16 | * (主要作用去除一些不必要的字段) 17 | * @author 18 | * @email 19 | * @date 2021-03-12 20:57:00 20 | */ 21 | public class MeishijianshangVO implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | 25 | /** 26 | * 美食名称 27 | */ 28 | 29 | private String meishimingcheng; 30 | 31 | /** 32 | * 美食类别 33 | */ 34 | 35 | private String meishileibie; 36 | 37 | /** 38 | * 美食介绍 39 | */ 40 | 41 | private String meishijieshao; 42 | 43 | /** 44 | * 商铺所在地 45 | */ 46 | 47 | private String shangpusuozaidi; 48 | 49 | /** 50 | * 推荐指数 51 | */ 52 | 53 | private String tuijianzhishu; 54 | 55 | /** 56 | * 美食照片 57 | */ 58 | 59 | private String meishizhaopian; 60 | 61 | /** 62 | * 商品价格 63 | */ 64 | 65 | private String shangpinjiage; 66 | 67 | /** 68 | * 用户名 69 | */ 70 | 71 | private String yonghuming; 72 | 73 | /** 74 | * 姓名 75 | */ 76 | 77 | private String xingming; 78 | 79 | /** 80 | * 赞 81 | */ 82 | 83 | private Integer thumbsupnum; 84 | 85 | /** 86 | * 踩 87 | */ 88 | 89 | private Integer crazilynum; 90 | 91 | /** 92 | * 最近点击时间 93 | */ 94 | 95 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 96 | @DateTimeFormat 97 | private Date clicktime; 98 | 99 | /** 100 | * 点击次数 101 | */ 102 | 103 | private Integer clicknum; 104 | 105 | 106 | /** 107 | * 设置:美食名称 108 | */ 109 | 110 | public void setMeishimingcheng(String meishimingcheng) { 111 | this.meishimingcheng = meishimingcheng; 112 | } 113 | 114 | /** 115 | * 获取:美食名称 116 | */ 117 | public String getMeishimingcheng() { 118 | return meishimingcheng; 119 | } 120 | 121 | 122 | /** 123 | * 设置:美食类别 124 | */ 125 | 126 | public void setMeishileibie(String meishileibie) { 127 | this.meishileibie = meishileibie; 128 | } 129 | 130 | /** 131 | * 获取:美食类别 132 | */ 133 | public String getMeishileibie() { 134 | return meishileibie; 135 | } 136 | 137 | 138 | /** 139 | * 设置:美食介绍 140 | */ 141 | 142 | public void setMeishijieshao(String meishijieshao) { 143 | this.meishijieshao = meishijieshao; 144 | } 145 | 146 | /** 147 | * 获取:美食介绍 148 | */ 149 | public String getMeishijieshao() { 150 | return meishijieshao; 151 | } 152 | 153 | 154 | /** 155 | * 设置:商铺所在地 156 | */ 157 | 158 | public void setShangpusuozaidi(String shangpusuozaidi) { 159 | this.shangpusuozaidi = shangpusuozaidi; 160 | } 161 | 162 | /** 163 | * 获取:商铺所在地 164 | */ 165 | public String getShangpusuozaidi() { 166 | return shangpusuozaidi; 167 | } 168 | 169 | 170 | /** 171 | * 设置:推荐指数 172 | */ 173 | 174 | public void setTuijianzhishu(String tuijianzhishu) { 175 | this.tuijianzhishu = tuijianzhishu; 176 | } 177 | 178 | /** 179 | * 获取:推荐指数 180 | */ 181 | public String getTuijianzhishu() { 182 | return tuijianzhishu; 183 | } 184 | 185 | 186 | /** 187 | * 设置:美食照片 188 | */ 189 | 190 | public void setMeishizhaopian(String meishizhaopian) { 191 | this.meishizhaopian = meishizhaopian; 192 | } 193 | 194 | /** 195 | * 获取:美食照片 196 | */ 197 | public String getMeishizhaopian() { 198 | return meishizhaopian; 199 | } 200 | 201 | 202 | /** 203 | * 设置:商品价格 204 | */ 205 | 206 | public void setShangpinjiage(String shangpinjiage) { 207 | this.shangpinjiage = shangpinjiage; 208 | } 209 | 210 | /** 211 | * 获取:商品价格 212 | */ 213 | public String getShangpinjiage() { 214 | return shangpinjiage; 215 | } 216 | 217 | 218 | /** 219 | * 设置:用户名 220 | */ 221 | 222 | public void setYonghuming(String yonghuming) { 223 | this.yonghuming = yonghuming; 224 | } 225 | 226 | /** 227 | * 获取:用户名 228 | */ 229 | public String getYonghuming() { 230 | return yonghuming; 231 | } 232 | 233 | 234 | /** 235 | * 设置:姓名 236 | */ 237 | 238 | public void setXingming(String xingming) { 239 | this.xingming = xingming; 240 | } 241 | 242 | /** 243 | * 获取:姓名 244 | */ 245 | public String getXingming() { 246 | return xingming; 247 | } 248 | 249 | 250 | /** 251 | * 设置:赞 252 | */ 253 | 254 | public void setThumbsupnum(Integer thumbsupnum) { 255 | this.thumbsupnum = thumbsupnum; 256 | } 257 | 258 | /** 259 | * 获取:赞 260 | */ 261 | public Integer getThumbsupnum() { 262 | return thumbsupnum; 263 | } 264 | 265 | 266 | /** 267 | * 设置:踩 268 | */ 269 | 270 | public void setCrazilynum(Integer crazilynum) { 271 | this.crazilynum = crazilynum; 272 | } 273 | 274 | /** 275 | * 获取:踩 276 | */ 277 | public Integer getCrazilynum() { 278 | return crazilynum; 279 | } 280 | 281 | 282 | /** 283 | * 设置:最近点击时间 284 | */ 285 | 286 | public void setClicktime(Date clicktime) { 287 | this.clicktime = clicktime; 288 | } 289 | 290 | /** 291 | * 获取:最近点击时间 292 | */ 293 | public Date getClicktime() { 294 | return clicktime; 295 | } 296 | 297 | 298 | /** 299 | * 设置:点击次数 300 | */ 301 | 302 | public void setClicknum(Integer clicknum) { 303 | this.clicknum = clicknum; 304 | } 305 | 306 | /** 307 | * 获取:点击次数 308 | */ 309 | public Integer getClicknum() { 310 | return clicknum; 311 | } 312 | 313 | } 314 | -------------------------------------------------------------------------------- /src/main/java/com/entity/model/MeishijianshangModel.java: -------------------------------------------------------------------------------- 1 | package com.entity.model; 2 | 3 | import com.entity.MeishijianshangEntity; 4 | 5 | import com.baomidou.mybatisplus.annotations.TableName; 6 | import java.util.Date; 7 | import org.springframework.format.annotation.DateTimeFormat; 8 | 9 | import com.fasterxml.jackson.annotation.JsonFormat; 10 | import java.io.Serializable; 11 | 12 | 13 | /** 14 | * 美食鉴赏 15 | * 接收传参的实体类 16 | *(实际开发中配合移动端接口开发手动去掉些没用的字段, 后端一般用entity就够用了) 17 | * 取自ModelAndView 的model名称 18 | * @author 19 | * @email 20 | * @date 2021-03-12 20:57:00 21 | */ 22 | public class MeishijianshangModel implements Serializable { 23 | private static final long serialVersionUID = 1L; 24 | 25 | 26 | /** 27 | * 美食名称 28 | */ 29 | 30 | private String meishimingcheng; 31 | 32 | /** 33 | * 美食类别 34 | */ 35 | 36 | private String meishileibie; 37 | 38 | /** 39 | * 美食介绍 40 | */ 41 | 42 | private String meishijieshao; 43 | 44 | /** 45 | * 商铺所在地 46 | */ 47 | 48 | private String shangpusuozaidi; 49 | 50 | /** 51 | * 推荐指数 52 | */ 53 | 54 | private String tuijianzhishu; 55 | 56 | /** 57 | * 美食照片 58 | */ 59 | 60 | private String meishizhaopian; 61 | 62 | /** 63 | * 商品价格 64 | */ 65 | 66 | private String shangpinjiage; 67 | 68 | /** 69 | * 用户名 70 | */ 71 | 72 | private String yonghuming; 73 | 74 | /** 75 | * 姓名 76 | */ 77 | 78 | private String xingming; 79 | 80 | /** 81 | * 赞 82 | */ 83 | 84 | private Integer thumbsupnum; 85 | 86 | /** 87 | * 踩 88 | */ 89 | 90 | private Integer crazilynum; 91 | 92 | /** 93 | * 最近点击时间 94 | */ 95 | 96 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 97 | @DateTimeFormat 98 | private Date clicktime; 99 | 100 | /** 101 | * 点击次数 102 | */ 103 | 104 | private Integer clicknum; 105 | 106 | 107 | /** 108 | * 设置:美食名称 109 | */ 110 | 111 | public void setMeishimingcheng(String meishimingcheng) { 112 | this.meishimingcheng = meishimingcheng; 113 | } 114 | 115 | /** 116 | * 获取:美食名称 117 | */ 118 | public String getMeishimingcheng() { 119 | return meishimingcheng; 120 | } 121 | 122 | 123 | /** 124 | * 设置:美食类别 125 | */ 126 | 127 | public void setMeishileibie(String meishileibie) { 128 | this.meishileibie = meishileibie; 129 | } 130 | 131 | /** 132 | * 获取:美食类别 133 | */ 134 | public String getMeishileibie() { 135 | return meishileibie; 136 | } 137 | 138 | 139 | /** 140 | * 设置:美食介绍 141 | */ 142 | 143 | public void setMeishijieshao(String meishijieshao) { 144 | this.meishijieshao = meishijieshao; 145 | } 146 | 147 | /** 148 | * 获取:美食介绍 149 | */ 150 | public String getMeishijieshao() { 151 | return meishijieshao; 152 | } 153 | 154 | 155 | /** 156 | * 设置:商铺所在地 157 | */ 158 | 159 | public void setShangpusuozaidi(String shangpusuozaidi) { 160 | this.shangpusuozaidi = shangpusuozaidi; 161 | } 162 | 163 | /** 164 | * 获取:商铺所在地 165 | */ 166 | public String getShangpusuozaidi() { 167 | return shangpusuozaidi; 168 | } 169 | 170 | 171 | /** 172 | * 设置:推荐指数 173 | */ 174 | 175 | public void setTuijianzhishu(String tuijianzhishu) { 176 | this.tuijianzhishu = tuijianzhishu; 177 | } 178 | 179 | /** 180 | * 获取:推荐指数 181 | */ 182 | public String getTuijianzhishu() { 183 | return tuijianzhishu; 184 | } 185 | 186 | 187 | /** 188 | * 设置:美食照片 189 | */ 190 | 191 | public void setMeishizhaopian(String meishizhaopian) { 192 | this.meishizhaopian = meishizhaopian; 193 | } 194 | 195 | /** 196 | * 获取:美食照片 197 | */ 198 | public String getMeishizhaopian() { 199 | return meishizhaopian; 200 | } 201 | 202 | 203 | /** 204 | * 设置:商品价格 205 | */ 206 | 207 | public void setShangpinjiage(String shangpinjiage) { 208 | this.shangpinjiage = shangpinjiage; 209 | } 210 | 211 | /** 212 | * 获取:商品价格 213 | */ 214 | public String getShangpinjiage() { 215 | return shangpinjiage; 216 | } 217 | 218 | 219 | /** 220 | * 设置:用户名 221 | */ 222 | 223 | public void setYonghuming(String yonghuming) { 224 | this.yonghuming = yonghuming; 225 | } 226 | 227 | /** 228 | * 获取:用户名 229 | */ 230 | public String getYonghuming() { 231 | return yonghuming; 232 | } 233 | 234 | 235 | /** 236 | * 设置:姓名 237 | */ 238 | 239 | public void setXingming(String xingming) { 240 | this.xingming = xingming; 241 | } 242 | 243 | /** 244 | * 获取:姓名 245 | */ 246 | public String getXingming() { 247 | return xingming; 248 | } 249 | 250 | 251 | /** 252 | * 设置:赞 253 | */ 254 | 255 | public void setThumbsupnum(Integer thumbsupnum) { 256 | this.thumbsupnum = thumbsupnum; 257 | } 258 | 259 | /** 260 | * 获取:赞 261 | */ 262 | public Integer getThumbsupnum() { 263 | return thumbsupnum; 264 | } 265 | 266 | 267 | /** 268 | * 设置:踩 269 | */ 270 | 271 | public void setCrazilynum(Integer crazilynum) { 272 | this.crazilynum = crazilynum; 273 | } 274 | 275 | /** 276 | * 获取:踩 277 | */ 278 | public Integer getCrazilynum() { 279 | return crazilynum; 280 | } 281 | 282 | 283 | /** 284 | * 设置:最近点击时间 285 | */ 286 | 287 | public void setClicktime(Date clicktime) { 288 | this.clicktime = clicktime; 289 | } 290 | 291 | /** 292 | * 获取:最近点击时间 293 | */ 294 | public Date getClicktime() { 295 | return clicktime; 296 | } 297 | 298 | 299 | /** 300 | * 设置:点击次数 301 | */ 302 | 303 | public void setClicknum(Integer clicknum) { 304 | this.clicknum = clicknum; 305 | } 306 | 307 | /** 308 | * 获取:点击次数 309 | */ 310 | public Integer getClicknum() { 311 | return clicknum; 312 | } 313 | 314 | } 315 | -------------------------------------------------------------------------------- /src/main/java/com/controller/UserController.java: -------------------------------------------------------------------------------- 1 | 2 | package com.controller; 3 | 4 | 5 | import java.util.Arrays; 6 | import java.util.Calendar; 7 | import java.util.Date; 8 | import java.util.Map; 9 | 10 | import javax.servlet.http.HttpServletRequest; 11 | 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.web.bind.annotation.GetMapping; 15 | import org.springframework.web.bind.annotation.PathVariable; 16 | import org.springframework.web.bind.annotation.PostMapping; 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.ResponseBody; 21 | import org.springframework.web.bind.annotation.RestController; 22 | 23 | import com.annotation.IgnoreAuth; 24 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 25 | import com.entity.TokenEntity; 26 | import com.entity.UserEntity; 27 | import com.service.TokenService; 28 | import com.service.UserService; 29 | import com.utils.CommonUtil; 30 | import com.utils.MPUtil; 31 | import com.utils.PageUtils; 32 | import com.utils.R; 33 | import com.utils.ValidatorUtils; 34 | 35 | /** 36 | * 登录相关 37 | */ 38 | @RequestMapping("users") 39 | @RestController 40 | public class UserController{ 41 | 42 | @Autowired 43 | private UserService userService; 44 | 45 | @Autowired 46 | private TokenService tokenService; 47 | 48 | /** 49 | * 登录 50 | */ 51 | @IgnoreAuth 52 | @PostMapping(value = "/login") 53 | public R login(String username, String password, String captcha, HttpServletRequest request) { 54 | UserEntity user = userService.selectOne(new EntityWrapper().eq("username", username)); 55 | if(user==null || !user.getPassword().equals(password)) { 56 | return R.error("账号或密码不正确"); 57 | } 58 | String token = tokenService.generateToken(user.getId(),username, "users", user.getRole()); 59 | return R.ok().put("token", token); 60 | } 61 | 62 | /** 63 | * 注册 64 | */ 65 | @IgnoreAuth 66 | @PostMapping(value = "/register") 67 | public R register(@RequestBody UserEntity user){ 68 | // ValidatorUtils.validateEntity(user); 69 | if(userService.selectOne(new EntityWrapper().eq("username", user.getUsername())) !=null) { 70 | return R.error("用户已存在"); 71 | } 72 | userService.insert(user); 73 | return R.ok(); 74 | } 75 | 76 | /** 77 | * 退出 78 | */ 79 | @GetMapping(value = "logout") 80 | public R logout(HttpServletRequest request) { 81 | request.getSession().invalidate(); 82 | return R.ok("退出成功"); 83 | } 84 | 85 | /** 86 | * 密码重置 87 | */ 88 | @IgnoreAuth 89 | @RequestMapping(value = "/resetPass") 90 | public R resetPass(String username, HttpServletRequest request){ 91 | UserEntity user = userService.selectOne(new EntityWrapper().eq("username", username)); 92 | if(user==null) { 93 | return R.error("账号不存在"); 94 | } 95 | user.setPassword("123456"); 96 | userService.update(user,null); 97 | return R.ok("密码已重置为:123456"); 98 | } 99 | 100 | /** 101 | * 列表 102 | */ 103 | @RequestMapping("/page") 104 | public R page(@RequestParam Map params,UserEntity user){ 105 | EntityWrapper ew = new EntityWrapper(); 106 | PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params)); 107 | return R.ok().put("data", page); 108 | } 109 | 110 | /** 111 | * 列表 112 | */ 113 | @RequestMapping("/list") 114 | public R list( UserEntity user){ 115 | EntityWrapper ew = new EntityWrapper(); 116 | ew.allEq(MPUtil.allEQMapPre( user, "user")); 117 | return R.ok().put("data", userService.selectListView(ew)); 118 | } 119 | 120 | /** 121 | * 信息 122 | */ 123 | @RequestMapping("/info/{id}") 124 | public R info(@PathVariable("id") String id){ 125 | UserEntity user = userService.selectById(id); 126 | return R.ok().put("data", user); 127 | } 128 | 129 | /** 130 | * 获取用户的session用户信息 131 | */ 132 | @RequestMapping("/session") 133 | public R getCurrUser(HttpServletRequest request){ 134 | Long id = (Long)request.getSession().getAttribute("userId"); 135 | UserEntity user = userService.selectById(id); 136 | return R.ok().put("data", user); 137 | } 138 | 139 | /** 140 | * 保存 141 | */ 142 | @PostMapping("/save") 143 | public R save(@RequestBody UserEntity user){ 144 | // ValidatorUtils.validateEntity(user); 145 | if(userService.selectOne(new EntityWrapper().eq("username", user.getUsername())) !=null) { 146 | return R.error("用户已存在"); 147 | } 148 | userService.insert(user); 149 | return R.ok(); 150 | } 151 | 152 | /** 153 | * 修改 154 | */ 155 | @RequestMapping("/update") 156 | public R update(@RequestBody UserEntity user){ 157 | // ValidatorUtils.validateEntity(user); 158 | UserEntity u = userService.selectOne(new EntityWrapper().eq("username", user.getUsername())); 159 | if(u!=null && u.getId()!=user.getId() && u.getUsername().equals(user.getUsername())) { 160 | return R.error("用户名已存在。"); 161 | } 162 | userService.updateById(user);//全部更新 163 | return R.ok(); 164 | } 165 | 166 | /** 167 | * 删除 168 | */ 169 | @RequestMapping("/delete") 170 | public R delete(@RequestBody Long[] ids){ 171 | userService.deleteBatchIds(Arrays.asList(ids)); 172 | return R.ok(); 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /src/main/java/com/utils/MPUtil.java: -------------------------------------------------------------------------------- 1 | package com.utils; 2 | 3 | import java.util.Arrays; 4 | import java.util.HashMap; 5 | import java.util.Iterator; 6 | import java.util.Map; 7 | 8 | import org.apache.commons.lang3.StringUtils; 9 | 10 | import cn.hutool.core.bean.BeanUtil; 11 | 12 | import com.baomidou.mybatisplus.mapper.Wrapper; 13 | 14 | /** 15 | * Mybatis-Plus工具类 16 | */ 17 | public class MPUtil { 18 | public static final char UNDERLINE = '_'; 19 | 20 | 21 | //mybatis plus allEQ 表达式转换 22 | public static Map allEQMapPre(Object bean,String pre) { 23 | Map map =BeanUtil.beanToMap(bean); 24 | return camelToUnderlineMap(map,pre); 25 | } 26 | 27 | //mybatis plus allEQ 表达式转换 28 | public static Map allEQMap(Object bean) { 29 | Map map =BeanUtil.beanToMap(bean); 30 | return camelToUnderlineMap(map,""); 31 | } 32 | 33 | public static Wrapper allLikePre(Wrapper wrapper,Object bean,String pre) { 34 | Map map =BeanUtil.beanToMap(bean); 35 | Map result = camelToUnderlineMap(map,pre); 36 | 37 | return genLike(wrapper,result); 38 | } 39 | 40 | public static Wrapper allLike(Wrapper wrapper,Object bean) { 41 | Map result = BeanUtil.beanToMap(bean, true, true); 42 | return genLike(wrapper,result); 43 | } 44 | 45 | 46 | public static Wrapper genLike( Wrapper wrapper,Map param) { 47 | Iterator> it = param.entrySet().iterator(); 48 | int i=0; 49 | while (it.hasNext()) { 50 | if(i>0) wrapper.and(); 51 | Map.Entry entry = it.next(); 52 | String key = entry.getKey(); 53 | String value = (String) entry.getValue(); 54 | wrapper.like(key, value); 55 | i++; 56 | } 57 | return wrapper; 58 | } 59 | 60 | public static Wrapper likeOrEq(Wrapper wrapper,Object bean) { 61 | Map result = BeanUtil.beanToMap(bean, true, true); 62 | return genLikeOrEq(wrapper,result); 63 | } 64 | 65 | public static Wrapper genLikeOrEq( Wrapper wrapper,Map param) { 66 | Iterator> it = param.entrySet().iterator(); 67 | int i=0; 68 | while (it.hasNext()) { 69 | if(i>0) wrapper.and(); 70 | Map.Entry entry = it.next(); 71 | String key = entry.getKey(); 72 | if(entry.getValue().toString().contains("%")) { 73 | wrapper.like(key, entry.getValue().toString().replace("%", "")); 74 | } else { 75 | wrapper.eq(key, entry.getValue()); 76 | } 77 | i++; 78 | } 79 | return wrapper; 80 | } 81 | 82 | public static Wrapper allEq(Wrapper wrapper,Object bean) { 83 | Map result = BeanUtil.beanToMap(bean, true, true); 84 | return genEq(wrapper,result); 85 | } 86 | 87 | 88 | public static Wrapper genEq( Wrapper wrapper,Map param) { 89 | Iterator> it = param.entrySet().iterator(); 90 | int i=0; 91 | while (it.hasNext()) { 92 | if(i>0) wrapper.and(); 93 | Map.Entry entry = it.next(); 94 | String key = entry.getKey(); 95 | wrapper.eq(key, entry.getValue()); 96 | i++; 97 | } 98 | return wrapper; 99 | } 100 | 101 | 102 | public static Wrapper between(Wrapper wrapper,Map params) { 103 | for(String key : params.keySet()) { 104 | String columnName = ""; 105 | if(key.endsWith("_start")) { 106 | columnName = key.substring(0, key.indexOf("_start")); 107 | if(StringUtils.isNotBlank(params.get(key).toString())) { 108 | wrapper.ge(columnName, params.get(key)); 109 | } 110 | } 111 | if(key.endsWith("_end")) { 112 | columnName = key.substring(0, key.indexOf("_end")); 113 | if(StringUtils.isNotBlank(params.get(key).toString())) { 114 | wrapper.le(columnName, params.get(key)); 115 | } 116 | } 117 | } 118 | return wrapper; 119 | } 120 | 121 | public static Wrapper sort(Wrapper wrapper,Map params) { 122 | String order = ""; 123 | if(params.get("order") != null && StringUtils.isNotBlank(params.get("order").toString())) { 124 | order = params.get("order").toString(); 125 | } 126 | if(params.get("sort") != null && StringUtils.isNotBlank(params.get("sort").toString())) { 127 | if(order.equalsIgnoreCase("desc")) { 128 | wrapper.orderDesc(Arrays.asList(params.get("sort"))); 129 | } else { 130 | wrapper.orderAsc(Arrays.asList(params.get("sort"))); 131 | } 132 | } 133 | return wrapper; 134 | } 135 | 136 | 137 | /** 138 | * 驼峰格式字符串转换为下划线格式字符串 139 | * 140 | * @param param 141 | * @return 142 | */ 143 | public static String camelToUnderline(String param) { 144 | if (param == null || "".equals(param.trim())) { 145 | return ""; 146 | } 147 | int len = param.length(); 148 | StringBuilder sb = new StringBuilder(len); 149 | for (int i = 0; i < len; i++) { 150 | char c = param.charAt(i); 151 | if (Character.isUpperCase(c)) { 152 | sb.append(UNDERLINE); 153 | sb.append(Character.toLowerCase(c)); 154 | } else { 155 | sb.append(c); 156 | } 157 | } 158 | return sb.toString(); 159 | } 160 | 161 | public static void main(String[] ages) { 162 | System.out.println(camelToUnderline("ABCddfANM")); 163 | } 164 | 165 | public static Map camelToUnderlineMap(Map param, String pre) { 166 | 167 | Map newMap = new HashMap(); 168 | Iterator> it = param.entrySet().iterator(); 169 | while (it.hasNext()) { 170 | Map.Entry entry = it.next(); 171 | String key = entry.getKey(); 172 | String newKey = camelToUnderline(key); 173 | if (pre.endsWith(".")) { 174 | newMap.put(pre + newKey, entry.getValue()); 175 | } else if (StringUtils.isEmpty(pre)) { 176 | newMap.put(newKey, entry.getValue()); 177 | } else { 178 | 179 | newMap.put(pre + "." + newKey, entry.getValue()); 180 | } 181 | } 182 | return newMap; 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /src/main/java/com/entity/MeishijianshangEntity.java: -------------------------------------------------------------------------------- 1 | package com.entity; 2 | 3 | import com.baomidou.mybatisplus.annotations.TableId; 4 | import com.baomidou.mybatisplus.annotations.TableName; 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.NotEmpty; 7 | import javax.validation.constraints.NotNull; 8 | 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import java.lang.reflect.InvocationTargetException; 11 | 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | import org.springframework.format.annotation.DateTimeFormat; 17 | import com.fasterxml.jackson.annotation.JsonFormat; 18 | import org.apache.commons.beanutils.BeanUtils; 19 | import com.baomidou.mybatisplus.annotations.TableField; 20 | import com.baomidou.mybatisplus.enums.FieldFill; 21 | import com.baomidou.mybatisplus.enums.IdType; 22 | 23 | 24 | /** 25 | * 美食鉴赏 26 | * 数据库通用操作实体类(普通增删改查) 27 | * @author 28 | * @email 29 | * @date 2021-03-12 20:57:00 30 | */ 31 | @TableName("meishijianshang") 32 | public class MeishijianshangEntity implements Serializable { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | public MeishijianshangEntity() { 37 | 38 | } 39 | 40 | public MeishijianshangEntity(T t) { 41 | try { 42 | BeanUtils.copyProperties(this, t); 43 | } catch (IllegalAccessException | InvocationTargetException e) { 44 | // TODO Auto-generated catch block 45 | e.printStackTrace(); 46 | } 47 | } 48 | 49 | /** 50 | * 主键id 51 | */ 52 | @TableId 53 | private Long id; 54 | /** 55 | * 发布时间 56 | */ 57 | 58 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd") 59 | @DateTimeFormat 60 | private Date fabushijian; 61 | 62 | /** 63 | * 美食名称 64 | */ 65 | 66 | private String meishimingcheng; 67 | 68 | /** 69 | * 美食类别 70 | */ 71 | 72 | private String meishileibie; 73 | 74 | /** 75 | * 美食介绍 76 | */ 77 | 78 | private String meishijieshao; 79 | 80 | /** 81 | * 商铺所在地 82 | */ 83 | 84 | private String shangpusuozaidi; 85 | 86 | /** 87 | * 推荐指数 88 | */ 89 | 90 | private String tuijianzhishu; 91 | 92 | /** 93 | * 美食照片 94 | */ 95 | 96 | private String meishizhaopian; 97 | 98 | /** 99 | * 商品价格 100 | */ 101 | 102 | private String shangpinjiage; 103 | 104 | /** 105 | * 用户名 106 | */ 107 | 108 | private String yonghuming; 109 | 110 | /** 111 | * 姓名 112 | */ 113 | 114 | private String xingming; 115 | 116 | /** 117 | * 赞 118 | */ 119 | 120 | private Integer thumbsupnum; 121 | 122 | /** 123 | * 踩 124 | */ 125 | 126 | private Integer crazilynum; 127 | 128 | /** 129 | * 最近点击时间 130 | */ 131 | 132 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 133 | @DateTimeFormat 134 | private Date clicktime; 135 | 136 | /** 137 | * 点击次数 138 | */ 139 | 140 | private Integer clicknum; 141 | 142 | 143 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 144 | @DateTimeFormat 145 | private Date addtime; 146 | 147 | public Date getAddtime() { 148 | return addtime; 149 | } 150 | public void setAddtime(Date addtime) { 151 | this.addtime = addtime; 152 | } 153 | 154 | public Long getId() { 155 | return id; 156 | } 157 | 158 | public void setId(Long id) { 159 | this.id = id; 160 | } 161 | /** 162 | * 设置:发布时间 163 | */ 164 | public void setFabushijian(Date fabushijian) { 165 | this.fabushijian = fabushijian; 166 | } 167 | /** 168 | * 获取:发布时间 169 | */ 170 | public Date getFabushijian() { 171 | return fabushijian; 172 | } 173 | /** 174 | * 设置:美食名称 175 | */ 176 | public void setMeishimingcheng(String meishimingcheng) { 177 | this.meishimingcheng = meishimingcheng; 178 | } 179 | /** 180 | * 获取:美食名称 181 | */ 182 | public String getMeishimingcheng() { 183 | return meishimingcheng; 184 | } 185 | /** 186 | * 设置:美食类别 187 | */ 188 | public void setMeishileibie(String meishileibie) { 189 | this.meishileibie = meishileibie; 190 | } 191 | /** 192 | * 获取:美食类别 193 | */ 194 | public String getMeishileibie() { 195 | return meishileibie; 196 | } 197 | /** 198 | * 设置:美食介绍 199 | */ 200 | public void setMeishijieshao(String meishijieshao) { 201 | this.meishijieshao = meishijieshao; 202 | } 203 | /** 204 | * 获取:美食介绍 205 | */ 206 | public String getMeishijieshao() { 207 | return meishijieshao; 208 | } 209 | /** 210 | * 设置:商铺所在地 211 | */ 212 | public void setShangpusuozaidi(String shangpusuozaidi) { 213 | this.shangpusuozaidi = shangpusuozaidi; 214 | } 215 | /** 216 | * 获取:商铺所在地 217 | */ 218 | public String getShangpusuozaidi() { 219 | return shangpusuozaidi; 220 | } 221 | /** 222 | * 设置:推荐指数 223 | */ 224 | public void setTuijianzhishu(String tuijianzhishu) { 225 | this.tuijianzhishu = tuijianzhishu; 226 | } 227 | /** 228 | * 获取:推荐指数 229 | */ 230 | public String getTuijianzhishu() { 231 | return tuijianzhishu; 232 | } 233 | /** 234 | * 设置:美食照片 235 | */ 236 | public void setMeishizhaopian(String meishizhaopian) { 237 | this.meishizhaopian = meishizhaopian; 238 | } 239 | /** 240 | * 获取:美食照片 241 | */ 242 | public String getMeishizhaopian() { 243 | return meishizhaopian; 244 | } 245 | /** 246 | * 设置:商品价格 247 | */ 248 | public void setShangpinjiage(String shangpinjiage) { 249 | this.shangpinjiage = shangpinjiage; 250 | } 251 | /** 252 | * 获取:商品价格 253 | */ 254 | public String getShangpinjiage() { 255 | return shangpinjiage; 256 | } 257 | /** 258 | * 设置:用户名 259 | */ 260 | public void setYonghuming(String yonghuming) { 261 | this.yonghuming = yonghuming; 262 | } 263 | /** 264 | * 获取:用户名 265 | */ 266 | public String getYonghuming() { 267 | return yonghuming; 268 | } 269 | /** 270 | * 设置:姓名 271 | */ 272 | public void setXingming(String xingming) { 273 | this.xingming = xingming; 274 | } 275 | /** 276 | * 获取:姓名 277 | */ 278 | public String getXingming() { 279 | return xingming; 280 | } 281 | /** 282 | * 设置:赞 283 | */ 284 | public void setThumbsupnum(Integer thumbsupnum) { 285 | this.thumbsupnum = thumbsupnum; 286 | } 287 | /** 288 | * 获取:赞 289 | */ 290 | public Integer getThumbsupnum() { 291 | return thumbsupnum; 292 | } 293 | /** 294 | * 设置:踩 295 | */ 296 | public void setCrazilynum(Integer crazilynum) { 297 | this.crazilynum = crazilynum; 298 | } 299 | /** 300 | * 获取:踩 301 | */ 302 | public Integer getCrazilynum() { 303 | return crazilynum; 304 | } 305 | /** 306 | * 设置:最近点击时间 307 | */ 308 | public void setClicktime(Date clicktime) { 309 | this.clicktime = clicktime; 310 | } 311 | /** 312 | * 获取:最近点击时间 313 | */ 314 | public Date getClicktime() { 315 | return clicktime; 316 | } 317 | /** 318 | * 设置:点击次数 319 | */ 320 | public void setClicknum(Integer clicknum) { 321 | this.clicknum = clicknum; 322 | } 323 | /** 324 | * 获取:点击次数 325 | */ 326 | public Integer getClicknum() { 327 | return clicknum; 328 | } 329 | 330 | } 331 | -------------------------------------------------------------------------------- /src/main/java/com/controller/StoreupController.java: -------------------------------------------------------------------------------- 1 | package com.controller; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.ArrayList; 5 | import java.util.Arrays; 6 | import java.util.Calendar; 7 | import java.util.Map; 8 | import java.util.HashMap; 9 | import java.util.Iterator; 10 | import java.util.Date; 11 | import java.util.List; 12 | import javax.servlet.http.HttpServletRequest; 13 | 14 | import com.utils.ValidatorUtils; 15 | import org.apache.commons.lang3.StringUtils; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.format.annotation.DateTimeFormat; 18 | import org.springframework.web.bind.annotation.PathVariable; 19 | import org.springframework.web.bind.annotation.RequestBody; 20 | import org.springframework.web.bind.annotation.RequestMapping; 21 | import org.springframework.web.bind.annotation.RequestParam; 22 | import org.springframework.web.bind.annotation.RestController; 23 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 24 | import com.baomidou.mybatisplus.mapper.Wrapper; 25 | import com.annotation.IgnoreAuth; 26 | 27 | import com.entity.StoreupEntity; 28 | import com.entity.view.StoreupView; 29 | 30 | import com.service.StoreupService; 31 | import com.service.TokenService; 32 | import com.utils.PageUtils; 33 | import com.utils.R; 34 | import com.utils.MD5Util; 35 | import com.utils.MPUtil; 36 | import com.utils.CommonUtil; 37 | 38 | 39 | /** 40 | * 收藏表 41 | * 后端接口 42 | * @author 43 | * @email 44 | * @date 2021-03-12 20:57:00 45 | */ 46 | @RestController 47 | @RequestMapping("/storeup") 48 | public class StoreupController { 49 | @Autowired 50 | private StoreupService storeupService; 51 | 52 | 53 | 54 | /** 55 | * 后端列表 56 | */ 57 | @RequestMapping("/page") 58 | public R page(@RequestParam Map params,StoreupEntity storeup, 59 | HttpServletRequest request){ 60 | if(!request.getSession().getAttribute("role").toString().equals("管理员")) { 61 | storeup.setUserid((Long)request.getSession().getAttribute("userId")); 62 | } 63 | EntityWrapper ew = new EntityWrapper(); 64 | PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params)); 65 | 66 | return R.ok().put("data", page); 67 | } 68 | 69 | /** 70 | * 前端列表 71 | */ 72 | @RequestMapping("/list") 73 | public R list(@RequestParam Map params,StoreupEntity storeup, HttpServletRequest request){ 74 | if(!request.getSession().getAttribute("role").toString().equals("管理员")) { 75 | storeup.setUserid((Long)request.getSession().getAttribute("userId")); 76 | } 77 | EntityWrapper ew = new EntityWrapper(); 78 | PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params)); 79 | return R.ok().put("data", page); 80 | } 81 | 82 | /** 83 | * 列表 84 | */ 85 | @RequestMapping("/lists") 86 | public R list( StoreupEntity storeup){ 87 | EntityWrapper ew = new EntityWrapper(); 88 | ew.allEq(MPUtil.allEQMapPre( storeup, "storeup")); 89 | return R.ok().put("data", storeupService.selectListView(ew)); 90 | } 91 | 92 | /** 93 | * 查询 94 | */ 95 | @RequestMapping("/query") 96 | public R query(StoreupEntity storeup){ 97 | EntityWrapper< StoreupEntity> ew = new EntityWrapper< StoreupEntity>(); 98 | ew.allEq(MPUtil.allEQMapPre( storeup, "storeup")); 99 | StoreupView storeupView = storeupService.selectView(ew); 100 | return R.ok("查询收藏表成功").put("data", storeupView); 101 | } 102 | 103 | /** 104 | * 后端详情 105 | */ 106 | @RequestMapping("/info/{id}") 107 | public R info(@PathVariable("id") Long id){ 108 | StoreupEntity storeup = storeupService.selectById(id); 109 | return R.ok().put("data", storeup); 110 | } 111 | 112 | /** 113 | * 前端详情 114 | */ 115 | @RequestMapping("/detail/{id}") 116 | public R detail(@PathVariable("id") Long id){ 117 | StoreupEntity storeup = storeupService.selectById(id); 118 | return R.ok().put("data", storeup); 119 | } 120 | 121 | 122 | 123 | 124 | /** 125 | * 后端保存 126 | */ 127 | @RequestMapping("/save") 128 | public R save(@RequestBody StoreupEntity storeup, HttpServletRequest request){ 129 | storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 130 | //ValidatorUtils.validateEntity(storeup); 131 | storeup.setUserid((Long)request.getSession().getAttribute("userId")); 132 | storeupService.insert(storeup); 133 | return R.ok(); 134 | } 135 | 136 | /** 137 | * 前端保存 138 | */ 139 | @RequestMapping("/add") 140 | public R add(@RequestBody StoreupEntity storeup, HttpServletRequest request){ 141 | storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 142 | //ValidatorUtils.validateEntity(storeup); 143 | storeup.setUserid((Long)request.getSession().getAttribute("userId")); 144 | storeupService.insert(storeup); 145 | return R.ok(); 146 | } 147 | 148 | /** 149 | * 修改 150 | */ 151 | @RequestMapping("/update") 152 | public R update(@RequestBody StoreupEntity storeup, HttpServletRequest request){ 153 | //ValidatorUtils.validateEntity(storeup); 154 | storeupService.updateById(storeup);//全部更新 155 | return R.ok(); 156 | } 157 | 158 | 159 | /** 160 | * 删除 161 | */ 162 | @RequestMapping("/delete") 163 | public R delete(@RequestBody Long[] ids){ 164 | storeupService.deleteBatchIds(Arrays.asList(ids)); 165 | return R.ok(); 166 | } 167 | 168 | /** 169 | * 提醒接口 170 | */ 171 | @RequestMapping("/remind/{columnName}/{type}") 172 | public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 173 | @PathVariable("type") String type,@RequestParam Map map) { 174 | map.put("column", columnName); 175 | map.put("type", type); 176 | 177 | if(type.equals("2")) { 178 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 179 | Calendar c = Calendar.getInstance(); 180 | Date remindStartDate = null; 181 | Date remindEndDate = null; 182 | if(map.get("remindstart")!=null) { 183 | Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); 184 | c.setTime(new Date()); 185 | c.add(Calendar.DAY_OF_MONTH,remindStart); 186 | remindStartDate = c.getTime(); 187 | map.put("remindstart", sdf.format(remindStartDate)); 188 | } 189 | if(map.get("remindend")!=null) { 190 | Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); 191 | c.setTime(new Date()); 192 | c.add(Calendar.DAY_OF_MONTH,remindEnd); 193 | remindEndDate = c.getTime(); 194 | map.put("remindend", sdf.format(remindEndDate)); 195 | } 196 | } 197 | 198 | Wrapper wrapper = new EntityWrapper(); 199 | if(map.get("remindstart")!=null) { 200 | wrapper.ge(columnName, map.get("remindstart")); 201 | } 202 | if(map.get("remindend")!=null) { 203 | wrapper.le(columnName, map.get("remindend")); 204 | } 205 | if(!request.getSession().getAttribute("role").toString().equals("管理员")) { 206 | wrapper.eq("userid", (Long)request.getSession().getAttribute("userId")); 207 | } 208 | 209 | 210 | int count = storeupService.selectCount(wrapper); 211 | return R.ok().put("count", count); 212 | } 213 | 214 | 215 | 216 | } 217 | -------------------------------------------------------------------------------- /src/main/java/com/controller/DiscussmeishijianshangController.java: -------------------------------------------------------------------------------- 1 | package com.controller; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.ArrayList; 5 | import java.util.Arrays; 6 | import java.util.Calendar; 7 | import java.util.Map; 8 | import java.util.HashMap; 9 | import java.util.Iterator; 10 | import java.util.Date; 11 | import java.util.List; 12 | import javax.servlet.http.HttpServletRequest; 13 | 14 | import com.utils.ValidatorUtils; 15 | import org.apache.commons.lang3.StringUtils; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.format.annotation.DateTimeFormat; 18 | import org.springframework.web.bind.annotation.PathVariable; 19 | import org.springframework.web.bind.annotation.RequestBody; 20 | import org.springframework.web.bind.annotation.RequestMapping; 21 | import org.springframework.web.bind.annotation.RequestParam; 22 | import org.springframework.web.bind.annotation.RestController; 23 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 24 | import com.baomidou.mybatisplus.mapper.Wrapper; 25 | import com.annotation.IgnoreAuth; 26 | 27 | import com.entity.DiscussmeishijianshangEntity; 28 | import com.entity.view.DiscussmeishijianshangView; 29 | 30 | import com.service.DiscussmeishijianshangService; 31 | import com.service.TokenService; 32 | import com.utils.PageUtils; 33 | import com.utils.R; 34 | import com.utils.MD5Util; 35 | import com.utils.MPUtil; 36 | import com.utils.CommonUtil; 37 | 38 | 39 | /** 40 | * 美食鉴赏评论表 41 | * 后端接口 42 | * @author 43 | * @email 44 | * @date 2021-03-12 20:57:00 45 | */ 46 | @RestController 47 | @RequestMapping("/discussmeishijianshang") 48 | public class DiscussmeishijianshangController { 49 | @Autowired 50 | private DiscussmeishijianshangService discussmeishijianshangService; 51 | 52 | 53 | 54 | /** 55 | * 后端列表 56 | */ 57 | @RequestMapping("/page") 58 | public R page(@RequestParam Map params,DiscussmeishijianshangEntity discussmeishijianshang, 59 | HttpServletRequest request){ 60 | EntityWrapper ew = new EntityWrapper(); 61 | PageUtils page = discussmeishijianshangService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discussmeishijianshang), params), params)); 62 | 63 | return R.ok().put("data", page); 64 | } 65 | 66 | /** 67 | * 前端列表 68 | */ 69 | @IgnoreAuth 70 | @RequestMapping("/list") 71 | public R list(@RequestParam Map params,DiscussmeishijianshangEntity discussmeishijianshang, HttpServletRequest request){ 72 | EntityWrapper ew = new EntityWrapper(); 73 | PageUtils page = discussmeishijianshangService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discussmeishijianshang), params), params)); 74 | return R.ok().put("data", page); 75 | } 76 | 77 | /** 78 | * 列表 79 | */ 80 | @RequestMapping("/lists") 81 | public R list( DiscussmeishijianshangEntity discussmeishijianshang){ 82 | EntityWrapper ew = new EntityWrapper(); 83 | ew.allEq(MPUtil.allEQMapPre( discussmeishijianshang, "discussmeishijianshang")); 84 | return R.ok().put("data", discussmeishijianshangService.selectListView(ew)); 85 | } 86 | 87 | /** 88 | * 查询 89 | */ 90 | @RequestMapping("/query") 91 | public R query(DiscussmeishijianshangEntity discussmeishijianshang){ 92 | EntityWrapper< DiscussmeishijianshangEntity> ew = new EntityWrapper< DiscussmeishijianshangEntity>(); 93 | ew.allEq(MPUtil.allEQMapPre( discussmeishijianshang, "discussmeishijianshang")); 94 | DiscussmeishijianshangView discussmeishijianshangView = discussmeishijianshangService.selectView(ew); 95 | return R.ok("查询美食鉴赏评论表成功").put("data", discussmeishijianshangView); 96 | } 97 | 98 | /** 99 | * 后端详情 100 | */ 101 | @RequestMapping("/info/{id}") 102 | public R info(@PathVariable("id") Long id){ 103 | DiscussmeishijianshangEntity discussmeishijianshang = discussmeishijianshangService.selectById(id); 104 | return R.ok().put("data", discussmeishijianshang); 105 | } 106 | 107 | /** 108 | * 前端详情 109 | */ 110 | @RequestMapping("/detail/{id}") 111 | public R detail(@PathVariable("id") Long id){ 112 | DiscussmeishijianshangEntity discussmeishijianshang = discussmeishijianshangService.selectById(id); 113 | return R.ok().put("data", discussmeishijianshang); 114 | } 115 | 116 | 117 | 118 | 119 | /** 120 | * 后端保存 121 | */ 122 | @RequestMapping("/save") 123 | public R save(@RequestBody DiscussmeishijianshangEntity discussmeishijianshang, HttpServletRequest request){ 124 | discussmeishijianshang.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 125 | //ValidatorUtils.validateEntity(discussmeishijianshang); 126 | discussmeishijianshangService.insert(discussmeishijianshang); 127 | return R.ok(); 128 | } 129 | 130 | /** 131 | * 前端保存 132 | */ 133 | @RequestMapping("/add") 134 | public R add(@RequestBody DiscussmeishijianshangEntity discussmeishijianshang, HttpServletRequest request){ 135 | discussmeishijianshang.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 136 | //ValidatorUtils.validateEntity(discussmeishijianshang); 137 | discussmeishijianshangService.insert(discussmeishijianshang); 138 | return R.ok(); 139 | } 140 | 141 | /** 142 | * 修改 143 | */ 144 | @RequestMapping("/update") 145 | public R update(@RequestBody DiscussmeishijianshangEntity discussmeishijianshang, HttpServletRequest request){ 146 | //ValidatorUtils.validateEntity(discussmeishijianshang); 147 | discussmeishijianshangService.updateById(discussmeishijianshang);//全部更新 148 | return R.ok(); 149 | } 150 | 151 | 152 | /** 153 | * 删除 154 | */ 155 | @RequestMapping("/delete") 156 | public R delete(@RequestBody Long[] ids){ 157 | discussmeishijianshangService.deleteBatchIds(Arrays.asList(ids)); 158 | return R.ok(); 159 | } 160 | 161 | /** 162 | * 提醒接口 163 | */ 164 | @RequestMapping("/remind/{columnName}/{type}") 165 | public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 166 | @PathVariable("type") String type,@RequestParam Map map) { 167 | map.put("column", columnName); 168 | map.put("type", type); 169 | 170 | if(type.equals("2")) { 171 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 172 | Calendar c = Calendar.getInstance(); 173 | Date remindStartDate = null; 174 | Date remindEndDate = null; 175 | if(map.get("remindstart")!=null) { 176 | Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); 177 | c.setTime(new Date()); 178 | c.add(Calendar.DAY_OF_MONTH,remindStart); 179 | remindStartDate = c.getTime(); 180 | map.put("remindstart", sdf.format(remindStartDate)); 181 | } 182 | if(map.get("remindend")!=null) { 183 | Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); 184 | c.setTime(new Date()); 185 | c.add(Calendar.DAY_OF_MONTH,remindEnd); 186 | remindEndDate = c.getTime(); 187 | map.put("remindend", sdf.format(remindEndDate)); 188 | } 189 | } 190 | 191 | Wrapper wrapper = new EntityWrapper(); 192 | if(map.get("remindstart")!=null) { 193 | wrapper.ge(columnName, map.get("remindstart")); 194 | } 195 | if(map.get("remindend")!=null) { 196 | wrapper.le(columnName, map.get("remindend")); 197 | } 198 | 199 | 200 | int count = discussmeishijianshangService.selectCount(wrapper); 201 | return R.ok().put("count", count); 202 | } 203 | 204 | 205 | 206 | } 207 | -------------------------------------------------------------------------------- /src/main/java/com/controller/WodehaoyouController.java: -------------------------------------------------------------------------------- 1 | package com.controller; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.ArrayList; 5 | import java.util.Arrays; 6 | import java.util.Calendar; 7 | import java.util.Map; 8 | import java.util.HashMap; 9 | import java.util.Iterator; 10 | import java.util.Date; 11 | import java.util.List; 12 | import javax.servlet.http.HttpServletRequest; 13 | 14 | import com.utils.ValidatorUtils; 15 | import org.apache.commons.lang3.StringUtils; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.format.annotation.DateTimeFormat; 18 | import org.springframework.web.bind.annotation.PathVariable; 19 | import org.springframework.web.bind.annotation.RequestBody; 20 | import org.springframework.web.bind.annotation.RequestMapping; 21 | import org.springframework.web.bind.annotation.RequestParam; 22 | import org.springframework.web.bind.annotation.RestController; 23 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 24 | import com.baomidou.mybatisplus.mapper.Wrapper; 25 | import com.annotation.IgnoreAuth; 26 | 27 | import com.entity.WodehaoyouEntity; 28 | import com.entity.view.WodehaoyouView; 29 | 30 | import com.service.WodehaoyouService; 31 | import com.service.TokenService; 32 | import com.utils.PageUtils; 33 | import com.utils.R; 34 | import com.utils.MD5Util; 35 | import com.utils.MPUtil; 36 | import com.utils.CommonUtil; 37 | 38 | 39 | /** 40 | * 我的好友 41 | * 后端接口 42 | * @author 43 | * @email 44 | * @date 2021-03-12 20:57:00 45 | */ 46 | @RestController 47 | @RequestMapping("/wodehaoyou") 48 | public class WodehaoyouController { 49 | @Autowired 50 | private WodehaoyouService wodehaoyouService; 51 | 52 | 53 | 54 | /** 55 | * 后端列表 56 | */ 57 | @RequestMapping("/page") 58 | public R page(@RequestParam Map params,WodehaoyouEntity wodehaoyou, 59 | @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date tianjiashijianstart, 60 | @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date tianjiashijianend, 61 | HttpServletRequest request){ 62 | if(!request.getSession().getAttribute("role").toString().equals("管理员")) { 63 | wodehaoyou.setUserid((Long)request.getSession().getAttribute("userId")); 64 | } 65 | EntityWrapper ew = new EntityWrapper(); 66 | if(tianjiashijianstart!=null) ew.ge("tianjiashijian", tianjiashijianstart); 67 | if(tianjiashijianend!=null) ew.le("tianjiashijian", tianjiashijianend); 68 | PageUtils page = wodehaoyouService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wodehaoyou), params), params)); 69 | 70 | return R.ok().put("data", page); 71 | } 72 | 73 | /** 74 | * 前端列表 75 | */ 76 | @RequestMapping("/list") 77 | public R list(@RequestParam Map params,WodehaoyouEntity wodehaoyou, HttpServletRequest request){ 78 | EntityWrapper ew = new EntityWrapper(); 79 | PageUtils page = wodehaoyouService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wodehaoyou), params), params)); 80 | return R.ok().put("data", page); 81 | } 82 | 83 | /** 84 | * 列表 85 | */ 86 | @RequestMapping("/lists") 87 | public R list( WodehaoyouEntity wodehaoyou){ 88 | EntityWrapper ew = new EntityWrapper(); 89 | ew.allEq(MPUtil.allEQMapPre( wodehaoyou, "wodehaoyou")); 90 | return R.ok().put("data", wodehaoyouService.selectListView(ew)); 91 | } 92 | 93 | /** 94 | * 查询 95 | */ 96 | @RequestMapping("/query") 97 | public R query(WodehaoyouEntity wodehaoyou){ 98 | EntityWrapper< WodehaoyouEntity> ew = new EntityWrapper< WodehaoyouEntity>(); 99 | ew.allEq(MPUtil.allEQMapPre( wodehaoyou, "wodehaoyou")); 100 | WodehaoyouView wodehaoyouView = wodehaoyouService.selectView(ew); 101 | return R.ok("查询我的好友成功").put("data", wodehaoyouView); 102 | } 103 | 104 | /** 105 | * 后端详情 106 | */ 107 | @RequestMapping("/info/{id}") 108 | public R info(@PathVariable("id") Long id){ 109 | WodehaoyouEntity wodehaoyou = wodehaoyouService.selectById(id); 110 | return R.ok().put("data", wodehaoyou); 111 | } 112 | 113 | /** 114 | * 前端详情 115 | */ 116 | @RequestMapping("/detail/{id}") 117 | public R detail(@PathVariable("id") Long id){ 118 | WodehaoyouEntity wodehaoyou = wodehaoyouService.selectById(id); 119 | return R.ok().put("data", wodehaoyou); 120 | } 121 | 122 | 123 | 124 | 125 | /** 126 | * 后端保存 127 | */ 128 | @RequestMapping("/save") 129 | public R save(@RequestBody WodehaoyouEntity wodehaoyou, HttpServletRequest request){ 130 | wodehaoyou.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 131 | //ValidatorUtils.validateEntity(wodehaoyou); 132 | wodehaoyou.setUserid((Long)request.getSession().getAttribute("userId")); 133 | wodehaoyouService.insert(wodehaoyou); 134 | return R.ok(); 135 | } 136 | 137 | /** 138 | * 前端保存 139 | */ 140 | @RequestMapping("/add") 141 | public R add(@RequestBody WodehaoyouEntity wodehaoyou, HttpServletRequest request){ 142 | wodehaoyou.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 143 | //ValidatorUtils.validateEntity(wodehaoyou); 144 | wodehaoyouService.insert(wodehaoyou); 145 | return R.ok(); 146 | } 147 | 148 | /** 149 | * 修改 150 | */ 151 | @RequestMapping("/update") 152 | public R update(@RequestBody WodehaoyouEntity wodehaoyou, HttpServletRequest request){ 153 | //ValidatorUtils.validateEntity(wodehaoyou); 154 | wodehaoyouService.updateById(wodehaoyou);//全部更新 155 | return R.ok(); 156 | } 157 | 158 | 159 | /** 160 | * 删除 161 | */ 162 | @RequestMapping("/delete") 163 | public R delete(@RequestBody Long[] ids){ 164 | wodehaoyouService.deleteBatchIds(Arrays.asList(ids)); 165 | return R.ok(); 166 | } 167 | 168 | /** 169 | * 提醒接口 170 | */ 171 | @RequestMapping("/remind/{columnName}/{type}") 172 | public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 173 | @PathVariable("type") String type,@RequestParam Map map) { 174 | map.put("column", columnName); 175 | map.put("type", type); 176 | 177 | if(type.equals("2")) { 178 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 179 | Calendar c = Calendar.getInstance(); 180 | Date remindStartDate = null; 181 | Date remindEndDate = null; 182 | if(map.get("remindstart")!=null) { 183 | Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); 184 | c.setTime(new Date()); 185 | c.add(Calendar.DAY_OF_MONTH,remindStart); 186 | remindStartDate = c.getTime(); 187 | map.put("remindstart", sdf.format(remindStartDate)); 188 | } 189 | if(map.get("remindend")!=null) { 190 | Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); 191 | c.setTime(new Date()); 192 | c.add(Calendar.DAY_OF_MONTH,remindEnd); 193 | remindEndDate = c.getTime(); 194 | map.put("remindend", sdf.format(remindEndDate)); 195 | } 196 | } 197 | 198 | Wrapper wrapper = new EntityWrapper(); 199 | if(map.get("remindstart")!=null) { 200 | wrapper.ge(columnName, map.get("remindstart")); 201 | } 202 | if(map.get("remindend")!=null) { 203 | wrapper.le(columnName, map.get("remindend")); 204 | } 205 | if(!request.getSession().getAttribute("role").toString().equals("管理员")) { 206 | wrapper.eq("userid", (Long)request.getSession().getAttribute("userId")); 207 | } 208 | 209 | 210 | int count = wodehaoyouService.selectCount(wrapper); 211 | return R.ok().put("count", count); 212 | } 213 | 214 | 215 | 216 | } 217 | -------------------------------------------------------------------------------- /src/main/java/com/controller/CommonController.java: -------------------------------------------------------------------------------- 1 | package com.controller; 2 | 3 | import java.io.File; 4 | import java.io.FileNotFoundException; 5 | import java.io.IOException; 6 | import java.text.SimpleDateFormat; 7 | import java.util.ArrayList; 8 | import java.util.Calendar; 9 | import java.util.Date; 10 | import java.util.HashMap; 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | import org.apache.commons.lang3.StringUtils; 15 | import org.json.JSONObject; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.util.ResourceUtils; 18 | import org.springframework.web.bind.annotation.PathVariable; 19 | import org.springframework.web.bind.annotation.RequestBody; 20 | import org.springframework.web.bind.annotation.RequestMapping; 21 | import org.springframework.web.bind.annotation.RequestParam; 22 | import org.springframework.web.bind.annotation.RestController; 23 | 24 | import com.annotation.IgnoreAuth; 25 | import com.baidu.aip.face.AipFace; 26 | import com.baidu.aip.face.MatchRequest; 27 | import com.baidu.aip.util.Base64Util; 28 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 29 | import com.baomidou.mybatisplus.mapper.Wrapper; 30 | import com.entity.ConfigEntity; 31 | import com.service.CommonService; 32 | import com.service.ConfigService; 33 | import com.utils.BaiduUtil; 34 | import com.utils.FileUtil; 35 | import com.utils.R; 36 | 37 | /** 38 | * 通用接口 39 | */ 40 | @RestController 41 | public class CommonController{ 42 | @Autowired 43 | private CommonService commonService; 44 | 45 | @Autowired 46 | private ConfigService configService; 47 | 48 | private static AipFace client = null; 49 | 50 | private static String BAIDU_DITU_AK = null; 51 | 52 | @RequestMapping("/location") 53 | public R location(String lng,String lat) { 54 | if(BAIDU_DITU_AK==null) { 55 | BAIDU_DITU_AK = configService.selectOne(new EntityWrapper().eq("name", "baidu_ditu_ak")).getValue(); 56 | if(BAIDU_DITU_AK==null) { 57 | return R.error("请在配置管理中正确配置baidu_ditu_ak"); 58 | } 59 | } 60 | Map map = BaiduUtil.getCityByLonLat(BAIDU_DITU_AK, lng, lat); 61 | return R.ok().put("data", map); 62 | } 63 | 64 | /** 65 | * 人脸比对 66 | * 67 | * @param face1 人脸1 68 | * @param face2 人脸2 69 | * @return 70 | */ 71 | @RequestMapping("/matchFace") 72 | public R matchFace(String face1, String face2) { 73 | if(client==null) { 74 | /*String AppID = configService.selectOne(new EntityWrapper().eq("name", "AppID")).getValue();*/ 75 | String APIKey = configService.selectOne(new EntityWrapper().eq("name", "APIKey")).getValue(); 76 | String SecretKey = configService.selectOne(new EntityWrapper().eq("name", "SecretKey")).getValue(); 77 | String token = BaiduUtil.getAuth(APIKey, SecretKey); 78 | if(token==null) { 79 | return R.error("请在配置管理中正确配置APIKey和SecretKey"); 80 | } 81 | client = new AipFace(null, APIKey, SecretKey); 82 | client.setConnectionTimeoutInMillis(2000); 83 | client.setSocketTimeoutInMillis(60000); 84 | } 85 | JSONObject res = null; 86 | try { 87 | File file1 = new File(ResourceUtils.getFile("classpath:static/upload").getAbsolutePath()+"/"+face1); 88 | File file2 = new File(ResourceUtils.getFile("classpath:static/upload").getAbsolutePath()+"/"+face2); 89 | String img1 = Base64Util.encode(FileUtil.FileToByte(file1)); 90 | String img2 = Base64Util.encode(FileUtil.FileToByte(file2)); 91 | MatchRequest req1 = new MatchRequest(img1, "BASE64"); 92 | MatchRequest req2 = new MatchRequest(img2, "BASE64"); 93 | ArrayList requests = new ArrayList(); 94 | requests.add(req1); 95 | requests.add(req2); 96 | res = client.match(requests); 97 | System.out.println(res.get("result")); 98 | } catch (FileNotFoundException e) { 99 | e.printStackTrace(); 100 | return R.error("文件不存在"); 101 | } catch (IOException e) { 102 | e.printStackTrace(); 103 | } 104 | return R.ok().put("data", com.alibaba.fastjson.JSONObject.parse(res.get("result").toString())); 105 | } 106 | 107 | /** 108 | * 获取table表中的column列表(联动接口) 109 | * @param table 110 | * @param column 111 | * @return 112 | */ 113 | @IgnoreAuth 114 | @RequestMapping("/option/{tableName}/{columnName}") 115 | public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,String level,String parent) { 116 | Map params = new HashMap(); 117 | params.put("table", tableName); 118 | params.put("column", columnName); 119 | if(StringUtils.isNotBlank(level)) { 120 | params.put("level", level); 121 | } 122 | if(StringUtils.isNotBlank(parent)) { 123 | params.put("parent", parent); 124 | } 125 | List data = commonService.getOption(params); 126 | return R.ok().put("data", data); 127 | } 128 | 129 | /** 130 | * 根据table中的column获取单条记录 131 | * @param table 132 | * @param column 133 | * @return 134 | */ 135 | @IgnoreAuth 136 | @RequestMapping("/follow/{tableName}/{columnName}") 137 | public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, @RequestParam String columnValue) { 138 | Map params = new HashMap(); 139 | params.put("table", tableName); 140 | params.put("column", columnName); 141 | params.put("columnValue", columnValue); 142 | Map result = commonService.getFollowByOption(params); 143 | return R.ok().put("data", result); 144 | } 145 | 146 | /** 147 | * 修改table表的sfsh状态 148 | * @param table 149 | * @param map 150 | * @return 151 | */ 152 | @RequestMapping("/sh/{tableName}") 153 | public R sh(@PathVariable("tableName") String tableName, @RequestBody Map map) { 154 | map.put("table", tableName); 155 | commonService.sh(map); 156 | return R.ok(); 157 | } 158 | 159 | /** 160 | * 获取需要提醒的记录数 161 | * @param tableName 162 | * @param columnName 163 | * @param type 1:数字 2:日期 164 | * @param map 165 | * @return 166 | */ 167 | @IgnoreAuth 168 | @RequestMapping("/remind/{tableName}/{columnName}/{type}") 169 | public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, 170 | @PathVariable("type") String type,@RequestParam Map map) { 171 | map.put("table", tableName); 172 | map.put("column", columnName); 173 | map.put("type", type); 174 | 175 | if(type.equals("2")) { 176 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 177 | Calendar c = Calendar.getInstance(); 178 | Date remindStartDate = null; 179 | Date remindEndDate = null; 180 | if(map.get("remindstart")!=null) { 181 | Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); 182 | c.setTime(new Date()); 183 | c.add(Calendar.DAY_OF_MONTH,remindStart); 184 | remindStartDate = c.getTime(); 185 | map.put("remindstart", sdf.format(remindStartDate)); 186 | } 187 | if(map.get("remindend")!=null) { 188 | Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); 189 | c.setTime(new Date()); 190 | c.add(Calendar.DAY_OF_MONTH,remindEnd); 191 | remindEndDate = c.getTime(); 192 | map.put("remindend", sdf.format(remindEndDate)); 193 | } 194 | } 195 | 196 | int count = commonService.remindCount(map); 197 | return R.ok().put("count", count); 198 | } 199 | 200 | /** 201 | * 单列求和 202 | */ 203 | @IgnoreAuth 204 | @RequestMapping("/cal/{tableName}/{columnName}") 205 | public R cal(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) { 206 | Map params = new HashMap(); 207 | params.put("table", tableName); 208 | params.put("column", columnName); 209 | Map result = commonService.selectCal(params); 210 | return R.ok().put("data", result); 211 | } 212 | 213 | /** 214 | * 分组统计 215 | */ 216 | @IgnoreAuth 217 | @RequestMapping("/group/{tableName}/{columnName}") 218 | public R group(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) { 219 | Map params = new HashMap(); 220 | params.put("table", tableName); 221 | params.put("column", columnName); 222 | List> result = commonService.selectGroup(params); 223 | return R.ok().put("data", result); 224 | } 225 | 226 | /** 227 | * (按值统计) 228 | */ 229 | @IgnoreAuth 230 | @RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}") 231 | public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName) { 232 | Map params = new HashMap(); 233 | params.put("table", tableName); 234 | params.put("xColumn", xColumnName); 235 | params.put("yColumn", yColumnName); 236 | List> result = commonService.selectValue(params); 237 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 238 | for(Map m : result) { 239 | for(String k : m.keySet()) { 240 | if(m.get(k) instanceof Date) { 241 | m.put(k, sdf.format((Date)m.get(k))); 242 | } 243 | } 244 | } 245 | return R.ok().put("data", result); 246 | } 247 | 248 | } 249 | --------------------------------------------------------------------------------