parent
3bc5d10b76
commit
2f9749c828
|
|
@ -0,0 +1,53 @@
|
|||
package com.bonus.system.api;
|
||||
|
||||
import com.bonus.common.core.constant.SecurityConstants;
|
||||
import com.bonus.common.core.constant.ServiceNameConstants;
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.system.api.domain.SysFileSource;
|
||||
import com.bonus.system.api.domain.SysOperLog;
|
||||
import com.bonus.system.api.factory.RemoteUserFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(contextId = "remoteSourceService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
|
||||
public interface RemoteSourceService {
|
||||
|
||||
/**
|
||||
* 保存资源信息
|
||||
* @param sysFileSource
|
||||
* @param source
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/fileSource/addFileSource")
|
||||
public R<Boolean> addFileSource(@RequestBody SysFileSource sysFileSource, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception;
|
||||
|
||||
/**
|
||||
* 保存资源信息
|
||||
* @param sysFileSource
|
||||
* 优先按照id 去删除
|
||||
* 如果没有id 则
|
||||
* 按照资源id去删除
|
||||
* @param source
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/fileSource/delSourceFile")
|
||||
public R<Boolean> delSourceFile(@RequestBody SysFileSource sysFileSource, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 查询文件资源信息
|
||||
* @param sourceId
|
||||
* @param source
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/fileSource/getSourceFileList")
|
||||
public R<List<SysFileSource>> getSourceFileList(@RequestBody String sourceId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
package com.bonus.system.api.domain;
|
||||
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class SysFileSource extends BaseEntity{
|
||||
|
||||
private String fileName;
|
||||
|
||||
private String fileSuffix;
|
||||
|
||||
private String filePath;
|
||||
|
||||
private int fileType;
|
||||
|
||||
|
||||
private String sourceId;
|
||||
|
||||
private String sourceType;
|
||||
|
||||
private String createUser;
|
||||
|
||||
private Long id;
|
||||
|
||||
private String updateUser;
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getFileSuffix() {
|
||||
return fileSuffix;
|
||||
}
|
||||
|
||||
public void setFileSuffix(String fileSuffix) {
|
||||
this.fileSuffix = fileSuffix;
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public int getFileType() {
|
||||
return fileType;
|
||||
}
|
||||
|
||||
public void setFileType(int fileType) {
|
||||
this.fileType = fileType;
|
||||
}
|
||||
|
||||
public String getSourceId() {
|
||||
return sourceId;
|
||||
}
|
||||
|
||||
public void setSourceId(String sourceId) {
|
||||
this.sourceId = sourceId;
|
||||
}
|
||||
|
||||
public String getSourceType() {
|
||||
return sourceType;
|
||||
}
|
||||
|
||||
public void setSourceType(String sourceType) {
|
||||
this.sourceType = sourceType;
|
||||
}
|
||||
|
||||
public String getCreateUser() {
|
||||
return createUser;
|
||||
}
|
||||
|
||||
public void setCreateUser(String createUser) {
|
||||
this.createUser = createUser;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getUpdateUser() {
|
||||
return updateUser;
|
||||
}
|
||||
|
||||
public void setUpdateUser(String updateUser) {
|
||||
this.updateUser = updateUser;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.bonus.system.api.factory;
|
||||
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.system.api.RemoteLogService;
|
||||
import com.bonus.system.api.RemoteSourceService;
|
||||
import com.bonus.system.api.RemoteUserService;
|
||||
import com.bonus.system.api.domain.SysFileSource;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件资源降级处理
|
||||
*
|
||||
* @author bonus
|
||||
*/
|
||||
@Component
|
||||
public class RemoteSourceFallbackFactory implements FallbackFactory<RemoteSourceService> {
|
||||
private static final Logger log = LoggerFactory.getLogger(RemoteSourceFallbackFactory.class);
|
||||
|
||||
|
||||
@Override
|
||||
public RemoteSourceService create(Throwable throwable) {
|
||||
log.error("日志服务调用失败:{}", throwable.getMessage());
|
||||
return new RemoteSourceService() {
|
||||
@Override
|
||||
public R<Boolean> addFileSource(SysFileSource sysFileSource, String source) throws Exception {
|
||||
return R.fail("添加文件资源失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Boolean> delSourceFile(SysFileSource sysFileSource, String source) throws Exception {
|
||||
return R.fail("删除文件资源失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<SysFileSource>> getSourceFileList(String sourceId, String source) throws Exception {
|
||||
return R.fail("查询文件资源失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
com.bonus.system.api.factory.RemoteUserFallbackFactory
|
||||
com.bonus.system.api.factory.RemoteLogFallbackFactory
|
||||
com.bonus.system.api.factory.RemoteFileFallbackFactory
|
||||
com.bonus.system.api.factory.RemoteSourceFallbackFactory
|
||||
|
|
|
|||
|
|
@ -21,4 +21,5 @@ public class ServiceNameConstants
|
|||
* 文件服务的serviceid
|
||||
*/
|
||||
public static final String FILE_SERVICE = "bonus-file";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
package com.bonus.common.core.utils;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 身份证工具类
|
||||
*/
|
||||
public class IdCardUtil {
|
||||
|
||||
|
||||
public static String getGenderByIdCard(String idCard) {
|
||||
if (idCard == null || (idCard.length() != 18 && idCard.length() != 15)) {
|
||||
throw new IllegalArgumentException("身份证号码长度不正确");
|
||||
}
|
||||
char sexFlag = idCard.charAt(idCard.length() - 2); // 性别标志位
|
||||
return (sexFlag % 2 == 0) ? "0" : "1";
|
||||
}
|
||||
public static boolean isValidChineseID(String id) {
|
||||
if (id == null || (id.length() != 18)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char[] idArray = id.toCharArray();
|
||||
int[] weight = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
|
||||
char[] checkCode = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
|
||||
int sum = 0;
|
||||
|
||||
for (int i = 0; i < idArray.length - 1; i++) {
|
||||
int num = Integer.parseInt(String.valueOf(idArray[i]));
|
||||
if (num < 0 || num > 9) {
|
||||
return false;
|
||||
}
|
||||
sum += num * weight[i];
|
||||
}
|
||||
|
||||
sum = sum % 11;
|
||||
char lastChar = idArray[17];
|
||||
return lastChar == checkCode[sum];
|
||||
}
|
||||
|
||||
private static final Pattern CHINA_MOBILE_PATTERN =
|
||||
Pattern.compile("^1[3-9]\\d{9}$");
|
||||
|
||||
/**
|
||||
* 验证手机号码是否有效。
|
||||
* @param number 要验证的手机号码
|
||||
* @return 如果手机号码有效,则返回true;否则返回false。
|
||||
*/
|
||||
public static boolean isValidChinaMobileNumber(String number) {
|
||||
return CHINA_MOBILE_PATTERN.matcher(number).matches();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.bonus.app.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 临时人员实体类
|
||||
*/
|
||||
@Data
|
||||
public class LsUserEntity {
|
||||
|
||||
private String id;
|
||||
/**
|
||||
* 图片了些
|
||||
*/
|
||||
private String imageType;
|
||||
/**
|
||||
* 身份证号码
|
||||
*/
|
||||
private String idCard;
|
||||
/**
|
||||
* 用户民成功
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
private String fileId;
|
||||
|
||||
private String proId;
|
||||
|
||||
private Long teamId;
|
||||
|
||||
private String sex;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.bonus.system.controller;
|
||||
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.security.annotation.InnerAuth;
|
||||
import com.bonus.system.api.domain.SysFileSource;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import com.bonus.system.service.SysFileSourceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/fileSource")
|
||||
public class SysFileSourceController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private SysFileSourceService service;
|
||||
/**
|
||||
* 新增资源i想你洗
|
||||
*/
|
||||
@InnerAuth
|
||||
@PostMapping("/addFileSource")
|
||||
public R<Boolean> addFileSource(@RequestBody SysFileSource fileSource) {
|
||||
return service.addFileSource(fileSource);
|
||||
}
|
||||
/**
|
||||
* 删除资源信息
|
||||
*/
|
||||
@InnerAuth
|
||||
@PostMapping("/delSourceFile")
|
||||
public R<Boolean> delSourceFile(@RequestBody SysFileSource fileSource) {
|
||||
return service.delSourceFile(fileSource);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前用户信息
|
||||
*/
|
||||
@InnerAuth
|
||||
@PostMapping("/getSourceFileList")
|
||||
public R<List<SysFileSource>> getSourceFileList(@RequestBody String sourceId) {
|
||||
return service.getSourceFileList(sourceId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.bonus.system.mapper;
|
||||
|
||||
import com.bonus.system.api.domain.SysFileSource;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysFileSourceMapper {
|
||||
/**
|
||||
* 文件资源存储
|
||||
* @param fileSource
|
||||
* @return
|
||||
*/
|
||||
int addFileSource(SysFileSource fileSource);
|
||||
|
||||
/**
|
||||
* 依据id
|
||||
* 删除
|
||||
* @param fileSource
|
||||
* @return
|
||||
*/
|
||||
int delSourceFileById(SysFileSource fileSource);
|
||||
/**
|
||||
* 依据 资源id
|
||||
* 删除
|
||||
* @param fileSource
|
||||
* @return
|
||||
*/
|
||||
int delSourceFileBySourceId(SysFileSource fileSource);
|
||||
|
||||
/**
|
||||
* 依据资源拆线呢数据
|
||||
* @param sourceId
|
||||
* @return
|
||||
*/
|
||||
List<SysFileSource> getSourceFileList(String sourceId);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.bonus.system.service;
|
||||
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.system.api.domain.SysFileSource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysFileSourceService {
|
||||
R<Boolean> addFileSource(SysFileSource fileSource);
|
||||
|
||||
/**
|
||||
* 删除资源数据
|
||||
* @param fileSource
|
||||
* @return
|
||||
*/
|
||||
R<Boolean> delSourceFile(SysFileSource fileSource);
|
||||
|
||||
/**
|
||||
* 查询资源文件
|
||||
* @param sourceId
|
||||
* @return
|
||||
*/
|
||||
R<List<SysFileSource>> getSourceFileList(String sourceId);
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.bonus.system.service.impl;
|
||||
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.system.api.domain.SysFileSource;
|
||||
import com.bonus.system.mapper.SysFileSourceMapper;
|
||||
import com.bonus.system.service.SysFileSourceService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件资源存储
|
||||
* @author 黑子
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysFileSourceServiceImpl implements SysFileSourceService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private SysFileSourceMapper mapper;
|
||||
/**
|
||||
*
|
||||
* @param fileSource
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R<Boolean> addFileSource(SysFileSource fileSource) {
|
||||
try{
|
||||
if(StringUtils.isEmpty(fileSource.getFilePath())){
|
||||
System.err.println("文件id为空");
|
||||
return R.fail(false);
|
||||
}
|
||||
int num=mapper.addFileSource(fileSource);
|
||||
if (num>0){
|
||||
return R.ok(true);
|
||||
}
|
||||
return R.fail(false);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return R.fail(false);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fileSource
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R<Boolean> delSourceFile(SysFileSource fileSource) {
|
||||
try{
|
||||
int num=0;
|
||||
if(ObjectUtils.isEmpty(fileSource.getId()) && fileSource.getId()!=0L){
|
||||
num= mapper.delSourceFileById(fileSource);
|
||||
}else if(StringUtils.isNotEmpty(fileSource.getSourceId())){
|
||||
num= mapper.delSourceFileBySourceId(fileSource);
|
||||
}
|
||||
if (num>0){
|
||||
return R.ok(true);
|
||||
}
|
||||
return R.fail(false);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
|
||||
return R.fail(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<SysFileSource>> getSourceFileList(String sourceId) {
|
||||
List<SysFileSource> list=mapper.getSourceFileList(sourceId);
|
||||
return R.ok(list);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.system.mapper.SysFileSourceMapper">
|
||||
|
||||
|
||||
<insert id="addFileSource">
|
||||
INSERT INTO sys_file_source(
|
||||
file_name, file_suffix, file_path,
|
||||
file_type, source_id, source_type,
|
||||
create_time,create_user,update_time,
|
||||
update_user, del_flag
|
||||
) VALUE(
|
||||
#{fileName},#{fileSuffix},#{filePath},
|
||||
#{fileType},#{sourceId},#{sourceType},
|
||||
now(),#{createUser},now(),
|
||||
#{updateUser},0
|
||||
)
|
||||
</insert>
|
||||
<delete id="delSourceFileById">
|
||||
update sys_file_source set del_flag=1 WHERE id=#{id}
|
||||
</delete>
|
||||
<delete id="delSourceFileBySourceId">
|
||||
update sys_file_source set del_flag=1 WHERE source_id=#{sourceId}
|
||||
|
||||
</delete>
|
||||
<select id="getSourceFileList" resultType="com.bonus.system.api.domain.SysFileSource">
|
||||
select id,file_name fileName, file_suffix fileSuffix, file_path filePath,
|
||||
file_type fileType, source_id sourceId, source_type sourceType,
|
||||
create_time,create_user createUser,update_time,
|
||||
update_user updateUser
|
||||
FROM
|
||||
sys_file_source
|
||||
where source_id=#{sourceId}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue