├── image ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png └── 7.png ├── limage └── 1.png ├── src ├── main │ ├── resources │ │ ├── mapper │ │ │ ├── ConfigDao.xml │ │ │ ├── UserDao.xml │ │ │ ├── TokenDao.xml │ │ │ ├── GangweiDao.xml │ │ │ ├── BumenxinxiDao.xml │ │ │ ├── GonggaoxinxiDao.xml │ │ │ ├── WendangxinxiDao.xml │ │ │ ├── YuangongDao.xml │ │ │ └── CommonDao.xml │ │ └── application.yml │ └── java │ │ └── com │ │ ├── dao │ │ ├── ConfigDao.java │ │ ├── UserDao.java │ │ ├── TokenDao.java │ │ ├── CommonDao.java │ │ ├── GangweiDao.java │ │ ├── YuangongDao.java │ │ ├── BumenxinxiDao.java │ │ ├── GonggaoxinxiDao.java │ │ └── WendangxinxiDao.java │ │ ├── annotation │ │ ├── IgnoreAuth.java │ │ ├── LoginUser.java │ │ └── APPLoginUser.java │ │ ├── service │ │ ├── ConfigService.java │ │ ├── CommonService.java │ │ ├── UserService.java │ │ ├── TokenService.java │ │ ├── impl │ │ │ ├── ConfigServiceImpl.java │ │ │ ├── CommonServiceImpl.java │ │ │ ├── UserServiceImpl.java │ │ │ ├── GangweiServiceImpl.java │ │ │ ├── YuangongServiceImpl.java │ │ │ ├── BumenxinxiServiceImpl.java │ │ │ ├── GonggaoxinxiServiceImpl.java │ │ │ ├── WendangxinxiServiceImpl.java │ │ │ └── TokenServiceImpl.java │ │ ├── GangweiService.java │ │ ├── YuangongService.java │ │ ├── BumenxinxiService.java │ │ ├── GonggaoxinxiService.java │ │ └── WendangxinxiService.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 │ │ ├── entity │ │ ├── vo │ │ │ ├── GangweiVO.java │ │ │ ├── BumenxinxiVO.java │ │ │ ├── GonggaoxinxiVO.java │ │ │ ├── WendangxinxiVO.java │ │ │ └── YuangongVO.java │ │ ├── model │ │ │ ├── GangweiModel.java │ │ │ ├── BumenxinxiModel.java │ │ │ ├── GonggaoxinxiModel.java │ │ │ ├── WendangxinxiModel.java │ │ │ └── YuangongModel.java │ │ ├── view │ │ │ ├── GangweiView.java │ │ │ ├── YuangongView.java │ │ │ ├── BumenxinxiView.java │ │ │ ├── GonggaoxinxiView.java │ │ │ └── WendangxinxiView.java │ │ ├── EIException.java │ │ ├── ConfigEntity.java │ │ ├── UserEntity.java │ │ ├── GangweiEntity.java │ │ ├── TokenEntity.java │ │ ├── BumenxinxiEntity.java │ │ ├── GonggaoxinxiEntity.java │ │ ├── WendangxinxiEntity.java │ │ └── YuangongEntity.java │ │ ├── SpringbootSchemaApplication.java │ │ ├── controller │ │ ├── ConfigController.java │ │ ├── FileController.java │ │ ├── UserController.java │ │ ├── GangweiController.java │ │ ├── BumenxinxiController.java │ │ ├── GonggaoxinxiController.java │ │ ├── WendangxinxiController.java │ │ ├── CommonController.java │ │ └── YuangongController.java │ │ └── interceptor │ │ └── AuthorizationInterceptor.java └── test │ └── java │ └── com │ └── SpringbootSchemaApplicationTests.java ├── .gitignore ├── README.md ├── pom.xml ├── pom-war.xml ├── mvnw.cmd └── mvnw /image/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No222Online-Document-Management-System/HEAD/image/1.png -------------------------------------------------------------------------------- /image/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No222Online-Document-Management-System/HEAD/image/2.png -------------------------------------------------------------------------------- /image/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No222Online-Document-Management-System/HEAD/image/3.png -------------------------------------------------------------------------------- /image/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No222Online-Document-Management-System/HEAD/image/4.png -------------------------------------------------------------------------------- /image/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No222Online-Document-Management-System/HEAD/image/5.png -------------------------------------------------------------------------------- /image/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No222Online-Document-Management-System/HEAD/image/6.png -------------------------------------------------------------------------------- /image/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No222Online-Document-Management-System/HEAD/image/7.png -------------------------------------------------------------------------------- /limage/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nature924/No222Online-Document-Management-System/HEAD/limage/1.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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /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/entity/vo/GangweiVO.java: -------------------------------------------------------------------------------- 1 | package com.entity.vo; 2 | 3 | import com.entity.GangweiEntity; 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-04-02 14:39:25 20 | */ 21 | public class GangweiVO implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /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/entity/model/GangweiModel.java: -------------------------------------------------------------------------------- 1 | package com.entity.model; 2 | 3 | import com.entity.GangweiEntity; 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-04-02 14:39:25 21 | */ 22 | public class GangweiModel implements Serializable { 23 | private static final long serialVersionUID = 1L; 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /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/GangweiView.java: -------------------------------------------------------------------------------- 1 | package com.entity.view; 2 | 3 | import com.entity.GangweiEntity; 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-04-02 14:39:25 19 | */ 20 | @TableName("gangwei") 21 | public class GangweiView extends GangweiEntity implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | public GangweiView(){ 25 | } 26 | 27 | public GangweiView(GangweiEntity gangweiEntity){ 28 | try { 29 | BeanUtils.copyProperties(this, gangweiEntity); 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/YuangongView.java: -------------------------------------------------------------------------------- 1 | package com.entity.view; 2 | 3 | import com.entity.YuangongEntity; 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-04-02 14:39:25 19 | */ 20 | @TableName("yuangong") 21 | public class YuangongView extends YuangongEntity implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | public YuangongView(){ 25 | } 26 | 27 | public YuangongView(YuangongEntity yuangongEntity){ 28 | try { 29 | BeanUtils.copyProperties(this, yuangongEntity); 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/BumenxinxiView.java: -------------------------------------------------------------------------------- 1 | package com.entity.view; 2 | 3 | import com.entity.BumenxinxiEntity; 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-04-02 14:39:25 19 | */ 20 | @TableName("bumenxinxi") 21 | public class BumenxinxiView extends BumenxinxiEntity implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | public BumenxinxiView(){ 25 | } 26 | 27 | public BumenxinxiView(BumenxinxiEntity bumenxinxiEntity){ 28 | try { 29 | BeanUtils.copyProperties(this, bumenxinxiEntity); 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/GonggaoxinxiView.java: -------------------------------------------------------------------------------- 1 | package com.entity.view; 2 | 3 | import com.entity.GonggaoxinxiEntity; 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-04-02 14:39:25 19 | */ 20 | @TableName("gonggaoxinxi") 21 | public class GonggaoxinxiView extends GonggaoxinxiEntity implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | public GonggaoxinxiView(){ 25 | } 26 | 27 | public GonggaoxinxiView(GonggaoxinxiEntity gonggaoxinxiEntity){ 28 | try { 29 | BeanUtils.copyProperties(this, gonggaoxinxiEntity); 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/WendangxinxiView.java: -------------------------------------------------------------------------------- 1 | package com.entity.view; 2 | 3 | import com.entity.WendangxinxiEntity; 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-04-02 14:39:25 19 | */ 20 | @TableName("wendangxinxi") 21 | public class WendangxinxiView extends WendangxinxiEntity implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | public WendangxinxiView(){ 25 | } 26 | 27 | public WendangxinxiView(WendangxinxiEntity wendangxinxiEntity){ 28 | try { 29 | BeanUtils.copyProperties(this, wendangxinxiEntity); 30 | } catch (IllegalAccessException | InvocationTargetException e) { 31 | // TODO Auto-generated catch block 32 | e.printStackTrace(); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /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/GangweiDao.java: -------------------------------------------------------------------------------- 1 | package com.dao; 2 | 3 | import com.entity.GangweiEntity; 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.GangweiVO; 11 | import com.entity.view.GangweiView; 12 | 13 | 14 | /** 15 | * 岗位 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-04-02 14:39:25 20 | */ 21 | public interface GangweiDao extends BaseMapper { 22 | 23 | List selectListVO(@Param("ew") Wrapper wrapper); 24 | 25 | GangweiVO 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 | GangweiView 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/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/dao/YuangongDao.java: -------------------------------------------------------------------------------- 1 | package com.dao; 2 | 3 | import com.entity.YuangongEntity; 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.YuangongVO; 11 | import com.entity.view.YuangongView; 12 | 13 | 14 | /** 15 | * 员工 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-04-02 14:39:25 20 | */ 21 | public interface YuangongDao extends BaseMapper { 22 | 23 | List selectListVO(@Param("ew") Wrapper wrapper); 24 | 25 | YuangongVO 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 | YuangongView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/dao/BumenxinxiDao.java: -------------------------------------------------------------------------------- 1 | package com.dao; 2 | 3 | import com.entity.BumenxinxiEntity; 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.BumenxinxiVO; 11 | import com.entity.view.BumenxinxiView; 12 | 13 | 14 | /** 15 | * 部门信息 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-04-02 14:39:25 20 | */ 21 | public interface BumenxinxiDao extends BaseMapper { 22 | 23 | List selectListVO(@Param("ew") Wrapper wrapper); 24 | 25 | BumenxinxiVO 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 | BumenxinxiView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/service/GangweiService.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.GangweiEntity; 7 | import java.util.List; 8 | import java.util.Map; 9 | import com.entity.vo.GangweiVO; 10 | import org.apache.ibatis.annotations.Param; 11 | import com.entity.view.GangweiView; 12 | 13 | 14 | /** 15 | * 岗位 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-04-02 14:39:25 20 | */ 21 | public interface GangweiService extends IService { 22 | 23 | PageUtils queryPage(Map params); 24 | 25 | List selectListVO(Wrapper wrapper); 26 | 27 | GangweiVO selectVO(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Wrapper wrapper); 30 | 31 | GangweiView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | PageUtils queryPage(Map params,Wrapper wrapper); 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/com/service/YuangongService.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.YuangongEntity; 7 | import java.util.List; 8 | import java.util.Map; 9 | import com.entity.vo.YuangongVO; 10 | import org.apache.ibatis.annotations.Param; 11 | import com.entity.view.YuangongView; 12 | 13 | 14 | /** 15 | * 员工 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-04-02 14:39:25 20 | */ 21 | public interface YuangongService extends IService { 22 | 23 | PageUtils queryPage(Map params); 24 | 25 | List selectListVO(Wrapper wrapper); 26 | 27 | YuangongVO selectVO(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Wrapper wrapper); 30 | 31 | YuangongView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | PageUtils queryPage(Map params,Wrapper wrapper); 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/com/dao/GonggaoxinxiDao.java: -------------------------------------------------------------------------------- 1 | package com.dao; 2 | 3 | import com.entity.GonggaoxinxiEntity; 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.GonggaoxinxiVO; 11 | import com.entity.view.GonggaoxinxiView; 12 | 13 | 14 | /** 15 | * 公告信息 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-04-02 14:39:25 20 | */ 21 | public interface GonggaoxinxiDao extends BaseMapper { 22 | 23 | List selectListVO(@Param("ew") Wrapper wrapper); 24 | 25 | GonggaoxinxiVO 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 | GonggaoxinxiView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/dao/WendangxinxiDao.java: -------------------------------------------------------------------------------- 1 | package com.dao; 2 | 3 | import com.entity.WendangxinxiEntity; 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.WendangxinxiVO; 11 | import com.entity.view.WendangxinxiView; 12 | 13 | 14 | /** 15 | * 文档信息 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-04-02 14:39:25 20 | */ 21 | public interface WendangxinxiDao extends BaseMapper { 22 | 23 | List selectListVO(@Param("ew") Wrapper wrapper); 24 | 25 | WendangxinxiVO 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 | WendangxinxiView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /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/BumenxinxiService.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.BumenxinxiEntity; 7 | import java.util.List; 8 | import java.util.Map; 9 | import com.entity.vo.BumenxinxiVO; 10 | import org.apache.ibatis.annotations.Param; 11 | import com.entity.view.BumenxinxiView; 12 | 13 | 14 | /** 15 | * 部门信息 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-04-02 14:39:25 20 | */ 21 | public interface BumenxinxiService extends IService { 22 | 23 | PageUtils queryPage(Map params); 24 | 25 | List selectListVO(Wrapper wrapper); 26 | 27 | BumenxinxiVO selectVO(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Wrapper wrapper); 30 | 31 | BumenxinxiView 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/service/GonggaoxinxiService.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.GonggaoxinxiEntity; 7 | import java.util.List; 8 | import java.util.Map; 9 | import com.entity.vo.GonggaoxinxiVO; 10 | import org.apache.ibatis.annotations.Param; 11 | import com.entity.view.GonggaoxinxiView; 12 | 13 | 14 | /** 15 | * 公告信息 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-04-02 14:39:25 20 | */ 21 | public interface GonggaoxinxiService extends IService { 22 | 23 | PageUtils queryPage(Map params); 24 | 25 | List selectListVO(Wrapper wrapper); 26 | 27 | GonggaoxinxiVO selectVO(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Wrapper wrapper); 30 | 31 | GonggaoxinxiView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | PageUtils queryPage(Map params,Wrapper wrapper); 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/com/service/WendangxinxiService.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.WendangxinxiEntity; 7 | import java.util.List; 8 | import java.util.Map; 9 | import com.entity.vo.WendangxinxiVO; 10 | import org.apache.ibatis.annotations.Param; 11 | import com.entity.view.WendangxinxiView; 12 | 13 | 14 | /** 15 | * 文档信息 16 | * 17 | * @author 18 | * @email 19 | * @date 2021-04-02 14:39:25 20 | */ 21 | public interface WendangxinxiService extends IService { 22 | 23 | PageUtils queryPage(Map params); 24 | 25 | List selectListVO(Wrapper wrapper); 26 | 27 | WendangxinxiVO selectVO(@Param("ew") Wrapper wrapper); 28 | 29 | List selectListView(Wrapper wrapper); 30 | 31 | WendangxinxiView selectView(@Param("ew") Wrapper wrapper); 32 | 33 | PageUtils queryPage(Map params,Wrapper wrapper); 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/main/resources/mapper/GangweiDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 16 | 17 | 22 | 23 | 29 | 30 | 34 | 35 | -------------------------------------------------------------------------------- /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/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/entity/vo/BumenxinxiVO.java: -------------------------------------------------------------------------------- 1 | package com.entity.vo; 2 | 3 | import com.entity.BumenxinxiEntity; 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-04-02 14:39:25 20 | */ 21 | public class BumenxinxiVO implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | 25 | /** 26 | * 人数 27 | */ 28 | 29 | private Integer renshu; 30 | 31 | /** 32 | * 人员架构 33 | */ 34 | 35 | private String renyuanjiagou; 36 | 37 | 38 | /** 39 | * 设置:人数 40 | */ 41 | 42 | public void setRenshu(Integer renshu) { 43 | this.renshu = renshu; 44 | } 45 | 46 | /** 47 | * 获取:人数 48 | */ 49 | public Integer getRenshu() { 50 | return renshu; 51 | } 52 | 53 | 54 | /** 55 | * 设置:人员架构 56 | */ 57 | 58 | public void setRenyuanjiagou(String renyuanjiagou) { 59 | this.renyuanjiagou = renyuanjiagou; 60 | } 61 | 62 | /** 63 | * 获取:人员架构 64 | */ 65 | public String getRenyuanjiagou() { 66 | return renyuanjiagou; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/resources/mapper/BumenxinxiDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 18 | 19 | 24 | 25 | 31 | 32 | 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/com/entity/model/BumenxinxiModel.java: -------------------------------------------------------------------------------- 1 | package com.entity.model; 2 | 3 | import com.entity.BumenxinxiEntity; 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-04-02 14:39:25 21 | */ 22 | public class BumenxinxiModel implements Serializable { 23 | private static final long serialVersionUID = 1L; 24 | 25 | 26 | /** 27 | * 人数 28 | */ 29 | 30 | private Integer renshu; 31 | 32 | /** 33 | * 人员架构 34 | */ 35 | 36 | private String renyuanjiagou; 37 | 38 | 39 | /** 40 | * 设置:人数 41 | */ 42 | 43 | public void setRenshu(Integer renshu) { 44 | this.renshu = renshu; 45 | } 46 | 47 | /** 48 | * 获取:人数 49 | */ 50 | public Integer getRenshu() { 51 | return renshu; 52 | } 53 | 54 | 55 | /** 56 | * 设置:人员架构 57 | */ 58 | 59 | public void setRenyuanjiagou(String renyuanjiagou) { 60 | this.renyuanjiagou = renyuanjiagou; 61 | } 62 | 63 | /** 64 | * 获取:人员架构 65 | */ 66 | public String getRenyuanjiagou() { 67 | return renyuanjiagou; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/resources/mapper/GonggaoxinxiDao.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/WendangxinxiDao.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/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/java/com/entity/vo/GonggaoxinxiVO.java: -------------------------------------------------------------------------------- 1 | package com.entity.vo; 2 | 3 | import com.entity.GonggaoxinxiEntity; 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-04-02 14:39:25 20 | */ 21 | public class GonggaoxinxiVO implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | 25 | /** 26 | * 图片 27 | */ 28 | 29 | private String tupian; 30 | 31 | /** 32 | * 内容 33 | */ 34 | 35 | private String neirong; 36 | 37 | /** 38 | * 发布日期 39 | */ 40 | 41 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 42 | @DateTimeFormat 43 | private Date faburiqi; 44 | 45 | 46 | /** 47 | * 设置:图片 48 | */ 49 | 50 | public void setTupian(String tupian) { 51 | this.tupian = tupian; 52 | } 53 | 54 | /** 55 | * 获取:图片 56 | */ 57 | public String getTupian() { 58 | return tupian; 59 | } 60 | 61 | 62 | /** 63 | * 设置:内容 64 | */ 65 | 66 | public void setNeirong(String neirong) { 67 | this.neirong = neirong; 68 | } 69 | 70 | /** 71 | * 获取:内容 72 | */ 73 | public String getNeirong() { 74 | return neirong; 75 | } 76 | 77 | 78 | /** 79 | * 设置:发布日期 80 | */ 81 | 82 | public void setFaburiqi(Date faburiqi) { 83 | this.faburiqi = faburiqi; 84 | } 85 | 86 | /** 87 | * 获取:发布日期 88 | */ 89 | public Date getFaburiqi() { 90 | return faburiqi; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /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 | ### 1 管理员功能模块 13 | 14 | 管理员登录 15 | 管理员通过填写注册时输入的用户名、密码和角色进行登录。 16 | 17 | 首页 18 | 管理员登录后可以查看首页、个人中心、公告信息管理、部门信息管理、岗位管理、员工管理、文档信息管理等功能。 19 | 20 | 公告信息管理 21 | 管理员可以在公告信息管理页面中查看公告标题、图片、发布日期、内容等信息,进行详情查看、修改或删除操作。 22 | 23 | 部门信息管理 24 | 管理员可以查看部门、人数等信息,并对部门信息进行详情查看、修改或删除等操作。 25 | 26 | 员工管理 27 | 管理员可以查看员工工号、姓名、性别、头像、部门、岗位、年龄、手机、邮箱、身份证等信息,并对员工信息进行详情查看、修改或删除等操作。 28 | 29 | 文档信息管理 30 | 管理员可以查看文档名称、类型、介绍、附件、发布日期等信息,并对文档信息进行详情查看、修改或删除等操作。 31 | 32 | ### 2 员工功能模块 33 | 34 | 登录 35 | 员工通过填写工号和密码进行登录。 36 | 37 | 首页 38 | 员工登录后可以查看首页、个人中心、公告信息管理、文档信息管理等功能。 39 | 40 | 个人中心 41 | 员工可以在个人信息页面中查看和编辑工号、姓名、性别、头像、部门、岗位、年龄、手机、邮箱、身份证等信息。 42 | 43 | 文档信息管理 44 | 员工可以在文档信息管理页面中查看文档名称、类型、介绍、附件、发布日期等信息,并根据需要进行下载或详细查看。 45 | 46 | 47 | 48 | 49 | 50 | 51 | 二、项目技术 52 | --- 53 | - 编程语言:Java 54 | - 数据库:MySQL 55 | - 项目管理工具:Maven 56 | - 前端技术:VUE、HTML、Jquery、Bootstrap 57 | - 后端技术:Spring、SpringMVC、MyBatis 58 | 59 | 三、运行环境 60 | --- 61 | - 操作系统:Windows、macOS都可以 62 | - JDK版本:JDK1.8以上都可以 63 | - 开发工具:IDEA、Ecplise、Myecplise都可以 64 | - 数据库: MySQL5.7以上都可以 65 | - Tomcat:任意版本都可以 66 | - Maven:任意版本都可以 67 | 68 | 四、运行截图 69 | --- 70 | ### 论文截图: 71 | ![image/1.png](limage/1.png) 72 | 73 | ### 程序截图: 74 | ![image/1.png](image/1.png) 75 | ![image/1.png](image/2.png) 76 | ![image/1.png](image/3.png) 77 | ![image/1.png](image/4.png) 78 | ![image/1.png](image/5.png) 79 | ![image/1.png](image/6.png) 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/main/java/com/entity/model/GonggaoxinxiModel.java: -------------------------------------------------------------------------------- 1 | package com.entity.model; 2 | 3 | import com.entity.GonggaoxinxiEntity; 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-04-02 14:39:25 21 | */ 22 | public class GonggaoxinxiModel implements Serializable { 23 | private static final long serialVersionUID = 1L; 24 | 25 | 26 | /** 27 | * 图片 28 | */ 29 | 30 | private String tupian; 31 | 32 | /** 33 | * 内容 34 | */ 35 | 36 | private String neirong; 37 | 38 | /** 39 | * 发布日期 40 | */ 41 | 42 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 43 | @DateTimeFormat 44 | private Date faburiqi; 45 | 46 | 47 | /** 48 | * 设置:图片 49 | */ 50 | 51 | public void setTupian(String tupian) { 52 | this.tupian = tupian; 53 | } 54 | 55 | /** 56 | * 获取:图片 57 | */ 58 | public String getTupian() { 59 | return tupian; 60 | } 61 | 62 | 63 | /** 64 | * 设置:内容 65 | */ 66 | 67 | public void setNeirong(String neirong) { 68 | this.neirong = neirong; 69 | } 70 | 71 | /** 72 | * 获取:内容 73 | */ 74 | public String getNeirong() { 75 | return neirong; 76 | } 77 | 78 | 79 | /** 80 | * 设置:发布日期 81 | */ 82 | 83 | public void setFaburiqi(Date faburiqi) { 84 | this.faburiqi = faburiqi; 85 | } 86 | 87 | /** 88 | * 获取:发布日期 89 | */ 90 | public Date getFaburiqi() { 91 | return faburiqi; 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: /springbootpkh49 8 | 9 | spring: 10 | datasource: 11 | driverClassName: com.mysql.jdbc.Driver 12 | url: jdbc:mysql://127.0.0.1:3306/springbootpkh49?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=springbootpkh49 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 | -------------------------------------------------------------------------------- /src/main/resources/mapper/YuangongDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 26 | 27 | 32 | 33 | 39 | 40 | 44 | 45 | -------------------------------------------------------------------------------- /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/service/impl/GangweiServiceImpl.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.GangweiDao; 16 | import com.entity.GangweiEntity; 17 | import com.service.GangweiService; 18 | import com.entity.vo.GangweiVO; 19 | import com.entity.view.GangweiView; 20 | 21 | @Service("gangweiService") 22 | public class GangweiServiceImpl extends ServiceImpl implements GangweiService { 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 GangweiVO 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 GangweiView selectView(Wrapper wrapper) { 59 | return baseMapper.selectView(wrapper); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/YuangongServiceImpl.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.YuangongDao; 16 | import com.entity.YuangongEntity; 17 | import com.service.YuangongService; 18 | import com.entity.vo.YuangongVO; 19 | import com.entity.view.YuangongView; 20 | 21 | @Service("yuangongService") 22 | public class YuangongServiceImpl extends ServiceImpl implements YuangongService { 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 YuangongVO 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 YuangongView selectView(Wrapper wrapper) { 59 | return baseMapper.selectView(wrapper); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/BumenxinxiServiceImpl.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.BumenxinxiDao; 16 | import com.entity.BumenxinxiEntity; 17 | import com.service.BumenxinxiService; 18 | import com.entity.vo.BumenxinxiVO; 19 | import com.entity.view.BumenxinxiView; 20 | 21 | @Service("bumenxinxiService") 22 | public class BumenxinxiServiceImpl extends ServiceImpl implements BumenxinxiService { 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 BumenxinxiVO 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 BumenxinxiView selectView(Wrapper wrapper) { 59 | return baseMapper.selectView(wrapper); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/entity/vo/WendangxinxiVO.java: -------------------------------------------------------------------------------- 1 | package com.entity.vo; 2 | 3 | import com.entity.WendangxinxiEntity; 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-04-02 14:39:25 20 | */ 21 | public class WendangxinxiVO implements Serializable { 22 | private static final long serialVersionUID = 1L; 23 | 24 | 25 | /** 26 | * 类型 27 | */ 28 | 29 | private String leixing; 30 | 31 | /** 32 | * 文档介绍 33 | */ 34 | 35 | private String wendangjieshao; 36 | 37 | /** 38 | * 附件 39 | */ 40 | 41 | private String fujian; 42 | 43 | /** 44 | * 发布日期 45 | */ 46 | 47 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 48 | @DateTimeFormat 49 | private Date faburiqi; 50 | 51 | 52 | /** 53 | * 设置:类型 54 | */ 55 | 56 | public void setLeixing(String leixing) { 57 | this.leixing = leixing; 58 | } 59 | 60 | /** 61 | * 获取:类型 62 | */ 63 | public String getLeixing() { 64 | return leixing; 65 | } 66 | 67 | 68 | /** 69 | * 设置:文档介绍 70 | */ 71 | 72 | public void setWendangjieshao(String wendangjieshao) { 73 | this.wendangjieshao = wendangjieshao; 74 | } 75 | 76 | /** 77 | * 获取:文档介绍 78 | */ 79 | public String getWendangjieshao() { 80 | return wendangjieshao; 81 | } 82 | 83 | 84 | /** 85 | * 设置:附件 86 | */ 87 | 88 | public void setFujian(String fujian) { 89 | this.fujian = fujian; 90 | } 91 | 92 | /** 93 | * 获取:附件 94 | */ 95 | public String getFujian() { 96 | return fujian; 97 | } 98 | 99 | 100 | /** 101 | * 设置:发布日期 102 | */ 103 | 104 | public void setFaburiqi(Date faburiqi) { 105 | this.faburiqi = faburiqi; 106 | } 107 | 108 | /** 109 | * 获取:发布日期 110 | */ 111 | public Date getFaburiqi() { 112 | return faburiqi; 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/GonggaoxinxiServiceImpl.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.GonggaoxinxiDao; 16 | import com.entity.GonggaoxinxiEntity; 17 | import com.service.GonggaoxinxiService; 18 | import com.entity.vo.GonggaoxinxiVO; 19 | import com.entity.view.GonggaoxinxiView; 20 | 21 | @Service("gonggaoxinxiService") 22 | public class GonggaoxinxiServiceImpl extends ServiceImpl implements GonggaoxinxiService { 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 GonggaoxinxiVO 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 GonggaoxinxiView selectView(Wrapper wrapper) { 59 | return baseMapper.selectView(wrapper); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/service/impl/WendangxinxiServiceImpl.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.WendangxinxiDao; 16 | import com.entity.WendangxinxiEntity; 17 | import com.service.WendangxinxiService; 18 | import com.entity.vo.WendangxinxiVO; 19 | import com.entity.view.WendangxinxiView; 20 | 21 | @Service("wendangxinxiService") 22 | public class WendangxinxiServiceImpl extends ServiceImpl implements WendangxinxiService { 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 WendangxinxiVO 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 WendangxinxiView selectView(Wrapper wrapper) { 59 | return baseMapper.selectView(wrapper); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/entity/GangweiEntity.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-04-02 14:39:25 30 | */ 31 | @TableName("gangwei") 32 | public class GangweiEntity implements Serializable { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | public GangweiEntity() { 37 | 38 | } 39 | 40 | public GangweiEntity(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 gangwei; 59 | 60 | 61 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 62 | @DateTimeFormat 63 | private Date addtime; 64 | 65 | public Date getAddtime() { 66 | return addtime; 67 | } 68 | public void setAddtime(Date addtime) { 69 | this.addtime = addtime; 70 | } 71 | 72 | public Long getId() { 73 | return id; 74 | } 75 | 76 | public void setId(Long id) { 77 | this.id = id; 78 | } 79 | /** 80 | * 设置:岗位 81 | */ 82 | public void setGangwei(String gangwei) { 83 | this.gangwei = gangwei; 84 | } 85 | /** 86 | * 获取:岗位 87 | */ 88 | public String getGangwei() { 89 | return gangwei; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/entity/model/WendangxinxiModel.java: -------------------------------------------------------------------------------- 1 | package com.entity.model; 2 | 3 | import com.entity.WendangxinxiEntity; 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-04-02 14:39:25 21 | */ 22 | public class WendangxinxiModel implements Serializable { 23 | private static final long serialVersionUID = 1L; 24 | 25 | 26 | /** 27 | * 类型 28 | */ 29 | 30 | private String leixing; 31 | 32 | /** 33 | * 文档介绍 34 | */ 35 | 36 | private String wendangjieshao; 37 | 38 | /** 39 | * 附件 40 | */ 41 | 42 | private String fujian; 43 | 44 | /** 45 | * 发布日期 46 | */ 47 | 48 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 49 | @DateTimeFormat 50 | private Date faburiqi; 51 | 52 | 53 | /** 54 | * 设置:类型 55 | */ 56 | 57 | public void setLeixing(String leixing) { 58 | this.leixing = leixing; 59 | } 60 | 61 | /** 62 | * 获取:类型 63 | */ 64 | public String getLeixing() { 65 | return leixing; 66 | } 67 | 68 | 69 | /** 70 | * 设置:文档介绍 71 | */ 72 | 73 | public void setWendangjieshao(String wendangjieshao) { 74 | this.wendangjieshao = wendangjieshao; 75 | } 76 | 77 | /** 78 | * 获取:文档介绍 79 | */ 80 | public String getWendangjieshao() { 81 | return wendangjieshao; 82 | } 83 | 84 | 85 | /** 86 | * 设置:附件 87 | */ 88 | 89 | public void setFujian(String fujian) { 90 | this.fujian = fujian; 91 | } 92 | 93 | /** 94 | * 获取:附件 95 | */ 96 | public String getFujian() { 97 | return fujian; 98 | } 99 | 100 | 101 | /** 102 | * 设置:发布日期 103 | */ 104 | 105 | public void setFaburiqi(Date faburiqi) { 106 | this.faburiqi = faburiqi; 107 | } 108 | 109 | /** 110 | * 获取:发布日期 111 | */ 112 | public Date getFaburiqi() { 113 | return faburiqi; 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /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/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/BumenxinxiEntity.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-04-02 14:39:25 30 | */ 31 | @TableName("bumenxinxi") 32 | public class BumenxinxiEntity implements Serializable { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | public BumenxinxiEntity() { 37 | 38 | } 39 | 40 | public BumenxinxiEntity(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 bumen; 59 | 60 | /** 61 | * 人数 62 | */ 63 | 64 | private Integer renshu; 65 | 66 | /** 67 | * 人员架构 68 | */ 69 | 70 | private String renyuanjiagou; 71 | 72 | 73 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 74 | @DateTimeFormat 75 | private Date addtime; 76 | 77 | public Date getAddtime() { 78 | return addtime; 79 | } 80 | public void setAddtime(Date addtime) { 81 | this.addtime = addtime; 82 | } 83 | 84 | public Long getId() { 85 | return id; 86 | } 87 | 88 | public void setId(Long id) { 89 | this.id = id; 90 | } 91 | /** 92 | * 设置:部门 93 | */ 94 | public void setBumen(String bumen) { 95 | this.bumen = bumen; 96 | } 97 | /** 98 | * 获取:部门 99 | */ 100 | public String getBumen() { 101 | return bumen; 102 | } 103 | /** 104 | * 设置:人数 105 | */ 106 | public void setRenshu(Integer renshu) { 107 | this.renshu = renshu; 108 | } 109 | /** 110 | * 获取:人数 111 | */ 112 | public Integer getRenshu() { 113 | return renshu; 114 | } 115 | /** 116 | * 设置:人员架构 117 | */ 118 | public void setRenyuanjiagou(String renyuanjiagou) { 119 | this.renyuanjiagou = renyuanjiagou; 120 | } 121 | /** 122 | * 获取:人员架构 123 | */ 124 | public String getRenyuanjiagou() { 125 | return renyuanjiagou; 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /src/main/java/com/entity/GonggaoxinxiEntity.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-04-02 14:39:25 30 | */ 31 | @TableName("gonggaoxinxi") 32 | public class GonggaoxinxiEntity implements Serializable { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | public GonggaoxinxiEntity() { 37 | 38 | } 39 | 40 | public GonggaoxinxiEntity(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 gonggaobiaoti; 59 | 60 | /** 61 | * 图片 62 | */ 63 | 64 | private String tupian; 65 | 66 | /** 67 | * 内容 68 | */ 69 | 70 | private String neirong; 71 | 72 | /** 73 | * 发布日期 74 | */ 75 | 76 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd") 77 | @DateTimeFormat 78 | private Date faburiqi; 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 setGonggaobiaoti(String gonggaobiaoti) { 103 | this.gonggaobiaoti = gonggaobiaoti; 104 | } 105 | /** 106 | * 获取:公告标题 107 | */ 108 | public String getGonggaobiaoti() { 109 | return gonggaobiaoti; 110 | } 111 | /** 112 | * 设置:图片 113 | */ 114 | public void setTupian(String tupian) { 115 | this.tupian = tupian; 116 | } 117 | /** 118 | * 获取:图片 119 | */ 120 | public String getTupian() { 121 | return tupian; 122 | } 123 | /** 124 | * 设置:内容 125 | */ 126 | public void setNeirong(String neirong) { 127 | this.neirong = neirong; 128 | } 129 | /** 130 | * 获取:内容 131 | */ 132 | public String getNeirong() { 133 | return neirong; 134 | } 135 | /** 136 | * 设置:发布日期 137 | */ 138 | public void setFaburiqi(Date faburiqi) { 139 | this.faburiqi = faburiqi; 140 | } 141 | /** 142 | * 获取:发布日期 143 | */ 144 | public Date getFaburiqi() { 145 | return faburiqi; 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/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/entity/WendangxinxiEntity.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-04-02 14:39:25 30 | */ 31 | @TableName("wendangxinxi") 32 | public class WendangxinxiEntity implements Serializable { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | public WendangxinxiEntity() { 37 | 38 | } 39 | 40 | public WendangxinxiEntity(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 wendangmingcheng; 59 | 60 | /** 61 | * 类型 62 | */ 63 | 64 | private String leixing; 65 | 66 | /** 67 | * 文档介绍 68 | */ 69 | 70 | private String wendangjieshao; 71 | 72 | /** 73 | * 附件 74 | */ 75 | 76 | private String fujian; 77 | 78 | /** 79 | * 发布日期 80 | */ 81 | 82 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd") 83 | @DateTimeFormat 84 | private Date faburiqi; 85 | 86 | 87 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 88 | @DateTimeFormat 89 | private Date addtime; 90 | 91 | public Date getAddtime() { 92 | return addtime; 93 | } 94 | public void setAddtime(Date addtime) { 95 | this.addtime = addtime; 96 | } 97 | 98 | public Long getId() { 99 | return id; 100 | } 101 | 102 | public void setId(Long id) { 103 | this.id = id; 104 | } 105 | /** 106 | * 设置:文档名称 107 | */ 108 | public void setWendangmingcheng(String wendangmingcheng) { 109 | this.wendangmingcheng = wendangmingcheng; 110 | } 111 | /** 112 | * 获取:文档名称 113 | */ 114 | public String getWendangmingcheng() { 115 | return wendangmingcheng; 116 | } 117 | /** 118 | * 设置:类型 119 | */ 120 | public void setLeixing(String leixing) { 121 | this.leixing = leixing; 122 | } 123 | /** 124 | * 获取:类型 125 | */ 126 | public String getLeixing() { 127 | return leixing; 128 | } 129 | /** 130 | * 设置:文档介绍 131 | */ 132 | public void setWendangjieshao(String wendangjieshao) { 133 | this.wendangjieshao = wendangjieshao; 134 | } 135 | /** 136 | * 获取:文档介绍 137 | */ 138 | public String getWendangjieshao() { 139 | return wendangjieshao; 140 | } 141 | /** 142 | * 设置:附件 143 | */ 144 | public void setFujian(String fujian) { 145 | this.fujian = fujian; 146 | } 147 | /** 148 | * 获取:附件 149 | */ 150 | public String getFujian() { 151 | return fujian; 152 | } 153 | /** 154 | * 设置:发布日期 155 | */ 156 | public void setFaburiqi(Date faburiqi) { 157 | this.faburiqi = faburiqi; 158 | } 159 | /** 160 | * 获取:发布日期 161 | */ 162 | public Date getFaburiqi() { 163 | return faburiqi; 164 | } 165 | 166 | } 167 | -------------------------------------------------------------------------------- /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/vo/YuangongVO.java: -------------------------------------------------------------------------------- 1 | package com.entity.vo; 2 | 3 | import com.entity.YuangongEntity; 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-04-02 14:39:25 20 | */ 21 | public class YuangongVO 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 yuangongxingming; 36 | 37 | /** 38 | * 性别 39 | */ 40 | 41 | private String xingbie; 42 | 43 | /** 44 | * 头像 45 | */ 46 | 47 | private String touxiang; 48 | 49 | /** 50 | * 部门 51 | */ 52 | 53 | private String bumen; 54 | 55 | /** 56 | * 岗位 57 | */ 58 | 59 | private String gangwei; 60 | 61 | /** 62 | * 年龄 63 | */ 64 | 65 | private Integer nianling; 66 | 67 | /** 68 | * 手机 69 | */ 70 | 71 | private String shouji; 72 | 73 | /** 74 | * 邮箱 75 | */ 76 | 77 | private String youxiang; 78 | 79 | /** 80 | * 身份证 81 | */ 82 | 83 | private String shenfenzheng; 84 | 85 | 86 | /** 87 | * 设置:密码 88 | */ 89 | 90 | public void setMima(String mima) { 91 | this.mima = mima; 92 | } 93 | 94 | /** 95 | * 获取:密码 96 | */ 97 | public String getMima() { 98 | return mima; 99 | } 100 | 101 | 102 | /** 103 | * 设置:员工姓名 104 | */ 105 | 106 | public void setYuangongxingming(String yuangongxingming) { 107 | this.yuangongxingming = yuangongxingming; 108 | } 109 | 110 | /** 111 | * 获取:员工姓名 112 | */ 113 | public String getYuangongxingming() { 114 | return yuangongxingming; 115 | } 116 | 117 | 118 | /** 119 | * 设置:性别 120 | */ 121 | 122 | public void setXingbie(String xingbie) { 123 | this.xingbie = xingbie; 124 | } 125 | 126 | /** 127 | * 获取:性别 128 | */ 129 | public String getXingbie() { 130 | return xingbie; 131 | } 132 | 133 | 134 | /** 135 | * 设置:头像 136 | */ 137 | 138 | public void setTouxiang(String touxiang) { 139 | this.touxiang = touxiang; 140 | } 141 | 142 | /** 143 | * 获取:头像 144 | */ 145 | public String getTouxiang() { 146 | return touxiang; 147 | } 148 | 149 | 150 | /** 151 | * 设置:部门 152 | */ 153 | 154 | public void setBumen(String bumen) { 155 | this.bumen = bumen; 156 | } 157 | 158 | /** 159 | * 获取:部门 160 | */ 161 | public String getBumen() { 162 | return bumen; 163 | } 164 | 165 | 166 | /** 167 | * 设置:岗位 168 | */ 169 | 170 | public void setGangwei(String gangwei) { 171 | this.gangwei = gangwei; 172 | } 173 | 174 | /** 175 | * 获取:岗位 176 | */ 177 | public String getGangwei() { 178 | return gangwei; 179 | } 180 | 181 | 182 | /** 183 | * 设置:年龄 184 | */ 185 | 186 | public void setNianling(Integer nianling) { 187 | this.nianling = nianling; 188 | } 189 | 190 | /** 191 | * 获取:年龄 192 | */ 193 | public Integer getNianling() { 194 | return nianling; 195 | } 196 | 197 | 198 | /** 199 | * 设置:手机 200 | */ 201 | 202 | public void setShouji(String shouji) { 203 | this.shouji = shouji; 204 | } 205 | 206 | /** 207 | * 获取:手机 208 | */ 209 | public String getShouji() { 210 | return shouji; 211 | } 212 | 213 | 214 | /** 215 | * 设置:邮箱 216 | */ 217 | 218 | public void setYouxiang(String youxiang) { 219 | this.youxiang = youxiang; 220 | } 221 | 222 | /** 223 | * 获取:邮箱 224 | */ 225 | public String getYouxiang() { 226 | return youxiang; 227 | } 228 | 229 | 230 | /** 231 | * 设置:身份证 232 | */ 233 | 234 | public void setShenfenzheng(String shenfenzheng) { 235 | this.shenfenzheng = shenfenzheng; 236 | } 237 | 238 | /** 239 | * 获取:身份证 240 | */ 241 | public String getShenfenzheng() { 242 | return shenfenzheng; 243 | } 244 | 245 | } 246 | -------------------------------------------------------------------------------- /src/main/java/com/entity/model/YuangongModel.java: -------------------------------------------------------------------------------- 1 | package com.entity.model; 2 | 3 | import com.entity.YuangongEntity; 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-04-02 14:39:25 21 | */ 22 | public class YuangongModel 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 yuangongxingming; 37 | 38 | /** 39 | * 性别 40 | */ 41 | 42 | private String xingbie; 43 | 44 | /** 45 | * 头像 46 | */ 47 | 48 | private String touxiang; 49 | 50 | /** 51 | * 部门 52 | */ 53 | 54 | private String bumen; 55 | 56 | /** 57 | * 岗位 58 | */ 59 | 60 | private String gangwei; 61 | 62 | /** 63 | * 年龄 64 | */ 65 | 66 | private Integer nianling; 67 | 68 | /** 69 | * 手机 70 | */ 71 | 72 | private String shouji; 73 | 74 | /** 75 | * 邮箱 76 | */ 77 | 78 | private String youxiang; 79 | 80 | /** 81 | * 身份证 82 | */ 83 | 84 | private String shenfenzheng; 85 | 86 | 87 | /** 88 | * 设置:密码 89 | */ 90 | 91 | public void setMima(String mima) { 92 | this.mima = mima; 93 | } 94 | 95 | /** 96 | * 获取:密码 97 | */ 98 | public String getMima() { 99 | return mima; 100 | } 101 | 102 | 103 | /** 104 | * 设置:员工姓名 105 | */ 106 | 107 | public void setYuangongxingming(String yuangongxingming) { 108 | this.yuangongxingming = yuangongxingming; 109 | } 110 | 111 | /** 112 | * 获取:员工姓名 113 | */ 114 | public String getYuangongxingming() { 115 | return yuangongxingming; 116 | } 117 | 118 | 119 | /** 120 | * 设置:性别 121 | */ 122 | 123 | public void setXingbie(String xingbie) { 124 | this.xingbie = xingbie; 125 | } 126 | 127 | /** 128 | * 获取:性别 129 | */ 130 | public String getXingbie() { 131 | return xingbie; 132 | } 133 | 134 | 135 | /** 136 | * 设置:头像 137 | */ 138 | 139 | public void setTouxiang(String touxiang) { 140 | this.touxiang = touxiang; 141 | } 142 | 143 | /** 144 | * 获取:头像 145 | */ 146 | public String getTouxiang() { 147 | return touxiang; 148 | } 149 | 150 | 151 | /** 152 | * 设置:部门 153 | */ 154 | 155 | public void setBumen(String bumen) { 156 | this.bumen = bumen; 157 | } 158 | 159 | /** 160 | * 获取:部门 161 | */ 162 | public String getBumen() { 163 | return bumen; 164 | } 165 | 166 | 167 | /** 168 | * 设置:岗位 169 | */ 170 | 171 | public void setGangwei(String gangwei) { 172 | this.gangwei = gangwei; 173 | } 174 | 175 | /** 176 | * 获取:岗位 177 | */ 178 | public String getGangwei() { 179 | return gangwei; 180 | } 181 | 182 | 183 | /** 184 | * 设置:年龄 185 | */ 186 | 187 | public void setNianling(Integer nianling) { 188 | this.nianling = nianling; 189 | } 190 | 191 | /** 192 | * 获取:年龄 193 | */ 194 | public Integer getNianling() { 195 | return nianling; 196 | } 197 | 198 | 199 | /** 200 | * 设置:手机 201 | */ 202 | 203 | public void setShouji(String shouji) { 204 | this.shouji = shouji; 205 | } 206 | 207 | /** 208 | * 获取:手机 209 | */ 210 | public String getShouji() { 211 | return shouji; 212 | } 213 | 214 | 215 | /** 216 | * 设置:邮箱 217 | */ 218 | 219 | public void setYouxiang(String youxiang) { 220 | this.youxiang = youxiang; 221 | } 222 | 223 | /** 224 | * 获取:邮箱 225 | */ 226 | public String getYouxiang() { 227 | return youxiang; 228 | } 229 | 230 | 231 | /** 232 | * 设置:身份证 233 | */ 234 | 235 | public void setShenfenzheng(String shenfenzheng) { 236 | this.shenfenzheng = shenfenzheng; 237 | } 238 | 239 | /** 240 | * 获取:身份证 241 | */ 242 | public String getShenfenzheng() { 243 | return shenfenzheng; 244 | } 245 | 246 | } 247 | -------------------------------------------------------------------------------- /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 | springbootpkh49 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 | -------------------------------------------------------------------------------- /pom-war.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 | springbootpkh49 14 | 0.0.1-SNAPSHOT 15 | springboot-schema 16 | springboot学习框架(war包对应的pom,打war包,执行【mvn clean package -f pom-war.xml】) 17 | war 18 | 19 | 20 | 1.8 21 | 1.2.8 22 | 3.1.1 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | org.mybatis.spring.boot 32 | mybatis-spring-boot-starter 33 | 2.1.1 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-jdbc 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-tomcat 43 | provided 44 | 45 | 46 | 47 | mysql 48 | mysql-connector-java 49 | 50 | 51 | org.apache.shiro 52 | shiro-spring 53 | 1.3.2 54 | 55 | 56 | 57 | com.baomidou 58 | mybatis-plus 59 | 2.3 60 | 61 | 62 | com.baomidou 63 | mybatisplus-spring-boot-starter 64 | 1.0.5 65 | 66 | 67 | com.google.protobuf 68 | protobuf-java 69 | 3.10.0 70 | 71 | 72 | 73 | org.apache.commons 74 | commons-lang3 75 | 3.0 76 | 77 | 78 | 79 | javax.validation 80 | validation-api 81 | 2.0.1.Final 82 | 83 | 84 | 85 | commons-io 86 | commons-io 87 | 2.5 88 | 89 | 90 | 91 | 92 | cn.hutool 93 | hutool-all 94 | 4.0.12 95 | 96 | 97 | 98 | 99 | com.alibaba 100 | fastjson 101 | ${fastjson.version} 102 | 103 | 104 | 105 | com.baidu.aip 106 | java-sdk 107 | 4.4.1 108 | 109 | 110 | 111 | org.springframework.boot 112 | spring-boot-starter-test 113 | test 114 | 115 | 116 | org.junit.vintage 117 | junit-vintage-engine 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | springbootpkh49 126 | 127 | 128 | org.springframework.boot 129 | spring-boot-maven-plugin 130 | 131 | 132 | 133 | org.apache.maven.plugins 134 | maven-surefire-plugin 135 | 136 | true 137 | 138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /src/main/java/com/entity/YuangongEntity.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-04-02 14:39:25 30 | */ 31 | @TableName("yuangong") 32 | public class YuangongEntity implements Serializable { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | public YuangongEntity() { 37 | 38 | } 39 | 40 | public YuangongEntity(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 yuangonggonghao; 59 | 60 | /** 61 | * 密码 62 | */ 63 | 64 | private String mima; 65 | 66 | /** 67 | * 员工姓名 68 | */ 69 | 70 | private String yuangongxingming; 71 | 72 | /** 73 | * 性别 74 | */ 75 | 76 | private String xingbie; 77 | 78 | /** 79 | * 头像 80 | */ 81 | 82 | private String touxiang; 83 | 84 | /** 85 | * 部门 86 | */ 87 | 88 | private String bumen; 89 | 90 | /** 91 | * 岗位 92 | */ 93 | 94 | private String gangwei; 95 | 96 | /** 97 | * 年龄 98 | */ 99 | 100 | private Integer nianling; 101 | 102 | /** 103 | * 手机 104 | */ 105 | 106 | private String shouji; 107 | 108 | /** 109 | * 邮箱 110 | */ 111 | 112 | private String youxiang; 113 | 114 | /** 115 | * 身份证 116 | */ 117 | 118 | private String shenfenzheng; 119 | 120 | 121 | @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 122 | @DateTimeFormat 123 | private Date addtime; 124 | 125 | public Date getAddtime() { 126 | return addtime; 127 | } 128 | public void setAddtime(Date addtime) { 129 | this.addtime = addtime; 130 | } 131 | 132 | public Long getId() { 133 | return id; 134 | } 135 | 136 | public void setId(Long id) { 137 | this.id = id; 138 | } 139 | /** 140 | * 设置:员工工号 141 | */ 142 | public void setYuangonggonghao(String yuangonggonghao) { 143 | this.yuangonggonghao = yuangonggonghao; 144 | } 145 | /** 146 | * 获取:员工工号 147 | */ 148 | public String getYuangonggonghao() { 149 | return yuangonggonghao; 150 | } 151 | /** 152 | * 设置:密码 153 | */ 154 | public void setMima(String mima) { 155 | this.mima = mima; 156 | } 157 | /** 158 | * 获取:密码 159 | */ 160 | public String getMima() { 161 | return mima; 162 | } 163 | /** 164 | * 设置:员工姓名 165 | */ 166 | public void setYuangongxingming(String yuangongxingming) { 167 | this.yuangongxingming = yuangongxingming; 168 | } 169 | /** 170 | * 获取:员工姓名 171 | */ 172 | public String getYuangongxingming() { 173 | return yuangongxingming; 174 | } 175 | /** 176 | * 设置:性别 177 | */ 178 | public void setXingbie(String xingbie) { 179 | this.xingbie = xingbie; 180 | } 181 | /** 182 | * 获取:性别 183 | */ 184 | public String getXingbie() { 185 | return xingbie; 186 | } 187 | /** 188 | * 设置:头像 189 | */ 190 | public void setTouxiang(String touxiang) { 191 | this.touxiang = touxiang; 192 | } 193 | /** 194 | * 获取:头像 195 | */ 196 | public String getTouxiang() { 197 | return touxiang; 198 | } 199 | /** 200 | * 设置:部门 201 | */ 202 | public void setBumen(String bumen) { 203 | this.bumen = bumen; 204 | } 205 | /** 206 | * 获取:部门 207 | */ 208 | public String getBumen() { 209 | return bumen; 210 | } 211 | /** 212 | * 设置:岗位 213 | */ 214 | public void setGangwei(String gangwei) { 215 | this.gangwei = gangwei; 216 | } 217 | /** 218 | * 获取:岗位 219 | */ 220 | public String getGangwei() { 221 | return gangwei; 222 | } 223 | /** 224 | * 设置:年龄 225 | */ 226 | public void setNianling(Integer nianling) { 227 | this.nianling = nianling; 228 | } 229 | /** 230 | * 获取:年龄 231 | */ 232 | public Integer getNianling() { 233 | return nianling; 234 | } 235 | /** 236 | * 设置:手机 237 | */ 238 | public void setShouji(String shouji) { 239 | this.shouji = shouji; 240 | } 241 | /** 242 | * 获取:手机 243 | */ 244 | public String getShouji() { 245 | return shouji; 246 | } 247 | /** 248 | * 设置:邮箱 249 | */ 250 | public void setYouxiang(String youxiang) { 251 | this.youxiang = youxiang; 252 | } 253 | /** 254 | * 获取:邮箱 255 | */ 256 | public String getYouxiang() { 257 | return youxiang; 258 | } 259 | /** 260 | * 设置:身份证 261 | */ 262 | public void setShenfenzheng(String shenfenzheng) { 263 | this.shenfenzheng = shenfenzheng; 264 | } 265 | /** 266 | * 获取:身份证 267 | */ 268 | public String getShenfenzheng() { 269 | return shenfenzheng; 270 | } 271 | 272 | } 273 | -------------------------------------------------------------------------------- /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/controller/GangweiController.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.GangweiEntity; 28 | import com.entity.view.GangweiView; 29 | 30 | import com.service.GangweiService; 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-04-02 14:39:25 45 | */ 46 | @RestController 47 | @RequestMapping("/gangwei") 48 | public class GangweiController { 49 | @Autowired 50 | private GangweiService gangweiService; 51 | 52 | 53 | 54 | /** 55 | * 后端列表 56 | */ 57 | @RequestMapping("/page") 58 | public R page(@RequestParam Map params,GangweiEntity gangwei, 59 | HttpServletRequest request){ 60 | EntityWrapper ew = new EntityWrapper(); 61 | PageUtils page = gangweiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, gangwei), params), params)); 62 | 63 | return R.ok().put("data", page); 64 | } 65 | 66 | /** 67 | * 前端列表 68 | */ 69 | @RequestMapping("/list") 70 | public R list(@RequestParam Map params,GangweiEntity gangwei, HttpServletRequest request){ 71 | EntityWrapper ew = new EntityWrapper(); 72 | PageUtils page = gangweiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, gangwei), params), params)); 73 | return R.ok().put("data", page); 74 | } 75 | 76 | /** 77 | * 列表 78 | */ 79 | @RequestMapping("/lists") 80 | public R list( GangweiEntity gangwei){ 81 | EntityWrapper ew = new EntityWrapper(); 82 | ew.allEq(MPUtil.allEQMapPre( gangwei, "gangwei")); 83 | return R.ok().put("data", gangweiService.selectListView(ew)); 84 | } 85 | 86 | /** 87 | * 查询 88 | */ 89 | @RequestMapping("/query") 90 | public R query(GangweiEntity gangwei){ 91 | EntityWrapper< GangweiEntity> ew = new EntityWrapper< GangweiEntity>(); 92 | ew.allEq(MPUtil.allEQMapPre( gangwei, "gangwei")); 93 | GangweiView gangweiView = gangweiService.selectView(ew); 94 | return R.ok("查询岗位成功").put("data", gangweiView); 95 | } 96 | 97 | /** 98 | * 后端详情 99 | */ 100 | @RequestMapping("/info/{id}") 101 | public R info(@PathVariable("id") Long id){ 102 | GangweiEntity gangwei = gangweiService.selectById(id); 103 | return R.ok().put("data", gangwei); 104 | } 105 | 106 | /** 107 | * 前端详情 108 | */ 109 | @RequestMapping("/detail/{id}") 110 | public R detail(@PathVariable("id") Long id){ 111 | GangweiEntity gangwei = gangweiService.selectById(id); 112 | return R.ok().put("data", gangwei); 113 | } 114 | 115 | 116 | 117 | 118 | /** 119 | * 后端保存 120 | */ 121 | @RequestMapping("/save") 122 | public R save(@RequestBody GangweiEntity gangwei, HttpServletRequest request){ 123 | gangwei.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 124 | //ValidatorUtils.validateEntity(gangwei); 125 | gangweiService.insert(gangwei); 126 | return R.ok(); 127 | } 128 | 129 | /** 130 | * 前端保存 131 | */ 132 | @RequestMapping("/add") 133 | public R add(@RequestBody GangweiEntity gangwei, HttpServletRequest request){ 134 | gangwei.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 135 | //ValidatorUtils.validateEntity(gangwei); 136 | gangweiService.insert(gangwei); 137 | return R.ok(); 138 | } 139 | 140 | /** 141 | * 修改 142 | */ 143 | @RequestMapping("/update") 144 | public R update(@RequestBody GangweiEntity gangwei, HttpServletRequest request){ 145 | //ValidatorUtils.validateEntity(gangwei); 146 | gangweiService.updateById(gangwei);//全部更新 147 | return R.ok(); 148 | } 149 | 150 | 151 | /** 152 | * 删除 153 | */ 154 | @RequestMapping("/delete") 155 | public R delete(@RequestBody Long[] ids){ 156 | gangweiService.deleteBatchIds(Arrays.asList(ids)); 157 | return R.ok(); 158 | } 159 | 160 | /** 161 | * 提醒接口 162 | */ 163 | @RequestMapping("/remind/{columnName}/{type}") 164 | public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 165 | @PathVariable("type") String type,@RequestParam Map map) { 166 | map.put("column", columnName); 167 | map.put("type", type); 168 | 169 | if(type.equals("2")) { 170 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 171 | Calendar c = Calendar.getInstance(); 172 | Date remindStartDate = null; 173 | Date remindEndDate = null; 174 | if(map.get("remindstart")!=null) { 175 | Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); 176 | c.setTime(new Date()); 177 | c.add(Calendar.DAY_OF_MONTH,remindStart); 178 | remindStartDate = c.getTime(); 179 | map.put("remindstart", sdf.format(remindStartDate)); 180 | } 181 | if(map.get("remindend")!=null) { 182 | Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); 183 | c.setTime(new Date()); 184 | c.add(Calendar.DAY_OF_MONTH,remindEnd); 185 | remindEndDate = c.getTime(); 186 | map.put("remindend", sdf.format(remindEndDate)); 187 | } 188 | } 189 | 190 | Wrapper wrapper = new EntityWrapper(); 191 | if(map.get("remindstart")!=null) { 192 | wrapper.ge(columnName, map.get("remindstart")); 193 | } 194 | if(map.get("remindend")!=null) { 195 | wrapper.le(columnName, map.get("remindend")); 196 | } 197 | 198 | 199 | int count = gangweiService.selectCount(wrapper); 200 | return R.ok().put("count", count); 201 | } 202 | 203 | 204 | 205 | } 206 | -------------------------------------------------------------------------------- /src/main/java/com/controller/BumenxinxiController.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.BumenxinxiEntity; 28 | import com.entity.view.BumenxinxiView; 29 | 30 | import com.service.BumenxinxiService; 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-04-02 14:39:25 45 | */ 46 | @RestController 47 | @RequestMapping("/bumenxinxi") 48 | public class BumenxinxiController { 49 | @Autowired 50 | private BumenxinxiService bumenxinxiService; 51 | 52 | 53 | 54 | /** 55 | * 后端列表 56 | */ 57 | @RequestMapping("/page") 58 | public R page(@RequestParam Map params,BumenxinxiEntity bumenxinxi, 59 | HttpServletRequest request){ 60 | EntityWrapper ew = new EntityWrapper(); 61 | PageUtils page = bumenxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, bumenxinxi), params), params)); 62 | 63 | return R.ok().put("data", page); 64 | } 65 | 66 | /** 67 | * 前端列表 68 | */ 69 | @RequestMapping("/list") 70 | public R list(@RequestParam Map params,BumenxinxiEntity bumenxinxi, HttpServletRequest request){ 71 | EntityWrapper ew = new EntityWrapper(); 72 | PageUtils page = bumenxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, bumenxinxi), params), params)); 73 | return R.ok().put("data", page); 74 | } 75 | 76 | /** 77 | * 列表 78 | */ 79 | @RequestMapping("/lists") 80 | public R list( BumenxinxiEntity bumenxinxi){ 81 | EntityWrapper ew = new EntityWrapper(); 82 | ew.allEq(MPUtil.allEQMapPre( bumenxinxi, "bumenxinxi")); 83 | return R.ok().put("data", bumenxinxiService.selectListView(ew)); 84 | } 85 | 86 | /** 87 | * 查询 88 | */ 89 | @RequestMapping("/query") 90 | public R query(BumenxinxiEntity bumenxinxi){ 91 | EntityWrapper< BumenxinxiEntity> ew = new EntityWrapper< BumenxinxiEntity>(); 92 | ew.allEq(MPUtil.allEQMapPre( bumenxinxi, "bumenxinxi")); 93 | BumenxinxiView bumenxinxiView = bumenxinxiService.selectView(ew); 94 | return R.ok("查询部门信息成功").put("data", bumenxinxiView); 95 | } 96 | 97 | /** 98 | * 后端详情 99 | */ 100 | @RequestMapping("/info/{id}") 101 | public R info(@PathVariable("id") Long id){ 102 | BumenxinxiEntity bumenxinxi = bumenxinxiService.selectById(id); 103 | return R.ok().put("data", bumenxinxi); 104 | } 105 | 106 | /** 107 | * 前端详情 108 | */ 109 | @RequestMapping("/detail/{id}") 110 | public R detail(@PathVariable("id") Long id){ 111 | BumenxinxiEntity bumenxinxi = bumenxinxiService.selectById(id); 112 | return R.ok().put("data", bumenxinxi); 113 | } 114 | 115 | 116 | 117 | 118 | /** 119 | * 后端保存 120 | */ 121 | @RequestMapping("/save") 122 | public R save(@RequestBody BumenxinxiEntity bumenxinxi, HttpServletRequest request){ 123 | bumenxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 124 | //ValidatorUtils.validateEntity(bumenxinxi); 125 | bumenxinxiService.insert(bumenxinxi); 126 | return R.ok(); 127 | } 128 | 129 | /** 130 | * 前端保存 131 | */ 132 | @RequestMapping("/add") 133 | public R add(@RequestBody BumenxinxiEntity bumenxinxi, HttpServletRequest request){ 134 | bumenxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 135 | //ValidatorUtils.validateEntity(bumenxinxi); 136 | bumenxinxiService.insert(bumenxinxi); 137 | return R.ok(); 138 | } 139 | 140 | /** 141 | * 修改 142 | */ 143 | @RequestMapping("/update") 144 | public R update(@RequestBody BumenxinxiEntity bumenxinxi, HttpServletRequest request){ 145 | //ValidatorUtils.validateEntity(bumenxinxi); 146 | bumenxinxiService.updateById(bumenxinxi);//全部更新 147 | return R.ok(); 148 | } 149 | 150 | 151 | /** 152 | * 删除 153 | */ 154 | @RequestMapping("/delete") 155 | public R delete(@RequestBody Long[] ids){ 156 | bumenxinxiService.deleteBatchIds(Arrays.asList(ids)); 157 | return R.ok(); 158 | } 159 | 160 | /** 161 | * 提醒接口 162 | */ 163 | @RequestMapping("/remind/{columnName}/{type}") 164 | public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 165 | @PathVariable("type") String type,@RequestParam Map map) { 166 | map.put("column", columnName); 167 | map.put("type", type); 168 | 169 | if(type.equals("2")) { 170 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 171 | Calendar c = Calendar.getInstance(); 172 | Date remindStartDate = null; 173 | Date remindEndDate = null; 174 | if(map.get("remindstart")!=null) { 175 | Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); 176 | c.setTime(new Date()); 177 | c.add(Calendar.DAY_OF_MONTH,remindStart); 178 | remindStartDate = c.getTime(); 179 | map.put("remindstart", sdf.format(remindStartDate)); 180 | } 181 | if(map.get("remindend")!=null) { 182 | Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); 183 | c.setTime(new Date()); 184 | c.add(Calendar.DAY_OF_MONTH,remindEnd); 185 | remindEndDate = c.getTime(); 186 | map.put("remindend", sdf.format(remindEndDate)); 187 | } 188 | } 189 | 190 | Wrapper wrapper = new EntityWrapper(); 191 | if(map.get("remindstart")!=null) { 192 | wrapper.ge(columnName, map.get("remindstart")); 193 | } 194 | if(map.get("remindend")!=null) { 195 | wrapper.le(columnName, map.get("remindend")); 196 | } 197 | 198 | 199 | int count = bumenxinxiService.selectCount(wrapper); 200 | return R.ok().put("count", count); 201 | } 202 | 203 | 204 | 205 | } 206 | -------------------------------------------------------------------------------- /src/main/java/com/controller/GonggaoxinxiController.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.GonggaoxinxiEntity; 28 | import com.entity.view.GonggaoxinxiView; 29 | 30 | import com.service.GonggaoxinxiService; 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-04-02 14:39:25 45 | */ 46 | @RestController 47 | @RequestMapping("/gonggaoxinxi") 48 | public class GonggaoxinxiController { 49 | @Autowired 50 | private GonggaoxinxiService gonggaoxinxiService; 51 | 52 | 53 | 54 | /** 55 | * 后端列表 56 | */ 57 | @RequestMapping("/page") 58 | public R page(@RequestParam Map params,GonggaoxinxiEntity gonggaoxinxi, 59 | HttpServletRequest request){ 60 | EntityWrapper ew = new EntityWrapper(); 61 | PageUtils page = gonggaoxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, gonggaoxinxi), params), params)); 62 | 63 | return R.ok().put("data", page); 64 | } 65 | 66 | /** 67 | * 前端列表 68 | */ 69 | @RequestMapping("/list") 70 | public R list(@RequestParam Map params,GonggaoxinxiEntity gonggaoxinxi, HttpServletRequest request){ 71 | EntityWrapper ew = new EntityWrapper(); 72 | PageUtils page = gonggaoxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, gonggaoxinxi), params), params)); 73 | return R.ok().put("data", page); 74 | } 75 | 76 | /** 77 | * 列表 78 | */ 79 | @RequestMapping("/lists") 80 | public R list( GonggaoxinxiEntity gonggaoxinxi){ 81 | EntityWrapper ew = new EntityWrapper(); 82 | ew.allEq(MPUtil.allEQMapPre( gonggaoxinxi, "gonggaoxinxi")); 83 | return R.ok().put("data", gonggaoxinxiService.selectListView(ew)); 84 | } 85 | 86 | /** 87 | * 查询 88 | */ 89 | @RequestMapping("/query") 90 | public R query(GonggaoxinxiEntity gonggaoxinxi){ 91 | EntityWrapper< GonggaoxinxiEntity> ew = new EntityWrapper< GonggaoxinxiEntity>(); 92 | ew.allEq(MPUtil.allEQMapPre( gonggaoxinxi, "gonggaoxinxi")); 93 | GonggaoxinxiView gonggaoxinxiView = gonggaoxinxiService.selectView(ew); 94 | return R.ok("查询公告信息成功").put("data", gonggaoxinxiView); 95 | } 96 | 97 | /** 98 | * 后端详情 99 | */ 100 | @RequestMapping("/info/{id}") 101 | public R info(@PathVariable("id") Long id){ 102 | GonggaoxinxiEntity gonggaoxinxi = gonggaoxinxiService.selectById(id); 103 | return R.ok().put("data", gonggaoxinxi); 104 | } 105 | 106 | /** 107 | * 前端详情 108 | */ 109 | @RequestMapping("/detail/{id}") 110 | public R detail(@PathVariable("id") Long id){ 111 | GonggaoxinxiEntity gonggaoxinxi = gonggaoxinxiService.selectById(id); 112 | return R.ok().put("data", gonggaoxinxi); 113 | } 114 | 115 | 116 | 117 | 118 | /** 119 | * 后端保存 120 | */ 121 | @RequestMapping("/save") 122 | public R save(@RequestBody GonggaoxinxiEntity gonggaoxinxi, HttpServletRequest request){ 123 | gonggaoxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 124 | //ValidatorUtils.validateEntity(gonggaoxinxi); 125 | gonggaoxinxiService.insert(gonggaoxinxi); 126 | return R.ok(); 127 | } 128 | 129 | /** 130 | * 前端保存 131 | */ 132 | @RequestMapping("/add") 133 | public R add(@RequestBody GonggaoxinxiEntity gonggaoxinxi, HttpServletRequest request){ 134 | gonggaoxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 135 | //ValidatorUtils.validateEntity(gonggaoxinxi); 136 | gonggaoxinxiService.insert(gonggaoxinxi); 137 | return R.ok(); 138 | } 139 | 140 | /** 141 | * 修改 142 | */ 143 | @RequestMapping("/update") 144 | public R update(@RequestBody GonggaoxinxiEntity gonggaoxinxi, HttpServletRequest request){ 145 | //ValidatorUtils.validateEntity(gonggaoxinxi); 146 | gonggaoxinxiService.updateById(gonggaoxinxi);//全部更新 147 | return R.ok(); 148 | } 149 | 150 | 151 | /** 152 | * 删除 153 | */ 154 | @RequestMapping("/delete") 155 | public R delete(@RequestBody Long[] ids){ 156 | gonggaoxinxiService.deleteBatchIds(Arrays.asList(ids)); 157 | return R.ok(); 158 | } 159 | 160 | /** 161 | * 提醒接口 162 | */ 163 | @RequestMapping("/remind/{columnName}/{type}") 164 | public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 165 | @PathVariable("type") String type,@RequestParam Map map) { 166 | map.put("column", columnName); 167 | map.put("type", type); 168 | 169 | if(type.equals("2")) { 170 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 171 | Calendar c = Calendar.getInstance(); 172 | Date remindStartDate = null; 173 | Date remindEndDate = null; 174 | if(map.get("remindstart")!=null) { 175 | Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); 176 | c.setTime(new Date()); 177 | c.add(Calendar.DAY_OF_MONTH,remindStart); 178 | remindStartDate = c.getTime(); 179 | map.put("remindstart", sdf.format(remindStartDate)); 180 | } 181 | if(map.get("remindend")!=null) { 182 | Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); 183 | c.setTime(new Date()); 184 | c.add(Calendar.DAY_OF_MONTH,remindEnd); 185 | remindEndDate = c.getTime(); 186 | map.put("remindend", sdf.format(remindEndDate)); 187 | } 188 | } 189 | 190 | Wrapper wrapper = new EntityWrapper(); 191 | if(map.get("remindstart")!=null) { 192 | wrapper.ge(columnName, map.get("remindstart")); 193 | } 194 | if(map.get("remindend")!=null) { 195 | wrapper.le(columnName, map.get("remindend")); 196 | } 197 | 198 | 199 | int count = gonggaoxinxiService.selectCount(wrapper); 200 | return R.ok().put("count", count); 201 | } 202 | 203 | 204 | 205 | } 206 | -------------------------------------------------------------------------------- /src/main/java/com/controller/WendangxinxiController.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.WendangxinxiEntity; 28 | import com.entity.view.WendangxinxiView; 29 | 30 | import com.service.WendangxinxiService; 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-04-02 14:39:25 45 | */ 46 | @RestController 47 | @RequestMapping("/wendangxinxi") 48 | public class WendangxinxiController { 49 | @Autowired 50 | private WendangxinxiService wendangxinxiService; 51 | 52 | 53 | 54 | /** 55 | * 后端列表 56 | */ 57 | @RequestMapping("/page") 58 | public R page(@RequestParam Map params,WendangxinxiEntity wendangxinxi, 59 | HttpServletRequest request){ 60 | EntityWrapper ew = new EntityWrapper(); 61 | PageUtils page = wendangxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wendangxinxi), params), params)); 62 | 63 | return R.ok().put("data", page); 64 | } 65 | 66 | /** 67 | * 前端列表 68 | */ 69 | @RequestMapping("/list") 70 | public R list(@RequestParam Map params,WendangxinxiEntity wendangxinxi, HttpServletRequest request){ 71 | EntityWrapper ew = new EntityWrapper(); 72 | PageUtils page = wendangxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wendangxinxi), params), params)); 73 | return R.ok().put("data", page); 74 | } 75 | 76 | /** 77 | * 列表 78 | */ 79 | @RequestMapping("/lists") 80 | public R list( WendangxinxiEntity wendangxinxi){ 81 | EntityWrapper ew = new EntityWrapper(); 82 | ew.allEq(MPUtil.allEQMapPre( wendangxinxi, "wendangxinxi")); 83 | return R.ok().put("data", wendangxinxiService.selectListView(ew)); 84 | } 85 | 86 | /** 87 | * 查询 88 | */ 89 | @RequestMapping("/query") 90 | public R query(WendangxinxiEntity wendangxinxi){ 91 | EntityWrapper< WendangxinxiEntity> ew = new EntityWrapper< WendangxinxiEntity>(); 92 | ew.allEq(MPUtil.allEQMapPre( wendangxinxi, "wendangxinxi")); 93 | WendangxinxiView wendangxinxiView = wendangxinxiService.selectView(ew); 94 | return R.ok("查询文档信息成功").put("data", wendangxinxiView); 95 | } 96 | 97 | /** 98 | * 后端详情 99 | */ 100 | @RequestMapping("/info/{id}") 101 | public R info(@PathVariable("id") Long id){ 102 | WendangxinxiEntity wendangxinxi = wendangxinxiService.selectById(id); 103 | return R.ok().put("data", wendangxinxi); 104 | } 105 | 106 | /** 107 | * 前端详情 108 | */ 109 | @RequestMapping("/detail/{id}") 110 | public R detail(@PathVariable("id") Long id){ 111 | WendangxinxiEntity wendangxinxi = wendangxinxiService.selectById(id); 112 | return R.ok().put("data", wendangxinxi); 113 | } 114 | 115 | 116 | 117 | 118 | /** 119 | * 后端保存 120 | */ 121 | @RequestMapping("/save") 122 | public R save(@RequestBody WendangxinxiEntity wendangxinxi, HttpServletRequest request){ 123 | wendangxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 124 | //ValidatorUtils.validateEntity(wendangxinxi); 125 | wendangxinxiService.insert(wendangxinxi); 126 | return R.ok(); 127 | } 128 | 129 | /** 130 | * 前端保存 131 | */ 132 | @RequestMapping("/add") 133 | public R add(@RequestBody WendangxinxiEntity wendangxinxi, HttpServletRequest request){ 134 | wendangxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 135 | //ValidatorUtils.validateEntity(wendangxinxi); 136 | wendangxinxiService.insert(wendangxinxi); 137 | return R.ok(); 138 | } 139 | 140 | /** 141 | * 修改 142 | */ 143 | @RequestMapping("/update") 144 | public R update(@RequestBody WendangxinxiEntity wendangxinxi, HttpServletRequest request){ 145 | //ValidatorUtils.validateEntity(wendangxinxi); 146 | wendangxinxiService.updateById(wendangxinxi);//全部更新 147 | return R.ok(); 148 | } 149 | 150 | 151 | /** 152 | * 删除 153 | */ 154 | @RequestMapping("/delete") 155 | public R delete(@RequestBody Long[] ids){ 156 | wendangxinxiService.deleteBatchIds(Arrays.asList(ids)); 157 | return R.ok(); 158 | } 159 | 160 | /** 161 | * 提醒接口 162 | */ 163 | @RequestMapping("/remind/{columnName}/{type}") 164 | public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 165 | @PathVariable("type") String type,@RequestParam Map map) { 166 | map.put("column", columnName); 167 | map.put("type", type); 168 | 169 | if(type.equals("2")) { 170 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 171 | Calendar c = Calendar.getInstance(); 172 | Date remindStartDate = null; 173 | Date remindEndDate = null; 174 | if(map.get("remindstart")!=null) { 175 | Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); 176 | c.setTime(new Date()); 177 | c.add(Calendar.DAY_OF_MONTH,remindStart); 178 | remindStartDate = c.getTime(); 179 | map.put("remindstart", sdf.format(remindStartDate)); 180 | } 181 | if(map.get("remindend")!=null) { 182 | Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); 183 | c.setTime(new Date()); 184 | c.add(Calendar.DAY_OF_MONTH,remindEnd); 185 | remindEndDate = c.getTime(); 186 | map.put("remindend", sdf.format(remindEndDate)); 187 | } 188 | } 189 | 190 | Wrapper wrapper = new EntityWrapper(); 191 | if(map.get("remindstart")!=null) { 192 | wrapper.ge(columnName, map.get("remindstart")); 193 | } 194 | if(map.get("remindend")!=null) { 195 | wrapper.le(columnName, map.get("remindend")); 196 | } 197 | 198 | 199 | int count = wendangxinxiService.selectCount(wrapper); 200 | return R.ok().put("count", count); 201 | } 202 | 203 | 204 | 205 | } 206 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /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 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 224 | for(Map m : result) { 225 | for(String k : m.keySet()) { 226 | if(m.get(k) instanceof Date) { 227 | m.put(k, sdf.format((Date)m.get(k))); 228 | } 229 | } 230 | } 231 | return R.ok().put("data", result); 232 | } 233 | 234 | /** 235 | * (按值统计) 236 | */ 237 | @IgnoreAuth 238 | @RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}") 239 | public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName) { 240 | Map params = new HashMap(); 241 | params.put("table", tableName); 242 | params.put("xColumn", xColumnName); 243 | params.put("yColumn", yColumnName); 244 | List> result = commonService.selectValue(params); 245 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 246 | for(Map m : result) { 247 | for(String k : m.keySet()) { 248 | if(m.get(k) instanceof Date) { 249 | m.put(k, sdf.format((Date)m.get(k))); 250 | } 251 | } 252 | } 253 | return R.ok().put("data", result); 254 | } 255 | 256 | } 257 | -------------------------------------------------------------------------------- /src/main/java/com/controller/YuangongController.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.YuangongEntity; 28 | import com.entity.view.YuangongView; 29 | 30 | import com.service.YuangongService; 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-04-02 14:39:25 45 | */ 46 | @RestController 47 | @RequestMapping("/yuangong") 48 | public class YuangongController { 49 | @Autowired 50 | private YuangongService yuangongService; 51 | 52 | @Autowired 53 | private TokenService tokenService; 54 | 55 | /** 56 | * 登录 57 | */ 58 | @IgnoreAuth 59 | @RequestMapping(value = "/login") 60 | public R login(String username, String password, String captcha, HttpServletRequest request) { 61 | YuangongEntity user = yuangongService.selectOne(new EntityWrapper().eq("yuangonggonghao", username)); 62 | if(user==null || !user.getMima().equals(password)) { 63 | return R.error("账号或密码不正确"); 64 | } 65 | 66 | String token = tokenService.generateToken(user.getId(), username,"yuangong", "员工" ); 67 | return R.ok().put("token", token); 68 | } 69 | 70 | /** 71 | * 注册 72 | */ 73 | @IgnoreAuth 74 | @RequestMapping("/register") 75 | public R register(@RequestBody YuangongEntity yuangong){ 76 | //ValidatorUtils.validateEntity(yuangong); 77 | YuangongEntity user = yuangongService.selectOne(new EntityWrapper().eq("yuangonggonghao", yuangong.getYuangonggonghao())); 78 | if(user!=null) { 79 | return R.error("注册用户已存在"); 80 | } 81 | Long uId = new Date().getTime(); 82 | yuangong.setId(uId); 83 | yuangongService.insert(yuangong); 84 | return R.ok(); 85 | } 86 | 87 | /** 88 | * 退出 89 | */ 90 | @RequestMapping("/logout") 91 | public R logout(HttpServletRequest request) { 92 | request.getSession().invalidate(); 93 | return R.ok("退出成功"); 94 | } 95 | 96 | /** 97 | * 获取用户的session用户信息 98 | */ 99 | @RequestMapping("/session") 100 | public R getCurrUser(HttpServletRequest request){ 101 | Long id = (Long)request.getSession().getAttribute("userId"); 102 | YuangongEntity user = yuangongService.selectById(id); 103 | return R.ok().put("data", user); 104 | } 105 | 106 | /** 107 | * 密码重置 108 | */ 109 | @IgnoreAuth 110 | @RequestMapping(value = "/resetPass") 111 | public R resetPass(String username, HttpServletRequest request){ 112 | YuangongEntity user = yuangongService.selectOne(new EntityWrapper().eq("yuangonggonghao", username)); 113 | if(user==null) { 114 | return R.error("账号不存在"); 115 | } 116 | user.setMima("123456"); 117 | yuangongService.updateById(user); 118 | return R.ok("密码已重置为:123456"); 119 | } 120 | 121 | 122 | /** 123 | * 后端列表 124 | */ 125 | @RequestMapping("/page") 126 | public R page(@RequestParam Map params,YuangongEntity yuangong, 127 | HttpServletRequest request){ 128 | EntityWrapper ew = new EntityWrapper(); 129 | PageUtils page = yuangongService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yuangong), params), params)); 130 | 131 | return R.ok().put("data", page); 132 | } 133 | 134 | /** 135 | * 前端列表 136 | */ 137 | @RequestMapping("/list") 138 | public R list(@RequestParam Map params,YuangongEntity yuangong, HttpServletRequest request){ 139 | EntityWrapper ew = new EntityWrapper(); 140 | PageUtils page = yuangongService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yuangong), params), params)); 141 | return R.ok().put("data", page); 142 | } 143 | 144 | /** 145 | * 列表 146 | */ 147 | @RequestMapping("/lists") 148 | public R list( YuangongEntity yuangong){ 149 | EntityWrapper ew = new EntityWrapper(); 150 | ew.allEq(MPUtil.allEQMapPre( yuangong, "yuangong")); 151 | return R.ok().put("data", yuangongService.selectListView(ew)); 152 | } 153 | 154 | /** 155 | * 查询 156 | */ 157 | @RequestMapping("/query") 158 | public R query(YuangongEntity yuangong){ 159 | EntityWrapper< YuangongEntity> ew = new EntityWrapper< YuangongEntity>(); 160 | ew.allEq(MPUtil.allEQMapPre( yuangong, "yuangong")); 161 | YuangongView yuangongView = yuangongService.selectView(ew); 162 | return R.ok("查询员工成功").put("data", yuangongView); 163 | } 164 | 165 | /** 166 | * 后端详情 167 | */ 168 | @RequestMapping("/info/{id}") 169 | public R info(@PathVariable("id") Long id){ 170 | YuangongEntity yuangong = yuangongService.selectById(id); 171 | return R.ok().put("data", yuangong); 172 | } 173 | 174 | /** 175 | * 前端详情 176 | */ 177 | @RequestMapping("/detail/{id}") 178 | public R detail(@PathVariable("id") Long id){ 179 | YuangongEntity yuangong = yuangongService.selectById(id); 180 | return R.ok().put("data", yuangong); 181 | } 182 | 183 | 184 | 185 | 186 | /** 187 | * 后端保存 188 | */ 189 | @RequestMapping("/save") 190 | public R save(@RequestBody YuangongEntity yuangong, HttpServletRequest request){ 191 | yuangong.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 192 | //ValidatorUtils.validateEntity(yuangong); 193 | YuangongEntity user = yuangongService.selectOne(new EntityWrapper().eq("yuangonggonghao", yuangong.getYuangonggonghao())); 194 | if(user!=null) { 195 | return R.error("用户已存在"); 196 | } 197 | yuangong.setId(new Date().getTime()); 198 | yuangongService.insert(yuangong); 199 | return R.ok(); 200 | } 201 | 202 | /** 203 | * 前端保存 204 | */ 205 | @RequestMapping("/add") 206 | public R add(@RequestBody YuangongEntity yuangong, HttpServletRequest request){ 207 | yuangong.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); 208 | //ValidatorUtils.validateEntity(yuangong); 209 | YuangongEntity user = yuangongService.selectOne(new EntityWrapper().eq("yuangonggonghao", yuangong.getYuangonggonghao())); 210 | if(user!=null) { 211 | return R.error("用户已存在"); 212 | } 213 | yuangong.setId(new Date().getTime()); 214 | yuangongService.insert(yuangong); 215 | return R.ok(); 216 | } 217 | 218 | /** 219 | * 修改 220 | */ 221 | @RequestMapping("/update") 222 | public R update(@RequestBody YuangongEntity yuangong, HttpServletRequest request){ 223 | //ValidatorUtils.validateEntity(yuangong); 224 | yuangongService.updateById(yuangong);//全部更新 225 | return R.ok(); 226 | } 227 | 228 | 229 | /** 230 | * 删除 231 | */ 232 | @RequestMapping("/delete") 233 | public R delete(@RequestBody Long[] ids){ 234 | yuangongService.deleteBatchIds(Arrays.asList(ids)); 235 | return R.ok(); 236 | } 237 | 238 | /** 239 | * 提醒接口 240 | */ 241 | @RequestMapping("/remind/{columnName}/{type}") 242 | public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 243 | @PathVariable("type") String type,@RequestParam Map map) { 244 | map.put("column", columnName); 245 | map.put("type", type); 246 | 247 | if(type.equals("2")) { 248 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 249 | Calendar c = Calendar.getInstance(); 250 | Date remindStartDate = null; 251 | Date remindEndDate = null; 252 | if(map.get("remindstart")!=null) { 253 | Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); 254 | c.setTime(new Date()); 255 | c.add(Calendar.DAY_OF_MONTH,remindStart); 256 | remindStartDate = c.getTime(); 257 | map.put("remindstart", sdf.format(remindStartDate)); 258 | } 259 | if(map.get("remindend")!=null) { 260 | Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); 261 | c.setTime(new Date()); 262 | c.add(Calendar.DAY_OF_MONTH,remindEnd); 263 | remindEndDate = c.getTime(); 264 | map.put("remindend", sdf.format(remindEndDate)); 265 | } 266 | } 267 | 268 | Wrapper wrapper = new EntityWrapper(); 269 | if(map.get("remindstart")!=null) { 270 | wrapper.ge(columnName, map.get("remindstart")); 271 | } 272 | if(map.get("remindend")!=null) { 273 | wrapper.le(columnName, map.get("remindend")); 274 | } 275 | 276 | 277 | int count = yuangongService.selectCount(wrapper); 278 | return R.ok().put("count", count); 279 | } 280 | 281 | 282 | 283 | } 284 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | --------------------------------------------------------------------------------