mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-21 02:25:56 +08:00
Pre Merge pull request !404 from lijiluncsdn/4.X
This commit is contained in:
commit
8771df4696
@ -121,6 +121,7 @@
|
||||
|
||||
### 其他
|
||||
|
||||
|
||||
* 同步升级 RuoYi-Vue
|
||||
* GitHub 地址 [RuoYi-Vue-Plus-github](https://github.com/dromara/RuoYi-Vue-Plus)
|
||||
* 单模块 分支 [RuoYi-Vue-Plus-fast](https://gitee.com/dromara/RuoYi-Vue-Plus/tree/fast/)
|
||||
|
||||
80
pom.xml
80
pom.xml
@ -39,6 +39,7 @@
|
||||
<bouncycastle.version>1.72</bouncycastle.version>
|
||||
<!-- 离线IP地址定位库 -->
|
||||
<ip2region.version>2.7.0</ip2region.version>
|
||||
<commons.fileupload.version>1.4</commons.fileupload.version>
|
||||
|
||||
<!-- 临时修复 snakeyaml 漏洞 -->
|
||||
<snakeyaml.version>1.33</snakeyaml.version>
|
||||
@ -118,6 +119,12 @@
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<!-- 文件上传工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>${commons.fileupload.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
@ -324,6 +331,12 @@
|
||||
<version>${ruoyi-vue-plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-text</artifactId>
|
||||
<version>1.9</version>
|
||||
</dependency>
|
||||
|
||||
<!-- demo模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
@ -331,6 +344,68 @@
|
||||
<version>${ruoyi-vue-plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 工作模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-work</artifactId>
|
||||
<version>${ruoyi-vue-plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 文件上传模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-file</artifactId>
|
||||
<version>${ruoyi-vue-plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-rabbitmq</artifactId>
|
||||
<version>${ruoyi-vue-plus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
<version>2.7.9</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Sa-Token 插件:整合SSO -->
|
||||
<!--<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-sso</artifactId>
|
||||
<version>${satoken.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-dao-redis-jackson</artifactId>
|
||||
<version>${satoken.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
<version>2.11.1</version>
|
||||
</dependency>-->
|
||||
|
||||
<!-- 视图引擎(在前后端不分离模式下提供视图支持) -->
|
||||
<!--<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>-->
|
||||
|
||||
<!-- Http请求工具(在模式三的单点注销功能下用到,如不需要可以注释掉) -->
|
||||
<!--<dependency>
|
||||
<groupId>com.dtflys.forest</groupId>
|
||||
<artifactId>forest-spring-boot-starter</artifactId>
|
||||
<version>1.5.26</version>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-core</artifactId>
|
||||
<version>4.2.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
@ -345,6 +420,11 @@
|
||||
<module>ruoyi-extend</module>
|
||||
<module>ruoyi-oss</module>
|
||||
<module>ruoyi-sms</module>
|
||||
<module>ruoyi-work</module>
|
||||
<module>ruoyi-file</module>
|
||||
<module>ruoyi-rabbitmq</module>
|
||||
|
||||
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
@ -78,12 +78,29 @@
|
||||
<artifactId>ruoyi-demo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-work</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-file</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-rabbitmq</artifactId>
|
||||
</dependency>-->
|
||||
|
||||
<!-- skywalking 整合 logback -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.skywalking</groupId>-->
|
||||
@ -95,6 +112,11 @@
|
||||
<!-- <artifactId>apm-toolkit-trace</artifactId>-->
|
||||
<!-- <version>${与你的agent探针版本保持一致}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-core</artifactId>
|
||||
<version>4.2.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ public class RuoYiApplication {
|
||||
application.setApplicationStartup(new BufferingApplicationStartup(2048));
|
||||
application.run(args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ RuoYi-Vue-Plus启动成功 ლ(´ڡ`ლ)゙");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,11 +4,18 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.captcha.AbstractCaptcha;
|
||||
import cn.hutool.captcha.generator.CodeGenerator;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.annotation.RateLimiter;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.enums.CaptchaType;
|
||||
import com.ruoyi.common.enums.LimitType;
|
||||
import com.ruoyi.common.enums.UserStatus;
|
||||
import com.ruoyi.common.exception.user.UserException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.email.MailUtils;
|
||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||
@ -16,13 +23,12 @@ import com.ruoyi.common.utils.reflect.ReflectUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.framework.config.properties.CaptchaProperties;
|
||||
import com.ruoyi.framework.config.properties.MailProperties;
|
||||
import com.ruoyi.sms.core.TelecomSendMsg;
|
||||
import com.ruoyi.sms.entity.SmsResult;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.sms4j.api.SmsBlend;
|
||||
import org.dromara.sms4j.api.entity.SmsResponse;
|
||||
import org.dromara.sms4j.core.factory.SmsFactory;
|
||||
import org.dromara.sms4j.provider.enumerate.SupplierType;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
@ -33,7 +39,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -51,28 +56,37 @@ public class CaptchaController {
|
||||
private final CaptchaProperties captchaProperties;
|
||||
private final ISysConfigService configService;
|
||||
private final MailProperties mailProperties;
|
||||
private final SysUserMapper sysUserMapper;
|
||||
|
||||
/**
|
||||
* 短信验证码
|
||||
*
|
||||
* @param phonenumber 用户手机号
|
||||
* @param username 用户手机号
|
||||
*/
|
||||
@GetMapping("/captchaSms")
|
||||
public R<Void> smsCaptcha(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) {
|
||||
String key = CacheConstants.CAPTCHA_CODE_KEY + phonenumber;
|
||||
String code = RandomUtil.randomNumbers(4);
|
||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
// 验证码模板id 自行处理 (查数据库或写死均可)
|
||||
String templateId = "";
|
||||
LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
|
||||
map.put("code", code);
|
||||
SmsBlend smsBlend = SmsFactory.createSmsBlend(SupplierType.ALIBABA);
|
||||
SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, templateId, map);
|
||||
if (!"OK".equals(smsResponse.getCode())) {
|
||||
log.error("验证码短信发送异常 => {}", smsResponse);
|
||||
return R.fail(smsResponse.getMessage());
|
||||
public R<Void> smsCaptcha(@NotBlank(message = "{user.phonenumber.not.blank}") String username) {
|
||||
//判断系统中是否存在该人才
|
||||
SysUser user = sysUserMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getPhonenumber, SysUser::getStatus)
|
||||
.eq(SysUser::getPhonenumber, username));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UserException("user.not.exists", username);
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", username);
|
||||
throw new UserException("user.blocked", username);
|
||||
}
|
||||
return R.ok();
|
||||
String key = CacheConstants.CAPTCHA_CODE_KEY + username;
|
||||
String code = RandomUtil.randomNumbers(6);
|
||||
System.out.println("code = " + code);
|
||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
TelecomSendMsg smsTemplate = SpringUtils.getBean(TelecomSendMsg.class);
|
||||
SmsResult result = smsTemplate.telecomSendCode(username, code, "login");
|
||||
if (!result.isSuccess()) {
|
||||
log.error("验证码短信发送异常 => {}", result);
|
||||
return R.fail(result.getMessage());
|
||||
}
|
||||
return R.ok("发送成功");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
package com.ruoyi.web.controller.common;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import com.ruoyi.file.service.ISysFileService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文件请求处理
|
||||
*
|
||||
* @author ruoyi*/
|
||||
|
||||
|
||||
@RestController
|
||||
public class SysFileController
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
|
||||
|
||||
@Autowired
|
||||
private ISysFileService sysFileService;
|
||||
|
||||
/*文件上传请求*/
|
||||
|
||||
|
||||
@PostMapping("upload")
|
||||
public R<Map> upload(MultipartFile file)
|
||||
{
|
||||
try{
|
||||
// 上传并返回访问地址
|
||||
String url = sysFileService.uploadFile(file);
|
||||
Map<String, String> map = new HashMap<>(2);
|
||||
map.put("url", url);
|
||||
map.put("fileName", FileUtils.getName(url));
|
||||
return R.ok(map);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("上传文件失败", e);
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,189 @@
|
||||
package com.ruoyi.web.controller.house;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.system.domain.BuyHouses;
|
||||
import com.ruoyi.system.domain.dto.BuyHousesEvent;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.vo.BuyHousesVo;
|
||||
import com.ruoyi.system.domain.bo.BuyHousesBo;
|
||||
import com.ruoyi.system.service.IBuyHousesService;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 一期后台接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-03-27
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/house")
|
||||
public class BuyHousesController extends BaseController {
|
||||
|
||||
private final IBuyHousesService iBuyHousesService;
|
||||
|
||||
/**
|
||||
* 一期后台接口查询列表
|
||||
*/
|
||||
@SaCheckPermission("system:houses:list")
|
||||
@Log(title = "获取数据库一期数据", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<BuyHousesVo> list(BuyHousesBo bo, PageQuery pageQuery) {
|
||||
return iBuyHousesService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预约导出
|
||||
* @param bo
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@SaCheckPermission("system:houses:subscribeExport")
|
||||
@PostMapping("/subscribeExport")
|
||||
public R subscribeExport(@RequestBody BuyHousesEvent bo) throws IOException {
|
||||
return iBuyHousesService.subscribeExport(bo);
|
||||
}
|
||||
/**
|
||||
* 导出excel
|
||||
*/
|
||||
@SaCheckPermission("system:houses:exportExcel")
|
||||
@PostMapping("/exportExcel")
|
||||
public void exportExcel(BuyHousesBo bo,HttpServletResponse response){
|
||||
iBuyHousesService.exportExcel(bo,response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 一期导出列表
|
||||
*/
|
||||
@SaCheckPermission("system:houses:export")
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("一期导出列表")
|
||||
public void export(BuyHousesBo bo, HttpServletResponse response) {
|
||||
List<BuyHousesVo> list = iBuyHousesService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "一期导出列表", BuyHousesVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system:houses:query")
|
||||
@GetMapping
|
||||
public R<BuyHousesVo> getInfo(Long id) {
|
||||
return R.ok(iBuyHousesService.queryById(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("system:houses:remove")
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")Long[] ids) {
|
||||
return toAjax(iBuyHousesService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取申报材料
|
||||
*/
|
||||
@Log(title = "获取申报材料",businessType = BusinessType.OTHER)
|
||||
@PostMapping("/review/material")
|
||||
public R<?> getMaterialInfo(@RequestBody BuyHousesBo bo){
|
||||
return iBuyHousesService.getMaterialInfo(bo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取消资格
|
||||
* @param buyHouses
|
||||
* @return
|
||||
*/
|
||||
@SaCheckPermission("system:houses:edit")
|
||||
@PutMapping
|
||||
public R<?>updateBuyHouses(@RequestBody BuyHouses buyHouses){
|
||||
return iBuyHousesService.updateBuyHouses(buyHouses);
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页购房申请表展示
|
||||
*/
|
||||
// @SaCheckPermission("system:houses:indexType")
|
||||
@GetMapping("/indexType")
|
||||
public R<?>getIndexType(){
|
||||
return iBuyHousesService.getIndexType();
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页企业所在地展示
|
||||
*/
|
||||
// @SaCheckPermission("system:houses:companyDistrict")
|
||||
@GetMapping("/companyDistrict")
|
||||
public R<?>getCompanyDistrict(){
|
||||
return iBuyHousesService.getCompanyDistrict();
|
||||
}
|
||||
/**
|
||||
* 首页国籍和婚姻状态展示
|
||||
*/
|
||||
// @SaCheckPermission("system:houses:nationalityAndMarital")
|
||||
@GetMapping("/nationalityAndMarital")
|
||||
public R<?>getNationalityAndMarital(){
|
||||
return iBuyHousesService.getNationalityAndMarital();
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页第一排基础数据
|
||||
*/
|
||||
// @SaCheckPermission("system:houses:basicData")
|
||||
@GetMapping("/basicData")
|
||||
public R getBasicData(){
|
||||
return iBuyHousesService.getBasicData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复审柱状图
|
||||
*/
|
||||
// @SaCheckPermission("system:houses:histogram")
|
||||
@GetMapping("/histogram")
|
||||
public R getHistogram(String date){
|
||||
return iBuyHousesService.getHistogram(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对市局系统单独推送
|
||||
*/
|
||||
@GetMapping("/push")
|
||||
public R push(String id) throws ParseException {
|
||||
return iBuyHousesService.push(id);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/out")
|
||||
public R logout(String id){
|
||||
return iBuyHousesService.logout(id);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,253 @@
|
||||
package com.ruoyi.web.controller.house;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.excel.ExcelResult;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.BuyHouses;
|
||||
import com.ruoyi.system.domain.HousesReview;
|
||||
import com.ruoyi.system.domain.bo.HousesReviewBo;
|
||||
import com.ruoyi.system.domain.dto.HousesReviewEvent;
|
||||
import com.ruoyi.system.domain.vo.HousesReviewVo;
|
||||
import com.ruoyi.system.mapper.BuyHousesMapper;
|
||||
import com.ruoyi.system.service.IHousesReviewService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 购房复审登记
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-03-08
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/house")
|
||||
public class HousesReviewController extends BaseController {
|
||||
|
||||
private final IHousesReviewService iHousesReviewService;
|
||||
private final BuyHousesMapper buyHousesMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 购房登记录入列表
|
||||
* @param bo
|
||||
* @param pageQuery
|
||||
* @return
|
||||
*/
|
||||
@SaCheckPermission("system:review:reviewList")
|
||||
@GetMapping("/review/list")
|
||||
public TableDataInfo<HousesReview> reviewList(HousesReviewBo bo, PageQuery pageQuery) {
|
||||
return iHousesReviewService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 购房登记录入管理列表
|
||||
* @param bo
|
||||
* @param pageQuery
|
||||
* @return
|
||||
*/
|
||||
@SaCheckPermission("system:manager:reviewList")
|
||||
@GetMapping("/manager/list")
|
||||
public TableDataInfo<HousesReview> managerReviewList(HousesReviewBo bo, PageQuery pageQuery) {
|
||||
return iHousesReviewService.managerQueryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预约导出
|
||||
* @param bo
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@SaCheckPermission("system:houses:subscribeExport")
|
||||
@PostMapping("/subscribeExport")
|
||||
public R subscribeExport(@RequestBody HousesReviewEvent bo) throws IOException {
|
||||
return iHousesReviewService.subscribeExport(bo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*/
|
||||
@SaCheckPermission("system:houses:exportExcel")
|
||||
@PostMapping("/exportExcel")
|
||||
public void exportExcel(HousesReviewBo bo,HttpServletResponse response){
|
||||
iHousesReviewService.exportExcel(bo,response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询购房复审登记列表
|
||||
*/
|
||||
@SaCheckPermission("system:review:list")
|
||||
@GetMapping("/registrationManagement/list")
|
||||
public TableDataInfo<HousesReview> list(HousesReviewBo bo, PageQuery pageQuery) {
|
||||
boolean admin = LoginHelper.isAdmin();
|
||||
if (!admin){
|
||||
bo.setProjectName(LoginHelper.getLoginUser().getProperties());
|
||||
}
|
||||
return iHousesReviewService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出购房复审登记列表
|
||||
*/
|
||||
@SaCheckPermission("system:review:export")
|
||||
@Log(title = "购房复审登记", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/registrationManagement/export")
|
||||
public void export(HousesReviewBo bo, HttpServletResponse response) {
|
||||
List<HousesReviewVo> list = iHousesReviewService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "购房复审登记", HousesReviewVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取购房复审登记详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system:review:edit")
|
||||
@GetMapping("/registrationManagement")
|
||||
public R<HousesReviewVo> getInfo(Long id) {
|
||||
return R.ok(iHousesReviewService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增购房复审登记
|
||||
*/
|
||||
@SaCheckPermission("system:review:add")
|
||||
@Log(title = "购房复审登记", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/registrationManagement")
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody HousesReviewBo bo) {
|
||||
return toAjax(iHousesReviewService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改购房复审登记
|
||||
*/
|
||||
@SaCheckPermission("system:review:edit")
|
||||
@Log(title = "购房复审登记", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/registrationManagement")
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody HousesReviewBo bo) {
|
||||
return toAjax(iHousesReviewService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除购房复审登记
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("system:review:remove")
|
||||
@Log(title = "购房复审登记", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/review")
|
||||
public R<Void> remove(Long[] ids) {
|
||||
return toAjax(iHousesReviewService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入
|
||||
* @param file
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Log(title = "购房复审导入", businessType = BusinessType.IMPORT)
|
||||
@SaCheckPermission("system:review:import")
|
||||
@PostMapping(value = "/review/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<Void> importData(@RequestPart("file") MultipartFile file) throws Exception {
|
||||
ExcelResult<HousesReviewVo> result = ExcelUtil.importExcel(file.getInputStream(), HousesReviewVo.class, true,3);
|
||||
List<HousesReviewVo> volist = result.getList();
|
||||
//判断时间格式是否正确
|
||||
volist.stream().forEach(v ->{
|
||||
if (!DateUtils.checkDate(v.getQualificationConfirmTime(),DateUtils.YYYY_MM_DD_HH_MM_SS)){
|
||||
throw new ServiceException("资格确认时间格式不正确,格式为:"+DateUtils.YYYY_MM_DD_HH_MM_SS);
|
||||
}
|
||||
if (!DateUtils.checkDate(v.getAuditTime(),DateUtils.YYYY_MM_DD)){
|
||||
throw new ServiceException("审核时间格式不正确,格式为:"+DateUtils.YYYY_MM_DD);
|
||||
}
|
||||
if (!DateUtils.checkDate(v.getRegisterFailureTime(),DateUtils.YYYY_MM_DD)){
|
||||
throw new ServiceException("登记失效时间格式不正确,格式为:"+DateUtils.YYYY_MM_DD);
|
||||
}
|
||||
});
|
||||
|
||||
List<HousesReview> list = BeanUtil.copyToList(volist, HousesReview.class);
|
||||
//先获取到导入数据的身份证去购房一期数据库去查
|
||||
//过滤出导入表中的身份证号码
|
||||
List<String> collect = list.stream()
|
||||
.filter( e ->ObjectUtil.isNotEmpty(e.getCard()))
|
||||
.map(HousesReview::getCard)
|
||||
.collect(Collectors.toList());
|
||||
if (collect.size()>0 && list.size()>0) {
|
||||
LambdaQueryWrapper<BuyHouses> queryWrapper = new LambdaQueryWrapper<BuyHouses>()
|
||||
.in(BuyHouses::getCardId, collect)
|
||||
.eq(BuyHouses::getProcessStatus,Constants.SUCCEED);
|
||||
//查询出导入数据中的身份证有那些是属于区级人才的
|
||||
List<String> collect1 = buyHousesMapper.selectList(queryWrapper)
|
||||
.stream()
|
||||
.map(BuyHouses::getCardId)
|
||||
.collect(Collectors.toList());
|
||||
for (HousesReview housesReview : list) {
|
||||
housesReview.setProcessKey("house_review");
|
||||
housesReview.setProcessStatus(Constants.SUBMIT);
|
||||
if ( collect1.size() > 0 && collect1.contains(housesReview.getCard()) ) {
|
||||
housesReview.setSourceBy("1");
|
||||
} else {
|
||||
housesReview.setSourceBy("2");
|
||||
}
|
||||
}
|
||||
}
|
||||
iHousesReviewService.saveBatch(list);
|
||||
return R.ok(result.getAnalysis());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入模板
|
||||
*/
|
||||
@Log(title = "获取导入模板", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/review/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
ExcelUtil.exportExcel(new ArrayList<>(), "用户数据", HousesReviewVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取申报材料
|
||||
*/
|
||||
@Log(title = "获取申报材料",businessType = BusinessType.OTHER)
|
||||
@PostMapping("/review/material")
|
||||
public R<?> getMaterialInfo(@RequestBody HousesReviewBo bo){
|
||||
return iHousesReviewService.getMaterialInfo(bo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取审核材料
|
||||
*/
|
||||
@Log(title = "审核时返回当前人材料",businessType = BusinessType.OTHER)
|
||||
@GetMapping("/getMaterial")
|
||||
public R<?> getMaterialByBusinessId(Long id){
|
||||
return iHousesReviewService.getMaterialByBusinessId(id);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
package com.ruoyi.web.controller.material;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.bo.MaterialModuleBo;
|
||||
import com.ruoyi.system.domain.vo.MaterialModuleVo;
|
||||
import com.ruoyi.system.service.IMaterialModuleService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 材料模块
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-03-09
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/material/module")
|
||||
public class MaterialModuleController extends BaseController {
|
||||
|
||||
private final IMaterialModuleService iMaterialModuleService;
|
||||
|
||||
/**
|
||||
* 查询材料模块列表
|
||||
*/
|
||||
@SaCheckPermission("material:module:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<MaterialModuleVo> list(MaterialModuleBo bo, PageQuery pageQuery) {
|
||||
return iMaterialModuleService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
@SaCheckPermission("material:materialList:list")
|
||||
@GetMapping("/materialList")
|
||||
public R<?> materialList(MaterialModuleBo bo) {
|
||||
return iMaterialModuleService.selectMaterialList(bo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出材料模块列表
|
||||
*/
|
||||
@SaCheckPermission("material:module:export")
|
||||
@Log(title = "材料模块", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(MaterialModuleBo bo, HttpServletResponse response) {
|
||||
List<MaterialModuleVo> list = iMaterialModuleService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "材料模块", MaterialModuleVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取材料模块详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("material:module:query")
|
||||
@GetMapping
|
||||
public R<MaterialModuleVo> getInfo(Long id) {
|
||||
return R.ok(iMaterialModuleService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增材料模块
|
||||
*/
|
||||
@SaCheckPermission("material:module:add")
|
||||
@Log(title = "材料模块", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody MaterialModuleBo bo) {
|
||||
return toAjax(iMaterialModuleService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改材料模块
|
||||
*/
|
||||
@SaCheckPermission("material:module:edit")
|
||||
@Log(title = "材料模块", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody MaterialModuleBo bo) {
|
||||
return toAjax(iMaterialModuleService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除材料模块
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("material:module:remove")
|
||||
@Log(title = "材料模块", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping
|
||||
public R<Void> remove(Long[] ids) {
|
||||
return toAjax(iMaterialModuleService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
package com.ruoyi.web.controller.material;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.bo.MaterialTalentsBo;
|
||||
import com.ruoyi.system.domain.vo.MaterialTalentsVo;
|
||||
import com.ruoyi.system.service.IMaterialTalentsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 材料关系
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-03-09
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/material/talents")
|
||||
public class MaterialTalentsController extends BaseController {
|
||||
|
||||
private final IMaterialTalentsService iMaterialTalentsService;
|
||||
|
||||
/**
|
||||
* 查询材料关系列表
|
||||
*/
|
||||
@SaCheckPermission("material:talents:list")
|
||||
@GetMapping("/list")
|
||||
public R<List<MaterialTalentsVo>> list(MaterialTalentsBo bo) {
|
||||
List<MaterialTalentsVo> list = iMaterialTalentsService.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出材料关系列表
|
||||
*/
|
||||
@SaCheckPermission("material:talents:export")
|
||||
@Log(title = "材料关系", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(MaterialTalentsBo bo, HttpServletResponse response) {
|
||||
List<MaterialTalentsVo> list = iMaterialTalentsService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "材料关系", MaterialTalentsVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取材料关系详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("material:talents:query")
|
||||
@GetMapping
|
||||
public R<MaterialTalentsVo> getInfo(Long id) {
|
||||
return R.ok(iMaterialTalentsService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增材料关系
|
||||
*/
|
||||
@SaCheckPermission("material:talents:add")
|
||||
@Log(title = "材料关系", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody MaterialTalentsBo bo) {
|
||||
return toAjax(iMaterialTalentsService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改材料关系
|
||||
*/
|
||||
@SaCheckPermission("material:talents:edit")
|
||||
@Log(title = "材料关系", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody MaterialTalentsBo bo) {
|
||||
return toAjax(iMaterialTalentsService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除材料关系
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("material:talents:remove")
|
||||
@Log(title = "材料关系", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping
|
||||
public R<Void> remove(Long[] ids) {
|
||||
return toAjax(iMaterialTalentsService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.vo.RsaSecurityVo;
|
||||
import com.ruoyi.system.domain.bo.RsaSecurityBo;
|
||||
import com.ruoyi.system.service.IRsaSecurityService;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 请求RSA数据加解密
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-05-17
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/security")
|
||||
public class RsaSecurityController extends BaseController {
|
||||
|
||||
private final IRsaSecurityService iRsaSecurityService;
|
||||
|
||||
/**
|
||||
* 查询请求RSA数据加解密列表
|
||||
*/
|
||||
@SaCheckPermission("system:security:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<RsaSecurityVo> list(RsaSecurityBo bo, PageQuery pageQuery) {
|
||||
return iRsaSecurityService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出请求RSA数据加解密列表
|
||||
*/
|
||||
@SaCheckPermission("system:security:export")
|
||||
@Log(title = "请求RSA数据加解密", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(RsaSecurityBo bo, HttpServletResponse response) {
|
||||
List<RsaSecurityVo> list = iRsaSecurityService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "请求RSA数据加解密", RsaSecurityVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求RSA数据加解密详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system:security:query")
|
||||
@GetMapping
|
||||
public R<RsaSecurityVo> getInfo(Long id) {
|
||||
return R.ok(iRsaSecurityService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增请求RSA数据加解密
|
||||
*/
|
||||
@SaCheckPermission("system:security:add")
|
||||
@Log(title = "请求RSA数据加解密", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody RsaSecurityBo bo) {
|
||||
iRsaSecurityService.insertByBo(bo);
|
||||
return toAjax(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改请求RSA数据加解密
|
||||
*/
|
||||
@SaCheckPermission("system:security:edit")
|
||||
@Log(title = "请求RSA数据加解密", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody RsaSecurityBo bo) {
|
||||
iRsaSecurityService.updateByBo(bo);
|
||||
return toAjax(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除请求RSA数据加解密
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("system:security:remove")
|
||||
@Log(title = "请求RSA数据加解密", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping
|
||||
public R<Void> remove(Long[] ids) {
|
||||
return toAjax(iRsaSecurityService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.vo.SubscribeExportVo;
|
||||
import com.ruoyi.system.domain.bo.SubscribeExportBo;
|
||||
import com.ruoyi.system.service.ISubscribeExportService;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 预约导出
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-04-20
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/export")
|
||||
public class SubscribeExportController extends BaseController {
|
||||
|
||||
private final ISubscribeExportService iSubscribeExportService;
|
||||
|
||||
/**
|
||||
* 查询预约导出列表
|
||||
*/
|
||||
@SaCheckPermission("system:export:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SubscribeExportVo> list(SubscribeExportBo bo, PageQuery pageQuery) {
|
||||
return iSubscribeExportService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出预约导出列表
|
||||
*/
|
||||
@SaCheckPermission("system:export:export")
|
||||
@Log(title = "预约导出", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(SubscribeExportBo bo, HttpServletResponse response) {
|
||||
List<SubscribeExportVo> list = iSubscribeExportService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "预约导出", SubscribeExportVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预约导出详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system:export:query")
|
||||
@GetMapping
|
||||
public R<SubscribeExportVo> getInfo(Long id) {
|
||||
return R.ok(iSubscribeExportService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增预约导出
|
||||
*/
|
||||
@SaCheckPermission("system:export:add")
|
||||
@Log(title = "预约导出", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SubscribeExportBo bo) {
|
||||
return toAjax(iSubscribeExportService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改预约导出
|
||||
*/
|
||||
@SaCheckPermission("system:export:edit")
|
||||
@Log(title = "预约导出", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SubscribeExportBo bo) {
|
||||
return toAjax(iSubscribeExportService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除预约导出
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("system:export:remove")
|
||||
@Log(title = "预约导出", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping
|
||||
public R<Void> remove(Long[] ids) {
|
||||
return toAjax(iSubscribeExportService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,6 @@ package com.ruoyi.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
@ -14,7 +13,6 @@ import com.ruoyi.system.service.ISysConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
@ -57,8 +55,8 @@ public class SysConfigController extends BaseController {
|
||||
* @param configId 参数ID
|
||||
*/
|
||||
@SaCheckPermission("system:config:query")
|
||||
@GetMapping(value = "/{configId}")
|
||||
public R<SysConfig> getInfo(@PathVariable Long configId) {
|
||||
@GetMapping
|
||||
public R<SysConfig> getInfo(Long configId) {
|
||||
return R.ok(configService.selectConfigById(configId));
|
||||
}
|
||||
|
||||
@ -67,8 +65,8 @@ public class SysConfigController extends BaseController {
|
||||
*
|
||||
* @param configKey 参数Key
|
||||
*/
|
||||
@GetMapping(value = "/configKey/{configKey}")
|
||||
public R<Void> getConfigKey(@PathVariable String configKey) {
|
||||
@GetMapping(value = "/configKey")
|
||||
public R<Void> getConfigKey(String configKey) {
|
||||
return R.ok(configService.selectConfigByKey(configKey));
|
||||
}
|
||||
|
||||
@ -118,8 +116,8 @@ public class SysConfigController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:config:remove")
|
||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{configIds}")
|
||||
public R<Void> remove(@PathVariable Long[] configIds) {
|
||||
@DeleteMapping
|
||||
public R<Void> remove(Long[] configIds) {
|
||||
configService.deleteConfigByIds(configIds);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ -45,8 +45,8 @@ public class SysDeptController extends BaseController {
|
||||
* @param deptId 部门ID
|
||||
*/
|
||||
@SaCheckPermission("system:dept:list")
|
||||
@GetMapping("/list/exclude/{deptId}")
|
||||
public R<List<SysDept>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
|
||||
@GetMapping("/list/exclude")
|
||||
public R<List<SysDept>> excludeChild(Long deptId) {
|
||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||
depts.removeIf(d -> d.getDeptId().equals(deptId)
|
||||
|| StringUtils.splitList(d.getAncestors()).contains(Convert.toStr(deptId)));
|
||||
@ -59,8 +59,8 @@ public class SysDeptController extends BaseController {
|
||||
* @param deptId 部门ID
|
||||
*/
|
||||
@SaCheckPermission("system:dept:query")
|
||||
@GetMapping(value = "/{deptId}")
|
||||
public R<SysDept> getInfo(@PathVariable Long deptId) {
|
||||
@GetMapping
|
||||
public R<SysDept> getInfo(Long deptId) {
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
return R.ok(deptService.selectDeptById(deptId));
|
||||
}
|
||||
@ -105,8 +105,8 @@ public class SysDeptController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:dept:remove")
|
||||
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deptId}")
|
||||
public R<Void> remove(@PathVariable Long deptId) {
|
||||
@DeleteMapping
|
||||
public R<Void> remove(Long deptId) {
|
||||
if (deptService.hasChildByDeptId(deptId)) {
|
||||
return R.warn("存在下级部门,不允许删除");
|
||||
}
|
||||
|
||||
@ -60,8 +60,8 @@ public class SysDictDataController extends BaseController {
|
||||
* @param dictCode 字典code
|
||||
*/
|
||||
@SaCheckPermission("system:dict:query")
|
||||
@GetMapping(value = "/{dictCode}")
|
||||
public R<SysDictData> getInfo(@PathVariable Long dictCode) {
|
||||
@GetMapping
|
||||
public R<SysDictData> getInfo(Long dictCode) {
|
||||
return R.ok(dictDataService.selectDictDataById(dictCode));
|
||||
}
|
||||
|
||||
@ -70,8 +70,8 @@ public class SysDictDataController extends BaseController {
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
*/
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
public R<List<SysDictData>> dictType(@PathVariable String dictType) {
|
||||
@GetMapping(value = "/type")
|
||||
public R<List<SysDictData>> dictType(String dictType) {
|
||||
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||
if (ObjectUtil.isNull(data)) {
|
||||
data = new ArrayList<>();
|
||||
@ -108,8 +108,8 @@ public class SysDictDataController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:dict:remove")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictCodes}")
|
||||
public R<Void> remove(@PathVariable Long[] dictCodes) {
|
||||
@DeleteMapping
|
||||
public R<Void> remove(Long[] dictCodes) {
|
||||
dictDataService.deleteDictDataByIds(dictCodes);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package com.ruoyi.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
@ -14,7 +13,6 @@ import com.ruoyi.system.service.ISysDictTypeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
@ -57,8 +55,8 @@ public class SysDictTypeController extends BaseController {
|
||||
* @param dictId 字典ID
|
||||
*/
|
||||
@SaCheckPermission("system:dict:query")
|
||||
@GetMapping(value = "/{dictId}")
|
||||
public R<SysDictType> getInfo(@PathVariable Long dictId) {
|
||||
@GetMapping
|
||||
public R<SysDictType> getInfo(Long dictId) {
|
||||
return R.ok(dictTypeService.selectDictTypeById(dictId));
|
||||
}
|
||||
|
||||
@ -97,8 +95,8 @@ public class SysDictTypeController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:dict:remove")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictIds}")
|
||||
public R<Void> remove(@PathVariable Long[] dictIds) {
|
||||
@DeleteMapping
|
||||
public R<Void> remove(Long[] dictIds) {
|
||||
dictTypeService.deleteDictTypeByIds(dictIds);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.ruoyi.common.annotation.RateLimiter;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||
@ -10,18 +12,20 @@ import com.ruoyi.common.core.domain.model.LoginBody;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.domain.model.SmsLoginBody;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.StrUtils;
|
||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.sms.core.TelecomSendMsg;
|
||||
import com.ruoyi.sms.entity.SmsResult;
|
||||
import com.ruoyi.system.domain.vo.RouterVo;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.system.service.SysLoginService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -40,6 +44,7 @@ public class SysLoginController {
|
||||
private final ISysMenuService menuService;
|
||||
private final ISysUserService userService;
|
||||
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
@ -48,7 +53,9 @@ public class SysLoginController {
|
||||
*/
|
||||
@SaIgnore
|
||||
@PostMapping("/login")
|
||||
public R<Map<String, Object>> login(@Validated @RequestBody LoginBody loginBody) {
|
||||
public R<Map<String, Object>> login(
|
||||
// @Validated({LoginBody.passwordLogin.class})
|
||||
@RequestBody LoginBody loginBody) {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
// 生成令牌
|
||||
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
||||
@ -57,6 +64,7 @@ public class SysLoginController {
|
||||
return R.ok(ajax);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 短信登录
|
||||
*
|
||||
@ -65,10 +73,12 @@ public class SysLoginController {
|
||||
*/
|
||||
@SaIgnore
|
||||
@PostMapping("/smsLogin")
|
||||
public R<Map<String, Object>> smsLogin(@Validated @RequestBody SmsLoginBody smsLoginBody) {
|
||||
public R<Map<String, Object>> smsLogin(
|
||||
@Validated({LoginBody.smgLogin.class})
|
||||
@RequestBody SmsLoginBody smsLoginBody) {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
// 生成令牌
|
||||
String token = loginService.smsLogin(smsLoginBody.getPhonenumber(), smsLoginBody.getSmsCode());
|
||||
String token = loginService.smsLogin(smsLoginBody.getUsername(), smsLoginBody.getVerificationCode());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return R.ok(ajax);
|
||||
}
|
||||
@ -116,7 +126,6 @@ public class SysLoginController {
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("getInfo")
|
||||
@ -141,4 +150,139 @@ public class SysLoginController {
|
||||
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||
return R.ok(menuService.buildMenus(menus));
|
||||
}
|
||||
|
||||
//----------------------------------------------------客户端-------------------------------------------------------------
|
||||
/**
|
||||
* 登录方法
|
||||
* @param loginBody 登录信息
|
||||
* @return 结果
|
||||
*/
|
||||
@SaIgnore
|
||||
@RateLimiter(count = 2, time = 10)
|
||||
@PostMapping("/userLogin")
|
||||
public R userLogin(
|
||||
@Validated({LoginBody.passwordLogin.class})
|
||||
@RequestBody LoginBody loginBody) {
|
||||
// 生成令牌
|
||||
return R.ok("登录成功",loginService.userLogin(loginBody.getUsername(), loginBody.getPassword()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号登录
|
||||
* @param loginBody
|
||||
* @return
|
||||
*/
|
||||
@SaIgnore
|
||||
// @RateLimiter(count = 2, time = 10)
|
||||
@PostMapping("/userSmsLogin")
|
||||
public R<Map<String, Object>> userSmsLogin(@Validated(LoginBody.smgLogin.class) @RequestBody LoginBody loginBody) {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
// 生成令牌
|
||||
String token = loginService.userSmsLogin(loginBody.getUsername(), loginBody.getCode());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return R.ok(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户端忘记密码修改
|
||||
* @param loginBody
|
||||
* @return
|
||||
*/
|
||||
@SaIgnore
|
||||
@RateLimiter(count = 1, time = 10)
|
||||
@PostMapping("/userUpdatePwd")
|
||||
public R<?> userUpdatePwd(@Validated(LoginBody.forgetPasswordLogin.class) @RequestBody LoginBody loginBody) {
|
||||
return loginService.userUpdatePwd(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
* @param loginBody
|
||||
* @return
|
||||
*/
|
||||
@SaIgnore
|
||||
@RateLimiter(count = 1, time = 10)
|
||||
@PostMapping("/userRegister")
|
||||
public R<?> userRegister(@Validated(LoginBody.registerUser.class) @RequestBody LoginBody loginBody) {
|
||||
return loginService.userRegister(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 忘记密码发送短信Aliyun
|
||||
* @param phones 电话号
|
||||
*/
|
||||
// @RateLimiter(count = 1)
|
||||
@SaIgnore
|
||||
@GetMapping("/forgotSendAliYun")
|
||||
public R<?> forgotSendAliYun(String phones) {
|
||||
boolean matches = phones.matches("^1(3\\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$");
|
||||
if (!matches) {
|
||||
return R.fail("手机号格式不正确");
|
||||
}
|
||||
return sendMsg(phones,CacheConstants.RORGOT_PASSWORD_SEND_MSG+phones,"forgetPwd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册用户发送验证码
|
||||
* @param phones
|
||||
* @return
|
||||
*/
|
||||
// @RateLimiter(count = 1,time = 20)
|
||||
@SaIgnore
|
||||
@GetMapping("/registerSendAliYun")
|
||||
public R<?> registerSendAliYun(String phones) {
|
||||
boolean matches = phones.matches("^1(3\\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$");
|
||||
if (!matches) {
|
||||
return R.fail("手机号格式不正确");
|
||||
}
|
||||
return sendMsg(phones,CacheConstants.REGISTER_SEND_MSG+phones,"register");
|
||||
}
|
||||
|
||||
/**
|
||||
* 短信登录发送验证码
|
||||
* @param phones
|
||||
* @return
|
||||
*/
|
||||
// @RateLimiter(count = 1,time = 20)
|
||||
@SaIgnore
|
||||
@GetMapping("/smsLoginSendAliYun")
|
||||
public R<?> smsLoginSendAliYun(String phones) {
|
||||
boolean matches = phones.matches("^1(3\\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$");
|
||||
if (!matches) {
|
||||
return R.fail("手机号格式不正确");
|
||||
}
|
||||
return sendMsg(phones,CacheConstants.SMS_LOGIN_SEND_MSG+phones,"login");
|
||||
}
|
||||
|
||||
public R<?> sendMsg(String phones,String key ,String type){
|
||||
//1.获取redis中是否存在该key
|
||||
Boolean aBoolean = RedisUtils.hasKey(key + phones);
|
||||
if (aBoolean) {
|
||||
return R.fail("当前账号验证码已发送,2分钟内有效,请勿再次点击");
|
||||
} else {
|
||||
TelecomSendMsg smsTemplate = SpringUtils.getBean(TelecomSendMsg.class);
|
||||
Map<String, String> map = new HashMap<>(1);
|
||||
String code = StrUtils.getRandomString(6);
|
||||
map.put("code",code);
|
||||
SmsResult send = smsTemplate.telecomSendCode(phones, code, type);
|
||||
if (send.isSuccess()){
|
||||
RedisUtils.setCacheObject(key + phones, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
return R.ok();
|
||||
}
|
||||
System.out.println(code);
|
||||
return R.fail(send.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@SaIgnore
|
||||
@RateLimiter(count = 2, time = 10)
|
||||
@PostMapping("/userOpenLogin")
|
||||
public R userOpenLogin(
|
||||
@Validated({LoginBody.userOpenLogin.class})
|
||||
@RequestBody LoginBody loginBody) {
|
||||
// 生成令牌
|
||||
return R.ok("登录成功",loginService.userOpenLogin(loginBody.getUsername(), loginBody.getApiKey()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,6 @@ import com.ruoyi.system.service.ISysMenuService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -47,8 +46,8 @@ public class SysMenuController extends BaseController {
|
||||
* @param menuId 菜单ID
|
||||
*/
|
||||
@SaCheckPermission("system:menu:query")
|
||||
@GetMapping(value = "/{menuId}")
|
||||
public R<SysMenu> getInfo(@PathVariable Long menuId) {
|
||||
@GetMapping
|
||||
public R<SysMenu> getInfo(Long menuId) {
|
||||
return R.ok(menuService.selectMenuById(menuId));
|
||||
}
|
||||
|
||||
@ -66,8 +65,8 @@ public class SysMenuController extends BaseController {
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||
public R<Map<String, Object>> roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
|
||||
@GetMapping(value = "/roleMenuTreeselect")
|
||||
public R<Map<String, Object>> roleMenuTreeselect(Long roleId) {
|
||||
List<SysMenu> menus = menuService.selectMenuList(getUserId());
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
||||
@ -114,8 +113,8 @@ public class SysMenuController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:menu:remove")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{menuId}")
|
||||
public R<Void> remove(@PathVariable("menuId") Long menuId) {
|
||||
@DeleteMapping
|
||||
public R<Void> remove(Long menuId) {
|
||||
if (menuService.hasChildByMenuId(menuId)) {
|
||||
return R.warn("存在子菜单,不允许删除");
|
||||
}
|
||||
|
||||
@ -41,8 +41,8 @@ public class SysNoticeController extends BaseController {
|
||||
* @param noticeId 公告ID
|
||||
*/
|
||||
@SaCheckPermission("system:notice:query")
|
||||
@GetMapping(value = "/{noticeId}")
|
||||
public R<SysNotice> getInfo(@PathVariable Long noticeId) {
|
||||
@GetMapping
|
||||
public R<SysNotice> getInfo(Long noticeId) {
|
||||
return R.ok(noticeService.selectNoticeById(noticeId));
|
||||
}
|
||||
|
||||
@ -73,8 +73,8 @@ public class SysNoticeController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:notice:remove")
|
||||
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{noticeIds}")
|
||||
public R<Void> remove(@PathVariable Long[] noticeIds) {
|
||||
@DeleteMapping
|
||||
public R<Void> remove(Long[] noticeIds) {
|
||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,9 +52,8 @@ public class SysOssConfigController extends BaseController {
|
||||
* @param ossConfigId OSS配置ID
|
||||
*/
|
||||
@SaCheckPermission("system:oss:query")
|
||||
@GetMapping("/{ossConfigId}")
|
||||
public R<SysOssConfigVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long ossConfigId) {
|
||||
@GetMapping
|
||||
public R<SysOssConfigVo> getInfo(Long ossConfigId) {
|
||||
return R.ok(iSysOssConfigService.queryById(ossConfigId));
|
||||
}
|
||||
|
||||
@ -87,9 +86,8 @@ public class SysOssConfigController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:oss:remove")
|
||||
@Log(title = "对象存储配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ossConfigIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ossConfigIds) {
|
||||
@DeleteMapping
|
||||
public R<Void> remove(Long[] ossConfigIds) {
|
||||
return toAjax(iSysOssConfigService.deleteWithValidByIds(Arrays.asList(ossConfigIds), true));
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.system.domain.bo.SysOssBo;
|
||||
import com.ruoyi.system.domain.vo.SysOssVo;
|
||||
import com.ruoyi.system.service.ISysOssService;
|
||||
@ -18,7 +19,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.IOException;
|
||||
|
||||
@ -2,7 +2,6 @@ package com.ruoyi.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
@ -14,7 +13,6 @@ import com.ruoyi.system.service.ISysPostService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
@ -57,8 +55,8 @@ public class SysPostController extends BaseController {
|
||||
* @param postId 岗位ID
|
||||
*/
|
||||
@SaCheckPermission("system:post:query")
|
||||
@GetMapping(value = "/{postId}")
|
||||
public R<SysPost> getInfo(@PathVariable Long postId) {
|
||||
@GetMapping
|
||||
public R<SysPost> getInfo(Long postId) {
|
||||
return R.ok(postService.selectPostById(postId));
|
||||
}
|
||||
|
||||
@ -99,7 +97,7 @@ public class SysPostController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:post:remove")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{postIds}")
|
||||
@DeleteMapping
|
||||
public R<Void> remove(@PathVariable Long[] postIds) {
|
||||
return toAjax(postService.deletePostByIds(postIds));
|
||||
}
|
||||
|
||||
@ -3,24 +3,24 @@ package com.ruoyi.web.controller.system;
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import com.ruoyi.common.utils.file.MimeTypeUtils;
|
||||
import com.ruoyi.system.domain.SysOss;
|
||||
import com.ruoyi.file.service.ISysFileService;
|
||||
import com.ruoyi.system.domain.vo.SysOssVo;
|
||||
import com.ruoyi.system.service.ISysOssService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -37,7 +37,8 @@ import java.util.Map;
|
||||
public class SysProfileController extends BaseController {
|
||||
|
||||
private final ISysUserService userService;
|
||||
private final ISysOssService iSysOssService;
|
||||
// private final ISysOssService iSysOssService;
|
||||
private final ISysFileService sysFileService;
|
||||
|
||||
/**
|
||||
* 个人信息
|
||||
@ -107,17 +108,18 @@ public class SysProfileController extends BaseController {
|
||||
*/
|
||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/avatar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile avatarfile) {
|
||||
public R<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile avatarfile) throws Exception {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
if (!avatarfile.isEmpty()) {
|
||||
String extension = FileUtil.extName(avatarfile.getOriginalFilename());
|
||||
if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) {
|
||||
return R.fail("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式");
|
||||
}
|
||||
SysOssVo oss = iSysOssService.upload(avatarfile);
|
||||
String avatar = oss.getUrl();
|
||||
if (userService.updateUserAvatar(getUsername(), avatar)) {
|
||||
ajax.put("imgUrl", avatar);
|
||||
String url = sysFileService.uploadFile(avatarfile);
|
||||
/*SysOssVo oss = iSysOssService.upload(avatarfile);
|
||||
String avatar = oss.getUrl();*/
|
||||
if (userService.updateUserAvatar(getUsername(), url)) {
|
||||
ajax.put("imgUrl", url);
|
||||
return R.ok(ajax);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
@ -19,7 +24,6 @@ import com.ruoyi.system.service.SysPermissionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -40,7 +44,6 @@ public class SysRoleController extends BaseController {
|
||||
private final ISysUserService userService;
|
||||
private final ISysDeptService deptService;
|
||||
private final SysPermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 获取角色信息列表
|
||||
*/
|
||||
@ -67,8 +70,8 @@ public class SysRoleController extends BaseController {
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
@SaCheckPermission("system:role:query")
|
||||
@GetMapping(value = "/{roleId}")
|
||||
public R<SysRole> getInfo(@PathVariable Long roleId) {
|
||||
@GetMapping
|
||||
public R<SysRole> getInfo(Long roleId) {
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
return R.ok(roleService.selectRoleById(roleId));
|
||||
}
|
||||
@ -143,8 +146,8 @@ public class SysRoleController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:role:remove")
|
||||
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{roleIds}")
|
||||
public R<Void> remove(@PathVariable Long[] roleIds) {
|
||||
@DeleteMapping
|
||||
public R<Void> remove(Long[] roleIds) {
|
||||
return toAjax(roleService.deleteRoleByIds(roleIds));
|
||||
}
|
||||
|
||||
@ -218,8 +221,8 @@ public class SysRoleController extends BaseController {
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
@SaCheckPermission("system:role:list")
|
||||
@GetMapping(value = "/deptTree/{roleId}")
|
||||
public R<Map<String, Object>> roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
|
||||
@GetMapping(value = "/deptTree")
|
||||
public R<Map<String, Object>> roleDeptTreeselect(Long roleId) {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
||||
ajax.put("depts", deptService.selectDeptTreeList(new SysDept()));
|
||||
|
||||
@ -7,7 +7,6 @@ import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
@ -33,7 +32,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -113,8 +111,8 @@ public class SysUserController extends BaseController {
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
@SaCheckPermission("system:user:query")
|
||||
@GetMapping(value = {"/", "/{userId}"})
|
||||
public R<Map<String, Object>> getInfo(@PathVariable(value = "userId", required = false) Long userId) {
|
||||
@GetMapping
|
||||
public R<Map<String, Object>> getInfo(Long userId) {
|
||||
userService.checkUserDataScope(userId);
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
List<SysRole> roles = roleService.selectRoleAll();
|
||||
@ -173,8 +171,8 @@ public class SysUserController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:user:remove")
|
||||
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{userIds}")
|
||||
public R<Void> remove(@PathVariable Long[] userIds) {
|
||||
@DeleteMapping
|
||||
public R<Void> remove(Long[] userIds) {
|
||||
if (ArrayUtil.contains(userIds, getUserId())) {
|
||||
return R.fail("当前用户不能删除");
|
||||
}
|
||||
@ -212,8 +210,8 @@ public class SysUserController extends BaseController {
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
@SaCheckPermission("system:user:query")
|
||||
@GetMapping("/authRole/{userId}")
|
||||
public R<Map<String, Object>> authRole(@PathVariable Long userId) {
|
||||
@GetMapping("/authRole")
|
||||
public R<Map<String, Object>> authRole( Long userId) {
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
|
||||
@ -0,0 +1,137 @@
|
||||
package com.ruoyi.web.controller.user;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.IdcardUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.RateLimiter;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.DownloadGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.system.domain.BuyHouses;
|
||||
import com.ruoyi.system.domain.bo.BuyHousesBo;
|
||||
import com.ruoyi.system.service.IBuyHousesService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 客户端购房申请相关接口
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/user/house")
|
||||
public class HouseController extends BaseController {
|
||||
private final IBuyHousesService iBuyHousesService;
|
||||
/**
|
||||
* 购房申请修改
|
||||
*/
|
||||
@Log(title = "【购房申请修改】", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BuyHousesBo bo) {
|
||||
return toAjax(iBuyHousesService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 购房获取详情
|
||||
*/
|
||||
@Log(title = "【购房获取详情】", businessType = BusinessType.OTHER)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/info")
|
||||
public R<?> getInfo(@RequestBody BuyHouses buyHouses) {
|
||||
return iBuyHousesService.getInfo(buyHouses);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下载人才认定申请表
|
||||
*/
|
||||
@Log(title = "下载人才认定申请表", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/download")
|
||||
@RateLimiter(count = 1, time = 10)
|
||||
public R downloadWord(@Validated(DownloadGroup.class) @RequestBody BuyHousesBo buyHousesBo){
|
||||
return iBuyHousesService.downloadWord(buyHousesBo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载认定通知单
|
||||
*/
|
||||
@GetMapping("/downloadInform")
|
||||
public R downloadInform(){
|
||||
return iBuyHousesService.downloadInform();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程进度列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/declareList")
|
||||
public R getDeclareList(){
|
||||
return R.ok(iBuyHousesService.getDeclareList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过调用高新人才判断该身份证是否具备人才资格
|
||||
*/
|
||||
@Log(title = "通过调用高新人才判断该身份证是否具备人才资格", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/CandidatesInfo")
|
||||
public R getGaoXinCandidateInfoByCardId(@RequestBody BuyHouses buyHouses){
|
||||
String cardId = buyHouses.getCardId();
|
||||
if (ObjectUtil.isNull(cardId) || ObjectUtil.isEmpty(cardId)){
|
||||
return R.fail("key.not.exist");
|
||||
}
|
||||
return iBuyHousesService.getGaoXinCandidateInfoByCardId(cardId);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/checkStatus")
|
||||
public R checkStatus(){
|
||||
return iBuyHousesService.checkStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取审核日志
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/buyHouseLogs")
|
||||
public R getBuyHouseLog(){
|
||||
return iBuyHousesService.getBuyHousesLogsByUserId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 外部推送接口
|
||||
* @param bo
|
||||
* @return
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@Log(title = "【外部推送接口】", businessType = BusinessType.OTHER)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/insertOpenBuyHouses")
|
||||
public R<?> insertOpenBuyHouses(@Validated(EditGroup.class)@RequestBody BuyHousesBo bo){
|
||||
bo.setApiKey("gaoxingongyuanchengshiju");
|
||||
if (ObjectUtil.isNull(bo.getUserId())){
|
||||
return R.fail("userId不可为空");
|
||||
}
|
||||
return iBuyHousesService.insertOpenBuyHouses(bo);
|
||||
}
|
||||
|
||||
@SaIgnore
|
||||
@GetMapping("/excelZip")
|
||||
public void excelZip(String id){
|
||||
ThreadUtil.execAsync(() -> {
|
||||
iBuyHousesService.excelZip(id);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,179 @@
|
||||
package com.ruoyi.web.controller.user;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.work.domain.ActProcess;
|
||||
import com.ruoyi.work.domain.TProcess;
|
||||
import com.ruoyi.work.domain.vo.ProcessVo;
|
||||
import com.ruoyi.work.dto.ProcessVoResultDto;
|
||||
import com.ruoyi.work.mapper.ProcessMapper;
|
||||
import com.ruoyi.work.utils.WorkComplyUtils;
|
||||
import com.ruoyi.work.utils.WorkUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.vo.UserVo;
|
||||
import com.ruoyi.system.domain.bo.UserBo;
|
||||
import com.ruoyi.system.service.IUserService;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 申报端用户项目
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-04-03
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserController extends BaseController {
|
||||
|
||||
private final ProcessMapper processMapper;
|
||||
private final IUserService iUserService;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<UserVo> list(UserBo bo, PageQuery pageQuery) {
|
||||
return iUserService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出【请填写功能名称】列表
|
||||
*/
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(UserBo bo, HttpServletResponse response) {
|
||||
List<UserVo> list = iUserService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "【请填写功能名称】", UserVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取【请填写功能名称】详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R<UserVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(iUserService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*/
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody UserBo bo) {
|
||||
return toAjax(iUserService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*/
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody UserBo bo) {
|
||||
return toAjax(iUserService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(iUserService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前业务进行步骤
|
||||
*/
|
||||
// @SaIgnore
|
||||
@Log(title = "获取当前业务运行到那一步",businessType = BusinessType.OTHER)
|
||||
@PostMapping("/processPlan")
|
||||
public R<?> processPlan(@RequestBody ActProcess actProcess){
|
||||
List<TProcess> tProcesses = processMapper.selectList(new LambdaQueryWrapper<TProcess>()
|
||||
.eq(TProcess::getProcessKey, actProcess.getProcessKey()));
|
||||
if (tProcesses.size()==0){
|
||||
throw new ServiceException("当前流程不存在");
|
||||
}
|
||||
LinkedHashMap<String, Object> hashMap = new LinkedHashMap<>();
|
||||
Map<String, Object> map = WorkUtils.getInfoToMap(tProcesses.get(0).getBean(), actProcess.getBusinessId());
|
||||
ProcessVo processVo = new ProcessVo();
|
||||
processVo.setBusinessId(actProcess.getBusinessId());
|
||||
processVo.setParams(map);
|
||||
hashMap.put("status",map.get("processStatus"));
|
||||
List<ProcessVoResultDto> processPlan= WorkComplyUtils.getProcessPlan(processVo);
|
||||
hashMap.put("list",processPlan);
|
||||
return R.ok(hashMap);
|
||||
}
|
||||
|
||||
@Log(title = "对外提供步骤接口",businessType = BusinessType.OTHER)
|
||||
@PostMapping("/stepProcessPlan")
|
||||
public R<?> stepProcessPlan(@RequestBody ActProcess actProcess){
|
||||
actProcess.setProcessKey("apply_house");
|
||||
if (ObjectUtil.isNull(actProcess.getBusinessId())){
|
||||
return R.fail("必要参数不可为空");
|
||||
}
|
||||
if (ObjectUtil.isNull(actProcess.getApiKey())){
|
||||
return R.fail("必要参数不可为空");
|
||||
}
|
||||
List<TProcess> tProcesses = processMapper.selectList(new LambdaQueryWrapper<TProcess>()
|
||||
.eq(TProcess::getProcessKey, actProcess.getProcessKey()));
|
||||
if (tProcesses.size()==0){
|
||||
throw new ServiceException("当前流程不存在");
|
||||
}
|
||||
LinkedHashMap<String, Object> hashMap = new LinkedHashMap<>();
|
||||
Map<String, Object> map = WorkUtils.getInfoToMap(tProcesses.get(0).getBean(), actProcess.getBusinessId());
|
||||
if (ObjectUtil.isNotNull(map)){
|
||||
Object apiKey = map.get("apiKey");
|
||||
if (ObjectUtil.isNull(apiKey) || !actProcess.getApiKey().equals(apiKey.toString())){
|
||||
return R.fail("无查看权限");
|
||||
}
|
||||
}else {
|
||||
return R.fail("数据查询失败:无此业务id");
|
||||
}
|
||||
ProcessVo processVo = new ProcessVo();
|
||||
processVo.setBusinessId(actProcess.getBusinessId());
|
||||
processVo.setParams(map);
|
||||
hashMap.put("status",map.get("processStatus"));
|
||||
List<ProcessVoResultDto> processPlan= WorkComplyUtils.getProcessPlan(processVo);
|
||||
hashMap.put("list",processPlan);
|
||||
return R.ok(hashMap);
|
||||
}
|
||||
@SaIgnore
|
||||
@GetMapping("/model")
|
||||
public void module(HttpServletResponse response) throws IOException {
|
||||
response.sendRedirect("https://dbxqtalents.cn/");
|
||||
}
|
||||
}
|
||||
BIN
ruoyi-admin/src/main/resources/404.jpg
Normal file
BIN
ruoyi-admin/src/main/resources/404.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@ -1,17 +1,17 @@
|
||||
--- # 监控中心配置
|
||||
spring.boot.admin.client:
|
||||
# 增加客户端开关
|
||||
enabled: true
|
||||
enabled: false
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
username: ruoyi
|
||||
password: 123456
|
||||
username: gaoxin
|
||||
password: 1234Qwer@
|
||||
|
||||
--- # xxl-job 配置
|
||||
xxl.job:
|
||||
# 执行器开关
|
||||
enabled: true
|
||||
enabled: false
|
||||
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
|
||||
admin-addresses: http://localhost:9100/xxl-job-admin
|
||||
# 执行器通讯TOKEN:非空时启用
|
||||
@ -49,9 +49,15 @@ spring:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
username: root
|
||||
password: root
|
||||
# url: jdbc:mysql://182.150.40.133:3309/ry-vue-house?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&useAffectedRows=true
|
||||
# username: root
|
||||
# password: 1234Qwer@
|
||||
url: jdbc:mysql://182.138.107.22:3409/ry-vue-house?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
username: gxrc
|
||||
password: 45Uuq5!aADGD
|
||||
# url: jdbc:mysql://localhost:3306/ry-vue-house?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
# username: root
|
||||
# password: 123456
|
||||
# 从库数据源
|
||||
slave:
|
||||
lazy: true
|
||||
@ -102,17 +108,51 @@ spring:
|
||||
spring:
|
||||
redis:
|
||||
# 地址
|
||||
host: localhost
|
||||
# host: 182.42.81.18
|
||||
host: 127.0.0.1
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 0
|
||||
# 数据库索3
|
||||
database: 5
|
||||
# 密码(如没有密码请注释掉)
|
||||
# password:
|
||||
password: 123456
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
ssl: false
|
||||
#mq
|
||||
rabbitmq:
|
||||
host: 182.42.90.82
|
||||
port: 5672
|
||||
username: cddbxqtalents
|
||||
password: 1234Qwer@
|
||||
virtual-host: /
|
||||
#确认消息已发送到队列
|
||||
publisher-returns: true
|
||||
#确认消息已发送到交换机
|
||||
publisher-confirm-type: correlated
|
||||
template:
|
||||
#交换机处理消息到路由失败,则会返回给生产者
|
||||
mandatory: true
|
||||
#指定消费端消息确认方式,手动确认
|
||||
listener:
|
||||
direct:
|
||||
acknowledge-mode: manual
|
||||
simple:
|
||||
acknowledge-mode: manual
|
||||
# 消费者预取1条数据到内存,默认为250条
|
||||
prefetch: 1
|
||||
#重试机制
|
||||
retry:
|
||||
enabled: false
|
||||
max-attempts: 5 #最大重试次数
|
||||
initial-interval: 1000 #重试间隔时间
|
||||
max-interval: 10000 #重试最大时间间隔
|
||||
# 乘子。间隔时间*乘子=下一次的间隔时间,不能超过max-interval
|
||||
# 以本处为例:第一次间隔 5 秒,第二次间隔 10 秒,以此类推
|
||||
multiplier: 2
|
||||
|
||||
|
||||
|
||||
redisson:
|
||||
# redis key前缀
|
||||
@ -184,3 +224,13 @@ sms:
|
||||
sdkAppId: appid
|
||||
#地域信息默认为 ap-guangzhou 如无特殊改变可不用设置
|
||||
territory: ap-guangzhou
|
||||
|
||||
# 本地文件存储
|
||||
file:
|
||||
domain: http://192.168.0.54:8084
|
||||
path: D:\\gaoxin\\images
|
||||
prefix: /images
|
||||
size: 10
|
||||
template: D:\\gaoxin\\file\\
|
||||
doc: D:\\gaoxin\\doc\\
|
||||
mapping: /doc
|
||||
|
||||
@ -4,7 +4,7 @@ spring.servlet.multipart.location: /ruoyi/server/temp
|
||||
--- # 监控中心配置
|
||||
spring.boot.admin.client:
|
||||
# 增加客户端开关
|
||||
enabled: true
|
||||
enabled: false
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
@ -14,7 +14,7 @@ spring.boot.admin.client:
|
||||
--- # xxl-job 配置
|
||||
xxl.job:
|
||||
# 执行器开关
|
||||
enabled: true
|
||||
enabled: false
|
||||
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
|
||||
admin-addresses: http://localhost:9100/xxl-job-admin
|
||||
# 执行器通讯TOKEN:非空时启用
|
||||
@ -40,7 +40,7 @@ spring:
|
||||
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
|
||||
dynamic:
|
||||
# 性能分析插件(有性能损耗 不建议生产环境使用)
|
||||
p6spy: false
|
||||
p6spy: true
|
||||
# 设置默认的数据源或者数据源组,默认值即为 master
|
||||
primary: master
|
||||
# 严格模式 匹配不到数据源则报错
|
||||
@ -52,9 +52,17 @@ spring:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
username: root
|
||||
password: root
|
||||
#测试地址
|
||||
# url: jdbc:mysql://182.150.40.133:3309/ry-vue-house?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
#url: jdbc:mysql://localhost:3306/ry-vue-jinniu?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
# username: root
|
||||
# password: 1234Qwer@
|
||||
#正式地址
|
||||
url: jdbc:mysql://172.12.9.1:3409/ry-vue-house?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
# url: jdbc:mysql://182.138.107.22:3409/ry-vue-house?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
#url: jdbc:mysql://localhost:3306/ry-vue-jinniu?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
username: gxrc
|
||||
password: 45Uuq5!aADGD
|
||||
# 从库数据源
|
||||
slave:
|
||||
lazy: true
|
||||
@ -105,13 +113,16 @@ spring:
|
||||
spring:
|
||||
redis:
|
||||
# 地址
|
||||
host: localhost
|
||||
# host: 182.42.81.18
|
||||
host: 172.12.9.2
|
||||
# host: 127.0.0.1
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 0
|
||||
database: 7
|
||||
# 密码(如没有密码请注释掉)
|
||||
# password:
|
||||
password: N8PTRAirBO
|
||||
# password: 123456
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
@ -121,9 +132,9 @@ redisson:
|
||||
# redis key前缀
|
||||
keyPrefix:
|
||||
# 线程池数量
|
||||
threads: 16
|
||||
threads: 4
|
||||
# Netty线程池数量
|
||||
nettyThreads: 32
|
||||
nettyThreads: 8
|
||||
# 单节点配置
|
||||
singleServerConfig:
|
||||
# 客户端名称
|
||||
@ -187,3 +198,42 @@ sms:
|
||||
sdkAppId: appid
|
||||
#地域信息默认为 ap-guangzhou 如无特殊改变可不用设置
|
||||
territory: ap-guangzhou
|
||||
|
||||
# 本地文件存储
|
||||
#windows
|
||||
#file:
|
||||
# domain: http://192.168.0.54:8080
|
||||
# path: D:\\gaoxin\\images
|
||||
# prefix: /images
|
||||
# size: 10
|
||||
# template: D:\\gaoxin\\template\\
|
||||
# doc: D:\\gaoxin\\doc\\
|
||||
# mapping: /doc
|
||||
|
||||
#Linux dev
|
||||
file:
|
||||
domain: https://rcaj.cdhtgycs.cn
|
||||
path: /usr/local/images
|
||||
prefix: /images
|
||||
size: 10
|
||||
template: /usr/local/template/
|
||||
doc: /usr/local/doc
|
||||
mapping: /doc
|
||||
|
||||
# domain: 192.168.0.54:8080
|
||||
# path: D:\\gaoxin\\images
|
||||
# prefix: /images
|
||||
# size: 10
|
||||
|
||||
#图片识别
|
||||
ocr:
|
||||
clientId: eo1xM8KcB6ICi6k1kVGsmnR9
|
||||
#clientId: lUDaDgrPGRsMFN7qw21u5Cta
|
||||
#clientSecret: znOBkwZwQ4G8PmeKT8ELDHoqdcPxnX4a
|
||||
clientSecret: lZ9q4E6C0ftstwgL0Tt8UCroI5bOZ6YD
|
||||
license:
|
||||
APPID: 2d33f6f6
|
||||
API_KEY: bd1a2416dfae01a9c018bb28a28eb7cb
|
||||
WEBOCR_URL: http://webapi.xfyun.cn/v1/service/v1/ocr/business_license
|
||||
ENGINE_TYPE: business_license
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ ruoyi:
|
||||
# 版本
|
||||
version: ${ruoyi-vue-plus.version}
|
||||
# 版权年份
|
||||
copyrightYear: 2022
|
||||
copyrightYear: 2023
|
||||
# 实例演示开关
|
||||
demoEnabled: true
|
||||
# 获取ip地址开关
|
||||
@ -27,7 +27,7 @@ captcha:
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为8080
|
||||
port: 8080
|
||||
port: 8085
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
@ -89,6 +89,7 @@ spring:
|
||||
jackson:
|
||||
# 日期格式化
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
serialization:
|
||||
# 格式化输出
|
||||
indent_output: false
|
||||
@ -140,6 +141,8 @@ security:
|
||||
# actuator 监控配置
|
||||
- /actuator
|
||||
- /actuator/**
|
||||
- #对外接口排除
|
||||
- /user/house/insertOpenBuyHouses
|
||||
|
||||
# MyBatisPlus配置
|
||||
# https://baomidou.com/config/
|
||||
@ -233,6 +236,8 @@ springdoc:
|
||||
packages-to-scan: com.ruoyi.web
|
||||
- group: 3.代码生成模块
|
||||
packages-to-scan: com.ruoyi.generator
|
||||
- group: 4.流程模块
|
||||
packages-to-scan: com.ruoyi.work
|
||||
|
||||
# 防止XSS攻击
|
||||
xss:
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
#错误消息
|
||||
not.null=* 必须填写
|
||||
user.jcaptcha.error=验证码错误
|
||||
user.jcaptcha.not.blank=验证码不可为空
|
||||
user.jcaptcha.expire=验证码已失效
|
||||
user.not.exists=对不起, 您的账号:{0} 不存在.
|
||||
user.password.not.match=用户不存在/密码错误
|
||||
user.password.retry.limit.count=密码输入错误{0}次
|
||||
user.password.retry.limit.count=密码输入错误{0}次,剩余{1}次
|
||||
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟
|
||||
user.password.delete=对不起,您的账号:{0} 已被删除
|
||||
user.blocked=对不起,您的账号:{0} 已禁用,请联系管理员
|
||||
@ -41,9 +42,12 @@ no.view.permission=您没有查看数据的权限,请联系管理员添加权
|
||||
repeat.submit.message=不允许重复提交,请稍候再试
|
||||
rate.limiter.message=访问过于频繁,请稍候再试
|
||||
sms.code.not.blank=短信验证码不能为空
|
||||
sms.code.retry.limit.count=短信验证码输入错误{0}次
|
||||
sms.code.retry.limit.count=短信验证码输入错误{0}次,剩余{1}次
|
||||
sms.code.retry.limit.exceed=短信验证码输入错误{0}次,帐户锁定{1}分钟
|
||||
email.code.not.blank=邮箱验证码不能为空
|
||||
email.code.retry.limit.count=邮箱验证码输入错误{0}次
|
||||
email.code.retry.limit.count=邮箱验证码输入错误{0}次,剩余{1}次
|
||||
email.code.retry.limit.exceed=邮箱验证码输入错误{0}次,帐户锁定{1}分钟
|
||||
xcx.code.not.blank=小程序code不能为空
|
||||
user.password.expired=对不起,您的账号:{0},密码已过期,请修改密码
|
||||
the.password.is.not.within.the.specified.range=密码不在指定范围(必须包含大小写字母和数字的组合,可以使用特殊字符,长度8-20位)
|
||||
user.id.cannot.be.empty=用户标识不可为空
|
||||
|
||||
@ -47,3 +47,8 @@ email.code.not.blank=Email code cannot be blank
|
||||
email.code.retry.limit.count=Email code input error {0} times
|
||||
email.code.retry.limit.exceed=Email code input error {0} times, account locked for {1} minutes
|
||||
xcx.code.not.blank=Mini program code cannot be blank
|
||||
user.password.expired=Password has expired
|
||||
user.jcaptcha.not.blank=user jcaptcha not blank
|
||||
user.id.cannot.be.empty=User ID cannot be empty
|
||||
the.password.is.not.within.the.specified.range=The password is not within the specified range (it must contain a combination of uppercase and lowercase letters and numbers, special characters can be used, with a length of 8-18 digits)
|
||||
|
||||
|
||||
@ -2,9 +2,10 @@
|
||||
not.null=* 必须填写
|
||||
user.jcaptcha.error=验证码错误
|
||||
user.jcaptcha.expire=验证码已失效
|
||||
user.jcaptcha.not.blank=验证码不可为空
|
||||
user.not.exists=对不起, 您的账号:{0} 不存在.
|
||||
user.password.not.match=用户不存在/密码错误
|
||||
user.password.retry.limit.count=密码输入错误{0}次
|
||||
user.password.retry.limit.count=密码输入错误{0}次,剩余{1}次
|
||||
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟
|
||||
user.password.delete=对不起,您的账号:{0} 已被删除
|
||||
user.blocked=对不起,您的账号:{0} 已禁用,请联系管理员
|
||||
@ -41,9 +42,12 @@ no.view.permission=您没有查看数据的权限,请联系管理员添加权
|
||||
repeat.submit.message=不允许重复提交,请稍候再试
|
||||
rate.limiter.message=访问过于频繁,请稍候再试
|
||||
sms.code.not.blank=短信验证码不能为空
|
||||
sms.code.retry.limit.count=短信验证码输入错误{0}次
|
||||
sms.code.retry.limit.count=短信验证码输入错误{0}次,剩余{1}次
|
||||
sms.code.retry.limit.exceed=短信验证码输入错误{0}次,帐户锁定{1}分钟
|
||||
email.code.not.blank=邮箱验证码不能为空
|
||||
email.code.retry.limit.count=邮箱验证码输入错误{0}次
|
||||
email.code.retry.limit.exceed=邮箱验证码输入错误{0}次,帐户锁定{1}分钟
|
||||
xcx.code.not.blank=小程序code不能为空
|
||||
user.password.expired=对不起,您的账号:{0},密码已过期,请修改密码
|
||||
the.password.is.not.within.the.specified.range=密码不在指定范围(必须包含大小写字母和数字的组合,可以使用特殊字符,长度8-20位)
|
||||
user.id.cannot.be.empty=用户标识不可为空
|
||||
|
||||
@ -7,7 +7,7 @@ appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
|
||||
# 使用日志系统记录 sql
|
||||
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
|
||||
# 设置 p6spy driver 代理
|
||||
#deregisterdrivers=true
|
||||
deregisterdrivers=true
|
||||
# 取消JDBC URL前缀
|
||||
useprefix=true
|
||||
# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset.
|
||||
|
||||
14
ruoyi-admin/src/main/resources/templates/111.html
Normal file
14
ruoyi-admin/src/main/resources/templates/111.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
|
||||
<title>Page Title</title>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||
<link rel='stylesheet' type='text/css' media='screen' href='main.css'>
|
||||
<script src='main.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
重定向来了
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
179
ruoyi-admin/src/test/java/com/ruoyi/test/HttpReq.java
Normal file
179
ruoyi-admin/src/test/java/com/ruoyi/test/HttpReq.java
Normal file
@ -0,0 +1,179 @@
|
||||
package com.ruoyi.test;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Node;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class HttpReq {
|
||||
|
||||
//private OkHttpClient client = new OkHttpClient();
|
||||
private final Request.Builder builder = new Request.Builder();
|
||||
private final OkHttpClient client = new OkHttpClient.Builder()
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.writeTimeout(30, TimeUnit.SECONDS)
|
||||
.build(); //设置各种超时时间
|
||||
|
||||
/**
|
||||
@param isAddXuexinHeader 是否加入学信网header到请求头
|
||||
*/
|
||||
public HttpReq(boolean isAddXuexinHeader){
|
||||
if (isAddXuexinHeader == true){
|
||||
builder.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
|
||||
builder.addHeader("Accept-Encoding","gzip, deflate, sdch, br");
|
||||
builder.addHeader("Accept-Language","zh-CN,zh;q=0.8");
|
||||
builder.addHeader("Cache-Control","max-age=0");
|
||||
builder.addHeader("Connection","keep-alive");
|
||||
builder.addHeader("Host","my.chsi.com.cn");
|
||||
builder.addHeader("If-Modified-Since","Tue, 13 Mar 2018 10:14:31 GMT");
|
||||
builder.addHeader("Upgrade-Insecure-Requests","1");
|
||||
builder.addHeader( "User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@param cookie 加入cookie到请求头
|
||||
*/
|
||||
public void addCookieToHeader(String cookie){
|
||||
builder.addHeader("cookie",cookie);
|
||||
}
|
||||
|
||||
/**
|
||||
@param url get请求的url
|
||||
*/
|
||||
public String get(String url) {
|
||||
builder.url(url);
|
||||
final Request request = builder.build();
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
return response.body().string();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@param url 图片的地址
|
||||
* */
|
||||
public void savePicture(String url) {
|
||||
builder.url(url);
|
||||
final Request request = builder.build();
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
byte[] bt = response.body().bytes();
|
||||
byte2image(bt, "./xueji.png");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void byte2image(byte[] data,String path){
|
||||
try {
|
||||
File file = new File(path);
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
fos.write(data, 0, data.length);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
System.out.println("保存图片成功。。");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void testBaidu(){
|
||||
HttpReq baiduHttp = new HttpReq(false);
|
||||
String respStr = baiduHttp.get("http://www.baidu.com");
|
||||
System.out.println(respStr);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// testBaidu();
|
||||
// HttpReq xuexinHttp = new HttpReq(true);
|
||||
// xuexinHttp.addCookieToHeader("aliyungf_tc=a44cd76725072e97c6625bc216dcf07870bb8f59efdab8e85142cd2903f45841; acw_tc=707c9f7216885291604143483e1ffdbde1d42ca14b99ec2b9ec8d2c48e0eb1; JSESSIONID=92648EE2F4820DEDD6FB627E7F9DFABE; CHSICC_CLIENTFLAGCHSI=d6d1556d12784a270db64720aa7652f7; goaYXsyEWlxdO=60.I6m8rZy8fEGYpPmjsxJzcQD7H_fstonBF3XyGvvyhDh1_7c_JIFFrAfHsmKk6KtOVWbM2ztenFjMrPRSWIm1a; Hm_lvt_9c8767bf2ffaff9d16e0e409bd28017b=1688529126; zg_did=%7B%22did%22%3A%20%22189242dc17d992-0d47d539a4c70c-3d267449-144000-189242dc17e9f3%22%7D; _gid=GA1.3.678250233.1688529126; CHSICC01=!bLuJc+pYd0Ah1bvzYxYLahOzddj6Y5Wo66QcNq34LuAZUVPejROt5X6Oa37p4b53SrFxCblP8+yMsQ==; zg_14e129856fe4458eb91a735923550aa6=%7B%22sid%22%3A%201688529125761%2C%22updated%22%3A%201688529387258%2C%22info%22%3A%201688529125764%2C%22superProperty%22%3A%20%22%7B%7D%22%2C%22platform%22%3A%20%22%7B%7D%22%2C%22utm%22%3A%20%22%7B%7D%22%2C%22referrerDomain%22%3A%20%22%22%7D; Hm_lpvt_9c8767bf2ffaff9d16e0e409bd28017b=1688529387; _gat_gtag_UA_100524_1=1; _ga_8YMQD1TE48=GS1.1.1688529126.1.1.1688529387.0.0.0; _ga=GA1.1.2127309674.1688529126; goaYXsyEWlxdP=0jBX.aMEoAQAFi9Gmc9MppqIgDOlO8y_aQsmwyuvCdpbPOREblHy3rBYZ3akqvFSvw4wcAomCzMD_pFYl8MVkZ2D23rBjUNOxrqv.5iDjY66XvY1Pna6naF2xfKgvnvDTi5eOmrfSMgXiCW0EXcoGodkTJzbf6zmAqNcyw9aqpiBX980BsYj_Cgp5dDZvXxPK6yti7dHIQ_Oc7fWCOHPmjc7fRt.Xb0WxDqaQ7nQHckj9in8oSZf6uK6M5cjzp804QvVOiUoBq07KdCj_jVLIJndVclyF8iiT5Y5ytnCRogjhcgk_iGonLzXlugXQ7gfCbLlgqtmvJCIkhX99I0PwWYJ_Y5xuQuDhUM7kfwqBJSxm6MrozS7XHgvpKxTtg7pwg07awfezZWbh4ZCNidpXf5E90ppv4hFizfKH7ZUgQ0a"); //由webview执行js返回。
|
||||
// xuexinHttp.savePicture("https://www.chsi.com.cn/xlcx/bg.do?vcode=AA33TE9X16WA202D&srcid=bgcx"); //由webview执行js返回。
|
||||
String s = HttpUtil.get("https://www.chsi.com.cn/xlcx/bg.do?vcode=AA33TE9X16WA202D&srcid=bgcx");
|
||||
parseXueJi(s);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 学籍解析
|
||||
*/
|
||||
private static void parseXueJi(String strHtml) {
|
||||
Document doc = Jsoup.parse(strHtml, "UTF-8");
|
||||
Elements eleDiv2 = doc.getElementsByClass("report-info");
|
||||
if (eleDiv2 != null && !eleDiv2.isEmpty()) {
|
||||
Elements eleTd = eleDiv2.get(0).getElementsByTag("div");
|
||||
String text = eleTd.get(4).text();
|
||||
/* if (eleTd != null && !eleTd.isEmpty()) {
|
||||
StuInfo stuInfo = new StuInfo();
|
||||
// 姓名是图片,调用腾讯API实现ocr识别
|
||||
String nameImg = eleTd.get(1).getElementsByTag("img").get(0).attr("src");
|
||||
stuInfo.setName(aiOcr(nameImg));
|
||||
stuInfo.setGender(eleTd.get(4).text());
|
||||
stuInfo.setIdCard(eleTd.get(6).text());
|
||||
stuInfo.setNation(eleTd.get(8).text());
|
||||
stuInfo.setBirthDay(eleTd.get(10).text());
|
||||
stuInfo.setUniversity(eleTd.get(12).text());
|
||||
stuInfo.setLevel(eleTd.get(14).text());
|
||||
stuInfo.setDepartment(eleTd.get(16).text());
|
||||
stuInfo.setSClass(eleTd.get(18).text());
|
||||
stuInfo.setDomain(eleTd.get(20).text());
|
||||
stuInfo.setStuNum(eleTd.get(22).text());
|
||||
stuInfo.setForm(eleTd.get(24).text());
|
||||
stuInfo.setEntranceDate(eleTd.get(26).text());
|
||||
stuInfo.setLenOfSchooling(eleTd.get(28).text());
|
||||
stuInfo.setType(eleTd.get(30).text());
|
||||
String[] status = eleTd.get(32).text().split("\\(");
|
||||
stuInfo.setStatus(status[0]);
|
||||
stuInfo.setGraduationDate(status[1].substring(0, status[1].length() - 1));*/
|
||||
// return stuInfo;
|
||||
// }
|
||||
}
|
||||
// return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 学历解析
|
||||
*/
|
||||
/*private static StuInfo parseXueLi(String strHtml) {
|
||||
Document doc = Jsoup.parse(strHtml, "UTF-8");
|
||||
Elements eleDiv2 = doc.getElementsByClass("div2");
|
||||
if (eleDiv2 != null && !eleDiv2.isEmpty()) {
|
||||
Elements eleTd = eleDiv2.get(0).getElementsByTag("td");
|
||||
if (eleTd != null && !eleTd.isEmpty()) {
|
||||
StuInfo stuInfo = new StuInfo();
|
||||
// 姓名是图片,调用腾讯API实现ocr识别
|
||||
String nameImg = eleTd.get(0).getElementsByTag("img").get(0).attr("src");
|
||||
stuInfo.setName(aiOcr(nameImg));
|
||||
stuInfo.setGender(eleTd.get(2).text());
|
||||
stuInfo.setBirthDay(eleTd.get(3).text());
|
||||
stuInfo.setEntranceDate(eleTd.get(4).text());
|
||||
stuInfo.setGraduationDate(eleTd.get(5).text());
|
||||
stuInfo.setType(eleTd.get(6).text());
|
||||
stuInfo.setLevel(eleTd.get(7).text());
|
||||
stuInfo.setUniversity(eleTd.get(8).text());
|
||||
stuInfo.setLenOfSchooling(eleTd.get(9).text());
|
||||
stuInfo.setDomain(eleTd.get(10).text());
|
||||
stuInfo.setForm(eleTd.get(11).text());
|
||||
stuInfo.setCertificateNum(eleTd.get(12).text());
|
||||
// 状态是图片,调用腾讯API实现ocr识别
|
||||
String statusImg = eleTd.get(13).getElementsByTag("img").get(0).attr("src");
|
||||
stuInfo.setStatus(aiOcr(statusImg));
|
||||
stuInfo.setPresident(eleTd.get(14).text());
|
||||
return stuInfo;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}*/
|
||||
}
|
||||
@ -165,6 +165,62 @@
|
||||
<artifactId>ip2region</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 导work-->
|
||||
<dependency>
|
||||
<groupId>com.deepoove</groupId>
|
||||
<artifactId>poi-tl</artifactId>
|
||||
<version>1.12.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- rsa加密-->
|
||||
<dependency>
|
||||
<groupId>com.antherd</groupId>
|
||||
<artifactId>sm-crypto</artifactId>
|
||||
<version>0.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 解析html-->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.15.4</version>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-excelant</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>-->
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@ -0,0 +1,151 @@
|
||||
package com.ruoyi.common.advice;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.useragent.Platform;
|
||||
import cn.hutool.http.useragent.UserAgent;
|
||||
import cn.hutool.http.useragent.UserAgentUtil;
|
||||
import com.ruoyi.common.core.domain.RsaSecurity;
|
||||
import com.ruoyi.common.core.service.ConfigService;
|
||||
import com.ruoyi.common.core.service.IRsaSecurityService2;
|
||||
import com.ruoyi.common.utils.RSAUtil;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpInputMessage;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Type;
|
||||
import java.rmi.ServerException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author monkey
|
||||
* @desc 请求数据解密
|
||||
* @date 2018/10/29 20:17
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class DecodeRequestBodyAdvice implements RequestBodyAdvice {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DecodeRequestBodyAdvice.class);
|
||||
private static final IRsaSecurityService2 rsaSecurityService= SpringUtils.getBean(IRsaSecurityService2.class);
|
||||
|
||||
@Override
|
||||
public boolean supports(MethodParameter methodParameter, Type type, Class<? extends HttpMessageConverter<?>> aClass) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object handleEmptyBody(Object body, HttpInputMessage httpInputMessage, MethodParameter methodParameter, Type type, Class<? extends HttpMessageConverter<?>> aClass) {
|
||||
return body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter methodParameter, Type type, Class<? extends HttpMessageConverter<?>> aClass) throws IOException {
|
||||
try {
|
||||
String path = inputMessage.getHeaders().getFirst("path");
|
||||
String method = inputMessage.getHeaders().getFirst("method");
|
||||
if (ObjectUtil.isNotNull(path)) {
|
||||
RsaSecurity info = rsaSecurityService.getInfo(path, StringUtils.toRootUpperCase(method));
|
||||
if (ObjectUtil.isNotNull(info)) {
|
||||
if ("1".equals(info.getRestricted())){
|
||||
throw new ServerException("接口已限制请求");
|
||||
}
|
||||
if ("1".equals(info.getInDecode())) {
|
||||
return new RsaHttpInputMessage(inputMessage, info.getPrivateKey());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/*if (methodParameter.getMethod().isAnnotationPresent(RsaSecurityParameter.class)) {
|
||||
//获取注解配置的包含和去除字段
|
||||
RsaSecurityParameter serializedField = methodParameter.getMethodAnnotation(RsaSecurityParameter.class);
|
||||
//入参是否需要解密
|
||||
if (serializedField.inDecode()) {
|
||||
logger.info("注解RsaSecurityParameter,对方法method :【" + methodParameter.getMethod().getName() + "】返回数据进行解密");
|
||||
return new RsaHttpInputMessage(inputMessage);
|
||||
}
|
||||
}*/
|
||||
return inputMessage;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("对方法method :【" + methodParameter.getMethod().getName() + "】返回数据进行解密出现异常:" + e.getMessage());
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object afterBodyRead(Object body, HttpInputMessage httpInputMessage, MethodParameter methodParameter, Type type, Class<? extends HttpMessageConverter<?>> aClass) {
|
||||
return body;
|
||||
}
|
||||
|
||||
class RsaHttpInputMessage implements HttpInputMessage {
|
||||
private HttpHeaders headers;
|
||||
|
||||
private InputStream body;
|
||||
|
||||
public RsaHttpInputMessage(HttpInputMessage inputMessage,String privateKey ) throws Exception {
|
||||
this.headers = inputMessage.getHeaders();
|
||||
String targe="pc";
|
||||
List<String> list = headers.get("targe");
|
||||
if (ObjectUtil.isNotNull(list) && list.size()>0) {
|
||||
boolean wxixin = list.contains("weixin");
|
||||
if (wxixin) {
|
||||
targe = "weixin";
|
||||
}
|
||||
}
|
||||
this.body = IoUtil.toUtf8Stream(easpString(IoUtil.readUtf8(inputMessage.getBody()),targe,privateKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
public String easpString(String requestData,String targe,String privateKey) throws IOException {
|
||||
if (requestData != null && !requestData.equals("")) {
|
||||
if (StringUtils.isEmpty(requestData)) {
|
||||
throw new RuntimeException("参数【requestData】缺失异常!");
|
||||
} else {
|
||||
String content = null;
|
||||
try {
|
||||
logger.info("解密密文:"+requestData);
|
||||
String substring1 = StringUtils.substring(requestData, 0, 1);
|
||||
if ("\"".equals(substring1)){
|
||||
String data1 = requestData.substring(1);
|
||||
String substring = requestData.substring(1, data1.length());
|
||||
content = RSAUtil.privateKeyDecryptStr(substring,privateKey);
|
||||
}else {
|
||||
content = RSAUtil.privateKeyDecryptStr(requestData,privateKey);
|
||||
}
|
||||
logger.info("解密明文:"+content);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("msg:参数【aseKey】解析异常!");
|
||||
}
|
||||
try {
|
||||
} catch (Exception e) {
|
||||
throw new ServerException("msg:参数【content】解析异常!");
|
||||
}
|
||||
if (StringUtils.isEmpty(content)) {
|
||||
throw new RuntimeException("msg:参数【requestData】解析参数空指针异常!");
|
||||
}
|
||||
return content;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("msg:参数【requestData】不合法异常!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package com.ruoyi.common.advice;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.RsaSecurity;
|
||||
import com.ruoyi.common.core.service.IRsaSecurityService2;
|
||||
import com.ruoyi.common.utils.JsonUtils;
|
||||
import com.ruoyi.common.utils.RSAUtil;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||
|
||||
/**
|
||||
* @author monkey
|
||||
* @desc 返回数据加密
|
||||
* @date 2018/10/25 20:17
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class EncodeResponseBodyAdvice implements ResponseBodyAdvice {
|
||||
private final static Logger logger = LoggerFactory.getLogger(EncodeResponseBodyAdvice.class);
|
||||
private static final IRsaSecurityService2 rsaSecurityService=SpringUtils.getBean(IRsaSecurityService2.class);
|
||||
|
||||
|
||||
@Override
|
||||
public boolean supports(MethodParameter methodParameter, Class aClass) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object beforeBodyWrite(Object body, MethodParameter methodParameter, MediaType mediaType, Class aClass, ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) {
|
||||
// 此处要用反射将字段中的注解解析出来
|
||||
String method = serverHttpRequest.getMethod().name();
|
||||
String path = serverHttpRequest.getURI().getPath();
|
||||
RsaSecurity info = rsaSecurityService.getInfo(path,method);
|
||||
if (ObjectUtil.isNotNull(info)) {
|
||||
if ("1".equals(info.getRestricted())){
|
||||
return R.fail("接口已限制请求");
|
||||
}
|
||||
if ("1".equals(info.getOutEncode())) {
|
||||
serverHttpResponse.getHeaders().add("isRsaencrypt","true");
|
||||
return encodeRsa(methodParameter, body, info.getPublicKey());
|
||||
}
|
||||
}
|
||||
serverHttpResponse.getHeaders().add("isRsaencrypt","false");
|
||||
return body;
|
||||
/*if (methodParameter.getMethod().isAnnotationPresent(RsaSecurityParameter.class)) {
|
||||
//获取注解配置的包含和去除字段
|
||||
RsaSecurityParameter serializedField = methodParameter.getMethodAnnotation(RsaSecurityParameter.class);
|
||||
//出参是否需要加密
|
||||
if (serializedField.outEncode()) {
|
||||
return encodeRsa(methodParameter, body,serializedField.outPublicKey());
|
||||
}
|
||||
}
|
||||
JSONObject jsonObject = JSONUtil.parseObj(body);
|
||||
Object code = jsonObject.get("code");
|
||||
String num = "500";
|
||||
String num2 ="401";
|
||||
String num3 ="403";
|
||||
if (ObjectUtil.isNotNull(code)){
|
||||
if (num.equals(code.toString()) || num2.equals(code.toString()) || num3.equals(code.toString())){
|
||||
return encodeRsa(methodParameter, body,"");
|
||||
}
|
||||
}
|
||||
return body;*/
|
||||
}
|
||||
|
||||
/**
|
||||
* RSA私钥加密
|
||||
*
|
||||
* @param methodParameter
|
||||
* @param body
|
||||
* @return
|
||||
*/
|
||||
private Object encodeRsa(MethodParameter methodParameter, Object body,String outPublicKey) {
|
||||
try {
|
||||
String result = JsonUtils.toJsonString(body);
|
||||
logger.info("对返回数据 :【" + result + "】进行加密");
|
||||
String s = RSAUtil.publicKeyEncryptBase64(result,outPublicKey);
|
||||
logger.info("加密之后密文:"+s);
|
||||
return s;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("对方法method :【" + methodParameter.getMethod().getName() + "】返回数据进行加密出现异常:" + e.getMessage());
|
||||
}
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -41,4 +41,20 @@ public interface CacheConstants {
|
||||
* 登录账户密码错误次数 redis key
|
||||
*/
|
||||
String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
||||
|
||||
|
||||
/**
|
||||
* 注册发送验证码
|
||||
*/
|
||||
String REGISTER_SEND_MSG = "register_send_msg:";
|
||||
|
||||
/**
|
||||
* 忘记密码发送验证码
|
||||
*/
|
||||
String RORGOT_PASSWORD_SEND_MSG = "rorgot_password_send_msg:";
|
||||
|
||||
/**
|
||||
* 短信登录发送验证码
|
||||
*/
|
||||
String SMS_LOGIN_SEND_MSG = "sms_login_send_msg:";
|
||||
}
|
||||
|
||||
@ -30,6 +30,9 @@ public interface CacheNames {
|
||||
*/
|
||||
String SYS_DICT = "sys_dict";
|
||||
|
||||
|
||||
String RSA_SECURITY = "rsa_security";
|
||||
|
||||
/**
|
||||
* 用户账户
|
||||
*/
|
||||
|
||||
@ -72,5 +72,46 @@ public interface Constants {
|
||||
*/
|
||||
String TOKEN = "token";
|
||||
|
||||
/**
|
||||
* 待提交
|
||||
*/
|
||||
String SUBMIT = "0";
|
||||
|
||||
/**
|
||||
* 审核等待中
|
||||
*/
|
||||
String WAIT = "1";
|
||||
|
||||
/**
|
||||
* 审核失败
|
||||
*/
|
||||
String FAILD = "2";
|
||||
|
||||
|
||||
/**
|
||||
* 公式中
|
||||
*/
|
||||
String PUBLICS = "3";
|
||||
|
||||
/**
|
||||
* 公式失败
|
||||
*/
|
||||
String PUBLICSFail = "4";
|
||||
|
||||
/**
|
||||
* 审核成功
|
||||
*/
|
||||
String SUCCEED = "5";
|
||||
|
||||
/**
|
||||
* 取消资格
|
||||
*/
|
||||
String CANCEL = "6";
|
||||
|
||||
/**
|
||||
* 数据不存在
|
||||
*/
|
||||
String NONENTITY = "nonentity";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -121,8 +121,9 @@ public interface UserConstants {
|
||||
/**
|
||||
* 密码长度限制
|
||||
*/
|
||||
int PASSWORD_MIN_LENGTH = 5;
|
||||
int PASSWORD_MIN_LENGTH = 8;
|
||||
int PASSWORD_MAX_LENGTH = 20;
|
||||
String PASSWORD_Pattern = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,18}$";
|
||||
|
||||
/**
|
||||
* 管理员ID
|
||||
|
||||
@ -2,6 +2,7 @@ package com.ruoyi.common.core.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
@ -39,6 +40,7 @@ public class BaseEntity implements Serializable {
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
@ -51,6 +53,7 @@ public class BaseEntity implements Serializable {
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
|
||||
@ -47,6 +47,9 @@ public class R<T> implements Serializable {
|
||||
public static <T> R<T> ok(String msg, T data) {
|
||||
return restResult(data, SUCCESS, msg);
|
||||
}
|
||||
public static <T> R<T> ok(int code,String msg, T data) {
|
||||
return restResult(data, code, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail() {
|
||||
return restResult(null, FAIL, "操作失败");
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
package com.ruoyi.common.core.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 请求RSA数据加解密对象 rsa_security
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-05-17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("rsa_security")
|
||||
public class RsaSecurity extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* 需要加密的接口
|
||||
*/
|
||||
private String path;
|
||||
/**
|
||||
* 入参是否解密,默认不解密
|
||||
*/
|
||||
private String inDecode;
|
||||
/**
|
||||
* 出参是否加密,默认加密
|
||||
*/
|
||||
private String outEncode;
|
||||
/**
|
||||
* 公钥
|
||||
*/
|
||||
private String publicKey;
|
||||
/**
|
||||
* 私钥
|
||||
*/
|
||||
private String privateKey;
|
||||
|
||||
/**
|
||||
* 请求方式
|
||||
*/
|
||||
private String method;
|
||||
|
||||
/**
|
||||
* 接口限制请求
|
||||
*/
|
||||
private String restricted;
|
||||
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
package com.ruoyi.common.core.domain.entity;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import lombok.Data;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* 高新人才接口返回所需
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class GaoXinCardInfo implements Serializable {
|
||||
|
||||
/**
|
||||
* 身份证
|
||||
*/
|
||||
private String card_id;
|
||||
/**
|
||||
* 国籍
|
||||
*/
|
||||
private String nationality;
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
private String company_name;
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String sex;
|
||||
/**
|
||||
* 公司所在区域
|
||||
*/
|
||||
private String district;
|
||||
/**
|
||||
* 人才类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 学历
|
||||
*/
|
||||
private String education;
|
||||
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
if (ObjectUtil.isNotNull(type) && ObjectUtil.isNotEmpty(type)) {
|
||||
type = StringUtils.trimAllWhitespace(type);
|
||||
if (type.length() == 1) {
|
||||
this.type = type + "类";
|
||||
}else {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getNationality() {
|
||||
return nationality;
|
||||
}
|
||||
|
||||
public void setNationality(String nationality) {
|
||||
if (ObjectUtil.isNotNull(nationality) && ObjectUtil.isNotEmpty(nationality)) {
|
||||
nationality = StringUtils.trimAllWhitespace(nationality);
|
||||
if ("中国".equals(nationality)) {
|
||||
this.nationality = nationality + "籍";
|
||||
}else {
|
||||
this.nationality = nationality;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package com.ruoyi.common.core.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class StuInfo implements Serializable {
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String headImg;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 证件号码
|
||||
*/
|
||||
private String idCard;
|
||||
/**
|
||||
* 民族
|
||||
*/
|
||||
private String nation;
|
||||
/**
|
||||
* 出生日期
|
||||
*/
|
||||
private String birthDay;
|
||||
/**
|
||||
* 院校
|
||||
*/
|
||||
private String university;
|
||||
/**
|
||||
* 院系
|
||||
*/
|
||||
private String department;
|
||||
/**
|
||||
* 专业
|
||||
*/
|
||||
private String domain;
|
||||
/**
|
||||
* 层次,如本科
|
||||
*/
|
||||
private String level;
|
||||
/**
|
||||
* 班级
|
||||
*/
|
||||
private String sClass;
|
||||
/**
|
||||
* 学号
|
||||
*/
|
||||
private String stuNum;
|
||||
/**
|
||||
* 形式
|
||||
*/
|
||||
private String form;
|
||||
/**
|
||||
* 入学时间
|
||||
*/
|
||||
private String entranceDate;
|
||||
/**
|
||||
* 学制
|
||||
*/
|
||||
private String lenOfSchooling;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 学籍状态
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 毕业时间
|
||||
*/
|
||||
private String graduationDate;
|
||||
/**
|
||||
* 学历证书编号
|
||||
*/
|
||||
private String certificateNum;
|
||||
/**
|
||||
* 校长
|
||||
*/
|
||||
private String president;
|
||||
|
||||
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.ruoyi.common.core.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@ -27,7 +28,7 @@ public class SysDept extends TreeEntity<SysDept> {
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@TableId(value = "dept_id")
|
||||
@TableId(value = "dept_id",type = IdType.AUTO)
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
|
||||
@ -2,6 +2,7 @@ package com.ruoyi.common.core.domain.entity;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.ExcelDictFormat;
|
||||
@ -30,7 +31,7 @@ public class SysDictData extends BaseEntity {
|
||||
* 字典编码
|
||||
*/
|
||||
@ExcelProperty(value = "字典编码")
|
||||
@TableId(value = "dict_code")
|
||||
@TableId(value = "dict_code",type = IdType.AUTO)
|
||||
private Long dictCode;
|
||||
|
||||
/**
|
||||
|
||||
@ -2,6 +2,7 @@ package com.ruoyi.common.core.domain.entity;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.ExcelDictFormat;
|
||||
@ -30,7 +31,7 @@ public class SysDictType extends BaseEntity {
|
||||
* 字典主键
|
||||
*/
|
||||
@ExcelProperty(value = "字典主键")
|
||||
@TableId(value = "dict_id")
|
||||
@TableId(value = "dict_id",type = IdType.AUTO)
|
||||
private Long dictId;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.ruoyi.common.core.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
@ -25,7 +26,7 @@ public class SysMenu extends TreeEntity<SysMenu> {
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
@TableId(value = "menu_id")
|
||||
@TableId(value = "menu_id",type = IdType.AUTO)
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
|
||||
@ -2,10 +2,7 @@ package com.ruoyi.common.core.domain.entity;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.ruoyi.common.annotation.ExcelDictFormat;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.convert.ExcelDictConvert;
|
||||
@ -35,7 +32,7 @@ public class SysRole extends BaseEntity {
|
||||
* 角色ID
|
||||
*/
|
||||
@ExcelProperty(value = "角色序号")
|
||||
@TableId(value = "role_id")
|
||||
@TableId(value = "role_id",type = IdType.AUTO)
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
|
||||
@ -33,7 +33,7 @@ public class SysUser extends BaseEntity {
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableId(value = "user_id")
|
||||
@TableId(value = "user_id",type = IdType.AUTO)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
@ -128,6 +128,11 @@ public class SysUser extends BaseEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 楼盘
|
||||
*/
|
||||
private String properties;
|
||||
|
||||
/**
|
||||
* 部门对象
|
||||
*/
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package com.ruoyi.common.core.domain.event;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 推送日志对象 push_log
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-07-20
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("push_log")
|
||||
public class PushLogEvent extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* 推送数据
|
||||
*/
|
||||
private String pushData;
|
||||
/**
|
||||
* 返回结果
|
||||
*/
|
||||
private String resultData;
|
||||
|
||||
}
|
||||
@ -5,6 +5,7 @@ import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* 用户登录对象
|
||||
@ -18,20 +19,22 @@ public class LoginBody {
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@NotBlank(message = "{user.username.not.blank}")
|
||||
@Length(min = UserConstants.USERNAME_MIN_LENGTH, max = UserConstants.USERNAME_MAX_LENGTH, message = "{user.username.length.valid}")
|
||||
@NotBlank(message = "{user.username.not.blank}",groups = {passwordLogin.class,smgLogin.class,forgetPasswordLogin.class,registerUser.class,userOpenLogin.class})
|
||||
@Length(min = UserConstants.USERNAME_MIN_LENGTH, max = UserConstants.USERNAME_MAX_LENGTH, message = "{user.username.length.valid}",groups = {passwordLogin.class,smgLogin.class,forgetPasswordLogin.class,registerUser.class})
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
@NotBlank(message = "{user.password.not.blank}")
|
||||
@Length(min = UserConstants.PASSWORD_MIN_LENGTH, max = UserConstants.PASSWORD_MAX_LENGTH, message = "{user.password.length.valid}")
|
||||
@NotBlank(message = "{user.password.not.blank}",groups = {passwordLogin.class,forgetPasswordLogin.class,registerUser.class})
|
||||
@Pattern(regexp = UserConstants.PASSWORD_Pattern,message = "{the.password.is.not.within.the.specified.range}",groups = {passwordLogin.class,forgetPasswordLogin.class,registerUser.class})
|
||||
@Length(min = UserConstants.PASSWORD_MIN_LENGTH, max = UserConstants.PASSWORD_MAX_LENGTH, message = "{user.password.length.valid}",groups = {passwordLogin.class,forgetPasswordLogin.class,registerUser.class})
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
@NotBlank(message = "{user.jcaptcha.not.blank}",groups = {smgLogin.class,forgetPasswordLogin.class,registerUser.class})
|
||||
private String code;
|
||||
|
||||
/**
|
||||
@ -39,4 +42,37 @@ public class LoginBody {
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
|
||||
/**
|
||||
* 外部用户标识key
|
||||
*/
|
||||
@NotBlank(message = "user.id.cannot.be.empty",groups ={userOpenLogin.class})
|
||||
private String apiKey;
|
||||
|
||||
|
||||
/**
|
||||
* 账号登录验证
|
||||
*/
|
||||
public interface passwordLogin {}
|
||||
|
||||
/**
|
||||
* 短信登录验证
|
||||
*/
|
||||
public interface smgLogin {}
|
||||
|
||||
/**
|
||||
* 忘记密码验证
|
||||
*/
|
||||
public interface forgetPasswordLogin {}
|
||||
|
||||
/**
|
||||
* 注册验证
|
||||
*/
|
||||
public interface registerUser {}
|
||||
|
||||
public interface userOpenLogin {}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -90,6 +90,17 @@ public class LoginUser implements Serializable {
|
||||
*/
|
||||
private String username;
|
||||
|
||||
private String nickName;
|
||||
|
||||
private String companyId;
|
||||
|
||||
/**
|
||||
* 楼盘
|
||||
*/
|
||||
private String properties;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 角色对象
|
||||
*/
|
||||
|
||||
@ -17,12 +17,12 @@ public class SmsLoginBody {
|
||||
* 手机号
|
||||
*/
|
||||
@NotBlank(message = "{user.phonenumber.not.blank}")
|
||||
private String phonenumber;
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 短信code
|
||||
*/
|
||||
@NotBlank(message = "{sms.code.not.blank}")
|
||||
private String smsCode;
|
||||
private String verificationCode;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
package com.ruoyi.common.core.domain.model;
|
||||
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 用户登录对象
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class UserLoginBody {
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@NotBlank(message = "{user.username.not.blank}")
|
||||
@Length(min = UserConstants.USERNAME_MIN_LENGTH, max = UserConstants.USERNAME_MAX_LENGTH, message = "{user.username.length.valid}")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
@NotBlank(message = "{user.password.not.blank}")
|
||||
@Length(min = UserConstants.PASSWORD_MIN_LENGTH, max = UserConstants.PASSWORD_MAX_LENGTH, message = "{user.password.length.valid}")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
@NotBlank(message = "{user.code.not.blank}")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 唯一标识
|
||||
*/
|
||||
@NotBlank(message = "{user.password.not.blank}")
|
||||
@Length(min = UserConstants.PASSWORD_MIN_LENGTH, max = UserConstants.PASSWORD_MAX_LENGTH, message = "{user.password.length.valid}")
|
||||
private String twoPassword;
|
||||
|
||||
}
|
||||
@ -1,5 +1,8 @@
|
||||
package com.ruoyi.common.core.service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 通用 参数配置服务
|
||||
*
|
||||
@ -15,4 +18,11 @@ public interface ConfigService {
|
||||
*/
|
||||
String getConfigValue(String configKey);
|
||||
|
||||
/**
|
||||
* 根据key获取数据
|
||||
* @param configKey
|
||||
* @return
|
||||
*/
|
||||
void selectConfigByConfigKey(String configKey);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
package com.ruoyi.common.core.service;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.domain.RsaSecurity;
|
||||
|
||||
public interface IRsaSecurityService2 {
|
||||
|
||||
RsaSecurity getInfo(String path,String method);
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
package com.ruoyi.common.core.validate;
|
||||
|
||||
public interface DownloadGroup {
|
||||
}
|
||||
@ -17,6 +17,12 @@ public enum LimitType {
|
||||
*/
|
||||
IP,
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
USERID,
|
||||
|
||||
|
||||
/**
|
||||
* 实例限流(集群多后端实例)
|
||||
*/
|
||||
|
||||
@ -41,4 +41,5 @@ public enum LoginType {
|
||||
* 登录重试限制计数提示
|
||||
*/
|
||||
final String retryLimitCount;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,83 @@
|
||||
package com.ruoyi.common.exception.file;
|
||||
|
||||
import org.apache.commons.fileupload.FileUploadException;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* 文件上传 误异常类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
|
||||
public class InvalidExtensionException extends FileUploadException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String[] allowedExtension;
|
||||
private String extension;
|
||||
private String filename;
|
||||
|
||||
public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
|
||||
{
|
||||
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");
|
||||
this.allowedExtension = allowedExtension;
|
||||
this.extension = extension;
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String[] getAllowedExtension()
|
||||
{
|
||||
return allowedExtension;
|
||||
}
|
||||
|
||||
public String getExtension()
|
||||
{
|
||||
return extension;
|
||||
}
|
||||
|
||||
public String getFilename()
|
||||
{
|
||||
return filename;
|
||||
}
|
||||
|
||||
public static class InvalidImageExtensionException extends InvalidExtensionException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename)
|
||||
{
|
||||
super(allowedExtension, extension, filename);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvalidFlashExtensionException extends InvalidExtensionException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename)
|
||||
{
|
||||
super(allowedExtension, extension, filename);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvalidMediaExtensionException extends InvalidExtensionException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename)
|
||||
{
|
||||
super(allowedExtension, extension, filename);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvalidVideoExtensionException extends InvalidExtensionException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename)
|
||||
{
|
||||
super(allowedExtension, extension, filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,22 @@
|
||||
package com.ruoyi.common.filter;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.ruoyi.common.core.service.ConfigService;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Repeatable 过滤器
|
||||
@ -13,9 +24,9 @@ import java.io.IOException;
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class RepeatableFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -23,9 +34,13 @@ public class RepeatableFilter implements Filter {
|
||||
throws IOException, ServletException {
|
||||
ServletRequest requestWrapper = null;
|
||||
if (request instanceof HttpServletRequest
|
||||
&& StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) {
|
||||
&& StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE) ) {
|
||||
requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
|
||||
}
|
||||
if (!isSafe((HttpServletRequest) request,(HttpServletResponse) response)) {
|
||||
((HttpServletResponse) response).setStatus(403);
|
||||
return;
|
||||
}
|
||||
if (null == requestWrapper) {
|
||||
chain.doFilter(request, response);
|
||||
} else {
|
||||
@ -37,4 +52,59 @@ public class RepeatableFilter implements Filter {
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断请求是正确
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
private boolean isSafe(HttpServletRequest request,HttpServletResponse response) {
|
||||
ConfigService sysConfigService = SpringUtils.getBean(ConfigService.class);
|
||||
String configValue = sysConfigService.getConfigValue("sys:preventing:hotlinking");
|
||||
List<String> strings = Arrays.asList(configValue.split(","));
|
||||
if (ObjectUtil.isEmpty(configValue)) {
|
||||
// 未设置任何链接,表示所有来源都可以访问
|
||||
return true;
|
||||
}
|
||||
String referer = request.getHeader("referer");
|
||||
if (referer == null || "".equals(referer)) {
|
||||
// 获取不到防盗链头部信息 -> 拦截
|
||||
System.out.println("referer为空进行拦截");
|
||||
return true;
|
||||
}
|
||||
for (String white : strings) {
|
||||
if (white.contains("*.")) {
|
||||
// 这里处理*.xxx.com,表示xxx.com下的所有二级域名均可访问,所以就截取掉'*.'符号
|
||||
white = white.replace("*.", "");
|
||||
}
|
||||
// 这里就简单的判断referer请求头中的链接是否包含我们白名单中的域名
|
||||
if (referer.contains(white)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理相应数据
|
||||
*
|
||||
* @param response
|
||||
*/
|
||||
public void handleResponse(HttpServletResponse response) {
|
||||
// 访问链接有问题
|
||||
try {
|
||||
Map<String, String> resultMsg = new HashMap<>();
|
||||
resultMsg.put("code", String.valueOf(HttpStatus.FORBIDDEN));
|
||||
resultMsg.put("msg", "资源不允许");
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String msg = objectMapper.writeValueAsString(resultMsg);
|
||||
response.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE);
|
||||
response.setStatus(403);
|
||||
response.getWriter().write(msg);
|
||||
} catch (IOException e) {
|
||||
System.out.println("防盗链过滤器处理response失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
199
ruoyi-common/src/main/java/com/ruoyi/common/utils/CardsUtil.java
Normal file
199
ruoyi-common/src/main/java/com/ruoyi/common/utils/CardsUtil.java
Normal file
@ -0,0 +1,199 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import jodd.util.StringUtil;
|
||||
|
||||
/**
|
||||
* @Description 各证件卡号校验类
|
||||
* @author longwei
|
||||
* @date 2020/7/23 14:17
|
||||
*/
|
||||
public class CardsUtil {
|
||||
|
||||
/** 正则表达式:验证身份证 */
|
||||
public static final String REGEX_ID_CARD = "(^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|" +
|
||||
"(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)";
|
||||
|
||||
/** 正则表达式:验证户口簿 9位数字 */
|
||||
public static final String REGEX_HUKOU_CARD = "\\d{9}";
|
||||
|
||||
/** 正则表达式:验证护照 数字+字母,共9位 */
|
||||
public static final String REGEX_PASSPORT_CARD = "^([a-zA-z]|[0-9]){9}$";
|
||||
|
||||
/** 正则表达式:验证军官证 汉字+8位数字 */
|
||||
public static final String REGEX_OFFICER_CARD = "^[\\u4E00-\\u9FA5](字第)([0-9a-zA-Z]{4,8})(号?)$";
|
||||
|
||||
/** 正则表达式:验证驾驶证 12位数字 */
|
||||
public static final String REGEX_DRIVE_CARD = "\\d{12}$";
|
||||
|
||||
/** 正则表达式:验证港澳居民通行证 H/M + 10位或8位数字 */
|
||||
public static final String REGEX_HK_CARD = "^[HMhm]{1}([0-9]{10}|[0-9]{8})$";
|
||||
|
||||
/** 正则表达式:验证台湾居民通行证 新版8位或18位数字,旧版10位数字 + 英文字母 */
|
||||
public static final String REGEX_TW_CARD = "^\\d{8}|^[a-zA-Z0-9]{10}|^\\d{18}$";
|
||||
|
||||
/**
|
||||
* 校验身份证
|
||||
*
|
||||
* @param idCardNo 身份证号
|
||||
* @return 校验通过返回true,否则返回false
|
||||
* @by https://blog.csdn.net/u011106915/article/details/76066985
|
||||
*/
|
||||
public static boolean isIDCard(String idCardNo) {
|
||||
//校验非空
|
||||
if (StringUtil.isEmpty(idCardNo)) {
|
||||
return false;
|
||||
}
|
||||
//校验长度
|
||||
int idCardLength = idCardNo.length();
|
||||
if (idCardLength != 18 && idCardLength != 15 && idCardLength != 9) {
|
||||
return false;
|
||||
}
|
||||
if (idCardLength==9){
|
||||
return idCardNo.matches(REGEX_PASSPORT_CARD);
|
||||
}
|
||||
// 定义判别用户身份证号的正则表达式(15位或者18位,最后一位可以为字母)
|
||||
//假设18位身份证号码:41000119910101123X 410001 19910101 123X
|
||||
//^开头
|
||||
//[1-9] 第一位1-9中的一个 4
|
||||
//\\d{5} 五位数字 10001(前六位省市县地区)
|
||||
//(18|19|20) 19(现阶段可能取值范围18xx-20xx年)
|
||||
//\\d{2} 91(年份)
|
||||
//((0[1-9])|(10|11|12)) 01(月份)
|
||||
//(([0-2][1-9])|10|20|30|31)01(日期)
|
||||
//\\d{3} 三位数字 123(第十七位奇数代表男,偶数代表女)
|
||||
//[0-9Xx] 0123456789Xx其中的一个 X(第十八位为校验值)
|
||||
//$结尾
|
||||
|
||||
//假设15位身份证号码:410001910101123 410001 910101 123
|
||||
//^开头
|
||||
//[1-9] 第一位1-9中的一个 4
|
||||
//\\d{5} 五位数字 10001(前六位省市县地区)
|
||||
//\\d{2} 91(年份)
|
||||
//((0[1-9])|(10|11|12)) 01(月份)
|
||||
//(([0-2][1-9])|10|20|30|31)01(日期)
|
||||
//\\d{3} 三位数字 123(第十五位奇数代表男,偶数代表女),15位身份证不含X
|
||||
//$结尾
|
||||
|
||||
boolean matches = idCardNo.matches(REGEX_ID_CARD);
|
||||
|
||||
//判断第18位校验值
|
||||
if (matches) {
|
||||
|
||||
//如是15位身份证,不做更多校验,直接返回合法
|
||||
if (idCardLength == 15) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (idCardLength == 18) {
|
||||
try {
|
||||
char[] charArray = idCardNo.toCharArray();
|
||||
//前十七位加权因子
|
||||
int[] idCardWi = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
|
||||
//这是除以11后,可能产生的11位余数对应的验证码
|
||||
String[] idCardY = {"1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"};
|
||||
int sum = 0;
|
||||
for (int i = 0; i < idCardWi.length; i++) {
|
||||
int current = Integer.parseInt(String.valueOf(charArray[i]));
|
||||
int count = current * idCardWi[i];
|
||||
sum += count;
|
||||
}
|
||||
char idCardLast = charArray[17];
|
||||
int idCardMod = sum % 11;
|
||||
return idCardY[idCardMod].toUpperCase().equals(String.valueOf(idCardLast).toUpperCase());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验户口簿
|
||||
*
|
||||
* @param huKouNo 户口簿号
|
||||
* @return 校验通过返回true,否则返回false
|
||||
*/
|
||||
public static boolean isHuKouCard(String huKouNo) {
|
||||
//校验非空 校验长度
|
||||
if (StringUtils.isEmpty(huKouNo) || huKouNo.length() != 9 ) {
|
||||
return false;
|
||||
}
|
||||
return huKouNo.matches(REGEX_HUKOU_CARD);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验护照
|
||||
*
|
||||
* @param passPortNo 护照号
|
||||
* @return 校验通过返回true,否则返回false
|
||||
*/
|
||||
public static boolean isPassPortCard(String passPortNo) {
|
||||
//校验非空
|
||||
if (StringUtil.isEmpty(passPortNo)) {
|
||||
return false;
|
||||
}
|
||||
return passPortNo.matches(REGEX_PASSPORT_CARD);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验军官证
|
||||
* 规则: 军/兵/士/文/职/广/(其他中文) + "字第" + 4到8位字母或数字 + "号"
|
||||
* 样本: 军字第2001988号, 士字第P011816X号
|
||||
* @param officerNo 军官证号
|
||||
* @return 校验通过返回true,否则返回false
|
||||
*/
|
||||
public static boolean isofficerCard(String officerNo) {
|
||||
//校验非空
|
||||
if (StringUtil.isEmpty(officerNo)) {
|
||||
return false;
|
||||
}
|
||||
return officerNo.matches(REGEX_OFFICER_CARD);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验驾驶证
|
||||
*
|
||||
* @param driveNo 驾驶证号
|
||||
* @return 校验通过返回true,否则返回false
|
||||
*/
|
||||
public static boolean isDriveCard(String driveNo) {
|
||||
//校验非空 校验长度
|
||||
if (StringUtil.isEmpty(driveNo) || driveNo.length() != 12 ) {
|
||||
return false;
|
||||
}
|
||||
return driveNo.matches(REGEX_DRIVE_CARD);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验港澳通行证
|
||||
*
|
||||
* @param HMNo 港澳通行证号
|
||||
* @return 校验通过返回true,否则返回false
|
||||
*/
|
||||
public static boolean isHMCard(String HMNo) {
|
||||
//校验非空
|
||||
if (StringUtil.isEmpty(HMNo)) {
|
||||
return false;
|
||||
}
|
||||
return HMNo.matches(REGEX_HK_CARD);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验台湾通行证
|
||||
* 规则 新版8位或18位数字,旧版10位数字 + 英文字母
|
||||
* @param TWNo 台湾通行证号
|
||||
* @return 校验通过返回true,否则返回false
|
||||
*/
|
||||
public static boolean isTWCard(String TWNo) {
|
||||
//校验非空
|
||||
if (StringUtil.isEmpty(TWNo)) {
|
||||
return false;
|
||||
}
|
||||
return TWNo.matches(REGEX_TW_CARD);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,769 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
/**
|
||||
* @Description 时间日期工具类 封装工作中常用的一些时间日期计算方法等,还可以提供更多的重载方法,用于时间的转化等
|
||||
* @author
|
||||
* @Date
|
||||
*/
|
||||
public class DateHolidayUtils {
|
||||
private DateHolidayUtils() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* hhmmFormat="HH:mm"
|
||||
*/
|
||||
public static final String hhmmFormat = "HH:mm";
|
||||
/**
|
||||
* MMddFormat="MM-dd"
|
||||
*/
|
||||
public static final String MMddFormat = "MM-dd";
|
||||
/**
|
||||
* yyyyFormat="yyyy"
|
||||
*/
|
||||
public static final String yyyyFormat = "yyyy";
|
||||
/**
|
||||
* yyyyFormat="yyyy-MM"
|
||||
*/
|
||||
public static final String yyyyMMFormat = "yyyy-MM";
|
||||
/**
|
||||
* yyyyChineseFormat="yyyy年"
|
||||
*/
|
||||
public static final String yyyyChineseFormat = "yyyy年";
|
||||
/**
|
||||
* yyyyMMddFormat="yyyy-MM-dd"
|
||||
*/
|
||||
public static final String yyyyMMddFormat = "yyyy-MM-dd";
|
||||
/**
|
||||
* fullFormat="yyyy-MM-dd HH:mm:ss"
|
||||
*/
|
||||
public static final String fullFormat = "yyyy-MM-dd HH:mm:ss";
|
||||
/**
|
||||
* yyyyMMddHHmmss="yyyyMMddHHmmss"
|
||||
*/
|
||||
public static final String yyyyMMddHHmmss = "yyyyMMddHHmmss";
|
||||
/**
|
||||
* strFormat="yyyy/MM/dd HH:mm:ss"
|
||||
*/
|
||||
public static final String strFormat = "yyyy/MM/dd HH:mm:ss";
|
||||
/**
|
||||
* MMddChineseFormat="MM月dd日"
|
||||
*/
|
||||
public static final String MMddChineseFormat = "MM月dd日";
|
||||
/**
|
||||
* yyyyMMddChineseFormat="yyyy年MM月dd日"
|
||||
*/
|
||||
public static final String yyyyMMddChineseFormat = "yyyy年MM月dd日";
|
||||
/**
|
||||
* yyyyMMddChineseFormat="yyyy年MM月"
|
||||
*/
|
||||
public static final String yyyyMMChineseFormat = "yyyy年MM月";
|
||||
/**
|
||||
* fullChineseFormat="yyyy年MM月dd日HH时mm分ss秒"
|
||||
*/
|
||||
public static final String fullChineseFormat = "yyyy年MM月dd日HH时mm分ss秒";
|
||||
/**
|
||||
* WEEKS={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"}
|
||||
*/
|
||||
public static final String[] WEEKS = { "星期日", "星期一", "星期二", "星期三", "星期四",
|
||||
"星期五", "星期六" };
|
||||
|
||||
/**
|
||||
* 得到指定时间的时间日期格式
|
||||
*
|
||||
* @param date
|
||||
* 指定的时间
|
||||
* @param format
|
||||
* 时间日期格式
|
||||
* @return
|
||||
*/
|
||||
public static String getFormatDateTime(Date date, String format) {
|
||||
if(date == null){return "";}
|
||||
DateFormat df = new SimpleDateFormat(format);
|
||||
return df.format(date);
|
||||
}
|
||||
/**
|
||||
* 得到指定时间的时间日期格式(返回date)
|
||||
*
|
||||
* @param date
|
||||
* 指定的时间
|
||||
* @param format
|
||||
* 时间日期格式
|
||||
* @return
|
||||
*/
|
||||
public static Date getDateFormatDateTime(Date date, String format) {
|
||||
DateFormat df = new SimpleDateFormat(format);
|
||||
String s=df.format(date);
|
||||
try {
|
||||
return df.parse(s);
|
||||
} catch (ParseException e) { };
|
||||
return date;
|
||||
}
|
||||
|
||||
public static String getFormatDateToday(String format) {
|
||||
return getFormatDateTime(new Date(), format);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是润年
|
||||
*
|
||||
* @param date
|
||||
* 指定的时间
|
||||
* @return true:是润年,false:不是润年
|
||||
*/
|
||||
public static boolean isLeapYear(Date date) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
return isLeapYear(cal.get(Calendar.YEAR));
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是润年
|
||||
*
|
||||
* @param year
|
||||
* 指定的年
|
||||
* @return true:是润年,false:不是润年
|
||||
*/
|
||||
public static boolean isLeapYear(int year) {
|
||||
GregorianCalendar calendar = new GregorianCalendar();
|
||||
return calendar.isLeapYear(year);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断指定的时间是否是今天
|
||||
*
|
||||
* @param date
|
||||
* 指定的时间
|
||||
* @return true:是今天,false:非今天
|
||||
*/
|
||||
public static boolean isInToday(Date date) {
|
||||
boolean flag = false;
|
||||
Date now = new Date();
|
||||
String fullFormat = getFormatDateTime(now, DateHolidayUtils.yyyyMMddFormat);
|
||||
String beginString = fullFormat + " 00:00:00";
|
||||
String endString = fullFormat + " 23:59:59";
|
||||
DateFormat df = new SimpleDateFormat(DateHolidayUtils.fullFormat);
|
||||
try {
|
||||
Date beginTime = df.parse(beginString);
|
||||
Date endTime = df.parse(endString);
|
||||
flag = date.before(endTime) && date.after(beginTime);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断两时间是否是同一天
|
||||
*
|
||||
* @param from
|
||||
* 第一个时间点
|
||||
* @param to
|
||||
* 第二个时间点
|
||||
* @return true:是同一天,false:非同一天
|
||||
*/
|
||||
public static boolean isSameDay(Date from, Date to) {
|
||||
boolean isSameDay = false;
|
||||
DateFormat df = new SimpleDateFormat(DateHolidayUtils.yyyyMMddFormat);
|
||||
String firstDate = df.format(from);
|
||||
String secondDate = df.format(to);
|
||||
isSameDay = firstDate.equals(secondDate);
|
||||
return isSameDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法描述: 判断两时间是否是同一时间,精确到秒 作者:zhanglei 时间:2013-11-2下午04:22:33
|
||||
*
|
||||
* @param from
|
||||
* 第一个时间点
|
||||
* @param to
|
||||
* 第二个时间点
|
||||
* @return true:是,false:非
|
||||
*/
|
||||
public static boolean isSameTime(Date from, Date to) {
|
||||
boolean isSameDay = false;
|
||||
DateFormat df = new SimpleDateFormat(DateHolidayUtils.yyyyMMddHHmmss);
|
||||
String firstDate = df.format(from);
|
||||
String secondDate = df.format(to);
|
||||
isSameDay = firstDate.equals(secondDate);
|
||||
return isSameDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* 求出指定的时间那天是星期几
|
||||
*
|
||||
* @param date
|
||||
* 指定的时间
|
||||
* @return 星期X
|
||||
*/
|
||||
public static String getWeekString(Date date) {
|
||||
return DateHolidayUtils.WEEKS[getWeek(date) - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* 求出指定时间那天是星期几
|
||||
*
|
||||
* @param date
|
||||
* 指定的时间
|
||||
* @return 0-6 分别代表星期日-星期六
|
||||
*/
|
||||
public static int getWeekDay(Date date) {
|
||||
int week = getWeek(date);
|
||||
return week-1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 求出指定时间那天是星期几
|
||||
*
|
||||
* @param date
|
||||
* 指定的时间
|
||||
* @return 1-7
|
||||
*/
|
||||
public static int getWeek(Date date) {
|
||||
int week = 0;
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
week = cal.get(Calendar.DAY_OF_WEEK);
|
||||
return week;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得指定时间离现在是多少时间以前,如:3秒前,2小时前等 注意:此计算方法不是精确的
|
||||
*
|
||||
* @param date
|
||||
* 已有的指定时间
|
||||
* @return 时间段描述
|
||||
*/
|
||||
public static String getAgoTimeString(Date date) {
|
||||
Date now = new Date();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
Date agoTime = cal.getTime();
|
||||
long mtime = now.getTime() - agoTime.getTime();
|
||||
String str = "";
|
||||
long stime = mtime / 1000;
|
||||
long minute = 60;
|
||||
long hour = 60 * 60;
|
||||
long day = 24 * 60 * 60;
|
||||
long weeks = 7 * 24 * 60 * 60;
|
||||
long months = 100 * 24 * 60 * 60;
|
||||
if (stime < minute) {
|
||||
long time_value = stime;
|
||||
if (time_value <= 0) {
|
||||
time_value = 1;
|
||||
}
|
||||
str = time_value + "秒前";
|
||||
} else if (stime >= minute && stime < hour) {
|
||||
long time_value = stime / minute;
|
||||
if (time_value <= 0) {
|
||||
time_value = 1;
|
||||
}
|
||||
str = time_value + "分前";
|
||||
} else if (stime >= hour && stime < day) {
|
||||
long time_value = stime / hour;
|
||||
if (time_value <= 0) {
|
||||
time_value = 1;
|
||||
}
|
||||
str = time_value + "小时前";
|
||||
} else if (stime >= day && stime < weeks) {
|
||||
long time_value = stime / day;
|
||||
if (time_value <= 0) {
|
||||
time_value = 1;
|
||||
}
|
||||
str = time_value + "天前";
|
||||
} else if (stime >= weeks && stime < months) {
|
||||
DateFormat df = new SimpleDateFormat(DateHolidayUtils.MMddFormat);
|
||||
str = df.format(date);
|
||||
} else {
|
||||
DateFormat df = new SimpleDateFormat(DateHolidayUtils.yyyyMMddFormat);
|
||||
str = df.format(date);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断指定时间是否是周末
|
||||
*
|
||||
* @param date
|
||||
* 指定的时间
|
||||
* @return true:是周末,false:非周末
|
||||
*/
|
||||
public static boolean isWeeks(Date date) {
|
||||
boolean isWeek = false;
|
||||
isWeek = (getWeek(date) - 1 == 0 || getWeek(date) - 1 == 6);
|
||||
return isWeek;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到今天的最开始时间
|
||||
*
|
||||
* @return 今天的最开始时间
|
||||
*/
|
||||
public static Date getTodayBeginTime() {
|
||||
Date beginTime = new Date();
|
||||
beginTime = getBeginTime(beginTime);
|
||||
return beginTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到指定日期的最开始时间
|
||||
*
|
||||
* @return 今天的最开始时间
|
||||
*/
|
||||
public static Date getBeginTime(Date date) {
|
||||
Date beginTime = date;
|
||||
String beginString = getFormatDateTime(beginTime, DateHolidayUtils.yyyyMMddFormat) + " 00:00:00";
|
||||
beginTime = str2Date(beginString, DateHolidayUtils.fullFormat);
|
||||
return beginTime;
|
||||
}
|
||||
|
||||
public static Long getBeginTimeStamp(Long timeStamp) {
|
||||
Date beginTime = new Date(timeStamp);
|
||||
String beginString = getFormatDateTime(beginTime, DateHolidayUtils.yyyyMMddFormat) + " 00:00:00";
|
||||
beginTime = str2Date(beginString, DateHolidayUtils.fullFormat);
|
||||
return beginTime.getTime();
|
||||
}
|
||||
|
||||
public static String getBeginTimeStr(Date date) {
|
||||
Date beginTime = date;
|
||||
String beginString = getFormatDateTime(beginTime, DateHolidayUtils.yyyyMMddFormat) + " 00:00:00";
|
||||
return beginString;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 得到今天的最后结束时间
|
||||
*
|
||||
* @return 今天的最后时间
|
||||
*/
|
||||
public static Date getTodayEndTime() {
|
||||
Date endTime = new Date();
|
||||
endTime = getEndTime(endTime);
|
||||
return endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到指定日期的最后结束时间
|
||||
*
|
||||
* @return 今天的最后时间
|
||||
*/
|
||||
public static Date getEndTime(Date date) {
|
||||
|
||||
Date endTime = date;
|
||||
String beginString = getFormatDateTime(endTime, DateHolidayUtils.yyyyMMddFormat) + " 23:59:59";
|
||||
endTime = str2Date(beginString, DateHolidayUtils.fullFormat);
|
||||
return endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到指定日期的最后结束时间
|
||||
*
|
||||
* @return 今天的最后时间
|
||||
*/
|
||||
public static Date getCalEndTime(Date date) {
|
||||
|
||||
Date endTime = addDays(date, 1);
|
||||
String beginString = getFormatDateTime(endTime, DateHolidayUtils.yyyyMMddFormat) + " 00:00:00";
|
||||
endTime = str2Date(beginString, DateHolidayUtils.fullFormat);
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public static String getEndTimeStr(Date date) {
|
||||
|
||||
Date endTime = date;
|
||||
String endString = getFormatDateTime(endTime, DateHolidayUtils.yyyyMMddFormat) + " 23:59:59";
|
||||
return endString;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取得本周的开始时间
|
||||
*
|
||||
* @return 本周的开始时间
|
||||
*/
|
||||
public static Date getThisWeekBeginTime() {
|
||||
Date beginTime = null;
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int week = getWeek(cal.getTime());
|
||||
week = week - 1;
|
||||
int days = 0;
|
||||
if (week == 0) {
|
||||
days = 6;
|
||||
} else {
|
||||
days = week - 1;
|
||||
}
|
||||
cal.add(Calendar.DAY_OF_MONTH, -days);
|
||||
beginTime = cal.getTime();
|
||||
return beginTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得指定日期所在周的开始时间
|
||||
*
|
||||
* @return 本周的开始时间
|
||||
*/
|
||||
public static Date getThisWeekBeginTime(Date date) {
|
||||
Date beginTime = null;
|
||||
int week = getWeek(date);
|
||||
week = week - 1;
|
||||
int days = 0;
|
||||
if (week == 0) {
|
||||
days = 6;
|
||||
} else {
|
||||
days = week - 1;
|
||||
}
|
||||
beginTime = addDays(date,-days);
|
||||
return beginTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得本周的开始日期
|
||||
*
|
||||
* @param format
|
||||
* 时间的格式
|
||||
* @return 指定格式的本周最开始时间
|
||||
*/
|
||||
public static String getThisWeekBeginTimeString(String format) {
|
||||
DateFormat df = new SimpleDateFormat(format);
|
||||
return df.format(getThisWeekBeginTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得本周的结束时间
|
||||
*
|
||||
* @return 本周的结束时间
|
||||
*/
|
||||
public static Date getThisWeekEndTime() {
|
||||
Date endTime = null;
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int week = getWeek(cal.getTime());
|
||||
week = week - 1;
|
||||
int days = 0;
|
||||
if (week != 0) {
|
||||
days = 7 - week;
|
||||
}
|
||||
cal.add(Calendar.DAY_OF_MONTH, days);
|
||||
endTime = cal.getTime();
|
||||
return endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得指定日期所在周的结束时间
|
||||
*
|
||||
* @return 本周的结束时间
|
||||
*/
|
||||
public static Date getThisWeekEndTime(Date date) {
|
||||
Date endTime = null;
|
||||
int week = getWeek(date);
|
||||
week = week - 1;
|
||||
int days = 0;
|
||||
if (week != 0) {
|
||||
days = 7 - week;
|
||||
}
|
||||
endTime = addDays(date, days);
|
||||
return endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得本周的结束日期
|
||||
*
|
||||
* @param format
|
||||
* 时间的格式
|
||||
* @return 指定格式的本周结束时间
|
||||
*/
|
||||
public static String getThisWeekEndTimeString(String format) {
|
||||
DateFormat df = new SimpleDateFormat(format);
|
||||
return df.format(getThisWeekEndTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得两时间相差的天数
|
||||
*
|
||||
* @param from
|
||||
* 第一个时间
|
||||
* @param to
|
||||
* 第二个时间
|
||||
* @return 相差的天数
|
||||
*/
|
||||
public static long getBetweenDays(Date from, Date to) {
|
||||
long days = 0;
|
||||
long dayTime = 24 * 60 * 60 * 1000;
|
||||
long fromTime = from.getTime();
|
||||
long toTime = to.getTime();
|
||||
// long times = Math.abs(fromTime - toTime);
|
||||
Long times = fromTime - toTime;
|
||||
days = times / dayTime;
|
||||
return days;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取时间相隔年份
|
||||
* @author zhanglei 2017-10-20 下午2:51:10
|
||||
* @param from
|
||||
* @param to
|
||||
* @return
|
||||
*/
|
||||
public static long getBetweenYears(Date from, Date to) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(from);
|
||||
int year = cal.get(Calendar.YEAR);
|
||||
cal.setTime(to);
|
||||
int year2 = cal.get(Calendar.YEAR);
|
||||
long years = Math.abs(year2 - year);
|
||||
return years;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得两时间相差的小时数
|
||||
*
|
||||
* @param from
|
||||
* 第一个时间
|
||||
* @param to
|
||||
* 第二个时间
|
||||
* @return 相差的小时数
|
||||
*/
|
||||
public static BigDecimal getBetweenHours(Date from, Date to) {
|
||||
long hours = 0;
|
||||
long hourTime = 60 * 60 * 1000;
|
||||
long fromTime = from.getTime();
|
||||
long toTime = to.getTime();
|
||||
long times = Math.abs(fromTime - toTime);
|
||||
return BigDecimal.valueOf(times).divide(BigDecimal.valueOf(hourTime), 2, BigDecimal.ROUND_DOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得两时间相差的分钟数
|
||||
*
|
||||
* @param from
|
||||
* 第一个时间
|
||||
* @param to
|
||||
* 第二个时间
|
||||
* @return 相差的分钟数
|
||||
*/
|
||||
public static long getBetweenMinutes(Date from, Date to) {
|
||||
long m = 0;
|
||||
long mTime = 60 * 1000;
|
||||
long fromTime = from.getTime();
|
||||
long toTime = to.getTime();
|
||||
long times = Math.abs(fromTime - toTime);
|
||||
m = times / mTime;
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得两时间相差的秒数
|
||||
*
|
||||
* @param from
|
||||
* 第一个时间
|
||||
* @param to
|
||||
* 第二个时间
|
||||
* @return 相差的秒数
|
||||
*/
|
||||
public static long getBetweenSeconds(Date from, Date to) {
|
||||
long s = 0;
|
||||
long sTime = 1000;
|
||||
long fromTime = from.getTime();
|
||||
long toTime = to.getTime();
|
||||
long times = Math.abs(fromTime - toTime);
|
||||
s = times / sTime;
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得在指定时间上加减 minute 分钟后的时间
|
||||
* @author zhanglei 2015 三月 24 10:15:21
|
||||
* @param date
|
||||
* @param minute
|
||||
* @return
|
||||
*/
|
||||
public static Date addMinutes(Date date, int minute) {
|
||||
Date time = null;
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.add(Calendar.MINUTE, minute);
|
||||
time = cal.getTime();
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取得在指定时间上加减days天后的时间
|
||||
*
|
||||
* @param date
|
||||
* 指定的时间
|
||||
* @param days
|
||||
* 天数,正为加,负为减
|
||||
* @return 在指定时间上加减days天后的时间
|
||||
*/
|
||||
public static Date addDays(Date date, int days) {
|
||||
Date time = null;
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.add(Calendar.DAY_OF_MONTH, days);
|
||||
time = cal.getTime();
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得在指定时间上加减months月后的时间
|
||||
*
|
||||
* @param date
|
||||
* 指定时间
|
||||
* @param months
|
||||
* 月数,正为加,负为减
|
||||
* @return 在指定时间上加减months月后的时间
|
||||
*/
|
||||
public static Date addMonths(Date date, int months) {
|
||||
Date time = null;
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.add(Calendar.MONTH, months);
|
||||
time = cal.getTime();
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得在指定时间上加减years年后的时间
|
||||
*
|
||||
* @param date
|
||||
* 指定时间
|
||||
* @param years
|
||||
* 年数,正为加,负为减
|
||||
* @return 在指定时间上加减years年后的时间
|
||||
*/
|
||||
public static Date addYears(Date date, int years) {
|
||||
Date time = null;
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.add(Calendar.YEAR, years);
|
||||
time = cal.getTime();
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法说明:"yyyyMMddHHmmss"格式的字符串转成日期
|
||||
*
|
||||
* @author zhanglei
|
||||
* @createDate 2013-10-24 上午01:35:15
|
||||
* @param str_date
|
||||
* @return date
|
||||
*/
|
||||
public static Date str2Date(String str_date, String format) {
|
||||
Date date = null;
|
||||
DateFormat df = new SimpleDateFormat(format == null ? DateHolidayUtils.yyyyMMddHHmmss:format);
|
||||
try {
|
||||
date = df.parse(str_date);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前年度
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getCurYear() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int yearInt = calendar.get(Calendar.YEAR);
|
||||
return String.valueOf(yearInt);
|
||||
}
|
||||
|
||||
public static Date getFirstDayOfYear(String year) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
if (year != null && !year.isEmpty()) {
|
||||
int yearInt = Integer.valueOf(year);
|
||||
calendar.set(Calendar.YEAR, yearInt);
|
||||
}
|
||||
calendar.set(Calendar.MONTH, 0);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
public static Date getLastDayOfYear(String year) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
if (year != null && !year.isEmpty()) {
|
||||
int yearInt = Integer.valueOf(year);
|
||||
calendar.set(Calendar.YEAR, yearInt);
|
||||
}
|
||||
calendar.set(Calendar.MONTH, 11);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 31);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 23);
|
||||
calendar.set(Calendar.MINUTE, 59);
|
||||
calendar.set(Calendar.SECOND, 59);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static Date getLastDayOfQuarter(String year, int quarter) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
if (year != null && !year.isEmpty()) {
|
||||
int yearInt = Integer.valueOf(year);
|
||||
calendar.set(Calendar.YEAR, yearInt);
|
||||
}
|
||||
if (quarter == 1) {
|
||||
calendar.set(Calendar.MONTH, 2);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 31);
|
||||
} else if (quarter == 2) {
|
||||
calendar.set(Calendar.MONTH, 5);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 30);
|
||||
} else if (quarter == 3) {
|
||||
calendar.set(Calendar.MONTH, 8);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 30);
|
||||
} else if (quarter == 4) {
|
||||
calendar.set(Calendar.MONTH, 11);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 31);
|
||||
}
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个月的第一天
|
||||
* @param dateStr
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static Date getMonthFirstDate(String dateStr) throws ParseException {
|
||||
DateFormat df = new SimpleDateFormat(yyyyMMFormat);
|
||||
Date data= df.parse(dateStr);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个月的最后一天
|
||||
*
|
||||
* @param dateStr
|
||||
* yyyy-MM
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static Date getMonthLastDate(String dateStr) throws ParseException {
|
||||
DateFormat df = new SimpleDateFormat(yyyyMMFormat);
|
||||
Date data = df.parse(dateStr);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(data);
|
||||
int value = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, value);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(DateHolidayUtils.str2Date("2020年10月28日", DateHolidayUtils.yyyyMMddChineseFormat));
|
||||
System.out.println(new Date(1595174400000L));
|
||||
// 2022-11-2 14:0:0
|
||||
// 2022-11-2 23:59:59
|
||||
System.out.println(getBetweenHours(new Date(1667368800000L), getEndTime(new Date(1667368800000L))));
|
||||
System.out.println(getBetweenHours(new Date(1667368800000L), new Date(1667404799000L)));
|
||||
System.out.println(getBetweenHours(new Date(1667368800000L), new Date(1667404800000L)));
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,12 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
@ -99,6 +101,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
return DateFormatUtils.format(now, "yyyyMMdd");
|
||||
}
|
||||
|
||||
public static String dateTime(String format) {
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, format);
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期型字符串转化为日期 格式
|
||||
*/
|
||||
@ -165,4 +172,24 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
|
||||
return Date.from(zdt.toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验是否符合时间格式
|
||||
* @param sDate
|
||||
* @param format
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkDate(String sDate,String format){
|
||||
int legalLen = sDate.length();
|
||||
if (ObjectUtil.isNull(legalLen) || legalLen==0){
|
||||
return false;
|
||||
}
|
||||
DateFormat formatter = new SimpleDateFormat(format);
|
||||
try {
|
||||
Date date = formatter.parse(sDate);
|
||||
return sDate.equals(formatter.format(date));
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,168 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 多任务处理工具类
|
||||
* @Author WhHao
|
||||
* @Date 2022/8/10 16:04
|
||||
* @Return
|
||||
*/
|
||||
@Slf4j
|
||||
public class FutureUtil {
|
||||
|
||||
/**
|
||||
* cpu 核心数
|
||||
*/
|
||||
private static final int AVALIABLE_PROCESSORS = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
// 最大超时时间
|
||||
private static final int TIMEOUT_VALUE = 1500;
|
||||
// 时间单位
|
||||
private static final TimeUnit TIMEOUT_UNIT = TimeUnit.MILLISECONDS;
|
||||
|
||||
|
||||
/**
|
||||
* Singleton delay scheduler, used only for starting and * cancelling tasks.
|
||||
*/
|
||||
public static final class Delayer {
|
||||
|
||||
static final ScheduledThreadPoolExecutor delayer;
|
||||
|
||||
/**
|
||||
* 异常线程,不做请求处理,只抛出异常
|
||||
*/
|
||||
static {
|
||||
delayer = new ScheduledThreadPoolExecutor(1, new DaemonThreadFactory());
|
||||
delayer.setRemoveOnCancelPolicy(true);
|
||||
}
|
||||
|
||||
static ScheduledFuture<?> delay(Runnable command, long delay, TimeUnit unit) {
|
||||
return delayer.schedule(command, delay, unit);
|
||||
}
|
||||
|
||||
static final class DaemonThreadFactory implements ThreadFactory {
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t = new Thread(r);
|
||||
t.setDaemon(true);
|
||||
t.setName("CompletableFutureScheduler");
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据服务器cpu自定义线程池
|
||||
*/
|
||||
private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
|
||||
AVALIABLE_PROCESSORS,
|
||||
3 * AVALIABLE_PROCESSORS,
|
||||
3,
|
||||
TimeUnit.SECONDS,
|
||||
new LinkedBlockingDeque<>(20),
|
||||
new ThreadPoolExecutor.CallerRunsPolicy()
|
||||
);
|
||||
|
||||
/**
|
||||
* 有返回值的异步
|
||||
* @param supplier
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> CompletableFuture<T> supplyAsync(Supplier<T> supplier){
|
||||
return supplyAsync(TIMEOUT_VALUE,TIMEOUT_UNIT,supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 有返回值的异步 - 可设置超时时间
|
||||
* @param timeout
|
||||
* @param unit
|
||||
* @param supplier
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> CompletableFuture<T> supplyAsync(long timeout, TimeUnit unit,Supplier<T> supplier){
|
||||
return CompletableFuture.supplyAsync(supplier, threadPoolExecutor)
|
||||
.applyToEither(timeoutAfter(timeout,unit), Function.identity())
|
||||
.exceptionally(throwable -> {
|
||||
throwable.printStackTrace();
|
||||
log.error(throwable.getMessage());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 无返回值的异步
|
||||
* @param runnable
|
||||
* @return
|
||||
*/
|
||||
public static CompletableFuture runAsync(Runnable runnable){
|
||||
return runAsync(TIMEOUT_VALUE,TIMEOUT_UNIT,runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 无返回值的异步 - 可设置超时时间
|
||||
* @param runnable
|
||||
* @return
|
||||
*/
|
||||
public static CompletableFuture runAsync(long timeout, TimeUnit unit,Runnable runnable){
|
||||
return CompletableFuture.runAsync(runnable,threadPoolExecutor)
|
||||
.applyToEither(timeoutAfter(timeout,unit), Function.identity())
|
||||
.exceptionally(throwable -> {
|
||||
throwable.printStackTrace();
|
||||
log.error(throwable.getMessage());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一处理异步结果
|
||||
* @param futures
|
||||
* @return
|
||||
*/
|
||||
public static CompletableFuture allOf(CompletableFuture... futures){
|
||||
return allOf(TIMEOUT_VALUE,TIMEOUT_UNIT,futures);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一处理异步结果 - 可设置超时时间
|
||||
* @param futures
|
||||
* @return
|
||||
*/
|
||||
public static CompletableFuture allOf(long timeout, TimeUnit unit,CompletableFuture... futures){
|
||||
return CompletableFuture.allOf(futures)
|
||||
.applyToEither(timeoutAfter(timeout,unit), Function.identity())
|
||||
.exceptionally(throwable -> {
|
||||
throwable.printStackTrace();
|
||||
log.error(throwable.getMessage());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步超时处理
|
||||
* @param timeout
|
||||
* @param unit
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> CompletableFuture<T> timeoutAfter(long timeout, TimeUnit unit) {
|
||||
CompletableFuture<T> result = new CompletableFuture<T>();
|
||||
// timeout 时间后 抛出TimeoutException 类似于sentinel / watcher
|
||||
Delayer.delayer.schedule(() -> result.completeExceptionally(new TimeoutException()), timeout, unit);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> CompletableFuture<T> timeoutAfter() {
|
||||
CompletableFuture<T> result = new CompletableFuture<T>();
|
||||
// timeout 时间后 抛出TimeoutException 类似于sentinel / watcher
|
||||
Delayer.delayer.schedule(() -> result.completeExceptionally(new TimeoutException()), TIMEOUT_VALUE, TIMEOUT_UNIT);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class MySerializerUtils extends JsonSerializer<Long> {
|
||||
@Override
|
||||
public void serialize(Long id, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
|
||||
String statusStr = String.valueOf(id);
|
||||
jsonGenerator.writeString(statusStr);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.crypto.Mode;
|
||||
import cn.hutool.crypto.Padding;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.digest.MD5;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.entity.GaoXinCardInfo;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* 对外所需要的工具类
|
||||
*/
|
||||
|
||||
|
||||
public class OpenUtils {
|
||||
private static final String appsecret ="JXYB7KpXlH9i0CL6";
|
||||
private static final String aesKey = "74242EAFE97F18BFAE9D2682590B6614";
|
||||
private static final String iv = "74242EAFE97F18BF";
|
||||
private static final String id="2023062804031";
|
||||
// private static final String url ="http://162.14.100.54:9010/index.php/Api/renju/get_user_info";//测试
|
||||
private static final String url ="http://118.122.86.24:8016/index.php/Api/renju/get_user_info";// 正式地址
|
||||
|
||||
public static R<?> getGaoXinCardInfo(String cardId){
|
||||
AES aes = new AES(Mode.CBC, Padding.PKCS5Padding,aesKey.getBytes(),iv.getBytes());
|
||||
String param=aes.encryptBase64(
|
||||
new JSONObject()
|
||||
.set("id_card",cardId)
|
||||
.toStringPretty());
|
||||
MD5 md5 = SecureUtil.md5();
|
||||
String sign=md5.digestHex(id+param+appsecret);
|
||||
JSONObject jsonObject = new JSONObject()
|
||||
.set("id",id)
|
||||
.set("param",param)
|
||||
.set("sign",sign);
|
||||
try {
|
||||
String content = HttpRequest.post(url)
|
||||
.timeout(5000)
|
||||
.body(jsonObject.toStringPretty())
|
||||
.execute()
|
||||
.body();
|
||||
System.out.println("content = " + content);
|
||||
JSONObject jsonObject1 = JSONUtil.parseObj(content);
|
||||
Integer code = jsonObject1.getInt("code");
|
||||
Object data = jsonObject1.get("data");
|
||||
String message = jsonObject1.getStr("message");
|
||||
if (code==200){
|
||||
if (ObjectUtil.isNull(data) || ObjectUtil.isEmpty(data)){
|
||||
return R.fail("暂未获取到当前"+cardId+"人才认定信息,如有疑问请联系客服人员! 电话:19940594954");
|
||||
}else {
|
||||
GaoXinCardInfo gaoXinCardInfo = JsonUtils.parseObject(JSONUtil.toJsonPrettyStr(data), GaoXinCardInfo.class);
|
||||
//判断值是否为空
|
||||
if (ObjectUtil.isEmpty(gaoXinCardInfo.getName())){
|
||||
return R.fail("获取人才认定数据接口返回异常,异常信息:姓名为空!请联系客服人员! 电话:19940594954");
|
||||
}else if (ObjectUtil.isEmpty(gaoXinCardInfo.getCard_id())){
|
||||
return R.fail("获取人才认定数据接口返回异常,异常信息:身份证为空!请联系客服人员! 电话:19940594954");
|
||||
}else if (ObjectUtil.isEmpty(gaoXinCardInfo.getSex())){
|
||||
return R.fail("获取人才认定数据接口返回异常,异常信息:性别为空!请联系客服人员! 电话:19940594954");
|
||||
}else if (ObjectUtil.isEmpty(gaoXinCardInfo.getNationality())){
|
||||
return R.fail("获取人才认定数据接口返回异常,异常信息:国籍为空!请联系客服人员! 电话:19940594954");
|
||||
}else if (ObjectUtil.isEmpty(gaoXinCardInfo.getEducation())){
|
||||
return R.fail("获取人才认定数据接口返回异常,异常信息:学历为空!请联系客服人员! 电话:19940594954");
|
||||
}else if (ObjectUtil.isEmpty(gaoXinCardInfo.getDistrict())){
|
||||
return R.fail("获取人才认定数据接口返回异常,异常信息:单位区域为空!请联系客服人员! 电话:19940594954");
|
||||
}else if (ObjectUtil.isEmpty(gaoXinCardInfo.getPhone())){
|
||||
return R.fail("获取人才认定数据接口返回异常,异常信息:手机号为空!请联系客服人员! 电话:19940594954");
|
||||
}else if (ObjectUtil.isEmpty(gaoXinCardInfo.getCompany_name())){
|
||||
return R.fail("获取人才认定数据接口返回异常,异常信息:公司名称为空!请联系客服人员! 电话:19940594954");
|
||||
}else if (ObjectUtil.isEmpty(gaoXinCardInfo.getType())){
|
||||
return R.fail("获取人才认定数据接口返回异常,异常信息:人才类型为空!请联系客服人员! 电话:19940594954");
|
||||
}
|
||||
gaoXinCardInfo.setType(gaoXinCardInfo.getType());
|
||||
gaoXinCardInfo.setNationality(gaoXinCardInfo.getNationality());
|
||||
return R.ok(gaoXinCardInfo);
|
||||
}
|
||||
}else if (code==400){
|
||||
return R.fail("获取人才认定数据接口返回异常,异常信息:"+message+"请联系客服人员! 电话:19940594954");
|
||||
}else {
|
||||
return R.fail("人才认定接口请求未知异常");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("人才认定接口请求错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.antherd.smcrypto.sm2.Sm2;
|
||||
|
||||
/**
|
||||
* RSA加解密工具类
|
||||
* @author Administrator
|
||||
*/
|
||||
public class RSAUtil {
|
||||
|
||||
|
||||
public static final String PRIVATE_KEY = "9cefdfcb925a32e10206d3a693ba204632c59e5f9a171faebb814885191dd35e";
|
||||
public static final String VUE_PUBLIC_KEY = "048af4184056315a9ecfcc14280b32504ba194ec8dd0e06b298c4a1aa557e7e9a5d15e1293392f741f7fb31a82e55785b7f1880d61b57def1e38e3f06435fb0502";
|
||||
/**
|
||||
* 公钥加密
|
||||
*/
|
||||
public static String publicKeyEncryptBase64(String data,String outPublicKey){
|
||||
if (ObjectUtil.isNotEmpty(outPublicKey)){
|
||||
return Sm2.doEncrypt(data, outPublicKey);
|
||||
}
|
||||
return Sm2.doEncrypt(data, VUE_PUBLIC_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私钥解密
|
||||
*/
|
||||
public static String privateKeyDecryptStr(String data,String privateKey){
|
||||
if (ObjectUtil.isNotEmpty(privateKey)){
|
||||
return Sm2.doDecrypt(data, privateKey);
|
||||
}
|
||||
return Sm2.doDecrypt(data,PRIVATE_KEY);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author yaohuaipeng
|
||||
* @date 2018/10/26-16:16
|
||||
*/
|
||||
public class StrUtils {
|
||||
/**
|
||||
* 把逗号分隔的字符串转换字符串数组
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String[] splitStr2StrArr(String str,String split) {
|
||||
if (str != null && !str.equals("")) {
|
||||
return str.split(split);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 把逗号分隔字符串转换List的Long
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static List<Long> splitStr2LongArr(String str) {
|
||||
String[] strings = splitStr2StrArr(str,",");
|
||||
if (strings == null) return null;
|
||||
|
||||
List<Long> result = new ArrayList<>();
|
||||
for (String string : strings) {
|
||||
result.add(Long.parseLong(string));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 把逗号分隔字符串转换List的Long
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static List<Long> splitStr2LongArr(String str,String split) {
|
||||
String[] strings = splitStr2StrArr(str,split);
|
||||
if (strings == null) return null;
|
||||
|
||||
List<Long> result = new ArrayList<>();
|
||||
for (String string : strings) {
|
||||
result.add(Long.parseLong(string));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getRandomString(int length) {
|
||||
String str = "0123456789";
|
||||
Random random = new Random();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < length; i++) {
|
||||
int number = random.nextInt(10);
|
||||
sb.append(str.charAt(number));
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
public static String getComplexRandomString(int length) {
|
||||
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
SecureRandom random = new SecureRandom();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < length; i++) {
|
||||
int number = random.nextInt(62);
|
||||
sb.append(str.charAt(number));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String convertPropertiesToHtml(String properties){
|
||||
//1:容量:6:32GB_4:样式:12:塑料壳
|
||||
StringBuilder sBuilder = new StringBuilder();
|
||||
String[] propArr = properties.split("_");
|
||||
for (String props : propArr) {
|
||||
String[] valueArr = props.split(":");
|
||||
sBuilder.append(valueArr[1]).append(":").append(valueArr[3]).append("<br>");
|
||||
}
|
||||
return sBuilder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -171,6 +171,15 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
return StrUtil.toUnderlineCase(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字母转大写
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String toUpperCase(String str) {
|
||||
return str.toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否包含字符串
|
||||
*
|
||||
@ -322,4 +331,17 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param str
|
||||
* @function 判断输入的数据是否是大于等于零的整数
|
||||
*/
|
||||
public static boolean isNumeric(String str) {
|
||||
for (int i = str.length(); --i >= 0;) {
|
||||
if (!Character.isDigit(str.charAt(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
public class XuexinUtils {
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package com.ruoyi.common.utils.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 文件类型工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class FileTypeUtils
|
||||
{
|
||||
/**
|
||||
* 获取文件类型
|
||||
* <p>
|
||||
* 例如: ruoyi.txt, 返回: txt
|
||||
*
|
||||
* @param file 文件名
|
||||
* @return 后缀(不含".")
|
||||
*/
|
||||
public static String getFileType(File file)
|
||||
{
|
||||
if (null == file)
|
||||
{
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return getFileType(file.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件类型
|
||||
* <p>
|
||||
* 例如: ruoyi.txt, 返回: txt
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @return 后缀(不含".")
|
||||
*/
|
||||
public static String getFileType(String fileName)
|
||||
{
|
||||
int separatorIndex = fileName.lastIndexOf(".");
|
||||
if (separatorIndex < 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return fileName.substring(separatorIndex + 1).toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件名的后缀
|
||||
*
|
||||
* @param file 表单文件
|
||||
* @return 后缀名
|
||||
*/
|
||||
public static final String getExtension(MultipartFile file)
|
||||
{
|
||||
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
||||
if (StringUtils.isEmpty(extension))
|
||||
{
|
||||
extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType()));
|
||||
}
|
||||
return extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件类型
|
||||
*
|
||||
* @param photoByte 文件字节码
|
||||
* @return 后缀(不含".")
|
||||
*/
|
||||
public static String getFileExtendName(byte[] photoByte)
|
||||
{
|
||||
String strFileExtendName = "JPG";
|
||||
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
|
||||
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97))
|
||||
{
|
||||
strFileExtendName = "GIF";
|
||||
}
|
||||
else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70))
|
||||
{
|
||||
strFileExtendName = "JPG";
|
||||
}
|
||||
else if ((photoByte[0] == 66) && (photoByte[1] == 77))
|
||||
{
|
||||
strFileExtendName = "BMP";
|
||||
}
|
||||
else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71))
|
||||
{
|
||||
strFileExtendName = "PNG";
|
||||
}
|
||||
return strFileExtendName;
|
||||
}
|
||||
}
|
||||
@ -37,4 +37,23 @@ public class MimeTypeUtils {
|
||||
// pdf
|
||||
"pdf"};
|
||||
|
||||
public static String getExtension(String prefix)
|
||||
{
|
||||
switch (prefix)
|
||||
{
|
||||
case IMAGE_PNG:
|
||||
return "png";
|
||||
case IMAGE_JPG:
|
||||
return "jpg";
|
||||
case IMAGE_JPEG:
|
||||
return "jpeg";
|
||||
case IMAGE_BMP:
|
||||
return "bmp";
|
||||
case IMAGE_GIF:
|
||||
return "gif";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,435 @@
|
||||
package com.ruoyi.common.utils.file;
|
||||
|
||||
import cn.hutool.core.io.resource.ClassPathResource;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 文件处理工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class MyFileUtils extends FileUtils
|
||||
{
|
||||
/** 字符常量:斜杠 {@code '/'} */
|
||||
public static final char SLASH = '/';
|
||||
|
||||
/** 字符常量:反斜杠 {@code '\\'} */
|
||||
public static final char BACKSLASH = '\\';
|
||||
|
||||
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
|
||||
|
||||
/**
|
||||
* 输出指定文件的byte数组
|
||||
*
|
||||
* @param filePath 文件路径
|
||||
* @param fileName 文件名字
|
||||
* @return
|
||||
*/
|
||||
public static void writeBytes(String filePath, String fileName) throws IOException
|
||||
{
|
||||
FileInputStream fis = null;
|
||||
FileOutputStream os = null;
|
||||
try
|
||||
{
|
||||
File file = new File(filePath);
|
||||
os = new FileOutputStream(fileName);
|
||||
if (!file.exists())
|
||||
{
|
||||
throw new FileNotFoundException(filePath);
|
||||
}
|
||||
fis = new FileInputStream(file);
|
||||
|
||||
byte[] b = new byte[1024];
|
||||
int length;
|
||||
while ((length = fis.read(b)) > 0)
|
||||
{
|
||||
os.write(b, 0, length);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
//不抛异常
|
||||
e.printStackTrace();
|
||||
// throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (os != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
os.close();
|
||||
}
|
||||
catch (IOException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (fis != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fis.close();
|
||||
}
|
||||
catch (IOException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void downLoadPic(String str,String fileName) {
|
||||
// 完成从网络上下载图片的功能
|
||||
try {
|
||||
// 建立连接
|
||||
URL url = new URL(str);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");//POST
|
||||
//防止屏蔽程序抓取而返回403错误
|
||||
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
|
||||
conn.setRequestProperty("Referer","https://rcaj.cdhtgycs.cn");
|
||||
conn.setConnectTimeout(5000);
|
||||
conn.setReadTimeout(5000);
|
||||
int responseCode = conn.getResponseCode();
|
||||
System.out.println("responseCode = " + responseCode);
|
||||
InputStream inputStream = conn.getInputStream();
|
||||
byte[] temp = new byte[inputStream.available()];
|
||||
if (responseCode==200) {
|
||||
if (temp.length==0) {
|
||||
ClassPathResource classPathResource = new ClassPathResource("/404.jpg");
|
||||
inputStream = classPathResource.getStream();
|
||||
temp = new byte[inputStream.available()];
|
||||
}
|
||||
FileOutputStream fos = new FileOutputStream(fileName);
|
||||
int len = 0;
|
||||
while ((len = inputStream.read(temp)) != -1) {
|
||||
fos.write(temp, 0, len);
|
||||
}
|
||||
inputStream.close();
|
||||
fos.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 对中文字符进行UTF-8编码
|
||||
* @param source 要转义的字符串
|
||||
* @return
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
public static String tranformStyle(String source) throws UnsupportedEncodingException
|
||||
{
|
||||
char[] arr = source.toCharArray();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0; i < arr.length; i++)
|
||||
{
|
||||
char temp = arr[i];
|
||||
if(isChinese(temp))
|
||||
{
|
||||
sb.append(URLEncoder.encode("" + temp, "UTF-8"));
|
||||
continue;
|
||||
}
|
||||
sb.append(arr[i]);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符的编码值
|
||||
* @param s
|
||||
* @return
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
public static int getValue(char s) throws UnsupportedEncodingException
|
||||
{
|
||||
String temp = (URLEncoder.encode("" + s, "GBK")).replace("%", "");
|
||||
if(temp.equals(s + ""))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
char[] arr = temp.toCharArray();
|
||||
int total = 0;
|
||||
for(int i = 0; i < arr.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
int t = Integer.parseInt((arr[i] + ""), 16);
|
||||
total = total * 16 + t;
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是不是中文字符
|
||||
* @param c
|
||||
* @return
|
||||
*/
|
||||
public static boolean isChinese(char c)
|
||||
{
|
||||
|
||||
Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
|
||||
|
||||
if(ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
|
||||
|
||||
|| ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
|
||||
|
||||
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
|
||||
|
||||
|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
|
||||
|
||||
|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
|
||||
|
||||
|| ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS)
|
||||
{
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param filePath 文件
|
||||
* @return
|
||||
*/
|
||||
public static boolean deleteFile(String filePath)
|
||||
{
|
||||
boolean flag = false;
|
||||
File file = new File(filePath);
|
||||
// 路径为文件且不为空则进行删除
|
||||
if (file.isFile() && file.exists())
|
||||
{
|
||||
file.delete();
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件名称验证
|
||||
*
|
||||
* @param filename 文件名称
|
||||
* @return true 正常 false 非法
|
||||
*/
|
||||
public static boolean isValidFilename(String filename)
|
||||
{
|
||||
return filename.matches(FILENAME_PATTERN);
|
||||
}
|
||||
|
||||
/* public static void main(String[] args) {
|
||||
boolean b = checkAllowDownload("C:\\Users\\vimdr\\Pictures\\Camera Roll\\Snipaste_2021-06-03_15-11-34.png");
|
||||
System.out.println(b);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 检查文件是否可下载
|
||||
*
|
||||
* @param resource 需要下载的文件
|
||||
* @return true 正常 false 非法
|
||||
*/
|
||||
public static boolean checkAllowDownload(String resource)
|
||||
{
|
||||
// 禁止目录上跳级别
|
||||
if (StringUtils.contains(resource, ".."))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查允许下载的文件规则
|
||||
if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 不在允许下载的文件规则
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件名重新编码
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param fileName 文件名
|
||||
* @return 编码后的文件名
|
||||
*/
|
||||
public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException
|
||||
{
|
||||
final String agent = request.getHeader("USER-AGENT");
|
||||
String filename = fileName;
|
||||
if (agent.contains("MSIE"))
|
||||
{
|
||||
// IE浏览器
|
||||
filename = URLEncoder.encode(filename, "utf-8");
|
||||
filename = filename.replace("+", " ");
|
||||
}
|
||||
else if (agent.contains("Firefox"))
|
||||
{
|
||||
// 火狐浏览器
|
||||
filename = new String(fileName.getBytes(), "ISO8859-1");
|
||||
}
|
||||
else if (agent.contains("Chrome"))
|
||||
{
|
||||
// google浏览器
|
||||
filename = URLEncoder.encode(filename, "utf-8");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 其它浏览器
|
||||
filename = URLEncoder.encode(filename, "utf-8");
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回文件名
|
||||
*
|
||||
* @param filePath 文件
|
||||
* @return 文件名
|
||||
*/
|
||||
public static String getName(String filePath)
|
||||
{
|
||||
if (null == filePath)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int len = filePath.length();
|
||||
if (0 == len)
|
||||
{
|
||||
return filePath;
|
||||
}
|
||||
if (isFileSeparator(filePath.charAt(len - 1)))
|
||||
{
|
||||
// 以分隔符结尾的去掉结尾分隔符
|
||||
len--;
|
||||
}
|
||||
|
||||
int begin = 0;
|
||||
char c;
|
||||
for (int i = len - 1; i > -1; i--)
|
||||
{
|
||||
c = filePath.charAt(i);
|
||||
if (isFileSeparator(c))
|
||||
{
|
||||
// 查找最后一个路径分隔符(/或者\)
|
||||
begin = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return filePath.substring(begin, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为Windows或者Linux(Unix)文件分隔符<br>
|
||||
* Windows平台下分隔符为\,Linux(Unix)为/
|
||||
*
|
||||
* @param c 字符
|
||||
* @return 是否为Windows或者Linux(Unix)文件分隔符
|
||||
*/
|
||||
public static boolean isFileSeparator(char c)
|
||||
{
|
||||
return SLASH == c || BACKSLASH == c;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件名重新编码
|
||||
*
|
||||
* @param response 响应对象
|
||||
* @param realFileName 真实文件名
|
||||
* @return
|
||||
*/
|
||||
public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException
|
||||
{
|
||||
String percentEncodedFileName = percentEncode(realFileName);
|
||||
|
||||
StringBuilder contentDispositionValue = new StringBuilder();
|
||||
contentDispositionValue.append("attachment; filename=")
|
||||
.append(percentEncodedFileName)
|
||||
.append(";")
|
||||
.append("filename*=")
|
||||
.append("utf-8''")
|
||||
.append(percentEncodedFileName);
|
||||
|
||||
response.setHeader("Content-disposition", contentDispositionValue.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 百分号编码工具方法
|
||||
*
|
||||
* @param s 需要百分号编码的字符串
|
||||
* @return 百分号编码后的字符串
|
||||
*/
|
||||
public static String percentEncode(String s) throws UnsupportedEncodingException
|
||||
{
|
||||
String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString());
|
||||
return encode.replaceAll("\\+", "%20");
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本地图片进行Base64位编码
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public static String encodeImgageToBase64(File imageFile) {
|
||||
// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
|
||||
// 其进行Base64编码处理
|
||||
byte[] data = null;
|
||||
// 读取图片字节数组
|
||||
try {
|
||||
InputStream in = new FileInputStream(imageFile);
|
||||
data = new byte[in.available()];
|
||||
in.read(data);
|
||||
in.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 对字节数组Base64编码
|
||||
// BASE64Encoder encoder = new BASE64Encoder();
|
||||
return Base64.encodeBase64String(data);
|
||||
// return encoder.encode(data);// 返回Base64编码过的字节数组字符串
|
||||
}
|
||||
|
||||
|
||||
public static File MultipartFileToFile(MultipartFile multipartFile) {
|
||||
// 获取文件名
|
||||
String fileName = multipartFile.getOriginalFilename();
|
||||
// 获取文件后缀
|
||||
String suffix = fileName.substring(fileName.lastIndexOf("."));
|
||||
try {
|
||||
File file = File.createTempFile(System.currentTimeMillis() + "", suffix);
|
||||
//multipartFile.transferTo(file);
|
||||
FileUtils.copyInputStreamToFile(multipartFile.getInputStream(), file);
|
||||
return file;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
package com.ruoyi.common.utils.poi;
|
||||
|
||||
/**
|
||||
* Created by shuaibin_yang on 2019/5/9 0009.
|
||||
*/
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 删除文件和目录
|
||||
*
|
||||
*/
|
||||
public class DeleteFileUtil {
|
||||
|
||||
/**
|
||||
* 删除文件,可以是文件或文件夹
|
||||
*
|
||||
* @param fileName
|
||||
* 要删除的文件名
|
||||
* @return 删除成功返回true,否则返回false
|
||||
*/
|
||||
public static boolean delete(String fileName) {
|
||||
File file = new File(fileName);
|
||||
if (!file.exists()) {
|
||||
System.out.println("删除文件失败:" + fileName + "不存在!");
|
||||
return false;
|
||||
} else {
|
||||
if (file.isFile())
|
||||
return deleteFile(fileName);
|
||||
else
|
||||
return deleteDirectory(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单个文件
|
||||
*
|
||||
* @param fileName
|
||||
* 要删除的文件的文件名
|
||||
* @return 单个文件删除成功返回true,否则返回false
|
||||
*/
|
||||
public static boolean deleteFile(String fileName) {
|
||||
File file = new File(fileName);
|
||||
// 如果文件路径所对应的文件存在,并且是一个文件,则直接删除
|
||||
if (file.exists() && file.isFile()) {
|
||||
if (file.delete()) {
|
||||
System.out.println("删除单个文件" + fileName + "成功!");
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("删除单个文件" + fileName + "失败!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
System.out.println("删除单个文件失败:" + fileName + "不存在!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除目录及目录下的文件
|
||||
*
|
||||
* @param dir
|
||||
* 要删除的目录的文件路径
|
||||
* @return 目录删除成功返回true,否则返回false
|
||||
*/
|
||||
public static boolean deleteDirectory(String dir) {
|
||||
// 如果dir不以文件分隔符结尾,自动添加文件分隔符
|
||||
if (!dir.endsWith(File.separator))
|
||||
dir = dir + File.separator;
|
||||
File dirFile = new File(dir);
|
||||
// 如果dir对应的文件不存在,或者不是一个目录,则退出
|
||||
if ((!dirFile.exists()) || (!dirFile.isDirectory())) {
|
||||
System.out.println("删除目录失败:" + dir + "不存在!");
|
||||
return false;
|
||||
}
|
||||
boolean flag = true;
|
||||
// 删除文件夹中的所有文件包括子目录
|
||||
File[] files = dirFile.listFiles();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
// 删除子文件
|
||||
if (files[i].isFile()) {
|
||||
flag = DeleteFileUtil.deleteFile(files[i].getAbsolutePath());
|
||||
if (!flag)
|
||||
break;
|
||||
}
|
||||
// 删除子目录
|
||||
else if (files[i].isDirectory()) {
|
||||
flag = DeleteFileUtil.deleteDirectory(files[i]
|
||||
.getAbsolutePath());
|
||||
if (!flag)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag) {
|
||||
System.out.println("删除目录失败!");
|
||||
return false;
|
||||
}
|
||||
// 删除当前目录
|
||||
if (dirFile.delete()) {
|
||||
System.out.println("删除目录" + dir + "成功!");
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* public static void main(String[] args) {
|
||||
// // 删除单个文件
|
||||
// String file = "c:/test/test.txt";
|
||||
// DeleteFileUtil.deleteFile(file);
|
||||
// System.out.println();
|
||||
// 删除一个目录
|
||||
String dir = "E:/template/20190509222628.zip";
|
||||
// DeleteFileUtil.deleteDirectory(dir);
|
||||
deleteFile(dir);
|
||||
// System.out.println();
|
||||
// // 删除文件
|
||||
// dir = "c:/test/test0";
|
||||
// DeleteFileUtil.delete(dir);
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
@ -54,9 +54,9 @@ public class ExcelUtil {
|
||||
* @param isValidate 是否 Validator 检验 默认为是
|
||||
* @return 转换后集合
|
||||
*/
|
||||
public static <T> ExcelResult<T> importExcel(InputStream is, Class<T> clazz, boolean isValidate) {
|
||||
public static <T> ExcelResult<T> importExcel(InputStream is, Class<T> clazz, boolean isValidate,Integer num) {
|
||||
DefaultExcelListener<T> listener = new DefaultExcelListener<>(isValidate);
|
||||
EasyExcel.read(is, clazz, listener).sheet().doRead();
|
||||
EasyExcel.read(is, clazz, listener).sheet().headRowNumber(num).doRead();
|
||||
return listener.getExcelResult();
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,138 @@
|
||||
package com.ruoyi.common.utils.poi;
|
||||
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.util.PoitlIOUtils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* word模板导出
|
||||
* @author ljl
|
||||
*/
|
||||
public class ExportWordUtil {
|
||||
private ExportWordUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 1.compile 编译模板
|
||||
* 2.render 渲染数据
|
||||
* 3.输出到流
|
||||
* @param hashMap
|
||||
*/
|
||||
public static String createWord(String templatePath, String fileDir, String fileName, Map<String,Object> hashMap ){
|
||||
Assert.notNull(templatePath, "word模板文件路径不能为空");
|
||||
Assert.notNull(fileDir, "生成的文件存放地址不能为空");
|
||||
Assert.notNull(fileName, "生成的文件名不能为空");
|
||||
|
||||
// 生成的word格式
|
||||
String formatSuffix = ".docx";
|
||||
// 拼接后的文件名
|
||||
fileName = fileName + formatSuffix;
|
||||
|
||||
// 生成的文件的存放路径
|
||||
if (!fileDir.endsWith("/")) {
|
||||
fileDir = fileDir + File.separator;
|
||||
}
|
||||
|
||||
File dir = new File(fileDir);
|
||||
if (!dir.exists()) {
|
||||
System.out.println("生成word数据时存储文件目录{}不存在,为您创建文件夹!");
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
String filePath = fileDir + fileName;
|
||||
// 读取模板templatePath并将paramMap的内容填充进模板,即编辑模板+渲染数据
|
||||
XWPFTemplate template = XWPFTemplate.compile(templatePath).render(hashMap);
|
||||
try {
|
||||
// 将填充之后的模板写入filePath
|
||||
template.writeToFile(filePath);
|
||||
template.close();
|
||||
} catch (Exception e) {
|
||||
System.out.println("生成word异常");
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出到网络中
|
||||
* @param response
|
||||
* @param templatePath
|
||||
* @param fileName
|
||||
* @param hashMap
|
||||
* @return
|
||||
*/
|
||||
public static String createWord(HttpServletResponse response, String templatePath, String fileName, Map<String,Object> hashMap){
|
||||
Assert.notNull(templatePath, "word模板文件路径不能为空");
|
||||
//Assert.notNull(fileDir, "生成的文件存放地址不能为空");
|
||||
Assert.notNull(fileName, "生成的文件名不能为空");
|
||||
// 生成的word格式
|
||||
String formatSuffix = ".docx";
|
||||
// 拼接后的文件名
|
||||
// fileName = fileName + formatSuffix;
|
||||
// 读取模板templatePath并将paramMap的内容填充进模板,即编辑模板+渲染数据
|
||||
XWPFTemplate template = XWPFTemplate.compile(templatePath).render(hashMap);
|
||||
try {
|
||||
response.reset();
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
// response.setContentType("application/msword");
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-disposition","attachment;filename="+new String(fileName.getBytes(StandardCharsets.UTF_8),StandardCharsets.ISO_8859_1));
|
||||
OutputStream out = response.getOutputStream();
|
||||
// 将填充之后的模板写入filePath
|
||||
// template.write(out);
|
||||
// out.flush();
|
||||
// template.close();
|
||||
// HttpServletResponse response
|
||||
BufferedOutputStream bos = new BufferedOutputStream(out);
|
||||
|
||||
template.write(bos);
|
||||
bos.flush();
|
||||
out.flush();
|
||||
PoitlIOUtils.closeQuietlyMulti(template, bos, out);
|
||||
} catch (Exception e) {
|
||||
System.out.println("生成word异常");
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
public static String createWord1(HttpServletResponse response, HttpServletRequest request, String templatePath, String fileName, Map<String,Object> hashMap, Configure configure){
|
||||
Assert.notNull(templatePath, "word模板文件路径不能为空");
|
||||
//Assert.notNull(fileDir, "生成的文件存放地址不能为空");
|
||||
Assert.notNull(fileName, "生成的文件名不能为空");
|
||||
// 生成的word格式
|
||||
String formatSuffix = ".docx";
|
||||
// 拼接后的文件名
|
||||
//fileName = fileName + formatSuffix;
|
||||
// 读取模板templatePath并将paramMap的内容填充进模板,即编辑模板+渲染数据
|
||||
XWPFTemplate template = XWPFTemplate.compile(templatePath,configure).render(hashMap);
|
||||
try {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-disposition","attachment;filename="+new String(fileName.getBytes(StandardCharsets.UTF_8),StandardCharsets.ISO_8859_1));
|
||||
//OutputStream out = response.getOutputStream();
|
||||
OutputStream out = response.getOutputStream();
|
||||
//BufferedOutputStream bos = new BufferedOutputStream(out);
|
||||
// 将填充之后的模板写入filePath
|
||||
template.write(out);
|
||||
template.close();
|
||||
} catch (Exception e) {
|
||||
System.out.println("生成word异常");
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,132 @@
|
||||
package com.ruoyi.common.utils.poi;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
|
||||
public class ZipUtils {
|
||||
private static final int BUFFER_SIZE = 2 * 1024;
|
||||
|
||||
|
||||
public static void toZip(String srcDir, String out, boolean KeepDirStructure)
|
||||
throws RuntimeException {
|
||||
long start = System.currentTimeMillis();
|
||||
ZipOutputStream zos = null;
|
||||
try {
|
||||
FileOutputStream fos1 = new FileOutputStream(new File(out));
|
||||
zos = new ZipOutputStream(fos1);
|
||||
File sourceFile = new File(srcDir);
|
||||
compress(sourceFile, zos, sourceFile.getName(), KeepDirStructure);
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println("压缩完成,耗时:" + (end - start) + " ms");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("zip error from ZipUtils", e);
|
||||
} finally {
|
||||
if (zos != null) {
|
||||
try {
|
||||
zos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void toZip(List<File> srcFiles, OutputStream out) throws RuntimeException {
|
||||
long start = System.currentTimeMillis();
|
||||
ZipOutputStream zos = null;
|
||||
try {
|
||||
zos = new ZipOutputStream(out);
|
||||
for (File srcFile : srcFiles) {
|
||||
byte[] buf = new byte[BUFFER_SIZE];
|
||||
zos.putNextEntry(new ZipEntry(srcFile.getName()));
|
||||
int len;
|
||||
FileInputStream in = new FileInputStream(srcFile);
|
||||
while ((len = in.read(buf)) != -1) {
|
||||
zos.write(buf, 0, len);
|
||||
}
|
||||
zos.closeEntry();
|
||||
in.close();
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println("压缩完成,耗时:" + (end - start) + " ms");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("zip error from ZipUtils", e);
|
||||
} finally {
|
||||
if (zos != null) {
|
||||
try {
|
||||
zos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void compress(File sourceFile, ZipOutputStream zos, String name,
|
||||
boolean KeepDirStructure) throws Exception {
|
||||
byte[] buf = new byte[BUFFER_SIZE];
|
||||
if (sourceFile.isFile()) {
|
||||
// 向zip输出流中添加一个zip实体,构造器中name为zip实体的文件的名字
|
||||
zos.putNextEntry(new ZipEntry(name));
|
||||
// copy文件到zip输出流中
|
||||
int len;
|
||||
FileInputStream in = new FileInputStream(sourceFile);
|
||||
while ((len = in.read(buf)) != -1) {
|
||||
zos.write(buf, 0, len);
|
||||
}
|
||||
zos.closeEntry();
|
||||
in.close();
|
||||
} else {
|
||||
File[] listFiles = sourceFile.listFiles();
|
||||
if (listFiles == null || listFiles.length == 0) {
|
||||
// 需要保留原来的文件结构时,需要对空文件夹进行处理
|
||||
if (KeepDirStructure) {
|
||||
// 空文件夹的处理
|
||||
zos.putNextEntry(new ZipEntry(name + "/"));
|
||||
// 没有文件,不需要文件的copy
|
||||
zos.closeEntry();
|
||||
}
|
||||
} else {
|
||||
for (File file : listFiles) {
|
||||
// 判断是否需要保留原来的文件结构
|
||||
if (KeepDirStructure) {
|
||||
// 注意:file.getName()前面需要带上父文件夹的名字加一斜杠,
|
||||
// 不然最后压缩包中就不能保留原来的文件结构,即:所有文件都跑到压缩包根目录下了
|
||||
compress(file, zos, name + "/" + file.getName(), KeepDirStructure);
|
||||
} else {
|
||||
compress(file, zos, file.getName(), KeepDirStructure);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// FileOutputStream fos1 = new FileOutputStream(new File("H:/mytest01.zip"));
|
||||
// ZipUtils.toZip("H:/a", fos1, true);
|
||||
|
||||
// List<File> fileList = new ArrayList<>();
|
||||
//// fileList.add(new File("H:/1.png"));
|
||||
// fileList.add(new File("E:/a"));
|
||||
// FileOutputStream fos2 = new FileOutputStream(new File("H:/123.zip"));
|
||||
// ZipUtils.toZip(fileList, fos2);
|
||||
// DocumentHandler documentHandler = new DocumentHandler();
|
||||
// String str = "http://192.168.0.66:8090/file/d4d076edcfc34415ae0e4296fd8dc035.png";
|
||||
//// String[] split = str.split(".");
|
||||
// String n1=str.substring(str.lastIndexOf("."));
|
||||
// System.out.println(n1);
|
||||
//// documentHandler.download(str, "aaaa"+split[split.length - 1]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package com.ruoyi.common.utils.uuid;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* @author ruoyi 序列生成类
|
||||
*/
|
||||
public class Seq
|
||||
{
|
||||
// 通用序列类型
|
||||
public static final String commSeqType = "COMMON";
|
||||
|
||||
// 上传序列类型
|
||||
public static final String uploadSeqType = "UPLOAD";
|
||||
|
||||
// 通用接口序列数
|
||||
private static AtomicInteger commSeq = new AtomicInteger(1);
|
||||
|
||||
// 上传接口序列数
|
||||
private static AtomicInteger uploadSeq = new AtomicInteger(1);
|
||||
|
||||
// 机器标识
|
||||
private static final String machineCode = "A";
|
||||
|
||||
/**
|
||||
* 获取通用序列号
|
||||
*
|
||||
* @return 序列值
|
||||
*/
|
||||
public static String getId()
|
||||
{
|
||||
return getId(commSeqType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认16位序列号 yyMMddHHmmss + 一位机器标识 + 3长度循环递增字符串
|
||||
*
|
||||
* @return 序列值
|
||||
*/
|
||||
public static String getId(String type)
|
||||
{
|
||||
AtomicInteger atomicInt = commSeq;
|
||||
if (uploadSeqType.equals(type))
|
||||
{
|
||||
atomicInt = uploadSeq;
|
||||
}
|
||||
return getId(atomicInt, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用接口序列号 yyMMddHHmmss + 一位机器标识 + length长度循环递增字符串
|
||||
*
|
||||
* @param atomicInt 序列数
|
||||
* @param length 数值长度
|
||||
* @return 序列值
|
||||
*/
|
||||
public static String getId(AtomicInteger atomicInt, int length)
|
||||
{
|
||||
String result = DateUtils.dateTimeNow();
|
||||
result += machineCode;
|
||||
result += getSeq(atomicInt, length);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 序列循环递增字符串[1, 10 的 (length)幂次方), 用0左补齐length位数
|
||||
*
|
||||
* @return 序列值
|
||||
*/
|
||||
private synchronized static String getSeq(AtomicInteger atomicInt, int length)
|
||||
{
|
||||
// 先取值再+1
|
||||
int value = atomicInt.getAndIncrement();
|
||||
|
||||
// 如果更新后值>=10 的 (length)幂次方则重置为1
|
||||
int maxSeq = (int) Math.pow(10, length);
|
||||
if (atomicInt.get() >= maxSeq)
|
||||
{
|
||||
atomicInt.set(1);
|
||||
}
|
||||
// 转字符串,用0左补齐
|
||||
return StringUtils.padl(value, length);
|
||||
}
|
||||
}
|
||||
@ -74,7 +74,7 @@ public class TestDemoController extends BaseController {
|
||||
@SaCheckPermission("demo:demo:import")
|
||||
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<Void> importData(@RequestPart("file") MultipartFile file) throws Exception {
|
||||
ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true);
|
||||
ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true,0);
|
||||
List<TestDemoImportVo> volist = excelResult.getList();
|
||||
List<TestDemo> list = BeanUtil.copyToList(volist, TestDemo.class);
|
||||
iTestDemoService.saveBatch(list);
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
package com.ruoyi.demo.domain;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||
import com.alibaba.excel.converters.string.StringImageConverter;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode
|
||||
@ContentRowHeight(100)
|
||||
@ColumnWidth(100 / 8)
|
||||
public class ImageDemoData {
|
||||
private File file;
|
||||
private InputStream inputStream;
|
||||
/**
|
||||
* 如果string类型 必须指定转换器,string默认转换成string
|
||||
*/
|
||||
@ExcelProperty(converter = StringImageConverter.class)
|
||||
private String string;
|
||||
private byte[] byteArray;
|
||||
/**
|
||||
* 根据url导出
|
||||
*
|
||||
* @since 2.1.1
|
||||
*/
|
||||
private URL url;
|
||||
|
||||
/**
|
||||
* 根据文件导出 并设置导出的位置。
|
||||
*
|
||||
* @since 3.0.0-beta1
|
||||
*/
|
||||
private WriteCellData<Void> writeCellDataFile;
|
||||
}
|
||||
@ -22,7 +22,7 @@ public class TestDemo extends BaseEntity {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
package com.ruoyi.demo.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.Version;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.ruoyi.common.core.domain.TreeEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -25,7 +22,7 @@ public class TestTree extends TreeEntity<TestTree> {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package com.ruoyi.demo.init;
|
||||
|
||||
/**
|
||||
* 延迟队列执行器
|
||||
* Created by LPB on 2021/04/20.
|
||||
*/
|
||||
public interface RedisDelayQueueHandle<T> {
|
||||
|
||||
void execute(T t);
|
||||
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
package com.ruoyi.demo.init;/*
|
||||
package cn.dbtalents.checktalents.init;
|
||||
import cn.dbtalents.checktalents.enums.RedisDelayQueueEnum;
|
||||
import cn.dbtalents.checktalents.handle.RedisDelayQueueHandle;
|
||||
import cn.dbtalents.checktalents.util.RedisDelayQueueUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
*/
|
||||
/**
|
||||
* 启动延迟队列
|
||||
*//*
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RedisDelayQueueRunner implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
private RedisDelayQueueUtil redisDelayQueueUtil;
|
||||
*/
|
||||
/* @Autowired
|
||||
private ThreadPoolTaskExecutor threadPool;
|
||||
ThreadPoolExecutor executorService = new ThreadPoolExecutor(10, 50, 30, TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<Runnable>(1000), Executors.defaultThreadFactory());*//*
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
*/
|
||||
/* threadPool.execute(() -> {
|
||||
while (true){*//*
|
||||
|
||||
try {
|
||||
RedisDelayQueueEnum[] queueEnums = RedisDelayQueueEnum.values();
|
||||
for (RedisDelayQueueEnum queueEnum : queueEnums) {
|
||||
Object value = redisDelayQueueUtil.getDelayQueue(queueEnum.getCode());
|
||||
if (value != null) {
|
||||
RedisDelayQueueHandle redisDelayQueueHandle = SpringUtil.getBean(queueEnum.getBeanId());
|
||||
redisDelayQueueHandle.execute(value);
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
log.error("(Redis延迟队列异常中断) {}", e.getMessage());
|
||||
}
|
||||
// }
|
||||
// });
|
||||
log.info("(Redis延迟队列启动成功)");
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ -0,0 +1,60 @@
|
||||
package com.ruoyi.demo.init;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.api.RBlockingQueue;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* redis 延时队列初始化
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class RedisDelayedQueueInit implements ApplicationContextAware {
|
||||
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
/**
|
||||
* 获取应用上下文并获取相应的接口实现类
|
||||
* @param applicationContext
|
||||
* @throws BeansException
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
Map<String, RedisDelayQueueHandle> map = applicationContext.getBeansOfType(RedisDelayQueueHandle.class);
|
||||
for (Map.Entry<String, RedisDelayQueueHandle> taskEventListenerEntry : map.entrySet()) {
|
||||
String listenerName = taskEventListenerEntry.getValue().getClass().getName();
|
||||
startThread(listenerName, taskEventListenerEntry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动线程获取队列
|
||||
* @param queueName 队列名称
|
||||
* @param redisDelayedQueueListener 任务回调监听
|
||||
*/
|
||||
private <T> void startThread(String queueName, RedisDelayQueueHandle redisDelayedQueueListener) {
|
||||
RBlockingQueue<T> blockingFairQueue = redissonClient.getBlockingQueue(queueName);
|
||||
//由于此线程需要常驻,可以新建线程,不用交给线程池管理
|
||||
Thread thread = new Thread(() -> {
|
||||
log.info("启动监听队列线程" + queueName);
|
||||
while (true) {
|
||||
try {
|
||||
T t = blockingFairQueue.take();
|
||||
log.info("监听队列线程{},获取到值:{}", queueName, t);
|
||||
redisDelayedQueueListener.execute(t);
|
||||
} catch (Exception e) {
|
||||
log.info("监听队列线程错误,", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.setName(queueName);
|
||||
thread.start();
|
||||
log.info("(Redis延迟队列启动成功)");
|
||||
}
|
||||
}
|
||||
@ -41,5 +41,5 @@ spring.boot.admin.client:
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
username: ruoyi
|
||||
password: 123456
|
||||
username: gaoxin
|
||||
password: 1234Qwer@
|
||||
|
||||
35
ruoyi-file/pom.xml
Normal file
35
ruoyi-file/pom.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi-vue-plus</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>4.8.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-file</artifactId>
|
||||
|
||||
<description>
|
||||
文件存放模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Minio -->
|
||||
<!-- <dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
<version>8.5.2</version>
|
||||
</dependency>-->
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,94 @@
|
||||
/*
|
||||
package com.ruoyi.file.config;
|
||||
|
||||
import io.minio.MinioClient;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
*/
|
||||
/**
|
||||
* Minio 配置信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*//*
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "minio")
|
||||
public class MinioConfig
|
||||
{
|
||||
*/
|
||||
/**
|
||||
* 服务地址
|
||||
*//*
|
||||
|
||||
private String url;
|
||||
|
||||
*/
|
||||
/**
|
||||
* 用户名
|
||||
*//*
|
||||
|
||||
private String accessKey;
|
||||
|
||||
*/
|
||||
/**
|
||||
* 密码
|
||||
*//*
|
||||
|
||||
private String secretKey;
|
||||
|
||||
*/
|
||||
/**
|
||||
* 存储桶名称
|
||||
*//*
|
||||
|
||||
private String bucketName;
|
||||
|
||||
public String getUrl()
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url)
|
||||
{
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getAccessKey()
|
||||
{
|
||||
return accessKey;
|
||||
}
|
||||
|
||||
public void setAccessKey(String accessKey)
|
||||
{
|
||||
this.accessKey = accessKey;
|
||||
}
|
||||
|
||||
public String getSecretKey()
|
||||
{
|
||||
return secretKey;
|
||||
}
|
||||
|
||||
public void setSecretKey(String secretKey)
|
||||
{
|
||||
this.secretKey = secretKey;
|
||||
}
|
||||
|
||||
public String getBucketName()
|
||||
{
|
||||
return bucketName;
|
||||
}
|
||||
|
||||
public void setBucketName(String bucketName)
|
||||
{
|
||||
this.bucketName = bucketName;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MinioClient getMinioClient()
|
||||
{
|
||||
return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build();
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ -0,0 +1,62 @@
|
||||
/*
|
||||
package com.ruoyi.file.config;
|
||||
|
||||
import java.io.File;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
*/
|
||||
/**
|
||||
* 通用映射配置
|
||||
*
|
||||
* @author ruoyi
|
||||
*//*
|
||||
|
||||
@Configuration
|
||||
public class ResourcesConfig implements WebMvcConfigurer
|
||||
{
|
||||
*/
|
||||
/**
|
||||
* 上传文件存储在本地的根路径
|
||||
*//*
|
||||
|
||||
@Value("${file.path}")
|
||||
private String localFilePath;
|
||||
|
||||
*/
|
||||
/**
|
||||
* 资源映射路径 前缀
|
||||
*//*
|
||||
|
||||
@Value("${file.prefix}")
|
||||
public String localFilePrefix;
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry)
|
||||
{
|
||||
*/
|
||||
/** 本地文件上传路径 *//*
|
||||
|
||||
registry.addResourceHandler(localFilePrefix + "/**")
|
||||
.addResourceLocations("file:" + localFilePath + File.separator);
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* 开启跨域
|
||||
*//*
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
// 设置允许跨域的路由
|
||||
registry.addMapping(localFilePrefix + "/**")
|
||||
// 设置允许跨域请求的域名
|
||||
.allowedOrigins("*")
|
||||
// 设置允许的方法
|
||||
.allowedMethods("GET");
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ -0,0 +1,53 @@
|
||||
/*
|
||||
package com.ruoyi.file.service;
|
||||
|
||||
import java.io.InputStream;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
||||
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||
import com.ruoyi.common.core.utils.file.FileTypeUtils;
|
||||
|
||||
*/
|
||||
/**
|
||||
* FastDFS 文件存储
|
||||
*
|
||||
* @author ruoyi
|
||||
*//*
|
||||
|
||||
@Service
|
||||
public class FastDfsSysFileServiceImpl implements ISysFileService
|
||||
{
|
||||
*/
|
||||
/**
|
||||
* 域名或本机访问地址
|
||||
*//*
|
||||
|
||||
@Value("${fdfs.domain}")
|
||||
public String domain;
|
||||
|
||||
@Autowired
|
||||
private FastFileStorageClient storageClient;
|
||||
|
||||
*/
|
||||
/**
|
||||
* FastDfs文件上传接口
|
||||
*
|
||||
* @param file 上传的文件
|
||||
* @return 访问地址
|
||||
* @throws Exception
|
||||
*//*
|
||||
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file) throws Exception
|
||||
{
|
||||
InputStream inputStream = file.getInputStream();
|
||||
StorePath storePath = storageClient.uploadFile(inputStream, file.getSize(),
|
||||
FileTypeUtils.getExtension(file), null);
|
||||
inputStream.close();
|
||||
return domain + "/" + storePath.getFullPath();
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ -0,0 +1,20 @@
|
||||
package com.ruoyi.file.service;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 文件上传接口
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysFileService
|
||||
{
|
||||
/**
|
||||
* 文件上传接口
|
||||
*
|
||||
* @param file 上传的文件
|
||||
* @return 访问地址
|
||||
* @throws Exception
|
||||
*/
|
||||
public String uploadFile(MultipartFile file) throws Exception;
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.ruoyi.file.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.file.utils.FileUploadUtils;
|
||||
|
||||
/**
|
||||
* 本地文件存储
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Primary
|
||||
@Service
|
||||
public class LocalSysFileServiceImpl implements ISysFileService
|
||||
{
|
||||
|
||||
/**
|
||||
* 资源映射路径 前缀
|
||||
*/
|
||||
@Value("${file.prefix}")
|
||||
public String localFilePrefix;
|
||||
|
||||
/**
|
||||
* 域名或本机访问地址
|
||||
*/
|
||||
@Value("${file.domain}")
|
||||
public String domain;
|
||||
|
||||
/**
|
||||
* 上传文件存储在本地的根路径
|
||||
*/
|
||||
@Value("${file.path}")
|
||||
private String localFilePath;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 本地文件上传接口
|
||||
*
|
||||
* @param file 上传的文件
|
||||
* @return 访问地址
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file) throws Exception
|
||||
{
|
||||
String name = FileUploadUtils.upload(localFilePath, file);
|
||||
String url = domain + localFilePrefix + name;
|
||||
return url;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user