commit 10e056aa4476699ab06686e1b8598e260e18c718 Author: thomas Date: Thu Jul 8 18:02:26 2021 +0800 init project diff --git a/1.设计文档/readme.md b/1.设计文档/readme.md new file mode 100644 index 0000000..e69de29 diff --git a/2.需求文档/readme.md b/2.需求文档/readme.md new file mode 100644 index 0000000..e69de29 diff --git a/3.测试文档/readme.md b/3.测试文档/readme.md new file mode 100644 index 0000000..e69de29 diff --git a/4.发布版本/readme.md b/4.发布版本/readme.md new file mode 100644 index 0000000..e69de29 diff --git a/5.数据库/readme.md b/5.数据库/readme.md new file mode 100644 index 0000000..e69de29 diff --git a/6.program/.drone.yml b/6.program/.drone.yml new file mode 100644 index 0000000..b565000 --- /dev/null +++ b/6.program/.drone.yml @@ -0,0 +1,39 @@ +--- +kind: pipeline +type: docker +name: default + +steps: +- name: build + image: docker:dind + volumes: + - name: dockersock + path: /var/run/docker.sock + - name: dockerconfig + path: /root/.docker + commands: + - docker build -t harbor.picaiba.com/wms/wms-cloud-api ./ && docker push harbor.picaiba.com/wms/wms-cloud-api + +# - name: deploy +# image: docker:dind +# volumes: +# - name: dockersock +# path: /var/run/docker.sock +# commands: +# - docker service update mes_mes --force +# depends_on: +# - build + +volumes: +- name: dockersock + host: + path: /var/run/docker.sock +- name: dockerconfig + host: + path: /root/.docker + +trigger: + branch: + - develop + event: + - push \ No newline at end of file diff --git a/6.program/.gitignore b/6.program/.gitignore new file mode 100644 index 0000000..0bcb3b9 --- /dev/null +++ b/6.program/.gitignore @@ -0,0 +1,41 @@ +# ---> Java +# Compiled class file +*.class + +.idea/ +*.iml + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# ---> Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + diff --git a/6.program/Dockerfile b/6.program/Dockerfile new file mode 100644 index 0000000..e69de29 diff --git a/6.program/README.md b/6.program/README.md new file mode 100644 index 0000000..2f1c825 --- /dev/null +++ b/6.program/README.md @@ -0,0 +1,3 @@ +# wms + +仓库系统 \ No newline at end of file diff --git a/6.program/pom.xml b/6.program/pom.xml new file mode 100644 index 0000000..7fbdf1c --- /dev/null +++ b/6.program/pom.xml @@ -0,0 +1,431 @@ + + + + 4.0.0 + + wms-gateway + wms-core + wms-common + wms-passport + wms-upms + wms-empty + + + + org.springframework.boot + spring-boot-starter-parent + 2.0.4.RELEASE + + + com.mt + wms + pom + 1.0 + + wms + wms + https://wms.picaiba.com + + + + dev + + true + + + dev + 8080 + wms + wms + + 127.0.0.1 + 5672 + guest + guest + + redis.picaiba.com:6380 + redis.picaiba.com + 6380 + + 5 + + jdbc:p6spy:mysql://mysql.picaiba.com:30306/wms?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false + + wms + 1qaz@WS + + smtp.mxhichina.com + + 465 + noreply@mt.com + noreply + + wms + true + + /work/uploadFile/ + http://127.0.0.1:8080 + http://127.0.0.1:8080 + + aliyun + Dysmsapi + dysmsapi.aliyuncs.com + 202020202020 + 202020202020 + 202020202020 + 202020202020 + 202020202020 + 202020202020 + + + + test + + false + + + test + + 9090 + + wms + wms + + 127.0.0.1 + 5672 + wms + wms + + redis.picaiba.com:6380 + redis.picaiba.com + 6380 + + 10 + + jdbc:p6spy:mysql://mysql.picaiba.com:30306/wms?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false + + wms + 1qaz@WS + + smtp.mxhichina.com + + 465 + noreply@mt.com + noreply + + wms + false + + /home/api/uploadFile/ + https://wms.mt.com + https://api.wms-test.mt.com + + aliyun + Dysmsapi + dysmsapi.aliyuncs.com + 202020202020 + 202020202020 + 202020202020 + 202020202020 + 202020202020 + 202020202020 + + + + prod + + false + + + prod + 8090 + wms + wms + + 127.0.0.1 + 5672 + wms + wms + + 127.0.0.1:6379 + 127.0.0.1 + 6379 + 2018 + 10 + + jdbc:p6spy:mysql://localhost:3306/wms?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false + + root + root + + smtp.mxhichina.com + + 465 + noreply@mt.com + noreply + + wms + false + + /home/api/uploadFile/ + https://wms.mt.com + https://api.wms.mt.com + + aliyun + Dysmsapi + dysmsapi.aliyuncs.com + 202020202020 + 202020202020 + 202020202020 + 202020202020 + 202020202020 + 202020202020 + + + + + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + 1.8 + dev + 2.0.4.RELEASE + Finchley.RELEASE + 2.0.2 + + 1.5.7 + 1.5.7 + + + 2.9.2 + + 3.7.0 + 3.11.0 + + 3.4.1 + 3.9.0 + 2.0.3 + + 1.2.75 + + 4.0.9 + 1.1.0 + 3.1.109 + + 4.1.21 + + 4.0.0 + + 2.0.1 + + 2.0 + + 5.11 + + 3.11.2 + + 6.9.0 + + 1.5.0 + + 0.4.13 + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + io.spring.platform + platform-bom + Cairo-SR2 + pom + import + + + de.codecentric + spring-boot-admin-dependencies + ${spring-boot-admin.version} + pom + import + + + io.springfox + springfox-swagger2 + ${springfox-swagger2.version} + + + io.springfox + springfox-swagger-ui + ${springfox-swagger2.version} + + + com.mt + wms-common + ${project.version} + + + com.mt + wms-core + ${project.version} + + + com.mt + wms-gateway + ${project.version} + + + com.mt + wms-passport + ${project.version} + + + com.mt + wms-upms + ${project.version} + + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus.version} + + + com.baomidou + mybatis-plus-generator + ${mybatis-plus.version} + + + org.apache.velocity + velocity-engine-core + 2.0 + + + p6spy + p6spy + ${p6spy.version} + + + + + com.alibaba + fastjson + ${fastjson.version} + + + + + + + + org.apache.poi + poi + ${cn.afterturn.version} + + + org.apache.poi + poi-ooxml + ${cn.afterturn.version} + + + net.sf.jasperreports + jasperreports + ${jasperreports.version} + + + net.sf.jasperreports + jasperreports-fonts + ${jasperreports.version} + + + + + com.imadcn.framework + idworker + ${idworker.version} + + + + + + net.coobird + thumbnailator + ${thumbnailator.version} + + + + + + + + + src/main/resources + true + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + build-info + + + + + + maven-compiler-plugin + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + true + + + + maven-surefire-plugin + + true + + + + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/libs-milestone + + + aliyun + aliyun + http://maven.aliyun.com/nexus/content/groups/public/ + + + diff --git a/6.program/wms-common/pom.xml b/6.program/wms-common/pom.xml new file mode 100644 index 0000000..3025294 --- /dev/null +++ b/6.program/wms-common/pom.xml @@ -0,0 +1,34 @@ + + + + wms + com.mt + 1.0 + + 4.0.0 + + wms-common + + + com.mt + wms-core + + + com.aliyun + aliyun-java-sdk-core + ${aliyun-java-sdk-core.version} + + + com.aliyun + aliyun-java-sdk-dysmsapi + ${aliyun-java-sdk-dysmsapi.version} + + + net.coobird + thumbnailator + + + + \ No newline at end of file diff --git a/6.program/wms-common/src/main/java/com/mt/wms/common/controller/AttachmentController.java b/6.program/wms-common/src/main/java/com/mt/wms/common/controller/AttachmentController.java new file mode 100644 index 0000000..0ebd827 --- /dev/null +++ b/6.program/wms-common/src/main/java/com/mt/wms/common/controller/AttachmentController.java @@ -0,0 +1,62 @@ +package com.mt.wms.common.controller; + +import com.mt.wms.common.params.DownloadFileParam; +import com.mt.wms.common.params.UploadFileBase64Param; +import com.mt.wms.common.service.AttachmentService; +import com.mt.wms.common.vo.SysFileVo; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.vo.R; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author jiff + * @date 2021/01/12 + * @since 1.0 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_COMMON + "attachment") +@Slf4j +@Api(value = "附件管理", tags = "附件管理", hidden = false) +public class AttachmentController extends BaseController { + @Autowired + private AttachmentService attachmentService; + + + @PostMapping(value = "uploadFile") + @ApiOperation(value = "上传文件", notes = "上传文件") + public R> uploadFile(@ApiParam(value = "文件类型", required = true) @NotEmpty(message = "文件类型编码不得为空") @RequestParam String typeCode) { + return attachmentService.uploadFile(typeCode); + } + + @PostMapping("uploadFileBase64") + @ApiOperation(value = "文件上传(base64字符串方式)", notes = "文件上传") + public R uploadFileBase64(@Validated @RequestBody UploadFileBase64Param param) { + return attachmentService.uploadFileBase64(param); + } + + @PostMapping("uploadFileFormData") + @ApiOperation(value = "文件上传(form表单形式)", notes = "文件上传") + public R> uploadFileFormData(@ApiParam(value = "文件类型", required = true) @NotEmpty(message = "文件类型编码不得为空") @RequestParam String typeCode, @ApiParam(value = "文件附件", required = true) @NotNull(message = "文件附件不能为空") @RequestParam("files") MultipartFile[] files) { + return attachmentService.uploadFileFormData(typeCode, files); + } + + @GetMapping(value = "downloadFile") + @ApiOperation(value = "下载文件", notes = "下载文件") + public R downloadFile(@Validated DownloadFileParam param) { + return attachmentService.downloadFile(param); + } + + +} diff --git a/6.program/wms-common/src/main/java/com/mt/wms/common/controller/CommonController.java b/6.program/wms-common/src/main/java/com/mt/wms/common/controller/CommonController.java new file mode 100644 index 0000000..2fe3035 --- /dev/null +++ b/6.program/wms-common/src/main/java/com/mt/wms/common/controller/CommonController.java @@ -0,0 +1,49 @@ +package com.mt.wms.common.controller; + +import com.mt.wms.common.service.CommonService; +import com.mt.wms.common.vo.SysFileVo; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.R; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/7/6 + * @since 1.0 + */ +@Api(value = "公共模块", tags = "公共模块") +@RestController +@RequestMapping(CommonConstant.API_MODULE_COMMON) +@Slf4j +@RequiredArgsConstructor +public class CommonController extends BaseController { + private final CommonService commonService; + + + @PostMapping(value = "downloadFile") + @ApiOperation(value = "获取附件下载地址", notes = "获取附件下载地址") + public R downloadFile(@Validated @RequestBody IdParam idParam) { + return successful(commonService.downloadFile(idParam.getId())); + } + + @GetMapping(value = "downLoadFileUrl") + @ApiOperation(value = "文件的预览", notes = "文件的预览") + public R downloadFile(@Validated IdParam idParam, HttpServletResponse response) { + return commonService.downLoadFileUrl(idParam, response); + } + + +} diff --git a/6.program/wms-common/src/main/java/com/mt/wms/common/mapper/CommonMapper.java b/6.program/wms-common/src/main/java/com/mt/wms/common/mapper/CommonMapper.java new file mode 100644 index 0000000..ba0f321 --- /dev/null +++ b/6.program/wms-common/src/main/java/com/mt/wms/common/mapper/CommonMapper.java @@ -0,0 +1,17 @@ +package com.mt.wms.common.mapper; + +import org.springframework.stereotype.Repository; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/7/6 + * @since 1.0 + */ +@Repository +public interface CommonMapper { + +} diff --git a/6.program/wms-common/src/main/java/com/mt/wms/common/params/DownloadFileParam.java b/6.program/wms-common/src/main/java/com/mt/wms/common/params/DownloadFileParam.java new file mode 100644 index 0000000..1fca76b --- /dev/null +++ b/6.program/wms-common/src/main/java/com/mt/wms/common/params/DownloadFileParam.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020. + * http://www.ulabcare.com + */ + +package com.mt.wms.common.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * 下载文件对象入参 + * + * @author jiff + * @date 2021/01/12 + * @since 1.0 + **/ +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@Data +@ApiModel(value = "下载文件信息对象", description = "下载文件信息对象") +public class DownloadFileParam extends BaseParam { + + @ApiModelProperty(value = "附件ID", example = "1") + @NotNull(message = "附件ID不能为空") + private Long attachmentId; + + @ApiModelProperty(value = "下载方式: 0、预览,1、下载", example = "0") + @NotNull(message = "下载方式不能为空") + private String type; + + @ApiModelProperty(value = "下载文件自定义文件名", example = "报销发票") + private String fileName; + + @ApiModelProperty(value = "压缩尺寸,取值范围(0.00--1.00),图片文件有效", example = "1") + private float scale = 1f; + + @ApiModelProperty(value = "压缩质量,取值范围(0.00--1.00),图片文件有效", example = "1") + private float outputQuality = 1f; +} diff --git a/6.program/wms-common/src/main/java/com/mt/wms/common/params/UploadFileBase64Param.java b/6.program/wms-common/src/main/java/com/mt/wms/common/params/UploadFileBase64Param.java new file mode 100644 index 0000000..2e7172a --- /dev/null +++ b/6.program/wms-common/src/main/java/com/mt/wms/common/params/UploadFileBase64Param.java @@ -0,0 +1,38 @@ +package com.mt.wms.common.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; + +/** + *

+ * 文件上传base64字符串方式 + *

+ * + * @author jiff + * @date 2021/01/12 + * @since 1.0 + **/ +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@Data +@ApiModel("文件上传base64字符串方式") +public class UploadFileBase64Param extends BaseParam { + + @ApiModelProperty("文件类型编码") + @NotEmpty(message = "文件类型编码不能为空") + private String typeCode; + + @ApiModelProperty("文件名") + @NotEmpty(message = "文件名不能为空") + private String fileName; + + @ApiModelProperty("base64字符串") + @NotEmpty(message = "文件base64字符串不能为空") + private String fileBase64Str; +} diff --git a/6.program/wms-common/src/main/java/com/mt/wms/common/service/AttachmentService.java b/6.program/wms-common/src/main/java/com/mt/wms/common/service/AttachmentService.java new file mode 100644 index 0000000..740d2c4 --- /dev/null +++ b/6.program/wms-common/src/main/java/com/mt/wms/common/service/AttachmentService.java @@ -0,0 +1,56 @@ +package com.mt.wms.common.service; + +import com.mt.wms.common.params.DownloadFileParam; +import com.mt.wms.common.params.UploadFileBase64Param; +import com.mt.wms.common.vo.SysFileVo; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.R; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +/** + * @author jiff + * @date 2021/01/12 + * @since 1.0 + */ +public interface AttachmentService { + + + /** + * 文件上传(支持多文件上传) + * + * @param typeCode + * @return + */ + R> uploadFile(String typeCode); + + /** + * 文件上传 + * + * @param uploadFileBase64Param 上传文件对象 + * @return + */ + R uploadFileBase64(UploadFileBase64Param uploadFileBase64Param); + + /** + * 文件上传(form表单形式) + * + * @param typeCode + * @param files + * @return + */ + R> uploadFileFormData(String typeCode, MultipartFile[] files); + + /** + * 文件下载(下载方式: 0、预览,1、下载) + * + * @param downloadFileParam + * @return + */ + R downloadFile(DownloadFileParam downloadFileParam); + + + + +} diff --git a/6.program/wms-common/src/main/java/com/mt/wms/common/service/CommonService.java b/6.program/wms-common/src/main/java/com/mt/wms/common/service/CommonService.java new file mode 100644 index 0000000..627e313 --- /dev/null +++ b/6.program/wms-common/src/main/java/com/mt/wms/common/service/CommonService.java @@ -0,0 +1,38 @@ +package com.mt.wms.common.service; + +import com.mt.wms.common.vo.SysFileVo; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.R; + +import javax.servlet.http.HttpServletResponse; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/7/6 + * @since 1.0 + */ +public interface CommonService { + + + /** + * 获取附件下载地址 + * + * @param fileId 附件ID + * @return 附件下载地址 + */ + SysFileVo downloadFile(Long fileId); + + /** + * 附件预览 + * + * @param idParam 附件ID + * @return 附件下载地址 + */ + R downLoadFileUrl(IdParam idParam, HttpServletResponse response); + + +} diff --git a/6.program/wms-common/src/main/java/com/mt/wms/common/service/impl/AttachmentServiceImpl.java b/6.program/wms-common/src/main/java/com/mt/wms/common/service/impl/AttachmentServiceImpl.java new file mode 100644 index 0000000..7291a31 --- /dev/null +++ b/6.program/wms-common/src/main/java/com/mt/wms/common/service/impl/AttachmentServiceImpl.java @@ -0,0 +1,231 @@ +package com.mt.wms.common.service.impl; + +import com.mt.wms.common.params.DownloadFileParam; +import com.mt.wms.common.params.UploadFileBase64Param; +import com.mt.wms.common.service.AttachmentService; +import com.mt.wms.common.vo.SysFileVo; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.config.CommonConfig; +import com.mt.wms.core.dal.entity.SysFile; +import com.mt.wms.core.dal.service.SysFileServiceBiz; +import com.mt.wms.core.utils.*; +import com.mt.wms.core.vo.R; +import lombok.extern.log4j.Log4j2; +import net.coobird.thumbnailator.Thumbnails; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.multipart.commons.CommonsMultipartResolver; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.net.URL; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * @author jiff + * @date 2021/1/12 + * @since 1.0 + */ +@Log4j2 +@Service +public class AttachmentServiceImpl extends BaseService implements AttachmentService { + + @Autowired + private SysFileServiceBiz sysFileServiceBiz; + @Autowired + private CommonConfig commonConfig; + + /** + * 文件上传(支持多文件上传) + * + * @param typeCode + * @return + */ + @Override + public R> uploadFile(String typeCode) { + //获取上传文件路径 + String uploadPath = commonConfig.getUploadPath() + typeCode + "/"; + log.debug("文件的上传路径:" + uploadPath); + File file = new File(uploadPath); + //判断文件是否存在,不存在则创建 + if (!file.exists()) { + file.mkdirs(); + } + List fileList = new ArrayList<>(); + //多文件上传 + CommonsMultipartResolver crm = new CommonsMultipartResolver(getHttpServletRequest().getSession().getServletContext()); + if (crm.isMultipart(getHttpServletRequest())) { + MultipartHttpServletRequest mRequest = (MultipartHttpServletRequest) (getHttpServletRequest()); + Iterator files = mRequest.getFileNames(); + log.debug("多文件" + files.toString()); + while (files.hasNext()) { + MultipartFile mFile = mRequest.getFile(files.next()); + log.debug("文件" + mFile.toString()); + // 文件名 + String fileName = mFile.getOriginalFilename(); + //新文件名 + String newFileName = DateUtil.getCurrentDateTime() + RandomCodeGenerator.numericCode(4); + // 文件扩展名 + String fileExtensionName = FileUtil.getExtensionName(fileName); + //上传文件的真实路径 + String filePath = uploadPath + newFileName + "." + fileExtensionName; + File localPath = new File(filePath); + try { + mFile.transferTo(localPath); + //保存文件信息 + SysFile sysFile = new SysFile(); + sysFile.setTypeCode(typeCode); + sysFile.setFileUrl(filePath); + sysFile.setFileName(newFileName); + if (getLoginUser() != null) { + setCommonField(sysFile); + } else { + sysFile.setCreateTime(LocalDateTime.now()); + sysFile.setCreator(1L); + sysFile.setCreatorName("system"); + } + fileList.add(sysFile); + } catch (Exception e) { + e.printStackTrace(); + log.error("文件上传失败:" + e.getMessage()); + return R.failed("文件上传失败"); + } + } + } + sysFileServiceBiz.saveBatch(fileList); + return R.ok(BeanUtils.copyList(fileList, SysFileVo.class)); + } + + /** + * 文件上传 + * + * @param uploadFileBase64Param 上传文件对象 + * @return + */ + @Override + public R uploadFileBase64(UploadFileBase64Param uploadFileBase64Param) { + return null; + } + + /** + * 文件上传(form表单形式) + * + * @param typeCode + * @param files + * @return + */ + @Override + public R> uploadFileFormData(String typeCode, MultipartFile[] files) { + //获取上传文件路径 + String uploadPath = commonConfig.getUploadPath() + typeCode + "/"; + log.debug("文件的上传路径:" + uploadPath); + File file = new File(uploadPath); + //判断文件是否存在,不存在则创建 + if (!file.exists()) { + file.mkdirs(); + } + List fileList = new ArrayList<>(); + for (MultipartFile multipartFile : files) { + + log.debug("上传文件" + multipartFile.toString()); + // 文件名 + String fileName = multipartFile.getOriginalFilename(); + //新文件名 + String newFileName = DateUtil.getCurrentDateTime() + RandomCodeGenerator.numericCode(4); + // 文件扩展名 + String fileExtensionName = FileUtil.getExtensionName(fileName); + //上传文件的真实路径 + String filePath = uploadPath + newFileName + "." + fileExtensionName; + File localPath = new File(filePath); + try { + multipartFile.transferTo(localPath); + //保存文件信息 + SysFile sysFile = new SysFile(); + sysFile.setTypeCode(typeCode); + sysFile.setFileUrl(filePath); + sysFile.setFileName(newFileName); + if (getLoginUser() != null) { + setCommonField(sysFile); + } else { + sysFile.setCreateTime(LocalDateTime.now()); + sysFile.setCreator(1L); + sysFile.setCreatorName("system"); + } + fileList.add(sysFile); + } catch (Exception e) { + e.printStackTrace(); + log.error("文件上传失败:" + e.getMessage()); + return R.failed("文件上传失败"); + } + } + + sysFileServiceBiz.saveBatch(fileList); + return R.ok(BeanUtils.copyList(fileList, SysFileVo.class)); + } + + /** + * 文件下载(下载方式: 0、预览,1、下载) + * + * @param downloadFileParam + * @return + */ + @Override + public R downloadFile(DownloadFileParam downloadFileParam) { + //根据id获取附件信息 + SysFile sysFile = sysFileServiceBiz.getById(downloadFileParam.getAttachmentId()); + if (sysFile == null) { + return R.failed("文件不存在"); + } + HttpServletResponse response = getHttpServletResponse(); + // 文件路径 + String path = sysFile.getFileUrl(); + File file = new File(path); + String fileName = file.getName(); + // 文件扩展名 + String suffix = fileName.substring(fileName.lastIndexOf(".") + 1); + try { + //判断下载方式是下载本地还是预览文件 + if (downloadFileParam.getType().equals("1")) { + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment; filename=" + new String((StringUtils.isEmpty(downloadFileParam.getFileName()) ? sysFile.getFileName() + "." + suffix : downloadFileParam.getFileName() + "." + suffix).getBytes(Charset.forName("GBK")), StandardCharsets.ISO_8859_1)); + } else { + URL u = new URL("file:///" + path); + String contentType = u.openConnection().getContentType(); + response.setContentType(contentType); + response.setHeader("Content-Disposition", "inline; filename=" + new String((StringUtils.isEmpty(downloadFileParam.getFileName()) ? sysFile.getFileName() + "." + suffix : downloadFileParam.getFileName() + "." + suffix).getBytes(Charset.forName("GBK")), StandardCharsets.ISO_8859_1)); + } + //判断是否是图片格式 + ServletOutputStream outputStream = response.getOutputStream(); + if ("PNGpngJPGjpg".contains(suffix)) { + Thumbnails.of(file) + .scale(downloadFileParam.getScale()) + .outputQuality(downloadFileParam.getOutputQuality()) + .toOutputStream(outputStream); + } else { + FileInputStream inputStream = new FileInputStream(file); + byte[] buffer = new byte[1024]; + int i = -1; + while ((i = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, i); + } + inputStream.close(); + } + outputStream.flush(); + outputStream.close(); + } catch (Exception e) { + e.printStackTrace(); + log.error("下载文件失败:{}", e.getMessage()); + return R.failed("下载文件失败"); + } + return null; + } +} diff --git a/6.program/wms-common/src/main/java/com/mt/wms/common/service/impl/CommonServiceImpl.java b/6.program/wms-common/src/main/java/com/mt/wms/common/service/impl/CommonServiceImpl.java new file mode 100644 index 0000000..c9b5883 --- /dev/null +++ b/6.program/wms-common/src/main/java/com/mt/wms/common/service/impl/CommonServiceImpl.java @@ -0,0 +1,101 @@ +package com.mt.wms.common.service.impl; + +import com.mt.wms.common.mapper.CommonMapper; +import com.mt.wms.common.service.CommonService; +import com.mt.wms.common.vo.SysFileVo; +import com.mt.wms.core.config.AliyunSmsConfig; +import com.mt.wms.core.config.CommonConfig; +import com.mt.wms.core.config.TencentCloudConfig; +import com.mt.wms.core.config.TencentCloudSmsConfig; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.vo.R; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URL; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/7/6 + * @since 1.0 + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class CommonServiceImpl extends BaseService implements CommonService { + + private final CommonMapper mCommonMapper; + + private final CommonConfig mCommonConfig; + + private final AliyunSmsConfig mAliyunSmsConfig; + + private final TencentCloudSmsConfig tencentCloudSmsConfig; + + private final TencentCloudConfig tencentCloudConfig; + + private final CommonConfig commonConfig; + + + + /** + * 获取附件下载地址 + * + * @param fileId 附件ID + * @return 附件下载地址 + */ + @Override + public SysFileVo downloadFile(Long fileId) { + + return new SysFileVo().setFileId(null).setFileName(null).setFileUrl(mCommonConfig.getApiHost() + "/common/" + "/home".replace(mCommonConfig.getUploadPath(), "")); + } + + + @Override + public R downLoadFileUrl(IdParam idParam, HttpServletResponse response) { + + // 文件扩展名 + String path = null; + File picFile = new File(path); + String fileName = picFile.getName(); + try { + // 文件扩展名 + String suffix = fileName.substring(fileName.lastIndexOf(".") + 1); + URL u = new URL("file:///" + path); + String contentType = null; + + contentType = u.openConnection().getContentType(); + + response.setContentType(contentType); + response.setHeader("Content-Disposition", "inline;filename=" + new String(("dw." + suffix).getBytes("GBK"), "ISO8859_1")); + ServletOutputStream outputStream = response.getOutputStream(); + FileInputStream inputStream = new FileInputStream(picFile); + byte[] buffer = new byte[1024]; + int i = -1; + while ((i = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, i); + } + outputStream.flush(); + outputStream.close(); + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + e.printStackTrace(); + log.error("文件预览失败:" + e.getMessage()); + return R.failed("文件预览失败"); + } + return null; + } + +} diff --git a/6.program/wms-common/src/main/java/com/mt/wms/common/vo/SysFileVo.java b/6.program/wms-common/src/main/java/com/mt/wms/common/vo/SysFileVo.java new file mode 100644 index 0000000..64fd461 --- /dev/null +++ b/6.program/wms-common/src/main/java/com/mt/wms/common/vo/SysFileVo.java @@ -0,0 +1,35 @@ +package com.mt.wms.common.vo; + +import com.mt.wms.core.base.BaseVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/7/8 + * @since 1.0 + */ +@ApiModel("文件对象") +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@Data +public class SysFileVo extends BaseVo { + @ApiModelProperty("文件ID") + private Long fileId; + + @ApiModelProperty("文件名称") + private String fileName; + + @ApiModelProperty("类型 1图片 2PDF") + private Integer fileType; + + @ApiModelProperty("下载路径") + private String fileUrl; +} diff --git a/6.program/wms-common/src/main/resources/mapper/CommonMapper.xml b/6.program/wms-common/src/main/resources/mapper/CommonMapper.xml new file mode 100644 index 0000000..e0b454e --- /dev/null +++ b/6.program/wms-common/src/main/resources/mapper/CommonMapper.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/6.program/wms-core/pom.xml b/6.program/wms-core/pom.xml new file mode 100644 index 0000000..2a2f577 --- /dev/null +++ b/6.program/wms-core/pom.xml @@ -0,0 +1,219 @@ + + + + wms + com.mt + 1.0 + + 4.0.0 + + wms-core + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.boot + spring-boot-starter-data-redis + + + org.springframework.session + spring-session-data-redis + + + javax.servlet + javax.servlet-api + + + com.squareup.okhttp3 + okhttp + ${okhttp3.version} + + + + mysql + mysql-connector-java + + + + com.baomidou + mybatis-plus-boot-starter + + + com.baomidou + mybatis-plus-generator + + + org.apache.velocity + velocity-engine-core + + + p6spy + p6spy + + + + org.projectlombok + lombok + + + + + com.alibaba + fastjson + + + + org.apache.commons + commons-lang3 + + + + commons-io + commons-io + + + + commons-fileupload + commons-fileupload + + + + + com.itextpdf + itextpdf + 5.5.13 + + + + com.itextpdf + itext-asian + 5.2.0 + + + + org.apache.pdfbox + pdfbox + ${pdfbox.version} + + + + org.apache.pdfbox + pdfbox-tools + ${pdfbox.version} + + + + net.sf.barcode4j + barcode4j-light + ${barcode4j.version} + + + + io.springfox + springfox-swagger2 + compile + + + + dom4j + dom4j + + + + cn.hutool + hutool-all + ${hutool.version} + + + + com.github.binarywang + weixin-java-mp + ${binarywang-weixin.version} + + + com.github.binarywang + weixin-java-pay + ${binarywang-weixin.version} + + + com.github.binarywang + weixin-java-miniapp + ${binarywang-weixin.version} + + + + org.junit.jupiter + junit-jupiter-api + + + junit + junit + test + + + + + cn.afterturn + easypoi-base + ${cn.afterturn.version} + + + org.apache.poi + poi-ooxml + + + org.apache.poi + poi + + + org.apache.poi + poi-ooxml-schemas + + + + + org.apache.poi + poi + + + org.apache.poi + poi-ooxml + + + org.apache.poi + poi-ooxml-schemas + ${cn.afterturn.version} + + + xerces + xercesImpl + + + + + + + + + org.redisson + redisson + ${redisson.version} + + + org.hibernate.validator + hibernate-validator + + + + com.tencentcloudapi + tencentcloud-sdk-java + ${tencentcloud-sdk-java.version} + + + + \ No newline at end of file diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/EnableMesCore.java b/6.program/wms-core/src/main/java/com/mt/wms/core/EnableMesCore.java new file mode 100644 index 0000000..5adf4bc --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/EnableMesCore.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core; + +import com.mt.wms.core.config.AutoConfiguration; +import org.springframework.context.annotation.Import; + +import java.lang.annotation.*; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Import(AutoConfiguration.class) +@Documented +@Inherited +public @interface EnableMesCore { +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/MyGenerator.java b/6.program/wms-core/src/main/java/com/mt/wms/core/MyGenerator.java new file mode 100644 index 0000000..d591e77 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/MyGenerator.java @@ -0,0 +1,154 @@ +package com.mt.wms.core; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.generator.AutoGenerator; +import com.baomidou.mybatisplus.generator.config.*; +import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder; +import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; +import com.mt.wms.core.utils.StringUtils; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * Created by FanYi on 2018-08-27 16:38. + **/ +public class MyGenerator { + /** + * 数据库地址 + */ + static String dbUrl = "jdbc:mysql://mysql.picaiba.com:30306/wms"; + static String userName = "wms"; + static String password = "1qaz@WS"; + /** + * 是否去掉生成实体的属性名前缀 + */ + static String[] fieldPrefix = new String[]{"t_"}; + + /** + * 代码生成器 + * + * @param include 需要包含的表名,允许正则表达式 + */ + private static void generateByTablesWithInjectConfig(String[] include) { + File file = new File(""); + String path = file.getAbsolutePath(); + // 全局配置 + GlobalConfig config = new GlobalConfig(); + // 开启 activeRecord 模式 + config.setActiveRecord(true) + //生成目录 + .setOutputDir(path + "/src/main/java") + //生成人 + .setAuthor("mt") + // 是否覆盖文件 + .setFileOverride(true) + // XML ResultMap + .setBaseResultMap(true) + // XML columList + .setBaseColumnList(true) + .setOpen(false) + // 自定义文件命名,注意 %s 会自动填充表实体属性! + .setMapperName("%sMapper") + .setXmlName("%sMapper") + .setServiceName("%sServiceBiz") + .setServiceImplName("%sServiceBizImpl"); + + // 数据源配置 + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setDbType(DbType.MYSQL) + .setUrl(dbUrl) + .setUsername(userName) + .setPassword(password) + .setDriverName("com.mysql.jdbc.Driver"); + // 策略配置 + StrategyConfig strategyConfig = new StrategyConfig(); + strategyConfig.setVersionFieldName("version") + .setLogicDeleteFieldName("valid") + .setCapitalMode(true) + .setChainModel(true) + .setEntityColumnConstant(true) + .setEnableSqlFilter(false) + .setNaming(NamingStrategy.underline_to_camel) + .setEntityLombokModel(true) + .setTablePrefix(fieldPrefix) + .setEntityTableFieldAnnotationEnable(true) + //修改替换成你需要的表名,多个表名传数组 + .setInclude(include); + // 包配置 + PackageConfig packageConfig = new PackageConfig(); + packageConfig.setParent("com.mt.wms.core.dal") + .setEntity("entity") + .setMapper("mapper") + .setService("service") + .setServiceImpl("service.impl") + .setXml("mapper"); + + //模板配置 + TemplateConfig templateConfig = new TemplateConfig(); + templateConfig.setController(null); + + // 代码生成器 +// AutoGenerator generator = new AutoGenerator(); + MybatisPlusGenerator generator = new MybatisPlusGenerator(); + generator.setExcludeTables("t_service"); + generator.setGlobalConfig(config) + .setDataSource(dataSourceConfig) + .setStrategy(strategyConfig) + .setPackageInfo(packageConfig) + .setTemplate(templateConfig) + .execute(); + } + + @Test + public void generateCodeWithInjectConfigForAllTable() { + generateByTablesWithInjectConfig(new String[]{"t_[a-zA-Z0-9_]*"}); + } + + public static void main(String[] args) { + generateByTablesWithInjectConfig(new String[]{"t_goods[a-zA-Z0-9_]*"}); + } + + + /** + * + */ + public static class MybatisPlusGenerator extends AutoGenerator { + + /** + * 需要排除的表名,允许正则表达式 + */ + private String[] excludeTables = null; + + @Override + protected ConfigBuilder pretreatmentConfigBuilder(ConfigBuilder config) { + super.pretreatmentConfigBuilder(config); + if (excludeTables != null && excludeTables.length > 0) { + List excludeTableList = Arrays.stream(excludeTables).filter(StringUtils::isNotEmpty).collect(Collectors.toList()); + config.setTableInfoList(config.getTableInfoList().stream() + .filter(tableInfo -> { + boolean excludeFlag = false; + String tableName = tableInfo.getName(); + for (String excludeTableName : excludeTableList) { + if (excludeTableName.equalsIgnoreCase(tableName) || Pattern.matches(excludeTableName, tableName)) { + excludeFlag = true; + break; + } + } + return !excludeFlag; + }).collect(Collectors.toList())); + } + return config; + } + + public AutoGenerator setExcludeTables(String... excludeTables) { + this.excludeTables = excludeTables; + return this; + } + + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/api/Assert.java b/6.program/wms-core/src/main/java/com/mt/wms/core/api/Assert.java new file mode 100644 index 0000000..1935c1e --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/api/Assert.java @@ -0,0 +1,418 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.api; + +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.mt.wms.core.base.IErrorCode; +import com.mt.wms.core.exception.ApiException; + +import java.util.Collection; +import java.util.Map; + +/** + * 接口参数断言工具类 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public class Assert { + + protected Assert() { + // to do noting + } + + /** + * 断言参数等于0,否则抛出错误消息 + * + * @param num 断言参数 + * @param errorCode 错误消息 + */ + public static void eqZero(Integer num, IErrorCode errorCode) { + if (num == null || num != 0) { + Assert.fail(errorCode); + } + } + + /** + * 断言参数等于0,否则抛出错误消息 + * + * @param num 断言参数 + * @param message 错误消息 + */ + public static void eqZero(Integer num, String message) { + if (num == null || num != 0) { + Assert.fail(message); + } + } + + /** + * 断言参数小于0,否则抛出错误消息 + * + * @param num 断言参数 + * @param errorCode 错误消息 + */ + public static void ltZero(Integer num, IErrorCode errorCode) { + if (num == null || num >= 0) { + Assert.fail(errorCode); + } + } + + /** + * 断言参数小于0,否则抛出错误消息 + * + * @param num 断言参数 + * @param message 错误消息 + */ + public static void ltZero(Integer num, String message) { + if (num == null || num >= 0) { + Assert.fail(message); + } + } + + /** + * 断言小于等于0,否则抛出错误消息 + * + * @param num 断言参数 + * @param errorCode 错误消息 + */ + public static void leZero(Integer num, IErrorCode errorCode) { + if (num == null || num > 0) { + Assert.fail(errorCode); + } + } + + /** + * 断言小于等于0,否则抛出错误消息 + * + * @param num 断言参数 + * @param message 错误消息 + */ + public static void leZero(Integer num, String message) { + if (num == null || num > 0) { + Assert.fail(message); + } + } + + /** + * 断言参数大于0,否则抛出错误消息 + * + * @param num 断言参数 + * @param errorCode 错误消息 + */ + public static void gtZero(Integer num, IErrorCode errorCode) { + if (num == null || num <= 0) { + Assert.fail(errorCode); + } + } + + /** + * 断言参数大于0,否则抛出错误消息 + * + * @param num 断言参数 + * @param message 错误消息 + */ + public static void gtZero(Integer num, String message) { + if (num == null || num <= 0) { + Assert.fail(message); + } + } + + /** + * 断言大于等于0,否则抛出错误消息 + * + * @param num 断言参数 + * @param errorCode 错误消息 + */ + public static void geZero(Integer num, IErrorCode errorCode) { + if (num == null || num < 0) { + Assert.fail(errorCode); + } + } + + /** + * 断言大于等于0,否则抛出错误消息 + * + * @param num 断言参数 + * @param message 错误消息 + */ + public static void geZero(Integer num, String message) { + if (num == null || num < 0) { + Assert.fail(message); + } + } + + /** + * 断言num1大于num2,否则抛出错误消息 + * + * @param num1 断言参数1 + * @param num2 断言参数2 + * @param errorCode 错误消息 + */ + public static void gt(Integer num1, Integer num2, IErrorCode errorCode) { + if (num1 <= num2) { + Assert.fail(errorCode); + } + } + + /** + * 断言num1大于num2,否则抛出错误消息 + * + * @param num1 断言参数1 + * @param num2 断言参数2 + * @param message 错误消息 + */ + public static void gt(Integer num1, Integer num2, String message) { + if (num1 <= num2) { + Assert.fail(message); + } + } + + /** + * 断言num1大于等于num2,否则抛出错误消息 + * + * @param num1 断言参数1 + * @param num2 断言参数2 + * @param errorCode 错误消息 + */ + public static void ge(Integer num1, Integer num2, IErrorCode errorCode) { + if (num1 < num2) { + Assert.fail(errorCode); + } + } + + /** + * 断言num1大于等于num2,否则抛出错误消息 + * + * @param num1 断言参数1 + * @param num2 断言参数2 + * @param message 错误消息 + */ + public static void ge(Integer num1, Integer num2, String message) { + if (num1 < num2) { + Assert.fail(message); + } + } + + /** + * 断言obj1 eq obj2,否则抛出错误消息 + * + * @param obj1 断言参数1 + * @param obj2 断言参数2 + * @param errorCode 错误消息 + */ + public static void eq(Object obj1, Object obj2, IErrorCode errorCode) { + if (!obj1.equals(obj2)) { + Assert.fail(errorCode); + } + } + + /** + * 断言obj1 eq obj2,否则抛出错误消息(错误码统一为{@link IErrorCode#CODE_FAILED}) + * + * @param obj1 断言参数1 + * @param obj2 断言参数2 + * @param message 错误消息 + */ + public static void eq(Object obj1, Object obj2, String message) { + if (!obj1.equals(obj2)) { + Assert.fail(message); + } + } + + /** + * 断言参数为true,否则抛出错误消息 + * + * @param condition 断言参数 + * @param errorCode 错误消息 + */ + public static void isTrue(boolean condition, IErrorCode errorCode) { + if (!condition) { + Assert.fail(errorCode); + } + } + + /** + * 断言参数为false,否则抛出错误消息 + * + * @param condition 断言参数 + * @param errorCode 错误消息 + */ + public static void isFalse(boolean condition, IErrorCode errorCode) { + if (condition) { + Assert.fail(errorCode); + } + } + + /** + * 断言给定的参数都为null,否则抛出错误消息 + * + * @param errorCode 错误消息 + * @param conditions 断言参数 + */ + public static void isNull(IErrorCode errorCode, Object... conditions) { + if (ObjectUtils.isNotNull(conditions)) { + Assert.fail(errorCode); + } + } + + /** + * 断言给定的参数都不为null,否则抛出错误消息 + * + * @param errorCode 错误消息 + * @param conditions 断言参数 + */ + public static void notNull(IErrorCode errorCode, Object... conditions) { + if (ObjectUtils.isNull(conditions)) { + Assert.fail(errorCode); + } + } + + /** + * 断言给定的参数都为null,否则抛出错误消息(错误码统一为{@link IErrorCode#CODE_FAILED}) + * + * @param message 错误消息 + * @param conditions 断言参数 + */ + public static void isNull(String message, Object... conditions) { + if (ObjectUtils.isNotNull(conditions)) { + Assert.fail(message); + } + } + + /** + * 断言给定的参数都不为null,否则抛出错误消息(错误码统一为{@link IErrorCode#CODE_FAILED}) + * + * @param message 错误消息 + * @param conditions 断言参数 + */ + public static void notNull(String message, Object... conditions) { + if (ObjectUtils.isNull(conditions)) { + Assert.fail(message); + } + } + + /** + *

+ * 抛出失败消息 + *

+ * + * @param errorCode 异常错误码 + */ + public static void fail(IErrorCode errorCode) { + throw new ApiException(errorCode); + } + + /** + * 根据断言条件判断是否抛出错误消息 + * + * @param condition 断言条件,true则抛出错误消息,否则正常执行 + * @param errorCode 错误消息 + */ + public static void fail(boolean condition, IErrorCode errorCode) { + if (condition) { + Assert.fail(errorCode); + } + } + + /** + *

+ * 抛出失败消息 + *

+ * + * @param message 错误消息 + */ + public static void fail(String message) { + throw new ApiException(message); + } + + /** + * 根据断言条件判断是否抛出错误消息 + * + * @param condition 断言条件,true则抛出错误消息,否则正常执行 + * @param message 错误消息 + */ + public static void fail(boolean condition, String message) { + if (condition) { + Assert.fail(message); + } + } + + /** + * 断言参数不为空,否则抛出错误消息 + * + * @param array 断言参数 + * @param errorCode 错误消息 + */ + public static void notEmpty(Object[] array, IErrorCode errorCode) { + if (ObjectUtils.isEmpty(array)) { + Assert.fail(errorCode); + } + } + + /** + * 断言数组中的对象没有null元素,否则抛出错误消息 + * + * @param array 断言参数 + * @param errorCode 错误消息 + */ + public static void noNullElements(Object[] array, IErrorCode errorCode) { + if (array != null) { + for (Object element : array) { + if (element == null) { + Assert.fail(errorCode); + } + } + } + } + + /** + * 断言参数不为空,否则抛出错误消息 + * + * @param collection 断言参数 + * @param errorCode 错误消息 + */ + public static void notEmpty(Collection collection, IErrorCode errorCode) { + if (CollectionUtils.isNotEmpty(collection)) { + Assert.fail(errorCode); + } + } + + /** + * 断言参数不为空,否则抛出错误消息 + * + * @param map 断言参数 + * @param errorCode 错误消息 + */ + public static void notEmpty(Map map, IErrorCode errorCode) { + if (ObjectUtils.isEmpty(map)) { + Assert.fail(errorCode); + } + } + + /** + * 断言对象是给定类型的实例,否则抛出错误消息 + * + * @param type 断言类型 + * @param obj 断言对象 + * @param errorCode 错误消息 + */ + public static void isInstanceOf(Class type, Object obj, IErrorCode errorCode) { + Assert.notNull(errorCode, type); + if (!type.isInstance(obj)) { + Assert.fail(errorCode); + } + } + + public static void isAssignable(Class superType, Class subType, IErrorCode errorCode) { + Assert.notNull(errorCode, superType); + if (subType == null || !superType.isAssignableFrom(subType)) { + Assert.fail(errorCode); + } + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseController.java b/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseController.java new file mode 100644 index 0000000..30c5a81 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseController.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.base; + +import org.springframework.web.bind.annotation.RestController; + +/** + * 控制器基类 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@RestController +public abstract class BaseController extends BaseSupport { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseDto.java b/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseDto.java new file mode 100644 index 0000000..551a52c --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseDto.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.base; + +import java.io.Serializable; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public class BaseDto implements Serializable { +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseParam.java b/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseParam.java new file mode 100644 index 0000000..534fa4f --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseParam.java @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.base; + +import java.io.Serializable; + +/** + * 接口请求参数基类 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public class BaseParam implements Serializable { +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseService.java b/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseService.java new file mode 100644 index 0000000..5bb18e2 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseService.java @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.base; + + +/** + * 服务基类 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public abstract class BaseService extends BaseSupport { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseSupport.java b/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseSupport.java new file mode 100644 index 0000000..6b6c359 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseSupport.java @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.base; + +import com.alibaba.fastjson.JSON; +import com.mt.wms.core.enums.WhetherEnum; +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.vo.R; +import lombok.Builder; +import lombok.Data; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.core.NamedThreadLocal; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 接口支持基类 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public abstract class BaseSupport { + private static final ThreadLocal loginUserHolder = new NamedThreadLocal<>("LoginUser"); + + /** + * 获取当前登录用户信息 + * + * @return + */ + protected LoginUser getLoginUser() { + // 后续完善拦截器再使用该方式 +// LoginUser loginUser = loginUserHolder.get(); +// if (loginUser != null) { +// return loginUser; +// } + HttpSession session = getHttpServletRequest().getSession(false); + LoginUser loginUser = null; + if (session != null) { + String loginUserJson = (String) session.getAttribute(LoginUser.HTTP_HEADER_NAME); + if (StringUtils.isNotBlank(loginUserJson)) { + loginUser = JSON.parseObject(loginUserJson, LoginUser.class); + return loginUser; + } + } + return null; + } + + /** + * 获取当前http请求对象 + * + * @return + */ + protected HttpServletRequest getHttpServletRequest() { + return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + } + + /** + * 获取当前http响应对象 + * + * @return + */ + protected HttpServletResponse getHttpServletResponse() { + return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse(); + } + + /** + *

+ * 请求成功 + *

+ * + * @param data 数据内容 + * @param 对象泛型 + * @return + */ + protected R successful(T data) { + return R.ok(data); + } + + /** + *

+ * 请求成功 + *

+ * + * @param msg 提示内容 + * @param data 数据内容 + * @param 对象泛型 + * @return + */ + protected R successful(String msg, T data) { + return R.ok(msg, data); + } + + /** + *

+ * 请求失败 + *

+ * + * @param code 错误码 + * @param msg 提示内容 + * @param 对象泛型 + * @return + */ + protected R failed(int code, String msg) { + return R.failed(code, msg); + } + + /** + *

+ * 请求失败 + *

+ * + * @param msg 提示内容 + * @param 对象泛型 + * @return + */ + protected R failed(String msg) { + return R.failed(msg); + } + + /** + *

+ * 请求失败 + *

+ * + * @param errorCode 请求错误码 + * @param 对象泛型 + * @return + */ + protected R failed(IErrorCode errorCode) { + return R.failed(errorCode); + } + + protected R addResult(boolean status) { + return status ? successful("添加成功", null) : failed("添加失败"); + } + + protected R editResult(boolean status) { + return status ? successful("修改成功", null) : failed("修改失败"); + } + + protected R delResult(boolean status) { + return status ? successful("删除成功", null) : failed("删除失败"); + } + + protected R enabledResult(boolean status) { + return status ? successful("已启用", null) : failed("已禁用"); + } + + /** + * 设置公共字段值,一般用于创建新记录,包含以下字段: + * + *

+ * {@link CommonField#enabled}
+ * {@link CommonField#valid}
+ * {@link CommonField#creator}
+ * {@link CommonField#creatorName}
+ * {@link CommonField#createTime}
+ * {@link CommonField#updater}
+ * {@link CommonField#updaterName}
+ * {@link CommonField#updateTime}
+ *

+ * + * @param t 需要设置的对象 + * @param ignoreProperties 忽略的字段 + * @param + */ + protected T setCommonField(T t, String... ignoreProperties) { + CommonField commonField = CommonField.builder() + .enabled(WhetherEnum.YES.getValue()) + .valid(WhetherEnum.YES.getValue()) + .createTime(LocalDateTime.now()) + .creator(getLoginUser().getUserId()) + .creatorName(getLoginUser().getUserName()) + .updateTime(LocalDateTime.now()) + .updater(getLoginUser().getUserId()) + .updaterName(getLoginUser().getUserName()) + .build(); + BeanUtils.copyProperties(commonField, t, ignoreProperties); + return t; + } + + /** + * 设置更新的公共字段值,一般用于更新记录,包含以下字段: + * + *

+ * {@link CommonField#updater}
+ * {@link CommonField#updaterName}
+ * {@link CommonField#updateTime}
+ *

+ * + * @param t 需要设置的对象 + * @param + */ + protected T setUpdateCommonField(T t) { + CommonField commonField = CommonField.builder() + .updater(getLoginUser().getUserId()) + .updaterName(getLoginUser().getUserName()) + .updateTime(LocalDateTime.now()) + .build(); + BeanUtils.copyProperties(commonField, t, "enabled", "valid"); + return t; + } + + @Data + @Builder + private static class CommonField implements Serializable { + /** + * 启用状态:0 、停用,1、启用 + */ + private Integer enabled; + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + private Integer valid; + + + /** + * 创建人 + */ + private Long creator; + /** + * 创建人 + */ + private String creatorName; + /** + * 创建时间 + */ + private LocalDateTime createTime; + + + /** + * 更新人 + */ + private Long updater; + /** + * 更新人 + */ + private String updaterName; + /** + * 更新时间 + */ + private LocalDateTime updateTime; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseVo.java new file mode 100644 index 0000000..d437b34 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/base/BaseVo.java @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.base; + +import java.io.Serializable; + +/** + * 视图对象基类 + * + * @author jiff + * @date 2018/11/7 + * @since 1.0 + */ +public class BaseVo implements Serializable { +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/base/IEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/base/IEnum.java new file mode 100644 index 0000000..b108afb --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/base/IEnum.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.base; + +import java.io.Serializable; + +/** + * 枚举接口 + * + * @param + * @author jiff + * @date 2018/11/7 + * @since 1.0 + */ +public interface IEnum { + + /** + * 数据值 + * + * @return 数据值 + */ + T getValue(); + + /** + * 标签名 + * + * @return 标签名 + */ + String getLabel(); + + /** + * 备注,对数据值进行详细说明 + * + * @return 备注 + */ + String getRemark(); + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/base/IErrorCode.java b/6.program/wms-core/src/main/java/com/mt/wms/core/base/IErrorCode.java new file mode 100644 index 0000000..4cd3701 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/base/IErrorCode.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.base; + + +/** + * api错误码定义 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public interface IErrorCode { + /** + * 成功 + */ + int CODE_SUCCESSFUL = 0; + /** + * 失败 + */ + int CODE_FAILED = 1; + /** + * 无效的请求参数 + */ + int CODE_INVALID_PARAMETER = 2; + /** + * 数据未授权 + */ + int CODE_FORBIDDEN_DATA = 9; + /** + * 用户已存在 + */ + int CODE_USER_EXISTENT = 10; + /** + * 用户不存在 + */ + int CODE_USER_NON_EXISTENT = 11; + /** + * 用户未登录 + */ + int CODE_UNAUTHORIZED = 401; + /** + * 用户未授权 + */ + int CODE_FORBIDDEN = 403; + + /** + * 错误编码:0、成功 否则失败 + * + * @return 错误码:0、成功 否则失败 + */ + int getCode(); + + /** + * 错误描述 + * + * @return 错误描述 + */ + String getMsg(); +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/base/ITree.java b/6.program/wms-core/src/main/java/com/mt/wms/core/base/ITree.java new file mode 100644 index 0000000..02e3fa2 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/base/ITree.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.base; + +import java.util.List; + +/** + * 树接口 + * + * @param 泛型参数 + * @author jiff + * @date 2018/11/27 + * @since 1.0 + */ +public interface ITree { + + /** + * 主键 + * + * @return ID + */ + Long getId(); + + /** + * 父ID + * + * @return 父ID + */ + Long getParentId(); + + /** + * 获取子列表 + * + * @return 子列表 + */ + List getChildren(); + + /** + * 设置子列表 + * + * @param children 子列表 + * @return 当前对象 + */ + T setChildren(List children); + + /** + * 设置选中状态 + * + * @param checked 选中状态,true:选中,否则未选中 + * @return 当前对象 + */ + default T setChecked(boolean checked) { + return (T) this; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/config/AliyunSmsConfig.java b/6.program/wms-core/src/main/java/com/mt/wms/core/config/AliyunSmsConfig.java new file mode 100644 index 0000000..f63ff6c --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/config/AliyunSmsConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotEmpty; + +/** + * @author jiff + * @date 2020-03-10 + * @since 1.0 + */ +@Component +@ConfigurationProperties(prefix = "wms.aliyun.sms") +@Data +@Validated +public class AliyunSmsConfig { + /** + * 开发者标识 + */ + @NotEmpty + private String product; + + @NotEmpty + private String domain; + /** + * 访问密钥ID + */ + @NotEmpty + private String accessKeyId; + /** + * 访问密钥 + */ + @NotEmpty + private String accessKeySecret; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/config/AutoConfiguration.java b/6.program/wms-core/src/main/java/com/mt/wms/core/config/AutoConfiguration.java new file mode 100644 index 0000000..9537938 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/config/AutoConfiguration.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.config; + +import com.mt.wms.core.runner.MesApplicationRunner; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@Configuration +@ComponentScan({"com.mt.wms.core.config", "com.mt.wms.core.handler", "com.mt.wms.core.dal.service", "com.mt.wms.core.service", "com.mt.wms.core.utils"}) +public class AutoConfiguration { + /** + * springboot启动之后会调用{@link MesApplicationRunner#run(ApplicationArguments)}方法 + * + * @param applicationContext + * @return + */ + @Bean + public ApplicationRunner lisApplicationRunner(ApplicationContext applicationContext) { + return new MesApplicationRunner(applicationContext); + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/config/CommonConfig.java b/6.program/wms-core/src/main/java/com/mt/wms/core/config/CommonConfig.java new file mode 100644 index 0000000..ca11003 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/config/CommonConfig.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotEmpty; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/7/6 + * @since 1.0 + */ +@Component +@ConfigurationProperties(prefix = "wms.common") +@Data +@Validated +public class CommonConfig { + + /** + * 文件上传路径 + */ + @NotEmpty + private String uploadPath; + + /** + * 前端主机地址 + */ + @NotEmpty + private String webHost; + /** + * 后端主机地址 + */ + @NotEmpty + private String apiHost; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/config/JacksonConfig.java b/6.program/wms-core/src/main/java/com/mt/wms/core/config/JacksonConfig.java new file mode 100644 index 0000000..7d93e91 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/config/JacksonConfig.java @@ -0,0 +1,68 @@ +package com.mt.wms.core.config; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; + +import java.io.IOException; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; + +/** + * @author shihairong + * @email + * @description 针对Long型ID序列化超过16位后导致前端js处理丢失精度,改成序列化成String + * @date 2020/12/31 11:37 + */ +@Configuration +@ConditionalOnClass(ObjectMapper.class) +@AutoConfigureBefore(JacksonAutoConfiguration.class) +public class JacksonConfig { + + @Bean + @Primary + @ConditionalOnMissingBean(ObjectMapper.class) + public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { + ObjectMapper objectMapper = builder.createXmlMapper(false).build(); + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addDeserializer(LocalDateTime.class, new MesLocalDateTimeDeserializer()); + simpleModule.addSerializer(Long.class, ToStringSerializer.instance); + objectMapper.registerModule(simpleModule); + return objectMapper; + } + + class MesLocalDateTimeDeserializer extends JsonDeserializer { + + @Override + public LocalDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { + String text = jsonParser.getText(); + if (text == null || text.length() == 0) { + return null; + } + if (text.length() > 10 && text.charAt(10) == 'T') { + if (text.endsWith("Z")) { + return LocalDateTime.ofInstant(Instant.parse(text), ZoneId.systemDefault()); + } + } + + return LocalDateTime.parse(text, DateTimeFormatter.ISO_LOCAL_DATE_TIME); + } + + } + + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/config/MybatisPlusConfig.java b/6.program/wms-core/src/main/java/com/mt/wms/core/config/MybatisPlusConfig.java new file mode 100644 index 0000000..8c689ac --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/config/MybatisPlusConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.config; + +import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; +import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize; +import org.mybatis.spring.mapper.MapperScannerConfigurer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@Configuration +public class MybatisPlusConfig { + + @Bean + public PaginationInterceptor paginationInterceptor() { + PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); + // 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false + // paginationInterceptor.setOverflow(false); + // 设置最大单页限制数量,默认 500 条,-1 不受限制 + paginationInterceptor.setLimit(500); + // 开启 count 的 join 优化,只针对部分 left join + paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true)); + return paginationInterceptor; + } + + @Bean + public OptimisticLockerInterceptor optimisticLockerInterceptor() { + return new OptimisticLockerInterceptor(); + } + + @Bean + public MapperScannerConfigurer mapperScannerConfigurer() { + MapperScannerConfigurer scannerConfigurer = new MapperScannerConfigurer(); + scannerConfigurer.setBasePackage("com.mt.wms.**.mapper*"); + return scannerConfigurer; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/config/RedissonAutoConfiguration.java b/6.program/wms-core/src/main/java/com/mt/wms/core/config/RedissonAutoConfiguration.java new file mode 100644 index 0000000..d53bf27 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/config/RedissonAutoConfiguration.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.config; + +import org.redisson.Redisson; +import org.redisson.api.RedissonClient; +import org.redisson.config.Config; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; +import org.springframework.boot.autoconfigure.data.redis.RedisProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; +import org.springframework.data.redis.core.RedisOperations; +import org.springframework.util.ReflectionUtils; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * redis客户端,主要使用其分布式锁 + * + * @author jiff + * @date 2019-08-25 + * @since 1.0 + */ +@Configuration +@ConditionalOnClass({Redisson.class, RedisOperations.class}) +@AutoConfigureBefore(RedisAutoConfiguration.class) +@EnableConfigurationProperties({RedissonProperties.class, RedisProperties.class}) +public class RedissonAutoConfiguration { + + @Autowired + private RedissonProperties redissonProperties; + + @Autowired + private RedisProperties redisProperties; + + @Autowired + private ApplicationContext ctx; + + + @Bean(destroyMethod = "shutdown") + @ConditionalOnMissingBean(RedissonClient.class) + public RedissonClient redisson() throws IOException { + Config config = null; + Method clusterMethod = ReflectionUtils.findMethod(RedisProperties.class, "getCluster"); + Method timeoutMethod = ReflectionUtils.findMethod(RedisProperties.class, "getTimeout"); + Object timeoutValue = ReflectionUtils.invokeMethod(timeoutMethod, redisProperties); + int timeout; + if (null == timeoutValue) { + timeout = 0; + } else if (!(timeoutValue instanceof Integer)) { + Method millisMethod = ReflectionUtils.findMethod(timeoutValue.getClass(), "toMillis"); + timeout = ((Long) ReflectionUtils.invokeMethod(millisMethod, timeoutValue)).intValue(); + } else { + timeout = (Integer) timeoutValue; + } + + if (redissonProperties.getConfig() != null) { + try { + InputStream is = getConfigStream(); + config = Config.fromJSON(is); + } catch (IOException e) { + // trying next format + try { + InputStream is = getConfigStream(); + config = Config.fromYAML(is); + } catch (IOException e1) { + throw new IllegalArgumentException("Can't parse config", e1); + } + } + } else if (redisProperties.getSentinel() != null) { + Method nodesMethod = ReflectionUtils.findMethod(RedisProperties.Sentinel.class, "getNodes"); + Object nodesValue = ReflectionUtils.invokeMethod(nodesMethod, redisProperties.getSentinel()); + + String[] nodes; + if (nodesValue instanceof String) { + nodes = convert(Arrays.asList(((String) nodesValue).split(","))); + } else { + nodes = convert((List) nodesValue); + } + + config = new Config(); + config.useSentinelServers() + .setMasterName(redisProperties.getSentinel().getMaster()) + .addSentinelAddress(nodes) + .setDatabase(redisProperties.getDatabase()) + .setConnectTimeout(timeout) + .setPassword(redisProperties.getPassword()); + } else if (clusterMethod != null && ReflectionUtils.invokeMethod(clusterMethod, redisProperties) != null) { + Object clusterObject = ReflectionUtils.invokeMethod(clusterMethod, redisProperties); + Method nodesMethod = ReflectionUtils.findMethod(clusterObject.getClass(), "getNodes"); + List nodesObject = (List) ReflectionUtils.invokeMethod(nodesMethod, clusterObject); + + String[] nodes = convert(nodesObject); + + config = new Config(); + config.useClusterServers() + .addNodeAddress(nodes) + .setConnectTimeout(timeout) + .setPassword(redisProperties.getPassword()); + } else { + config = new Config(); + String prefix = "redis://"; + Method method = ReflectionUtils.findMethod(RedisProperties.class, "isSsl"); + if (method != null && (Boolean) ReflectionUtils.invokeMethod(method, redisProperties)) { + prefix = "rediss://"; + } + + config.useSingleServer() + .setAddress(prefix + redisProperties.getHost() + ":" + redisProperties.getPort()) + .setConnectTimeout(timeout) + .setDatabase(redisProperties.getDatabase()) + .setPassword(redisProperties.getPassword()); + } + + return Redisson.create(config); + } + + private String[] convert(List nodesObject) { + List nodes = new ArrayList(nodesObject.size()); + for (String node : nodesObject) { + if (!node.startsWith("redis://") && !node.startsWith("rediss://")) { + nodes.add("redis://" + node); + } else { + nodes.add(node); + } + } + return nodes.toArray(new String[nodes.size()]); + } + + private InputStream getConfigStream() throws IOException { + Resource resource = ctx.getResource(redissonProperties.getConfig()); + InputStream is = resource.getInputStream(); + return is; + } + + +} \ No newline at end of file diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/config/RedissonProperties.java b/6.program/wms-core/src/main/java/com/mt/wms/core/config/RedissonProperties.java new file mode 100644 index 0000000..ea16ecd --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/config/RedissonProperties.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * @author jiff + * @date 2019-08-25 + * @since 1.0 + */ +@ConfigurationProperties(prefix = "spring.redis.redisson") +public class RedissonProperties { + + private String config; + + public String getConfig() { + return config; + } + + public void setConfig(String config) { + this.config = config; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/config/TencentCloudConfig.java b/6.program/wms-core/src/main/java/com/mt/wms/core/config/TencentCloudConfig.java new file mode 100644 index 0000000..ec1f97f --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/config/TencentCloudConfig.java @@ -0,0 +1,31 @@ +package com.mt.wms.core.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; +import org.springframework.validation.annotation.Validated; + +/** + *

+ * 腾讯云公共配置 + *

+ * + * @author Mr.ZhangShi + * @version 1.0 + * @date 2020/8/10 + */ +@Component +@ConfigurationProperties(prefix = "wms.tencentcloud") +@Data +public class TencentCloudConfig { + + /** + * 账户id + */ + private String secretId; + + /** + * 账户密钥 + */ + private String secretKey; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/config/TencentCloudSmsConfig.java b/6.program/wms-core/src/main/java/com/mt/wms/core/config/TencentCloudSmsConfig.java new file mode 100644 index 0000000..fe35549 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/config/TencentCloudSmsConfig.java @@ -0,0 +1,31 @@ +package com.mt.wms.core.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; +import org.springframework.validation.annotation.Validated; + +/** + *

+ * 腾讯云短信配置 + *

+ * + * @author Mr.ZhangShi + * @version 1.0 + * @date 2020/8/10 + */ +@Component +@ConfigurationProperties(prefix = "wms.tencentcloud.sms") +@Data +public class TencentCloudSmsConfig{ + + /** + * 短信应用id + */ + private String appId; + + /** + * 短信应用key + */ + private String appKey; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/config/UploadFileConfig.java b/6.program/wms-core/src/main/java/com/mt/wms/core/config/UploadFileConfig.java new file mode 100644 index 0000000..d58c5f5 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/config/UploadFileConfig.java @@ -0,0 +1,29 @@ +package com.mt.wms.core.config; + +import org.springframework.boot.web.servlet.MultipartConfigFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.servlet.MultipartConfigElement; + +/** + *

+ *

+ * + * @author Mr.ZhangShi + * @date 2019/4/28 + * @since 1.0 + */ +@Configuration +public class UploadFileConfig { + + @Bean + public MultipartConfigElement multipartConfigElement() { + MultipartConfigFactory factory = new MultipartConfigFactory(); + //文件最大 KB,MB + factory.setMaxFileSize("100MB"); + /// 设置总上传数据总大小 + factory.setMaxRequestSize("100MB"); + return factory.createMultipartConfig(); + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/config/ValidatorConfig.java b/6.program/wms-core/src/main/java/com/mt/wms/core/config/ValidatorConfig.java new file mode 100644 index 0000000..7f4a26c --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/config/ValidatorConfig.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.config; + +import org.hibernate.validator.HibernateValidator; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + +/** + * 参数验证器配置,可以配置验证模式是快速失败返回还是普通模式,开发阶段先开启普通模式 + * + * @author jiff + * @date 2018/11/6 + * @since 1.0 + */ +@Configuration +public class ValidatorConfig { + @Bean + public Validator validator() { + ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class) + .configure() + //failFast:true 快速失败返回模式,false 普通模式 + .failFast(false) +// .addProperty("hibernate.validator.fail_fast", "true") + .buildValidatorFactory(); + Validator validator = validatorFactory.getValidator(); + + return validator; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/config/WxConfig.java b/6.program/wms-core/src/main/java/com/mt/wms/core/config/WxConfig.java new file mode 100644 index 0000000..5e2c8ea --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/config/WxConfig.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2020. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.config; + +import lombok.Data; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotNull; + +/** + * @author jiff + * @date 2020-03-10 + * @since 1.0 + */ +@Component +@ConditionalOnProperty(prefix = "wms.wechat", name = {"ma.appId"}) +@ConfigurationProperties(prefix = "wms.wechat") +@Data +@Validated +public class WxConfig { + + private String mchId; + private String mchKey; + @NotNull + private WechatProperties ma; + + + @Data + public static class WechatProperties { + /** + * 应用ID + */ + private String appId; + /** + * 接口秘钥 + */ + private String appSecret; + /** + * 微信公众号开发模式接口配置信息中的Token保持一致 + */ + private String token; + /** + * 微信生成的 ASEKey + */ + private String aseKey; + /** + * 商户号 + */ + private String mchId; + /** + * 商户秘钥 + */ + private String mchKey; + + /** + * 证书路径 + */ + private String keyPath; + } + + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/constants/CommonConstant.java b/6.program/wms-core/src/main/java/com/mt/wms/core/constants/CommonConstant.java new file mode 100644 index 0000000..870a6bf --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/constants/CommonConstant.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.constants; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public interface CommonConstant { + + + /** + * 版本控制 + */ + Integer VERSION = 0; + + /** + * 默认密码 + */ + String DEFAULT_PASSWORD = "123456"; + + /** + * 公共服务模块 + */ + String API_MODULE_BASE = "api/"; + + /** + * 公共服务模块 + */ + String API_MODULE_COMMON = API_MODULE_BASE + "common/"; + + /** + * 统一认证模块 + */ + String API_MODULE_PASSPORT = API_MODULE_BASE + "passport/"; + + /** + * 管理模块 + */ + String API_MODULE_MANAGER = API_MODULE_BASE + "manager/"; + + /** + * 用户管理模块 + */ + String API_MODULE_UPMS = API_MODULE_BASE + "upms/"; + + + /** + * 移动端模块 + */ + String API_MODULE_MOBILE = API_MODULE_BASE + "mobile/"; + + /** + * 报表端模块 + */ + String API_MODULE_REPORT = API_MODULE_BASE + "report/"; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/constants/MessageQueueConstant.java b/6.program/wms-core/src/main/java/com/mt/wms/core/constants/MessageQueueConstant.java new file mode 100644 index 0000000..6195bbe --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/constants/MessageQueueConstant.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.constants; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public interface MessageQueueConstant { + String SMS_CODE = "sms_code"; + String SMS_DINGTALK = "sms_dingtalk"; + String LOGIN_LOG = "login_log"; + String API_LOG = "api_log"; + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/constants/RedisConstant.java b/6.program/wms-core/src/main/java/com/mt/wms/core/constants/RedisConstant.java new file mode 100644 index 0000000..fb80902 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/constants/RedisConstant.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.constants; + +import com.mt.wms.core.utils.StringUtils; + +/** + * redis key 常量定义类,为了防止key冲突,第一个命名空间尽量定义在该类中。 + *

+ * 建议使用命名空间格式设置key名称: + *

+ * 1.1 key = 用途:业务限定:key。
+ * 例如:lock:order:xxx; sequence:order_no:xxx
+ * 1.2 key采用小写结构,不采用驼峰格式,中间利用下滑线(_)做连接,例如:user_name、user_pass。
+ * 1.3 key的长度限制在128字节之内,既可以节省空间,又可以加快查询速度。
+ * 

+ * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public interface RedisConstant { + /** + * key命名空间分隔符{@value} + */ + String KEY_NAMESPACE_SEPARATOR = ":"; + + /** + * 分布式锁的key命名空间 + */ + String LOCK_PREFIX = "lock:"; + + /** + * 短信的key命名空间{@value} + */ + String SMS_PREFIX = "sms"; + + /** + * 微信的key命名空间{@value} + */ + String WECHAT_PREFIX = "wechat"; + + /** + * 生成短信验证码键值 + * + * @param mobile 手机号码 + * @return key + */ + static String genSmsCodeKey(String mobile) { + return genKey(SMS_PREFIX, "code", mobile); + } + + /** + * 生成微信oauthCode键值 + * + * @param appId appId + * @param oauthCode oauthCode + * @return key + */ + static String genWechatOauthCodeKey(String appId, String oauthCode) { + return genKey(WECHAT_PREFIX, "oauth_code", appId, oauthCode); + } + + /** + * 生成微信jsApiTicket键值 + * + * @param appId appId + * @return key + */ + static String genWechatJsApiTicketKey(String appId) { + return genKey(WECHAT_PREFIX, "wechat_jsapi_ticket", appId); + } + + + /** + * 生成微信weChatAccessTokenCode键值 + * + * @param appId appId + * @return key + */ + static String genWechatAccessTokenCodeKey(String appId) { + return genKey(WECHAT_PREFIX, "wechat_access_token", appId); + } + + /** + * 生成redis键值 + * + * @param keys 键值数组 + * @return key0:key1:key2:keyN + */ + static String genKey(String... keys) { + return StringUtils.join(keys, KEY_NAMESPACE_SEPARATOR); + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/LoginLog.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/LoginLog.java new file mode 100644 index 0000000..002bf86 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/LoginLog.java @@ -0,0 +1,448 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 登录日志表,存放历史会话信息 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_login_log") +public class LoginLog extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 会话ID + */ + @TableField("session_id") + private String sessionId; + + /** + * 账号ID + */ + @TableField("account_id") + private Long accountId; + + /** + * 用户ID + */ + @TableField("user_id") + private Long userId; + + /** + * 公司ID + */ + @TableField("corp_id") + private Long corpId; + + /** + * 医院ID + */ + @TableField("hospital_id") + private Long hospitalId; + + /** + * 组织ID + */ + @TableField("org_id") + private Long orgId; + + /** + * 账号 + */ + @TableField("account") + private String account; + + /** + * 手机号 + */ + @TableField("mobile") + private String mobile; + + /** + * 用户名称 + */ + @TableField("user_name") + private String userName; + + /** + * 公司名称 + */ + @TableField("corp_name") + private String corpName; + + /** + * 医院名称 + */ + @TableField("hospital_name") + private String hospitalName; + + /** + * 组织名称,存放平台组织或者医院科室或者公司门店 + */ + @TableField("org_name") + private String orgName; + + /** + * 用户类型:1、平台用户,2、公司用户,3、医院用户,4、患者 + */ + @TableField("user_type") + private Integer userType; + + /** + * 应用类型:1、pc,2、app,3、wechat,4、miniapp + */ + @TableField("app_type") + private Integer appType; + + /** + * 应用编码:暂未使用 + */ + @TableField("app_code") + private Integer appCode; + + /** + * 登录类型:1、自主登录,2、漫游登录 + */ + @TableField("login_type") + private Integer loginType; + + /** + * 退出类型:1、自主退出,2、管理退出,3,超时退出 + */ + @TableField("logout_type") + private Integer logoutType; + + /** + * 登录时间 + */ + @TableField("login_time") + private LocalDateTime loginTime; + + /** + * 退出时间 + */ + @TableField("logout_time") + private LocalDateTime logoutTime; + + /** + * 设备类型 + */ + @TableField("device_class") + private String deviceClass; + + /** + * 设备名称 + */ + @TableField("device_name") + private String deviceName; + + /** + * 设备品牌 + */ + @TableField("device_brand") + private String deviceBrand; + + /** + * 操作系统 + */ + @TableField("os") + private String os; + + /** + * 浏览器 + */ + @TableField("browser") + private String browser; + + /** + * 国家 + */ + @TableField("country") + private String country; + + /** + * 省份 + */ + @TableField("province") + private String province; + + /** + * 地市 + */ + @TableField("city") + private String city; + + /** + * 区县 + */ + @TableField("county") + private String county; + + /** + * 地址 + */ + @TableField("address") + private String address; + + /** + * 精度 + */ + @TableField("lng") + private String lng; + + /** + * 纬度 + */ + @TableField("lat") + private String lat; + + /** + * 网络服务提供商 + */ + @TableField("isp") + private String isp; + + /** + * IP地址 + */ + @TableField("ip") + private String ip; + + /** + * 用户代理,存放用户登录时客户端信息 + */ + @TableField("user_agent") + private String userAgent; + + /** + * 退出地址 + */ + @TableField("logout_address") + private String logoutAddress; + + /** + * 退出IP地址 + */ + @TableField("logout_ip") + private String logoutIp; + + /** + * 退出用户代理,存放用户退出时客户端信息 + */ + @TableField("logout_user_agent") + private String logoutUserAgent; + + /** + * 异常状态:0、正常,1、省份异常,2、地市异常,3、区县异常 + */ + @TableField("abnormal_status") + private Integer abnormalStatus; + + /** + * ip转地址状态:0、未获取,1、登录地址获取成功,2、退出地址获取成功,-1、登录地址获取失败,-2、退出地址获取失败 + */ + @TableField("ip_to_address_status") + private Integer ipToAddressStatus; + + /** + * ip转地址次数,最多转换3次,三次失败修改状态为失败(-1、-2) + */ + @TableField("ip_to_address_count") + private Integer ipToAddressCount; + + /** + * ip转地址时间 + */ + @TableField("ip_to_address_time") + private LocalDateTime ipToAddressTime; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String SESSION_ID = "session_id"; + + public static final String ACCOUNT_ID = "account_id"; + + public static final String USER_ID = "user_id"; + + public static final String CORP_ID = "corp_id"; + + public static final String HOSPITAL_ID = "hospital_id"; + + public static final String ORG_ID = "org_id"; + + public static final String ACCOUNT = "account"; + + public static final String MOBILE = "mobile"; + + public static final String USER_NAME = "user_name"; + + public static final String CORP_NAME = "corp_name"; + + public static final String HOSPITAL_NAME = "hospital_name"; + + public static final String ORG_NAME = "org_name"; + + public static final String USER_TYPE = "user_type"; + + public static final String APP_TYPE = "app_type"; + + public static final String APP_CODE = "app_code"; + + public static final String LOGIN_TYPE = "login_type"; + + public static final String LOGOUT_TYPE = "logout_type"; + + public static final String LOGIN_TIME = "login_time"; + + public static final String LOGOUT_TIME = "logout_time"; + + public static final String DEVICE_CLASS = "device_class"; + + public static final String DEVICE_NAME = "device_name"; + + public static final String DEVICE_BRAND = "device_brand"; + + public static final String OS = "os"; + + public static final String BROWSER = "browser"; + + public static final String COUNTRY = "country"; + + public static final String PROVINCE = "province"; + + public static final String CITY = "city"; + + public static final String COUNTY = "county"; + + public static final String ADDRESS = "address"; + + public static final String LNG = "lng"; + + public static final String LAT = "lat"; + + public static final String ISP = "isp"; + + public static final String IP = "ip"; + + public static final String USER_AGENT = "user_agent"; + + public static final String LOGOUT_ADDRESS = "logout_address"; + + public static final String LOGOUT_IP = "logout_ip"; + + public static final String LOGOUT_USER_AGENT = "logout_user_agent"; + + public static final String ABNORMAL_STATUS = "abnormal_status"; + + public static final String IP_TO_ADDRESS_STATUS = "ip_to_address_status"; + + public static final String IP_TO_ADDRESS_COUNT = "ip_to_address_count"; + + public static final String IP_TO_ADDRESS_TIME = "ip_to_address_time"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/LoginSession.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/LoginSession.java new file mode 100644 index 0000000..d508918 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/LoginSession.java @@ -0,0 +1,390 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 登录会话表,存放在线用户信息 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_login_session") +public class LoginSession extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 会话ID + */ + @TableField("session_id") + private String sessionId; + + /** + * 账号ID + */ + @TableField("account_id") + private Long accountId; + + /** + * 用户ID + */ + @TableField("user_id") + private Long userId; + + /** + * 公司ID + */ + @TableField("corp_id") + private Long corpId; + + /** + * 医院ID + */ + @TableField("hospital_id") + private Long hospitalId; + + /** + * 组织ID + */ + @TableField("org_id") + private Long orgId; + + /** + * 账号 + */ + @TableField("account") + private String account; + + /** + * 手机号 + */ + @TableField("mobile") + private String mobile; + + /** + * 用户名称 + */ + @TableField("user_name") + private String userName; + + /** + * 公司名称 + */ + @TableField("corp_name") + private String corpName; + + /** + * 医院名称 + */ + @TableField("hospital_name") + private String hospitalName; + + /** + * 组织名称,存放平台组织或者医院科室或者公司门店 + */ + @TableField("org_name") + private String orgName; + + /** + * 用户类型:1、平台用户,2、公司用户,3、医院用户,4、患者 + */ + @TableField("user_type") + private Integer userType; + + /** + * 应用类型:1、pc,2、app,3、wechat,4、miniapp + */ + @TableField("app_type") + private Integer appType; + + /** + * 应用编码:暂未使用 + */ + @TableField("app_code") + private Integer appCode; + + /** + * 登录类型:1、自主登录,2、漫游登录 + */ + @TableField("login_type") + private Integer loginType; + + /** + * 登录时间 + */ + @TableField("login_time") + private LocalDateTime loginTime; + + /** + * 设备类型 + */ + @TableField("device_class") + private String deviceClass; + + /** + * 设备名称 + */ + @TableField("device_name") + private String deviceName; + + /** + * 设备品牌 + */ + @TableField("device_brand") + private String deviceBrand; + + /** + * 操作系统 + */ + @TableField("os") + private String os; + + /** + * 浏览器 + */ + @TableField("browser") + private String browser; + + /** + * 国家 + */ + @TableField("country") + private String country; + + /** + * 省份 + */ + @TableField("province") + private String province; + + /** + * 地市 + */ + @TableField("city") + private String city; + + /** + * 区县 + */ + @TableField("county") + private String county; + + /** + * 地址 + */ + @TableField("address") + private String address; + + /** + * 精度 + */ + @TableField("lng") + private String lng; + + /** + * 纬度 + */ + @TableField("lat") + private String lat; + + /** + * 网络服务提供商 + */ + @TableField("isp") + private String isp; + + /** + * IP地址 + */ + @TableField("ip") + private String ip; + + /** + * 用户代理,存放用户登录时客户端信息 + */ + @TableField("user_agent") + private String userAgent; + + /** + * ip转地址状态:0、未获取,1、登录地址获取成功,2、退出地址获取成功,-1、登录地址获取失败,-2、退出地址获取失败 + */ + @TableField("ip_to_address_status") + private Integer ipToAddressStatus; + + /** + * ip转地址次数,最多转换3次,三次失败修改状态为失败(-1、-2) + */ + @TableField("ip_to_address_count") + private Integer ipToAddressCount; + + /** + * ip转地址时间 + */ + @TableField("ip_to_address_time") + private LocalDateTime ipToAddressTime; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String SESSION_ID = "session_id"; + + public static final String ACCOUNT_ID = "account_id"; + + public static final String USER_ID = "user_id"; + + public static final String CORP_ID = "corp_id"; + + public static final String HOSPITAL_ID = "hospital_id"; + + public static final String ORG_ID = "org_id"; + + public static final String ACCOUNT = "account"; + + public static final String MOBILE = "mobile"; + + public static final String USER_NAME = "user_name"; + + public static final String CORP_NAME = "corp_name"; + + public static final String HOSPITAL_NAME = "hospital_name"; + + public static final String ORG_NAME = "org_name"; + + public static final String USER_TYPE = "user_type"; + + public static final String APP_TYPE = "app_type"; + + public static final String APP_CODE = "app_code"; + + public static final String LOGIN_TYPE = "login_type"; + + public static final String LOGIN_TIME = "login_time"; + + public static final String DEVICE_CLASS = "device_class"; + + public static final String DEVICE_NAME = "device_name"; + + public static final String DEVICE_BRAND = "device_brand"; + + public static final String OS = "os"; + + public static final String BROWSER = "browser"; + + public static final String COUNTRY = "country"; + + public static final String PROVINCE = "province"; + + public static final String CITY = "city"; + + public static final String COUNTY = "county"; + + public static final String ADDRESS = "address"; + + public static final String LNG = "lng"; + + public static final String LAT = "lat"; + + public static final String ISP = "isp"; + + public static final String IP = "ip"; + + public static final String USER_AGENT = "user_agent"; + + public static final String IP_TO_ADDRESS_STATUS = "ip_to_address_status"; + + public static final String IP_TO_ADDRESS_COUNT = "ip_to_address_count"; + + public static final String IP_TO_ADDRESS_TIME = "ip_to_address_time"; + + public static final String REMARK = "remark"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/Resource.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/Resource.java new file mode 100644 index 0000000..f551ab2 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/Resource.java @@ -0,0 +1,176 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 资源表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_resource") +public class Resource extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 服务ID + */ + @TableField("service_id") + private Long serviceId; + + /** + * 名称 + */ + @TableField("name") + private String name; + + /** + * 请求地址,可以用于前端ajax调用,后端用于做权限控制 + */ + @TableField("url") + private String url; + + /** + * 请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE + */ + @TableField("method") + private String method; + + /** + * 子系统:0、common,1、platform,2、partner,3、hospital,4、patient 用于限定维护菜单资源关系,公共资源允许所有菜单关联,其他资源只允许对应的菜单关联,如:平台菜单只允许关联到公共资源和平台资源 + */ + @TableField("subsystem") + private Integer subsystem; + + /** + * 分类:0、common,1、pc,2、app,3、wechat,4、miniapp + */ + @TableField("category") + private Integer category; + + /** + * 启用状态:0 、停用,1、启用 + */ + @TableField("enabled") + private Integer enabled; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String SERVICE_ID = "service_id"; + + public static final String NAME = "name"; + + public static final String URL = "url"; + + public static final String METHOD = "method"; + + public static final String SUBSYSTEM = "subsystem"; + + public static final String CATEGORY = "category"; + + public static final String ENABLED = "enabled"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/Service.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/Service.java new file mode 100644 index 0000000..cc578c3 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/Service.java @@ -0,0 +1,144 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 服务表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_service") +public class Service extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 编码 + */ + @TableField("code") + private String code; + + /** + * 名称 + */ + @TableField("name") + private String name; + + /** + * 启用状态:0 、停用,1、启用 + */ + @TableField("enabled") + private Integer enabled; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String CODE = "code"; + + public static final String NAME = "name"; + + public static final String ENABLED = "enabled"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsCode.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsCode.java new file mode 100644 index 0000000..b683bf8 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsCode.java @@ -0,0 +1,160 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 短信验证码表,过期时间和使用状态可以不用 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sms_code") +public class SmsCode extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 手机号码 + */ + @TableField("mobile") + private String mobile; + + /** + * 验证码 + */ + @TableField("code") + private String code; + + /** + * 1、注册 2、找回密码 3、动态密码 + */ + @TableField("type") + private Integer type; + + /** + * 过期时间 + */ + @TableField("expires_time") + private LocalDateTime expiresTime; + + /** + * 使用状态:0、未使用,1、已使用 + */ + @TableField("used_status") + private Integer usedStatus; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String MOBILE = "mobile"; + + public static final String CODE = "code"; + + public static final String TYPE = "type"; + + public static final String EXPIRES_TIME = "expires_time"; + + public static final String USED_STATUS = "used_status"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsScene.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsScene.java new file mode 100644 index 0000000..c0625eb --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsScene.java @@ -0,0 +1,176 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 短信场景表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sms_scene") +public class SmsScene extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 公司ID,0为公用,默认使用0对应的短信场景 + */ + @TableField("corp_id") + private Long corpId; + + /** + * 场景类型 0、其他/未分类 1、注册 2、找回密码 3、动态密码 4、订单 5、支付 6、报告单 9、系统通知 + */ + @TableField("type") + private Integer type; + + /** + * 场景编码,业务系统根据该编码区分不同的业务场景 + */ + @TableField("code") + private String code; + + /** + * 场景名称 + */ + @TableField("name") + private String name; + + /** + * 短信签名ID + */ + @TableField("sign_id") + private Long signId; + + /** + * 短信模板ID + */ + @TableField("template_id") + private Long templateId; + + /** + * 启用状态:0 、停用,1、启用 + */ + @TableField("enabled") + private Integer enabled; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String CORP_ID = "corp_id"; + + public static final String TYPE = "type"; + + public static final String CODE = "code"; + + public static final String NAME = "name"; + + public static final String SIGN_ID = "sign_id"; + + public static final String TEMPLATE_ID = "template_id"; + + public static final String ENABLED = "enabled"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsSend.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsSend.java new file mode 100644 index 0000000..9ed747c --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsSend.java @@ -0,0 +1,208 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 短信发送表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sms_send") +public class SmsSend extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 公司ID,0为公用,默认使用0对应的短信场景 + */ + @TableField("corp_id") + private Long corpId; + + /** + * 短信场景ID + */ + @TableField("scene_id") + private Long sceneId; + + /** + * 模板编号,第三方模板编码,如阿里云短信模板code + */ + @TableField("template_code") + private String templateCode; + + /** + * 短信类型 0、其他/未分类 1、注册 2、找回密码 3、动态密码 4、订单 5、支付 6、报告单 9、系统通知 + */ + @TableField("type") + private Integer type; + + /** + * 手机号码,多个号码用户英文逗号(,)分隔 + */ + @TableField("mobile") + private String mobile; + + /** + * 短信内容 + */ + @TableField("content") + private String content; + + /** + * 关联ID,如:用户ID、订单ID等 + */ + @TableField("relation_id") + private String relationId; + + /** + * 短信接口测ID + */ + @TableField("sid") + private String sid; + + /** + * 发送条数 + */ + @TableField("send") + private Integer send; + + /** + * 短信接口结果码 + */ + @TableField("result_code") + private String resultCode; + + /** + * 短信接口结果说明 + */ + @TableField("result_info") + private String resultInfo; + + /** + * 短信接口响应消息,完整的响应包 + */ + @TableField("response") + private String response; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String CORP_ID = "corp_id"; + + public static final String SCENE_ID = "scene_id"; + + public static final String TEMPLATE_CODE = "template_code"; + + public static final String TYPE = "type"; + + public static final String MOBILE = "mobile"; + + public static final String CONTENT = "content"; + + public static final String RELATION_ID = "relation_id"; + + public static final String SID = "sid"; + + public static final String SEND = "send"; + + public static final String RESULT_CODE = "result_code"; + + public static final String RESULT_INFO = "result_info"; + + public static final String RESPONSE = "response"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsSign.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsSign.java new file mode 100644 index 0000000..c0aa4a0 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsSign.java @@ -0,0 +1,144 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 短信签名表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sms_sign") +public class SmsSign extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 签名名称 + */ + @TableField("name") + private String name; + + /** + * 申请时间 + */ + @TableField("apply_time") + private LocalDateTime applyTime; + + /** + * 启用状态:0 、停用,1、启用 + */ + @TableField("enabled") + private Integer enabled; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String NAME = "name"; + + public static final String APPLY_TIME = "apply_time"; + + public static final String ENABLED = "enabled"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsTemplate.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsTemplate.java new file mode 100644 index 0000000..c42c099 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SmsTemplate.java @@ -0,0 +1,176 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 短信模板表,用于定义阿里云短信模板 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sms_template") +public class SmsTemplate extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 模板类型:1、验证码,2、短信通知 + */ + @TableField("type") + private Integer type; + + /** + * 模板编号,第三方模板编码,如阿里云短信模板code + */ + @TableField("code") + private String code; + + /** + * 模板名称 + */ + @TableField("name") + private String name; + + /** + * 模板内容 + */ + @TableField("content") + private String content; + + /** + * 模板描述 + */ + @TableField("description") + private String description; + + /** + * 申请时间 + */ + @TableField("apply_time") + private LocalDateTime applyTime; + + /** + * 启用状态:0 、停用,1、启用 + */ + @TableField("enabled") + private Integer enabled; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String TYPE = "type"; + + public static final String CODE = "code"; + + public static final String NAME = "name"; + + public static final String CONTENT = "content"; + + public static final String DESCRIPTION = "description"; + + public static final String APPLY_TIME = "apply_time"; + + public static final String ENABLED = "enabled"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysDictData.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysDictData.java new file mode 100644 index 0000000..f5c3e65 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysDictData.java @@ -0,0 +1,160 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 数据字典表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sys_dict_data") +public class SysDictData extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 字典类型ID + */ + @TableField("dict_type_id") + private Long dictTypeId; + + /** + * 数据字典类型编号 + */ + @TableField("type_code") + private String typeCode; + + /** + * 数据字典类型名称 + */ + @TableField("type_name") + private String typeName; + + /** + * 数据字典编号 + */ + @TableField("data_code") + private String dataCode; + + /** + * 数据字典名称 + */ + @TableField("data_name") + private String dataName; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String DICT_TYPE_ID = "dict_type_id"; + + public static final String TYPE_CODE = "type_code"; + + public static final String TYPE_NAME = "type_name"; + + public static final String DATA_CODE = "data_code"; + + public static final String DATA_NAME = "data_name"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysDictType.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysDictType.java new file mode 100644 index 0000000..d85738d --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysDictType.java @@ -0,0 +1,136 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 数据字典类型表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sys_dict_type") +public class SysDictType extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 数据字典类型 + */ + @TableField("type_code") + private String typeCode; + + /** + * 类型名称 + */ + @TableField("type_name") + private String typeName; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String TYPE_CODE = "type_code"; + + public static final String TYPE_NAME = "type_name"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysFile.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysFile.java new file mode 100644 index 0000000..4301c08 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysFile.java @@ -0,0 +1,152 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 文件表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sys_file") +public class SysFile extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 文件类型编号 如病例ID + */ + @TableField("type_code") + private String typeCode; + + /** + * 文件编号 + */ + @TableField("file_code") + private String fileCode; + + /** + * 文件名称 + */ + @TableField("file_name") + private String fileName; + + /** + * 文件路径URL + */ + @TableField("file_url") + private String fileUrl; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String TYPE_CODE = "type_code"; + + public static final String FILE_CODE = "file_code"; + + public static final String FILE_NAME = "file_name"; + + public static final String FILE_URL = "file_url"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysFileType.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysFileType.java new file mode 100644 index 0000000..1ea743d --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysFileType.java @@ -0,0 +1,136 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 文件类型表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sys_file_type") +public class SysFileType extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 文件类型编号 + */ + @TableField("type_code") + private String typeCode; + + /** + * 文件类型名称 + */ + @TableField("type_name") + private String typeName; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String TYPE_CODE = "type_code"; + + public static final String TYPE_NAME = "type_name"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysMenu.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysMenu.java new file mode 100644 index 0000000..eaa1fd4 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysMenu.java @@ -0,0 +1,224 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 菜单表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sys_menu") +public class SysMenu extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 父菜单ID + */ + @TableField("parent_id") + private Long parentId; + + /** + * 菜单编码 + */ + @TableField("code") + private String code; + + /** + * 菜单名称 + */ + @TableField("name") + private String name; + + /** + * 菜单图标 + */ + @TableField("icon") + private String icon; + + /** + * 链接地址,可以是页面地址,也可以是函数事件 + */ + @TableField("href") + private String href; + + /** + * 请求地址,可以用于前端ajax调用,后端用于做权限控制 + */ + @TableField("url") + private String url; + + /** + * 请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE + */ + @TableField("method") + private String method; + + /** + * 权限,可以有多个,用逗号分隔,可用于第三方权限框架扩展 + */ + @TableField("permission") + private String permission; + + /** + * 分类:1、pc,2、app,3、wechat,4、miniapp + */ + @TableField("category") + private Integer category; + + /** + * 类型:1、module,2、menu,3、button + */ + @TableField("type") + private Integer type; + + /** + * 层级,从1开始 + */ + @TableField("level") + private Integer level; + + /** + * 显示顺序 + */ + @TableField("order_num") + private Integer orderNum; + + /** + * 启用状态:0 、停用,1、启用 + */ + @TableField("enabled") + private Integer enabled; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String PARENT_ID = "parent_id"; + + public static final String CODE = "code"; + + public static final String NAME = "name"; + + public static final String ICON = "icon"; + + public static final String HREF = "href"; + + public static final String URL = "url"; + + public static final String METHOD = "method"; + + public static final String PERMISSION = "permission"; + + public static final String CATEGORY = "category"; + + public static final String TYPE = "type"; + + public static final String LEVEL = "level"; + + public static final String ORDER_NUM = "order_num"; + + public static final String ENABLED = "enabled"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysMenuResource.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysMenuResource.java new file mode 100644 index 0000000..58c9958 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysMenuResource.java @@ -0,0 +1,136 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 菜单资源关系表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sys_menu_resource") +public class SysMenuResource extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 菜单ID + */ + @TableField("menu_id") + private Long menuId; + + /** + * 资源ID + */ + @TableField("resource_id") + private Long resourceId; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String MENU_ID = "menu_id"; + + public static final String RESOURCE_ID = "resource_id"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysOrg.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysOrg.java new file mode 100644 index 0000000..bfb38b7 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysOrg.java @@ -0,0 +1,184 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 系统组织表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sys_org") +public class SysOrg extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 父组织ID + */ + @TableField("parent_id") + private Long parentId; + + /** + * 家谱ID,格式:/rootId/.../grandfatherId/parentId + */ + @TableField("genealogy_id") + private String genealogyId; + + /** + * 名称 + */ + @TableField("name") + private String name; + + /** + * 联系人 + */ + @TableField("contact") + private String contact; + + /** + * 联系电话 + */ + @TableField("phone") + private String phone; + + /** + * 联系地址 + */ + @TableField("address") + private String address; + + /** + * 邮箱 + */ + @TableField("email") + private String email; + + /** + * 启用状态:0 、停用,1、启用 + */ + @TableField("enabled") + private Integer enabled; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String PARENT_ID = "parent_id"; + + public static final String GENEALOGY_ID = "genealogy_id"; + + public static final String NAME = "name"; + + public static final String CONTACT = "contact"; + + public static final String PHONE = "phone"; + + public static final String ADDRESS = "address"; + + public static final String EMAIL = "email"; + + public static final String ENABLED = "enabled"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysPost.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysPost.java new file mode 100644 index 0000000..811d7c7 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysPost.java @@ -0,0 +1,168 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 岗位表,需根据岗位编码判断用户是否有销售、物流权限 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sys_post") +public class SysPost extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 上级岗位ID,第一个岗位的上级岗位ID填0 + */ + @TableField("parent_id") + private Long parentId; + + /** + * 类型:0、内部岗位,1、代理商岗位 + */ + @TableField("type") + private Integer type; + + /** + * 编码: 内部岗位:省区经理、provincial_manager,地市主管、area_manager,业务员、sale 代理商岗位:代理商、agent + */ + @TableField("code") + private String code; + + /** + * 名称 + */ + @TableField("name") + private String name; + + /** + * 预设标志:1 预设 0 非预设 + */ + @TableField("preset") + private Integer preset; + + /** + * 启用状态:0 、停用,1、启用 + */ + @TableField("enabled") + private Integer enabled; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String PARENT_ID = "parent_id"; + + public static final String TYPE = "type"; + + public static final String CODE = "code"; + + public static final String NAME = "name"; + + public static final String PRESET = "preset"; + + public static final String ENABLED = "enabled"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysRole.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysRole.java new file mode 100644 index 0000000..d5f337f --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysRole.java @@ -0,0 +1,176 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 角色表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sys_role") +public class SysRole extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 角色编码 + */ + @TableField("code") + private String code; + + /** + * 角色名称 + */ + @TableField("name") + private String name; + + /** + * 类型:1、平台,2、药店,3、医院 + */ + @TableField("type") + private Integer type; + + /** + * 分类:1、pc,2、app,3、wechat,4、miniapp + */ + @TableField("category") + private Integer category; + + /** + * 管理角色标志:1 管理角色0 非管理角色,管理角色不允许修改角色菜单关系 + */ + @TableField("manager_flag") + private Integer managerFlag; + + /** + * 预设角色标志:1 预设 0 非预设 + */ + @TableField("preset") + private Integer preset; + + /** + * 启用状态:0 、停用,1、启用 + */ + @TableField("enabled") + private Integer enabled; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String CODE = "code"; + + public static final String NAME = "name"; + + public static final String TYPE = "type"; + + public static final String CATEGORY = "category"; + + public static final String MANAGER_FLAG = "manager_flag"; + + public static final String PRESET = "preset"; + + public static final String ENABLED = "enabled"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysRoleMenu.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysRoleMenu.java new file mode 100644 index 0000000..a6016bd --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysRoleMenu.java @@ -0,0 +1,136 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 角色菜单关系表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sys_role_menu") +public class SysRoleMenu extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 角色ID + */ + @TableField("role_id") + private Long roleId; + + /** + * 菜单ID + */ + @TableField("menu_id") + private Long menuId; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String ROLE_ID = "role_id"; + + public static final String MENU_ID = "menu_id"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysUser.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysUser.java new file mode 100644 index 0000000..890bf07 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysUser.java @@ -0,0 +1,273 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import java.time.LocalDate; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 系统用户表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sys_user") +public class SysUser extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 组织ID + */ + @TableField("org_id") + private Long orgId; + + /** + * 帐号 + */ + @TableField("account") + private String account; + + /** + * 密码,存放加密后的密码,加密方式:md5(password+nonce_str),转成小写存储 + */ + @TableField("password") + private String password; + + /** + * 工号 + */ + @TableField("code") + private String code; + + /** + * 姓名 + */ + @TableField("name") + private String name; + + /** + * 性别:1、男性,2、女性,0、未知 + */ + @TableField("sex") + private Integer sex; + + /** + * 系统用户手机号 + */ + @TableField("mobile") + private String mobile; + + /** + * 电话号码 + */ + @TableField("phone") + private String phone; + + /** + * 身份证 + */ + @TableField("idcard") + private String idcard; + + /** + * 生日 + */ + @TableField("birthday") + private LocalDate birthday; + + /** + * 系统用户邮箱 + */ + @TableField("email") + private String email; + + /** + * 头像 + */ + @TableField("portrait") + private String portrait; + + /** + * 微信 + */ + @TableField("wechat") + private String wechat; + + /** + * QQ + */ + @TableField("qq") + private String qq; + + /** + * 联系地址 + */ + @TableField("address") + private String address; + + /** + * 密码随机串,用于加密明文密码 + */ + @TableField("nonce_str") + private String nonceStr; + + /** + * 修改密码时间 + */ + @TableField("modify_password_time") + private LocalDateTime modifyPasswordTime; + + /** + * 手机号码是否激活:0、未激活,1、激活,根据是否使用过短信验证码登录确认是否激活状态 + */ + @TableField("mobile_enabled") + private Integer mobileEnabled; + + /** + * 启用状态:0 、停用,1、启用 + */ + @TableField("enabled") + private Integer enabled; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String ORG_ID = "org_id"; + + public static final String ACCOUNT = "account"; + + public static final String PASSWORD = "password"; + + public static final String CODE = "code"; + + public static final String NAME = "name"; + + public static final String SEX = "sex"; + + public static final String MOBILE = "mobile"; + + public static final String PHONE = "phone"; + + public static final String IDCARD = "idcard"; + + public static final String BIRTHDAY = "birthday"; + + public static final String EMAIL = "email"; + + public static final String PORTRAIT = "portrait"; + + public static final String WECHAT = "wechat"; + + public static final String QQ = "qq"; + + public static final String ADDRESS = "address"; + + public static final String NONCE_STR = "nonce_str"; + + public static final String MODIFY_PASSWORD_TIME = "modify_password_time"; + + public static final String MOBILE_ENABLED = "mobile_enabled"; + + public static final String ENABLED = "enabled"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysUserPost.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysUserPost.java new file mode 100644 index 0000000..d2ed655 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysUserPost.java @@ -0,0 +1,136 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 用户岗位关系表,先限定一个用只有一种岗位 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sys_user_post") +public class SysUserPost extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 用户ID + */ + @TableField("user_id") + private Long userId; + + /** + * 岗位ID + */ + @TableField("post_id") + private Long postId; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String USER_ID = "user_id"; + + public static final String POST_ID = "post_id"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysUserRole.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysUserRole.java new file mode 100644 index 0000000..1ae9af0 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/SysUserRole.java @@ -0,0 +1,136 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 用户角色关系表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_sys_user_role") +public class SysUserRole extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 用户ID + */ + @TableField("user_id") + private Long userId; + + /** + * 角色ID + */ + @TableField("role_id") + private Long roleId; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String USER_ID = "user_id"; + + public static final String ROLE_ID = "role_id"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/WechatTemplateMessage.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/WechatTemplateMessage.java new file mode 100644 index 0000000..f4a93d9 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/WechatTemplateMessage.java @@ -0,0 +1,208 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 微信模板消息表 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_wechat_template_message") +public class WechatTemplateMessage extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 账号ID + */ + @TableField("account_id") + private Long accountId; + + /** + * 用户类型 1、平台 2、药店 3、医院 4、患者 + */ + @TableField("user_type") + private Integer userType; + + /** + * 用户ID + */ + @TableField("user_id") + private Long userId; + + /** + * 微信用户ID + */ + @TableField("open_id") + private String openId; + + /** + * 消息模板ID + */ + @TableField("template_id") + private String templateId; + + /** + * 标题 + */ + @TableField("title") + private String title; + + /** + * 消息内容 + */ + @TableField("content") + private String content; + + /** + * 链接地址 + */ + @TableField("url") + private String url; + + /** + * 消息ID + */ + @TableField("message_id") + private String messageId; + + /** + * 状态 0、未发送 1、发送中 2、已发送 -1、失败 + */ + @TableField("status") + private Integer status; + + /** + * 预留字段 + */ + @TableField("reserved") + private String reserved; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + /** + * 删除标志,是否有效:1 可用 0不可用 + */ + @TableField("valid") + @TableLogic + private Integer valid; + + /** + * 创建人 + */ + @TableField("creator") + private Long creator; + + /** + * 创建人姓名 + */ + @TableField("creator_name") + private String creatorName; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新人 + */ + @TableField("updater") + private Long updater; + + /** + * 更新人姓名 + */ + @TableField("updater_name") + private String updaterName; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 版本号 + */ + @TableField("version") + @Version + private Integer version; + + + public static final String ID = "id"; + + public static final String ACCOUNT_ID = "account_id"; + + public static final String USER_TYPE = "user_type"; + + public static final String USER_ID = "user_id"; + + public static final String OPEN_ID = "open_id"; + + public static final String TEMPLATE_ID = "template_id"; + + public static final String TITLE = "title"; + + public static final String CONTENT = "content"; + + public static final String URL = "url"; + + public static final String MESSAGE_ID = "message_id"; + + public static final String STATUS = "status"; + + public static final String RESERVED = "reserved"; + + public static final String REMARK = "remark"; + + public static final String VALID = "valid"; + + public static final String CREATOR = "creator"; + + public static final String CREATOR_NAME = "creator_name"; + + public static final String CREATE_TIME = "create_time"; + + public static final String UPDATER = "updater"; + + public static final String UPDATER_NAME = "updater_name"; + + public static final String UPDATE_TIME = "update_time"; + + public static final String VERSION = "version"; + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/LoginLogMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/LoginLogMapper.java new file mode 100644 index 0000000..edaf912 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/LoginLogMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.LoginLog; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 登录日志表,存放历史会话信息 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface LoginLogMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/LoginLogMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/LoginLogMapper.xml new file mode 100644 index 0000000..f70871a --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/LoginLogMapper.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, session_id, account_id, user_id, corp_id, hospital_id, org_id, account, mobile, user_name, corp_name, hospital_name, org_name, user_type, app_type, app_code, login_type, logout_type, login_time, logout_time, device_class, device_name, device_brand, os, browser, country, province, city, county, address, lng, lat, isp, ip, user_agent, logout_address, logout_ip, logout_user_agent, abnormal_status, ip_to_address_status, ip_to_address_count, ip_to_address_time, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/LoginSessionMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/LoginSessionMapper.java new file mode 100644 index 0000000..a19ce0f --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/LoginSessionMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.LoginSession; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 登录会话表,存放在线用户信息 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface LoginSessionMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/LoginSessionMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/LoginSessionMapper.xml new file mode 100644 index 0000000..ed08df7 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/LoginSessionMapper.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, session_id, account_id, user_id, corp_id, hospital_id, org_id, account, mobile, user_name, corp_name, hospital_name, org_name, user_type, app_type, app_code, login_type, login_time, device_class, device_name, device_brand, os, browser, country, province, city, county, address, lng, lat, isp, ip, user_agent, ip_to_address_status, ip_to_address_count, ip_to_address_time, remark, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ResourceMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ResourceMapper.java new file mode 100644 index 0000000..7a32162 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ResourceMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.Resource; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 资源表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface ResourceMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ResourceMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ResourceMapper.xml new file mode 100644 index 0000000..189b39a --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ResourceMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, service_id, name, url, method, subsystem, category, enabled, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ServiceMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ServiceMapper.java new file mode 100644 index 0000000..09b0111 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ServiceMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.Service; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 服务表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface ServiceMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ServiceMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ServiceMapper.xml new file mode 100644 index 0000000..f3ce46e --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ServiceMapper.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + id, code, name, enabled, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsCodeMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsCodeMapper.java new file mode 100644 index 0000000..2acf173 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsCodeMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SmsCode; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 短信验证码表,过期时间和使用状态可以不用 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SmsCodeMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsCodeMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsCodeMapper.xml new file mode 100644 index 0000000..fed434d --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsCodeMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + id, mobile, code, type, expires_time, used_status, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSceneMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSceneMapper.java new file mode 100644 index 0000000..e739a60 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSceneMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SmsScene; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 短信场景表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SmsSceneMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSceneMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSceneMapper.xml new file mode 100644 index 0000000..7e00cb4 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSceneMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, corp_id, type, code, name, sign_id, template_id, enabled, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSendMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSendMapper.java new file mode 100644 index 0000000..bd29027 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSendMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SmsSend; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 短信发送表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SmsSendMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSendMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSendMapper.xml new file mode 100644 index 0000000..7774e26 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSendMapper.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, corp_id, scene_id, template_code, type, mobile, content, relation_id, sid, send, result_code, result_info, response, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSignMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSignMapper.java new file mode 100644 index 0000000..0292e09 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSignMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SmsSign; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 短信签名表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SmsSignMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSignMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSignMapper.xml new file mode 100644 index 0000000..b6c00a0 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsSignMapper.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + id, name, apply_time, enabled, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsTemplateMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsTemplateMapper.java new file mode 100644 index 0000000..3ecd200 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsTemplateMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SmsTemplate; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 短信模板表,用于定义阿里云短信模板 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SmsTemplateMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsTemplateMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsTemplateMapper.xml new file mode 100644 index 0000000..fcc4c08 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SmsTemplateMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, type, code, name, content, description, apply_time, enabled, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysDictDataMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysDictDataMapper.java new file mode 100644 index 0000000..1ae3982 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysDictDataMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SysDictData; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 数据字典表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysDictDataMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysDictDataMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysDictDataMapper.xml new file mode 100644 index 0000000..4b69cb3 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysDictDataMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + id, dict_type_id, type_code, type_name, data_code, data_name, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysDictTypeMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysDictTypeMapper.java new file mode 100644 index 0000000..ff3690b --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysDictTypeMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SysDictType; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 数据字典类型表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysDictTypeMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysDictTypeMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysDictTypeMapper.xml new file mode 100644 index 0000000..95165af --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysDictTypeMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + id, type_code, type_name, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysFileMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysFileMapper.java new file mode 100644 index 0000000..b3ad5aa --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysFileMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SysFile; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 文件表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysFileMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysFileMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysFileMapper.xml new file mode 100644 index 0000000..562dbf0 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysFileMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + id, type_code, file_code, file_name, file_url, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysFileTypeMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysFileTypeMapper.java new file mode 100644 index 0000000..f3726ac --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysFileTypeMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SysFileType; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 文件类型表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysFileTypeMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysFileTypeMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysFileTypeMapper.xml new file mode 100644 index 0000000..56fe3bb --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysFileTypeMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + id, type_code, type_name, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysMenuMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysMenuMapper.java new file mode 100644 index 0000000..d8b5491 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysMenuMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SysMenu; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 菜单表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysMenuMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysMenuMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysMenuMapper.xml new file mode 100644 index 0000000..ccefd9c --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysMenuMapper.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, parent_id, code, name, icon, href, url, method, permission, category, type, level, order_num, enabled, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysMenuResourceMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysMenuResourceMapper.java new file mode 100644 index 0000000..cd1afce --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysMenuResourceMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SysMenuResource; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 菜单资源关系表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysMenuResourceMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysMenuResourceMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysMenuResourceMapper.xml new file mode 100644 index 0000000..a9ed0ea --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysMenuResourceMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + id, menu_id, resource_id, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysOrgMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysOrgMapper.java new file mode 100644 index 0000000..a44d651 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysOrgMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SysOrg; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 系统组织表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysOrgMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysOrgMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysOrgMapper.xml new file mode 100644 index 0000000..d5511eb --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysOrgMapper.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, parent_id, genealogy_id, name, contact, phone, address, email, enabled, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysPostMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysPostMapper.java new file mode 100644 index 0000000..2bcd18e --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysPostMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SysPost; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 岗位表,需根据岗位编码判断用户是否有销售、物流权限 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysPostMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysPostMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysPostMapper.xml new file mode 100644 index 0000000..e603987 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysPostMapper.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + id, parent_id, type, code, name, preset, enabled, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysRoleMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysRoleMapper.java new file mode 100644 index 0000000..cbc0095 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysRoleMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SysRole; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 角色表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysRoleMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysRoleMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysRoleMapper.xml new file mode 100644 index 0000000..e16288e --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysRoleMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, code, name, type, category, manager_flag, preset, enabled, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysRoleMenuMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysRoleMenuMapper.java new file mode 100644 index 0000000..90835dd --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysRoleMenuMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SysRoleMenu; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 角色菜单关系表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysRoleMenuMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysRoleMenuMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysRoleMenuMapper.xml new file mode 100644 index 0000000..44e8c08 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysRoleMenuMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + id, role_id, menu_id, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserMapper.java new file mode 100644 index 0000000..329b8a0 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SysUser; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 系统用户表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysUserMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserMapper.xml new file mode 100644 index 0000000..a62195b --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserMapper.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, org_id, account, password, code, name, sex, mobile, phone, idcard, birthday, email, portrait, wechat, qq, address, nonce_str, modify_password_time, mobile_enabled, enabled, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserPostMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserPostMapper.java new file mode 100644 index 0000000..b143207 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserPostMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SysUserPost; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 用户岗位关系表,先限定一个用只有一种岗位 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysUserPostMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserPostMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserPostMapper.xml new file mode 100644 index 0000000..76056b1 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserPostMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + id, user_id, post_id, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserRoleMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserRoleMapper.java new file mode 100644 index 0000000..6450764 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserRoleMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.SysUserRole; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 用户角色关系表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysUserRoleMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserRoleMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserRoleMapper.xml new file mode 100644 index 0000000..30e5e82 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/SysUserRoleMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + id, user_id, role_id, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/WechatTemplateMessageMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/WechatTemplateMessageMapper.java new file mode 100644 index 0000000..f2bd6c7 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/WechatTemplateMessageMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.WechatTemplateMessage; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 微信模板消息表 Mapper 接口 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface WechatTemplateMessageMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/WechatTemplateMessageMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/WechatTemplateMessageMapper.xml new file mode 100644 index 0000000..758dc27 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/WechatTemplateMessageMapper.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, account_id, user_type, user_id, open_id, template_id, title, content, url, message_id, status, reserved, remark, valid, creator, creator_name, create_time, updater, updater_name, update_time, version + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/LoginLogServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/LoginLogServiceBiz.java new file mode 100644 index 0000000..e2e9812 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/LoginLogServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.LoginLog; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 登录日志表,存放历史会话信息 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface LoginLogServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/LoginSessionServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/LoginSessionServiceBiz.java new file mode 100644 index 0000000..9768a57 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/LoginSessionServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.LoginSession; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 登录会话表,存放在线用户信息 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface LoginSessionServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ResourceServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ResourceServiceBiz.java new file mode 100644 index 0000000..4fbee01 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ResourceServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.Resource; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 资源表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface ResourceServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ServiceServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ServiceServiceBiz.java new file mode 100644 index 0000000..e04bc69 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ServiceServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.Service; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface ServiceServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsCodeServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsCodeServiceBiz.java new file mode 100644 index 0000000..b3e06d7 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsCodeServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SmsCode; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 短信验证码表,过期时间和使用状态可以不用 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SmsCodeServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsSceneServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsSceneServiceBiz.java new file mode 100644 index 0000000..aebfaaa --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsSceneServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SmsScene; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 短信场景表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SmsSceneServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsSendServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsSendServiceBiz.java new file mode 100644 index 0000000..1fc4b37 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsSendServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SmsSend; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 短信发送表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SmsSendServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsSignServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsSignServiceBiz.java new file mode 100644 index 0000000..3876586 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsSignServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SmsSign; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 短信签名表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SmsSignServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsTemplateServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsTemplateServiceBiz.java new file mode 100644 index 0000000..7004f6e --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SmsTemplateServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SmsTemplate; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 短信模板表,用于定义阿里云短信模板 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SmsTemplateServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysDictDataServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysDictDataServiceBiz.java new file mode 100644 index 0000000..2a9e788 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysDictDataServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SysDictData; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 数据字典表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysDictDataServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysDictTypeServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysDictTypeServiceBiz.java new file mode 100644 index 0000000..1d6fc21 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysDictTypeServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SysDictType; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 数据字典类型表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysDictTypeServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysFileServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysFileServiceBiz.java new file mode 100644 index 0000000..52860f8 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysFileServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SysFile; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 文件表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysFileServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysFileTypeServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysFileTypeServiceBiz.java new file mode 100644 index 0000000..fb78bc6 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysFileTypeServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SysFileType; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 文件类型表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysFileTypeServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysMenuResourceServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysMenuResourceServiceBiz.java new file mode 100644 index 0000000..83ba761 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysMenuResourceServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SysMenuResource; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 菜单资源关系表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysMenuResourceServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysMenuServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysMenuServiceBiz.java new file mode 100644 index 0000000..6ec0ec2 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysMenuServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SysMenu; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 菜单表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysMenuServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysOrgServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysOrgServiceBiz.java new file mode 100644 index 0000000..cb5f9d6 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysOrgServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SysOrg; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 系统组织表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysOrgServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysPostServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysPostServiceBiz.java new file mode 100644 index 0000000..87be355 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysPostServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SysPost; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 岗位表,需根据岗位编码判断用户是否有销售、物流权限 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysPostServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysRoleMenuServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysRoleMenuServiceBiz.java new file mode 100644 index 0000000..9ec8742 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysRoleMenuServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SysRoleMenu; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 角色菜单关系表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysRoleMenuServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysRoleServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysRoleServiceBiz.java new file mode 100644 index 0000000..7196c01 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysRoleServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SysRole; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 角色表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysRoleServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysUserPostServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysUserPostServiceBiz.java new file mode 100644 index 0000000..dc5ea35 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysUserPostServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SysUserPost; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 用户岗位关系表,先限定一个用只有一种岗位 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysUserPostServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysUserRoleServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysUserRoleServiceBiz.java new file mode 100644 index 0000000..61556a3 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysUserRoleServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SysUserRole; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 用户角色关系表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysUserRoleServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysUserServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysUserServiceBiz.java new file mode 100644 index 0000000..c8ac62a --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/SysUserServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.SysUser; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 系统用户表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface SysUserServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/WechatTemplateMessageServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/WechatTemplateMessageServiceBiz.java new file mode 100644 index 0000000..dda71ed --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/WechatTemplateMessageServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.WechatTemplateMessage; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 微信模板消息表 服务类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +public interface WechatTemplateMessageServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/LoginLogServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/LoginLogServiceBizImpl.java new file mode 100644 index 0000000..0a259a5 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/LoginLogServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.LoginLog; +import com.mt.wms.core.dal.mapper.LoginLogMapper; +import com.mt.wms.core.dal.service.LoginLogServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 登录日志表,存放历史会话信息 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class LoginLogServiceBizImpl extends ServiceImpl implements LoginLogServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/LoginSessionServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/LoginSessionServiceBizImpl.java new file mode 100644 index 0000000..67f7af6 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/LoginSessionServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.LoginSession; +import com.mt.wms.core.dal.mapper.LoginSessionMapper; +import com.mt.wms.core.dal.service.LoginSessionServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 登录会话表,存放在线用户信息 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class LoginSessionServiceBizImpl extends ServiceImpl implements LoginSessionServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ResourceServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ResourceServiceBizImpl.java new file mode 100644 index 0000000..716cb53 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ResourceServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.Resource; +import com.mt.wms.core.dal.mapper.ResourceMapper; +import com.mt.wms.core.dal.service.ResourceServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 资源表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class ResourceServiceBizImpl extends ServiceImpl implements ResourceServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ServiceServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ServiceServiceBizImpl.java new file mode 100644 index 0000000..bd26d62 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ServiceServiceBizImpl.java @@ -0,0 +1,19 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.Service; +import com.mt.wms.core.dal.mapper.ServiceMapper; +import com.mt.wms.core.dal.service.ServiceServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +/** + *

+ * 服务表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@org.springframework.stereotype.Service +public class ServiceServiceBizImpl extends ServiceImpl implements ServiceServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsCodeServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsCodeServiceBizImpl.java new file mode 100644 index 0000000..3211315 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsCodeServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SmsCode; +import com.mt.wms.core.dal.mapper.SmsCodeMapper; +import com.mt.wms.core.dal.service.SmsCodeServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 短信验证码表,过期时间和使用状态可以不用 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SmsCodeServiceBizImpl extends ServiceImpl implements SmsCodeServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsSceneServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsSceneServiceBizImpl.java new file mode 100644 index 0000000..b6e7ac0 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsSceneServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SmsScene; +import com.mt.wms.core.dal.mapper.SmsSceneMapper; +import com.mt.wms.core.dal.service.SmsSceneServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 短信场景表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SmsSceneServiceBizImpl extends ServiceImpl implements SmsSceneServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsSendServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsSendServiceBizImpl.java new file mode 100644 index 0000000..9621855 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsSendServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SmsSend; +import com.mt.wms.core.dal.mapper.SmsSendMapper; +import com.mt.wms.core.dal.service.SmsSendServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 短信发送表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SmsSendServiceBizImpl extends ServiceImpl implements SmsSendServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsSignServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsSignServiceBizImpl.java new file mode 100644 index 0000000..601c9db --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsSignServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SmsSign; +import com.mt.wms.core.dal.mapper.SmsSignMapper; +import com.mt.wms.core.dal.service.SmsSignServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 短信签名表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SmsSignServiceBizImpl extends ServiceImpl implements SmsSignServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsTemplateServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsTemplateServiceBizImpl.java new file mode 100644 index 0000000..f1b0a59 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SmsTemplateServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SmsTemplate; +import com.mt.wms.core.dal.mapper.SmsTemplateMapper; +import com.mt.wms.core.dal.service.SmsTemplateServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 短信模板表,用于定义阿里云短信模板 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SmsTemplateServiceBizImpl extends ServiceImpl implements SmsTemplateServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysDictDataServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysDictDataServiceBizImpl.java new file mode 100644 index 0000000..6333bd7 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysDictDataServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SysDictData; +import com.mt.wms.core.dal.mapper.SysDictDataMapper; +import com.mt.wms.core.dal.service.SysDictDataServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 数据字典表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SysDictDataServiceBizImpl extends ServiceImpl implements SysDictDataServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysDictTypeServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysDictTypeServiceBizImpl.java new file mode 100644 index 0000000..747f1a8 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysDictTypeServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SysDictType; +import com.mt.wms.core.dal.mapper.SysDictTypeMapper; +import com.mt.wms.core.dal.service.SysDictTypeServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 数据字典类型表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SysDictTypeServiceBizImpl extends ServiceImpl implements SysDictTypeServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysFileServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysFileServiceBizImpl.java new file mode 100644 index 0000000..16905e0 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysFileServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SysFile; +import com.mt.wms.core.dal.mapper.SysFileMapper; +import com.mt.wms.core.dal.service.SysFileServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 文件表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SysFileServiceBizImpl extends ServiceImpl implements SysFileServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysFileTypeServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysFileTypeServiceBizImpl.java new file mode 100644 index 0000000..85eded3 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysFileTypeServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SysFileType; +import com.mt.wms.core.dal.mapper.SysFileTypeMapper; +import com.mt.wms.core.dal.service.SysFileTypeServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 文件类型表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SysFileTypeServiceBizImpl extends ServiceImpl implements SysFileTypeServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysMenuResourceServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysMenuResourceServiceBizImpl.java new file mode 100644 index 0000000..639f85d --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysMenuResourceServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SysMenuResource; +import com.mt.wms.core.dal.mapper.SysMenuResourceMapper; +import com.mt.wms.core.dal.service.SysMenuResourceServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 菜单资源关系表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SysMenuResourceServiceBizImpl extends ServiceImpl implements SysMenuResourceServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysMenuServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysMenuServiceBizImpl.java new file mode 100644 index 0000000..6acf5a5 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysMenuServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SysMenu; +import com.mt.wms.core.dal.mapper.SysMenuMapper; +import com.mt.wms.core.dal.service.SysMenuServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 菜单表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SysMenuServiceBizImpl extends ServiceImpl implements SysMenuServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysOrgServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysOrgServiceBizImpl.java new file mode 100644 index 0000000..2fb0150 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysOrgServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SysOrg; +import com.mt.wms.core.dal.mapper.SysOrgMapper; +import com.mt.wms.core.dal.service.SysOrgServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 系统组织表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SysOrgServiceBizImpl extends ServiceImpl implements SysOrgServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysPostServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysPostServiceBizImpl.java new file mode 100644 index 0000000..d35f58c --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysPostServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SysPost; +import com.mt.wms.core.dal.mapper.SysPostMapper; +import com.mt.wms.core.dal.service.SysPostServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 岗位表,需根据岗位编码判断用户是否有销售、物流权限 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SysPostServiceBizImpl extends ServiceImpl implements SysPostServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysRoleMenuServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysRoleMenuServiceBizImpl.java new file mode 100644 index 0000000..7ea5110 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysRoleMenuServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SysRoleMenu; +import com.mt.wms.core.dal.mapper.SysRoleMenuMapper; +import com.mt.wms.core.dal.service.SysRoleMenuServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 角色菜单关系表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SysRoleMenuServiceBizImpl extends ServiceImpl implements SysRoleMenuServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysRoleServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysRoleServiceBizImpl.java new file mode 100644 index 0000000..98343a6 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysRoleServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SysRole; +import com.mt.wms.core.dal.mapper.SysRoleMapper; +import com.mt.wms.core.dal.service.SysRoleServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 角色表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SysRoleServiceBizImpl extends ServiceImpl implements SysRoleServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysUserPostServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysUserPostServiceBizImpl.java new file mode 100644 index 0000000..a9933d1 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysUserPostServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SysUserPost; +import com.mt.wms.core.dal.mapper.SysUserPostMapper; +import com.mt.wms.core.dal.service.SysUserPostServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 用户岗位关系表,先限定一个用只有一种岗位 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SysUserPostServiceBizImpl extends ServiceImpl implements SysUserPostServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysUserRoleServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysUserRoleServiceBizImpl.java new file mode 100644 index 0000000..4ad0902 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysUserRoleServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SysUserRole; +import com.mt.wms.core.dal.mapper.SysUserRoleMapper; +import com.mt.wms.core.dal.service.SysUserRoleServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 用户角色关系表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SysUserRoleServiceBizImpl extends ServiceImpl implements SysUserRoleServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysUserServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysUserServiceBizImpl.java new file mode 100644 index 0000000..05c9789 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/SysUserServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.SysUser; +import com.mt.wms.core.dal.mapper.SysUserMapper; +import com.mt.wms.core.dal.service.SysUserServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 系统用户表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class SysUserServiceBizImpl extends ServiceImpl implements SysUserServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/WechatTemplateMessageServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/WechatTemplateMessageServiceBizImpl.java new file mode 100644 index 0000000..29395a1 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/WechatTemplateMessageServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.WechatTemplateMessage; +import com.mt.wms.core.dal.mapper.WechatTemplateMessageMapper; +import com.mt.wms.core.dal.service.WechatTemplateMessageServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 微信模板消息表 服务实现类 + *

+ * + * @author mt + * @since 2020-12-21 + */ +@Service +public class WechatTemplateMessageServiceBizImpl extends ServiceImpl implements WechatTemplateMessageServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dto/ApiLogDto.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dto/ApiLogDto.java new file mode 100644 index 0000000..677bc78 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dto/ApiLogDto.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.dto; + + +import com.mt.wms.core.base.BaseDto; +import lombok.Builder; +import lombok.Data; + +import java.util.Date; + +/** + * api调用日志传输对象 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@Data +@Builder +public class ApiLogDto extends BaseDto { + private String sessionId; + private Long passportUserId; + private Long userId; + private String userName; + private int userType; + + private String ip; + /** + * 用户代理 + */ + private String userAgent; + /** + * 请求地址 + */ + private String url; + /** + * 操作方式 + */ + private String method; + + /** + * 操作提交的数据 + */ + private String params; + + /** + * 异常信息 + */ + private String exception; + + /** + * 请求时间 + */ + private Date time; + + /** + * 执行时长 + */ + private long duration; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dto/LoginLogDto.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dto/LoginLogDto.java new file mode 100644 index 0000000..94d467c --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dto/LoginLogDto.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.dto; + +import com.mt.wms.core.base.BaseDto; +import lombok.Builder; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 登录日志传输对象 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@Data +@Accessors(chain = true) +@Builder +public class LoginLogDto extends BaseDto { + public static final int ACTION_LOGIN = 1; + public static final int ACTION_LOGOUT = 2; + public static final int LOGIN_TYPE_SELF = 1; + public static final int LOGIN_TYPE_ROAM = 2; + public static final int LOGOUT_TYPE_SELF = 1; + public static final int LOGOUT_TYPE_MANAGE = 2; + public static final int LOGOUT_TYPE_EXPIRED = 3; + private String parentSessionId; + private String parentUserName; + private String sessionId; + private Long passportUserId; + private Long userId; + private Long accountId; + private Long orgId; + private String account; + private String mobile; + private String userName; + private int userType; + private int appType; + private int appCode; + + private String ip; + + /** + * 用户代理 + */ + private String userAgent; + private Date loginTime; + private Date logoutTime; + private int result; + /** + * 登录类型:1、自主登录,2、漫游登录 + */ + private int loginType; + /** + * 退出类型:1、自主退出,2、管理退出,3,超时退出 + */ + private int logoutType; + /** + * 操作动作:1、登录,2、退出 + */ + private int action; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dto/LoginUser.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dto/LoginUser.java new file mode 100644 index 0000000..60f8ba6 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dto/LoginUser.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.dto; + +import com.mt.wms.core.base.BaseDto; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Builder +@Data +@Accessors(chain = true) +public class LoginUser extends BaseDto { + public static final String HTTP_HEADER_NAME = "loginUser"; + public static final int USER_TYPE_PLATFORM = 1; + public static final int USER_TYPE_PARTNER = 2; + public static final int USER_TYPE_HOSPITAL = 3; + public static final int USER_TYPE_PATIENT = 4; + /** + * 会话ID + */ + private String sessionId; + private Long passportUserId; + private Long userId; + private Long partnerId; + private Long hospitalId; + private Long orgId; + private String mobile; + private String userName; + /** + * 用户类型 + */ + private int userType; + /** + * 应用类型 + */ + private int appType; + /** + * 应用代码 + */ + private int appCode; + /** + * 登录类型:1、自主登录,2、漫游登录 + */ + private int loginType; + /** + * 微信appId + */ + private String wechatAppId; + /** + * 微信openId + */ + private String openId; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dto/Permission.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dto/Permission.java new file mode 100644 index 0000000..ccd61a7 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dto/Permission.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.dto; + +import com.mt.wms.core.base.BaseDto; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 权限类 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@Builder +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "权限类", description = "用于统一用户服务对接口鉴权") +public class Permission extends BaseDto { + /** + * 请求地址,可以用于前端ajax调用,后端用于做权限控制 + */ + @ApiModelProperty(value = "url", required = true, example = "/platform-upms/resource/add") + private String url; + + /** + * 请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE + */ + @ApiModelProperty(value = "请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE", required = true, example = "post") + private String method; + + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/enums/AppTypeEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/AppTypeEnum.java new file mode 100644 index 0000000..2492251 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/AppTypeEnum.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.enums; + +import com.mt.wms.core.base.IEnum; + +/** + * 应用类型枚举:1、pc,2、app,3、wechat,4、miniapp + * + * @author jiff + * @date 2018/11/13 + * @since 1.0 + */ +public enum AppTypeEnum implements IEnum { + /** + * pc + */ + PC(1, "pc"), + /** + * app + */ + APP(2, "app"), + /** + * wechat公众号 + */ + WECHAT(3, "wechat"), + /** + * miniapp小程序 + */ + MINIAPP(4, "miniapp"); + + + private final Integer value; + private final String label; + private final String remark; + + AppTypeEnum(final int value, final String label) { + this(value, label, null); + } + + AppTypeEnum(final int value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public Integer getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/enums/CaptchaEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/CaptchaEnum.java new file mode 100644 index 0000000..91b56ba --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/CaptchaEnum.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.enums; + +import com.mt.wms.core.base.IEnum; + +/** + *

+ * 是、否有效枚举 + *

+ * + * @author FanYi + * @date 2018/11/8 + * @since 1.0 + */ +public enum CaptchaEnum implements IEnum { + + QT(0, "其他"), + + PATIENT_ZC(1, "患者注册"), + + PATIENT_XG(2, "患者修改密码"); + + private final Integer value; + private final String label; + private final String remark; + + CaptchaEnum(final int value, final String label) { + this(value, label, null); + } + + CaptchaEnum(final int value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public Integer getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/enums/HttpMethodEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/HttpMethodEnum.java new file mode 100644 index 0000000..74ef07f --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/HttpMethodEnum.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.enums; + +import com.mt.wms.core.base.IEnum; + +/** + * 请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE + * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +public enum HttpMethodEnum implements IEnum { + /** + * get + */ + GET("get", "get"), + /** + * head + */ + HEAD("head", "head"), + /** + * post + */ + POST("post", "post"), + /** + * patch + */ + PATCH("patch", "patch"), + /** + * delete + */ + DELETE("delete", "delete"), + /** + * options + */ + OPTIONS("options", "options"), + /** + * trace + */ + TRACE("trace", "trace"); + + + private final String value; + private final String label; + private final String remark; + + HttpMethodEnum(final String value, final String label) { + this(value, label, null); + } + + HttpMethodEnum(final String value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public String getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/enums/MenuCategoryEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/MenuCategoryEnum.java new file mode 100644 index 0000000..d225ae6 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/MenuCategoryEnum.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.enums; + +import com.mt.wms.core.base.IEnum; + +/** + * 菜单分类枚举:1、pc,2、app,3、wechat,4、miniapp + *
角色分类共用该枚举类型 + * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +public enum MenuCategoryEnum implements IEnum { + /** + * pc + */ + PC(1, "pc"), + /** + * app + */ + APP(2, "app"), + /** + * 微信公众号 + */ + WECHAT(3, "微信公众号"), + /** + * 微信小程序 + */ + MINIAPP(4, "微信小程序"); + + + private final Integer value; + private final String label; + private final String remark; + + MenuCategoryEnum(final Integer value, final String label) { + this(value, label, null); + } + + MenuCategoryEnum(final Integer value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public Integer getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/enums/MenuTypeEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/MenuTypeEnum.java new file mode 100644 index 0000000..ecaec09 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/MenuTypeEnum.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.enums; + +import com.mt.wms.core.base.IEnum; + +/** + * 菜单类型枚举:1、module,2、menu,3、button + * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +public enum MenuTypeEnum implements IEnum { + /** + * 模块 + */ + MODULE(1, "模块"), + /** + * 菜单 + */ + MENU(2, "菜单"), + /** + * 按钮 + */ + BUTTON(3, "按钮"); + + + private final Integer value; + private final String label; + private final String remark; + + MenuTypeEnum(final Integer value, final String label) { + this(value, label, null); + } + + MenuTypeEnum(final Integer value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public Integer getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/enums/OrderStatusEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/OrderStatusEnum.java new file mode 100644 index 0000000..50530d3 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/OrderStatusEnum.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.enums; + +import com.mt.wms.core.base.IEnum; + +/** + * 订单状态枚举 + */ +public enum OrderStatusEnum implements IEnum { + ORDER_INIT(0, "订单初始化"), + + ORDER_NOPAY(1, "未支付"), + + ORDER_PAYED(2, "已支付"), + + ORDER_CHECKING(3, "检验中"), + + ORDER_SUCCESS(4, "已完成"), + + ORDER_CANCEL(-1, "已取消"); + + private final Integer value; + private final String label; + private final String remark; + + + OrderStatusEnum(final int value, final String label) { + this(value, label, null); + } + + OrderStatusEnum(final int value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public Integer getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/enums/ResourceCategoryEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/ResourceCategoryEnum.java new file mode 100644 index 0000000..d2d5d0d --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/ResourceCategoryEnum.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.enums; + +import com.mt.wms.core.base.IEnum; + +/** + * 资源分类:0、common,1、pc,2、app,3、wechat,4、miniapp + * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +public enum ResourceCategoryEnum implements IEnum { + /** + * 公用 + */ + COMMON(0, "公用"), + /** + * pc + */ + PC(1, "pc"), + /** + * app + */ + APP(2, "app"), + /** + * 微信公众号 + */ + WECHAT(3, "微信公众号"), + /** + * 微信小程序 + */ + MINIAPP(4, "微信小程序"); + + + private final Integer value; + private final String label; + private final String remark; + + ResourceCategoryEnum(final Integer value, final String label) { + this(value, label, null); + } + + ResourceCategoryEnum(final Integer value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public Integer getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/enums/SceneCodeEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/SceneCodeEnum.java new file mode 100644 index 0000000..9f6a89b --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/SceneCodeEnum.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.enums; + +import com.mt.wms.core.base.IEnum; + +/** + *

+ * 场景编码枚举 + *

+ * + * @author FanYi + * @date 2018/11/8 + * @since 1.0 + */ +public enum SceneCodeEnum implements IEnum { + /** + * 验证码短信 + */ + CAPTCHA("CAPTCHA", "验证码短信"); + + private final String value; + private final String label; + private final String remark; + + SceneCodeEnum(final String value, final String label) { + this(value, label, null); + } + + SceneCodeEnum(final String value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public String getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/enums/SexEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/SexEnum.java new file mode 100644 index 0000000..ae3d1cf --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/SexEnum.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.enums; + +import com.mt.wms.core.base.IEnum; + +/** + * 性别:1、男,2、女 + * + * @author jiff + * @date 2018/11/7 + * @since 1.0 + */ +public enum SexEnum implements IEnum { + + /** + * 男 + */ + MALE(1, "男"), + /** + * 女 + */ + FEMALE(2, "女"); + + private final Integer value; + private final String label; + private final String remark; + + SexEnum(final int value, final String label) { + this(value, label, null); + } + + SexEnum(final int value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public Integer getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/enums/SmsSendTypeEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/SmsSendTypeEnum.java new file mode 100644 index 0000000..16395d1 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/SmsSendTypeEnum.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.enums; + +import com.mt.wms.core.base.IEnum; + +/** + *

+ * 短信发送类型枚举 + *

+ * + * @author FanYi + * @date 2018/11/8 + * @since 1.0 + */ +public enum SmsSendTypeEnum implements IEnum { + + QT(0, "其他"), + + ZC(1, "注册"), + + ZHMM(2, "找回密码"), + + DTMM(3, "动态密码"), + + XTTZ(9, "系统通知"); + + private final Integer value; + private final String label; + private final String remark; + + SmsSendTypeEnum(final int value, final String label) { + this(value, label, null); + } + + SmsSendTypeEnum(final int value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public Integer getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/enums/SubsystemEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/SubsystemEnum.java new file mode 100644 index 0000000..38acc94 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/SubsystemEnum.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.enums; + +import com.mt.wms.core.base.IEnum; + +/** + * 子系统:0、common,1、system,2、patient + * 用于限定维护菜单资源关系,公共资源允许所有菜单关联,其他资源只允许对应的菜单关联,如:平台菜单只允许关联到公共资源和平台资源 + * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +public enum SubsystemEnum implements IEnum { + /** + * 公用 + */ + COMMON(0, "公用"), + /** + * 平台 + */ + PLATFORM(1, "平台"); + + + private final Integer value; + private final String label; + private final String remark; + + SubsystemEnum(final Integer value, final String label) { + this(value, label, null); + } + + SubsystemEnum(final Integer value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public Integer getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/enums/UserTypeEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/UserTypeEnum.java new file mode 100644 index 0000000..fbba7d4 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/UserTypeEnum.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.enums; + +import com.mt.wms.core.base.IEnum; + +/** + * 用户类型枚举 + * + * @author jiff + * @date 2018/11/13 + * @since 1.0 + */ +public enum UserTypeEnum implements IEnum { + /** + * 系统用户 + */ + PLATFORM(1, "平台用户"), + + ; + + + private final Integer value; + private final String label; + private final String remark; + + UserTypeEnum(final int value, final String label) { + this(value, label, null); + } + + UserTypeEnum(final int value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public Integer getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/enums/WhetherEnum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/WhetherEnum.java new file mode 100644 index 0000000..3140dce --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/enums/WhetherEnum.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.enums; + +import com.mt.wms.core.base.IEnum; + +/** + *

+ * 是、否有效枚举 + *

+ * + * @author FanYi + * @date 2018/11/8 + * @since 1.0 + */ +public enum WhetherEnum implements IEnum { + + NO(0, "否"), + + YES(1, "是"); + + private final Integer value; + private final String label; + private final String remark; + + WhetherEnum(final int value, final String label) { + this(value, label, null); + } + + WhetherEnum(final int value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public Integer getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/errorcode/ApiErrorCode.java b/6.program/wms-core/src/main/java/com/mt/wms/core/errorcode/ApiErrorCode.java new file mode 100644 index 0000000..099c49c --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/errorcode/ApiErrorCode.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.errorcode; + + +import com.mt.wms.core.base.IErrorCode; + +/** + * REST API 错误码 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public enum ApiErrorCode implements IErrorCode { + + /** + * 成功 + */ + SUCCESSFUL(CODE_SUCCESSFUL, "成功"), + /** + * 失败 + */ + FAILED(CODE_FAILED, "失败"), + /** + * 无效的请求参数 + */ + INVALID_PARAMETER(CODE_INVALID_PARAMETER, "无效的请求参数"), + /** + * 数据未授权 + */ + FORBIDDEN_DATA(CODE_FORBIDDEN_DATA, "数据未授权"), + /** + * 用户已存在 + */ + USER_EXISTENT(CODE_USER_EXISTENT, "用户已存在"), + /** + * 用户不存在 + */ + USER_NON_EXISTENT(CODE_USER_NON_EXISTENT, "用户不存在"), + /** + * 用户已停用 + */ + USER_DISABLED(CODE_FAILED, "用户已停用"), + /** + * 用户不存在或密码错误 + */ + USER_NON_EXISTENT_OR_INVALID_PASSWORD(CODE_FAILED, "用户不存在或密码错误"), + /** + * 密码错误 + */ + INVALID_PASSWORD(CODE_FAILED, "密码错误"), + + /** + * 电话号码不能为空 + */ + MOBILE_IS_EMPTY(CODE_FAILED, "手机号码不能为空"), + + /** + * 用户未登录 + */ + UNAUTHORIZED(CODE_UNAUTHORIZED, "用户未登录"), + /** + * 用户未授权 + */ + FORBIDDEN(CODE_FORBIDDEN, "用户未授权"); + + private final int code; + private final String msg; + + ApiErrorCode(final int code, final String msg) { + this.code = code; + this.msg = msg; + } + + public static ApiErrorCode fromCode(int code) { + ApiErrorCode[] apiErrorCodes = ApiErrorCode.values(); + for (ApiErrorCode apiErrorCode : apiErrorCodes) { + if (apiErrorCode.getCode() == code) { + return apiErrorCode; + } + } + return SUCCESSFUL; + } + + @Override + public int getCode() { + return code; + } + + @Override + public String getMsg() { + return msg; + } + + @Override + public String toString() { + return String.format(" ErrorCode:{code=%s, msg=%s} ", code, msg); + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/exception/ApiException.java b/6.program/wms-core/src/main/java/com/mt/wms/core/exception/ApiException.java new file mode 100644 index 0000000..bc96cb1 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/exception/ApiException.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.exception; + + +import com.mt.wms.core.base.IErrorCode; + +/** + * API异常 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public class ApiException extends RuntimeException { + + /** + * 错误码 + */ + private IErrorCode errorCode; + + public ApiException(IErrorCode errorCode) { + super(errorCode.getMsg()); + this.errorCode = errorCode; + } + + public ApiException(String message) { + super(message); + } + + public ApiException(Throwable cause) { + super(cause); + } + + public ApiException(String message, Throwable cause) { + super(message, cause); + } + + public IErrorCode getErrorCode() { + return errorCode; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/handler/GlobalExceptionHandler.java b/6.program/wms-core/src/main/java/com/mt/wms/core/handler/GlobalExceptionHandler.java new file mode 100644 index 0000000..a48db2a --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/handler/GlobalExceptionHandler.java @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.handler; + +import com.mt.wms.core.errorcode.ApiErrorCode; +import com.mt.wms.core.base.IErrorCode; +import com.mt.wms.core.exception.ApiException; +import com.mt.wms.core.vo.R; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.exceptions.PersistenceException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.dao.DataAccessException; +import org.springframework.http.HttpStatus; +import org.springframework.http.converter.HttpMessageConversionException; +import org.springframework.util.StringUtils; +import org.springframework.validation.BindException; +import org.springframework.validation.BindingResult; +import org.springframework.web.HttpMediaTypeNotSupportedException; +import org.springframework.web.HttpRequestMethodNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; +import javax.validation.ElementKind; +import javax.validation.Path; +import java.util.*; + +/** + * 全局异常拦截器 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@RestControllerAdvice +@Slf4j +public class GlobalExceptionHandler { + + @Autowired + private MessageSource messageSource; + + /** + *

+ * 自定义 REST 业务异常 + *

+ * + * @param e 异常类型 + * @return 错误消息 + */ + @ExceptionHandler(value = ApiException.class) + public R apiException(ApiException e) { + IErrorCode errorCode = e.getErrorCode(); + if (null != errorCode) { + log.debug("Rest request failed, {}", errorCode.toString()); + return R.failed(errorCode); + } + log.debug("Rest request failed, {}", e.getMessage()); + return R.failed(e.getMessage()); + } + + /** + * 无注解model参数校验异常 + * + * @param e 异常类型 + * @return 错误消息 + */ + @ExceptionHandler(value = BindException.class) + public R bindException(BindException e) { + return bindingResult(e.getBindingResult()); + } + + /** + * {@link org.springframework.web.bind.annotation.RequestBody}参数校验异常 + * + * @param e 异常类型 + * @return 错误消息 + */ + @ExceptionHandler(value = MethodArgumentNotValidException.class) + public R methodArgumentNotValidException(MethodArgumentNotValidException e) { + return bindingResult(e.getBindingResult()); + } + + /** + * @param bindingResult 绑定结果 + * @return 错误消息 + */ + private R bindingResult(BindingResult bindingResult) { + if (null != bindingResult && bindingResult.hasErrors()) { + List errorMsgs = new ArrayList<>(); + List jsonList = new ArrayList<>(); + bindingResult.getFieldErrors().forEach(fieldError -> { + String message = fieldError.getDefaultMessage(); + //数据绑定错误 + if (fieldError.isBindingFailure()) { + String[] codes = fieldError.getCodes(); + if (codes != null && codes.length > 0) { + message = messageSource.getMessage(codes[0], new Object[]{fieldError.getField()}, + "参数[{0}]解析错误", LocaleContextHolder.getLocale()); + } + } + Map jsonObject = new HashMap<>(3); + jsonObject.put("name", fieldError.getField()); + jsonObject.put("msg", message); + jsonObject.put("invalidValue", fieldError.getRejectedValue()); + jsonList.add(jsonObject); + errorMsgs.add(message); + }); + return R.r(IErrorCode.CODE_INVALID_PARAMETER, StringUtils.collectionToCommaDelimitedString(errorMsgs), jsonList); + } + return R.failed(ApiErrorCode.INVALID_PARAMETER); + } + + /** + * {@link org.springframework.web.bind.annotation.RequestParam}参数校验异常 + * + * @param e 异常类型 + * @return 错误消息 + */ + @ExceptionHandler(value = ConstraintViolationException.class) + public R constraintViolationException(ConstraintViolationException e) { + Set> violations = e.getConstraintViolations(); + log.debug("violation message is {}", violations.toString()); + List violationMessages = new ArrayList<>(); + List jsonList = new ArrayList<>(); + for (ConstraintViolation violation : violations) { + StringBuilder name = new StringBuilder(); + violation.getPropertyPath().forEach((Path.Node node) -> { + if (node.getKind() == ElementKind.PARAMETER) { + name.append(node.getName()); + return; + } + }); + violationMessages.add(violation.getMessage()); + Map jsonObject = new HashMap<>(3); + jsonObject.put("name", name.toString()); + jsonObject.put("msg", violation.getMessage()); + jsonObject.put("invalidValue", violation.getInvalidValue()); + jsonList.add(jsonObject); + } + if (violationMessages.size() > 0) { + return R.r(IErrorCode.CODE_INVALID_PARAMETER, StringUtils.collectionToCommaDelimitedString(violationMessages), jsonList); + } + return R.failed(ApiErrorCode.INVALID_PARAMETER); + } + + /** + * http请求方法异常 + * + * @param e 异常类型 + * @return 错误消息 + * @see org.springframework.http.HttpMethod + */ + @ExceptionHandler(HttpRequestMethodNotSupportedException.class) + @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) + public R httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { + List jsonList = new ArrayList<>(); + Map jsonObject = new HashMap<>(3); + jsonObject.put("name", "Request Method"); + jsonObject.put("msg", e.getMessage()); + jsonObject.put("invalidValue", e.getMethod()); + jsonList.add(jsonObject); + String message = messageSource.getMessage("globalExceptionHandler.httpRequestMethodNotSupportedException", + new Object[]{StringUtils.arrayToCommaDelimitedString(e.getSupportedMethods())}, + "接口只允许[{0}]请求方法", LocaleContextHolder.getLocale()); + return R.r(IErrorCode.CODE_INVALID_PARAMETER, message, jsonList); + } + + /** + * http媒体类型异常 + * + * @param e 异常类型 + * @return 错误消息 + * @see org.springframework.http.MediaType + */ + @ExceptionHandler(HttpMediaTypeNotSupportedException.class) + @ResponseStatus(HttpStatus.UNSUPPORTED_MEDIA_TYPE) + public R httpMediaTypeNotSupportedException(HttpMediaTypeNotSupportedException e) { + List jsonList = new ArrayList<>(); + Map jsonObject = new HashMap<>(3); + jsonObject.put("name", "Content-Type"); + jsonObject.put("msg", e.getMessage()); + jsonObject.put("invalidValue", e.getContentType()); + jsonList.add(jsonObject); + String message = messageSource.getMessage("globalExceptionHandler.httpMediaTypeNotSupportedException", + new Object[]{StringUtils.collectionToCommaDelimitedString(e.getSupportedMediaTypes())}, + "接口只允许[{0}]媒体类型", LocaleContextHolder.getLocale()); + return R.r(IErrorCode.CODE_INVALID_PARAMETER, message, jsonList); + } + + /** + * http请求消息转换异常 + * + * @param e 异常类型 + * @return 错误消息 + * @see org.springframework.http.converter.HttpMessageConverter + */ + @ExceptionHandler(HttpMessageConversionException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public R httpMessageConversionException(HttpMessageConversionException e) { + List jsonList = new ArrayList<>(); + Map jsonObject = new HashMap<>(2); + jsonObject.put("name", "body"); + jsonObject.put("msg", e.getMessage()); + jsonList.add(jsonObject); + String message = messageSource.getMessage("globalExceptionHandler.httpMessageConversionException", + null, + "接口请求消息转换失败", LocaleContextHolder.getLocale()); + return R.r(IErrorCode.CODE_INVALID_PARAMETER, message, jsonList); + } + + /** + * 数据库操作异常 + * + * @param e 异常类型 + * @return 错误消息 + * @see DataAccessException + */ + @ExceptionHandler({DataAccessException.class}) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public R dataAccessException(DataAccessException e) { + log.error("数据库操作异常StackTrace:", e); + List jsonList = new ArrayList<>(); + Map jsonObject = new HashMap<>(2); + jsonObject.put("name", "database"); + jsonObject.put("msg", e.getMessage()); + jsonList.add(jsonObject); + String message = messageSource.getMessage("globalExceptionHandler.dataAccessException", + null, + "数据库操作失败", LocaleContextHolder.getLocale()); + return R.r(IErrorCode.CODE_INVALID_PARAMETER, message, jsonList); + } + + /** + * 数据库操作异常 + * + * @param e 异常类型 + * @return 错误消息 + * @see PersistenceException + */ + @ExceptionHandler({PersistenceException.class}) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public R persistenceException(PersistenceException e) { + log.error("数据库操作异常StackTrace:", e); + List jsonList = new ArrayList<>(); + Map jsonObject = new HashMap<>(2); + jsonObject.put("name", "database"); + jsonObject.put("msg", e.getMessage()); + jsonList.add(jsonObject); + String message = messageSource.getMessage("globalExceptionHandler.dataAccessException", + null, + "Mybatis数据库操作失败", LocaleContextHolder.getLocale()); + return R.r(IErrorCode.CODE_INVALID_PARAMETER, message, jsonList); + } + + /** + * 全局异常 + * + * @param e 异常 + * @return 错误消息 + */ + @ExceptionHandler(Exception.class) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public R exception(Exception e) { + /* + 系统内部异常,打印异常栈 + */ + log.error("系统内部异常StackTrace:", e); + return R.failed(ApiErrorCode.FAILED); + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/message/DingTalkMessage.java b/6.program/wms-core/src/main/java/com/mt/wms/core/message/DingTalkMessage.java new file mode 100644 index 0000000..72743ac --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/message/DingTalkMessage.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.message; + +import lombok.Data; +import lombok.ToString; + +import java.io.Serializable; + +/** + * 钉钉消息模板 + * + *

+ *

+ *  {
+ *      "msgtype": "text",
+ *      "text": {
+ *          "content": "我就是我,  @13505711314 是不一样的烟火"
+ *      },
+ *      "at": {
+ *          "atMobiles": [
+ *              "13505711314"
+ *          ],
+ *          "isAtAll": false
+ *      }
+ *  }
+ * 
+ *

+ * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@Data +@ToString +public class DingTalkMessage implements Serializable { + private String msgtype; + private TextBean text; + + @Data + public static class TextBean { + /** + * content : 服务: lis-center-gateway 状态:UP + */ + private String content; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/message/SmsMessage.java b/6.program/wms-core/src/main/java/com/mt/wms/core/message/SmsMessage.java new file mode 100644 index 0000000..aacbdd6 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/message/SmsMessage.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.message; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 短信消息模板 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@Data +public class SmsMessage implements Serializable { + /** + * 手机号 + */ + private String mobile; + /** + * 组装后的模板内容JSON字符串 + */ + private String context; + /** + * 短信通道 + */ + private String channel; + /** + * 短信类型(验证码或者通知短信) + */ + private String type; + /** + * 短信签名 + */ + private String signName; + /** + * 短信模板 + */ + private String template; + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/params/BasePageParam.java b/6.program/wms-core/src/main/java/com/mt/wms/core/params/BasePageParam.java new file mode 100644 index 0000000..39e43dd --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/params/BasePageParam.java @@ -0,0 +1,34 @@ +package com.mt.wms.core.params; + +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.groups.PageGroup; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.hibernate.validator.constraints.Range; + +import javax.validation.constraints.NotNull; + +/** + * 分页入参基础类 + * + * @author Mr.ZhangShi + * @date 2018/11/6 11:03 + */ +@Data +@EqualsAndHashCode(callSuper = false) +public class BasePageParam extends BaseParam { + @ApiModelProperty(value = "当前页", required = true, example = "1") + @NotNull(message = "页码不能为空", groups = PageGroup.class) + @Range(min = 1, message = "页码必须大于等于1") + private Integer current; + + @ApiModelProperty(value = "每页显示条数", required = true, example = "10") + @NotNull(message = "每页显示条数不能为空", groups = PageGroup.class) + @Range(min = 1, max = 1000, message = "每页显示条数范围需在1-1000之间") + private Integer size; + + @ApiModelProperty(value = "启用状态", notes = "0 、停用,1、启用", example = "1") + @Range(min = 0, max = 1, message = "启用状态只能为0或1") + private Integer enabled; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/params/DictValueParam.java b/6.program/wms-core/src/main/java/com/mt/wms/core/params/DictValueParam.java new file mode 100644 index 0000000..5b18492 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/params/DictValueParam.java @@ -0,0 +1,27 @@ +package com.mt.wms.core.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/7/6 + * @since 1.0 + */ +@ApiModel("查询字典列表入参") +@EqualsAndHashCode(callSuper = true) +@Data +public class DictValueParam extends BaseParam { + @ApiModelProperty(value = "字典类型") + @NotBlank(message = "字典类型不能为空") + private String typeCode; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/params/EnabledParam.java b/6.program/wms-core/src/main/java/com/mt/wms/core/params/EnabledParam.java new file mode 100644 index 0000000..9fc5218 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/params/EnabledParam.java @@ -0,0 +1,32 @@ +package com.mt.wms.core.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.hibernate.validator.constraints.Range; + +import javax.validation.constraints.NotNull; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/7/7 + * @since 1.0 + */ +@ApiModel("启用or禁用入参对象") +@EqualsAndHashCode(callSuper = true) +@Data +public class EnabledParam extends BaseParam { + @ApiModelProperty("业务主键ID") + @NotNull(message = "id不能为空!") + private Long id; + + @ApiModelProperty(value = "启用状态", notes = "0 、停用,1、启用", example = "1") + @Range(min = 0, max = 1, message = "启用状态只能为0或1") + private Integer enabled; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/params/IdListParam.java b/6.program/wms-core/src/main/java/com/mt/wms/core/params/IdListParam.java new file mode 100644 index 0000000..b1140d3 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/params/IdListParam.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + + +/** + * 主键列表请求参数对象 + * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel("主键列表参数对象") +public class IdListParam extends BaseParam { + @ApiModelProperty(value = "主键列表", required = true, example = "[1]", notes = "根据实际接口传递不同对象的主键列表") + @NotNull(message = "主键列表不能为空") + @Size(message = "主键列表不能为空", min = 1) + private List ids; + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/params/IdPageParam.java b/6.program/wms-core/src/main/java/com/mt/wms/core/params/IdPageParam.java new file mode 100644 index 0000000..4978427 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/params/IdPageParam.java @@ -0,0 +1,24 @@ +package com.mt.wms.core.params; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + *

+ *

+ * + * @author Mr.ZhangShi + * @version 1.0 + * @date 2020/8/4 + */ +@Data +@ApiModel("根据id查询分页入参") +public class IdPageParam extends BasePageParam { + + @NotNull(message = "主键不能为空") + @ApiModelProperty(value = "主键", required = true, example = "1", notes = "根据实际接口传递不同对象的主键") + private Long id; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/params/IdParam.java b/6.program/wms-core/src/main/java/com/mt/wms/core/params/IdParam.java new file mode 100644 index 0000000..06e381e --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/params/IdParam.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotNull; + + +/** + * 主键请求参数对象 + * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Data +@Builder +@ApiModel("主键参数对象") +public class IdParam extends BaseParam { + @NotNull(message = "主键不能为空") + @ApiModelProperty(value = "主键", required = true, example = "1", notes = "根据实际接口传递不同对象的主键") + private Long id; + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/params/JsapiSignatureParam.java b/6.program/wms-core/src/main/java/com/mt/wms/core/params/JsapiSignatureParam.java new file mode 100644 index 0000000..70ee3c4 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/params/JsapiSignatureParam.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2020. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; + +/** + *

+ * Jsapi授权入参对象 + *

+ * + * @author FanYi + * @date 2018-11-30 + * @since 1.0 + */ +@ApiModel(description = "Jsapi授权入参对象") +@Data +@Accessors(chain = true) +public class JsapiSignatureParam extends BaseParam { + @ApiModelProperty(value = "公众号的唯一标识") + @NotBlank(message = "appId不能为空") + private String appId; + /** + * 前端调用不需要填写该参数,后端服务间调用需要填写 + */ + @ApiModelProperty(value = "公众号的appSecret", hidden = true) + @NotBlank(message = "secret不能为空") + private String secret; + + @ApiModelProperty(value = "前端页面url") + @NotBlank(message = "前端页面url不能为空") + private String url; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/params/MobileParam.java b/6.program/wms-core/src/main/java/com/mt/wms/core/params/MobileParam.java new file mode 100644 index 0000000..8c5ae32 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/params/MobileParam.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + + +/** + * 手机号码请求参数对象 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel("手机号码对象") +public class MobileParam extends BaseParam { + @ApiModelProperty(value = "手机号码", required = true, example = "17621022121") + @NotBlank(message = "手机号码不能为空") + @Pattern(regexp = "^1[3456789]\\d{9}$", message = "手机号码格式不正确") + private String mobile; + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/params/SendMessageParam.java b/6.program/wms-core/src/main/java/com/mt/wms/core/params/SendMessageParam.java new file mode 100644 index 0000000..a10181d --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/params/SendMessageParam.java @@ -0,0 +1,39 @@ +package com.mt.wms.core.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/4/27 + * @since 1.0 + */ +@ApiModel("发送短信所需参数") +@EqualsAndHashCode(callSuper = true) +@Data +@Accessors(chain = true) +public class SendMessageParam extends BaseParam { + @ApiModelProperty("医院ID,若不传则使用默认模板") + private Long corpId; + + @ApiModelProperty("场景编码,业务系统根据该编码区分不同的业务场景") + @NotBlank(message = "场景编码必填!") + private String smsSceneCode; + + @ApiModelProperty("短信接收号码,支持以英文逗号分隔的形式进行批量调用,批量上限为1000个手机号码") + @NotBlank(message = "短信接收号码必填!") + private String phoneNumbers; + + @ApiModelProperty("短信模板参数值,多个按顺序,隔开,只填入参数即可会自动完成填充") + private String templateParam; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/params/SmsCaptchaParam.java b/6.program/wms-core/src/main/java/com/mt/wms/core/params/SmsCaptchaParam.java new file mode 100644 index 0000000..b3293f5 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/params/SmsCaptchaParam.java @@ -0,0 +1,33 @@ +package com.mt.wms.core.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/7/13 + * @since 1.0 + */ +@ApiModel("查询验证码是否有效入参") +@EqualsAndHashCode(callSuper = true) +@Data +public class SmsCaptchaParam extends BaseParam { + @ApiModelProperty(value = "手机号码", required = true, example = "17621022121") + @NotBlank(message = "手机号码必填!") + @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码格式不正确") + private String mobile; + + @ApiModelProperty(value = "验证码", required = true) + @NotBlank(message = "验证码必填!") + private String code; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/runner/MesApplicationRunner.java b/6.program/wms-core/src/main/java/com/mt/wms/core/runner/MesApplicationRunner.java new file mode 100644 index 0000000..7cadbd6 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/runner/MesApplicationRunner.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.runner; + +import org.springframework.beans.factory.DisposableBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.context.ApplicationContext; + +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author jiff + * @date 2019-08-27 + * @since 1.0 + */ +public class MesApplicationRunner implements ApplicationRunner, DisposableBean { + private final ApplicationContext applicationContext; + + private List initializers; + + @Autowired + public MesApplicationRunner(ApplicationContext applicationContext) { + this.applicationContext = applicationContext; + } + + @Override + public void run(ApplicationArguments args) throws Exception { + Map runnerMap = applicationContext.getBeansOfType(MesInitializer.class); + initializers = runnerMap.values().stream().sorted(Comparator.comparing(MesInitializer::order)) + .collect(Collectors.toList()); + + for (MesInitializer mesInitializer : initializers) { + mesInitializer.init(); + } + } + + @Override + public void destroy() throws Exception { + for (MesInitializer mesInitializer : initializers) { + mesInitializer.destroy(); + } + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/runner/MesInitializer.java b/6.program/wms-core/src/main/java/com/mt/wms/core/runner/MesInitializer.java new file mode 100644 index 0000000..0133d4c --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/runner/MesInitializer.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ +package com.mt.wms.core.runner; + +import java.io.Serializable; + +/** + * springboot启动之后会调用实现该接口的类的init方法,类必须注册为一个spring的bean + * + * @author jiff + * @date 2019-08-27 + * @since 1.0 + */ +public interface MesInitializer extends Serializable { + + /** + * init + * + * @throws Exception + */ + default void init() throws Exception { + } + + /** + * destroy + * + * @throws Exception + */ + default void destroy() throws Exception { + } + + /** + * order,执行顺序,数值小的先执行 + * + * @return int + */ + default int order() { + return 0; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/service/RedisService.java b/6.program/wms-core/src/main/java/com/mt/wms/core/service/RedisService.java new file mode 100644 index 0000000..3a5e0a2 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/service/RedisService.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2020. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.service; + +/** + * @author jiff + * @date 2019-07-20 + * @since 1.0 + */ +public interface RedisService { + /** + * @param key + * @param value + */ + void set(String key, String value); + + /** + * @param key + * @param value + * @param expired 过期时间,单位秒 + */ + void set(String key, String value, long expired); + + /** + * @param key + * @param value 不能为null,使用json方式存储 + */ + void set(String key, Object value); + + /** + * @param key + * @param value 不能为null,使用json方式存储 + * @param expired 过期时间,单位秒 + */ + void set(String key, Object value, long expired); + + /** + * @param key + * @return + */ + String get(String key); + + T get(String key, Class clazz); + + boolean containsKeyPattern(String keyPattern); + + boolean hasKey(String key); + + boolean del(String key); + + long getExpire(String key); +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/service/impl/RedisServiceImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/service/impl/RedisServiceImpl.java new file mode 100644 index 0000000..f684f4b --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/service/impl/RedisServiceImpl.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2020. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.service.impl; + +import com.alibaba.fastjson.JSON; +import com.mt.wms.core.service.RedisService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +/** + * @author jiff + * @date 2019-07-20 + * @since 1.0 + */ +@Service +public class RedisServiceImpl implements RedisService { + public static final int EXPIRED_TIME = 54000; + + private RedisTemplate redisTemplate; + + private String namespace; + + public RedisTemplate getRedisTemplate() { + return this.redisTemplate; + } + + @Autowired(required = false) + public void setRedisTemplate(RedisTemplate redisTemplate) { + RedisSerializer stringSerializer = new StringRedisSerializer(); + //设置序列化Key的实例化对象 + redisTemplate.setKeySerializer(stringSerializer); + //设置序列化Value的实例化对象 + redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); + redisTemplate.setHashKeySerializer(stringSerializer); + redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer()); + redisTemplate.setStringSerializer(stringSerializer); + redisTemplate.afterPropertiesSet(); + this.redisTemplate = redisTemplate; + } + + public String getNamespace() { + return this.namespace; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + private String queryKey(String key) { + if (StringUtils.isEmpty(key)) { + throw new IllegalArgumentException("Redis key is null!"); + } + return key; + } + + @Override + public void set(String key, String value) { + key = queryKey(key); + ValueOperations ops = redisTemplate.opsForValue(); + ops.set(key, value); + } + + @Override + public void set(String key, String value, long expired) { + key = queryKey(key); + ValueOperations ops = redisTemplate.opsForValue(); + ops.set(key, value, expired, TimeUnit.SECONDS); + } + + @Override + public void set(String key, Object value) { + if (value == null) { + throw new IllegalArgumentException("Object is null!"); + } + key = queryKey(key); + ValueOperations ops = redisTemplate.opsForValue(); + ops.set(key, JSON.toJSONString(value)); + } + + @Override + public void set(String key, Object value, long expired) { + if (value == null) { + throw new IllegalArgumentException("Object is null!"); + } + key = queryKey(key); + ValueOperations ops = redisTemplate.opsForValue(); + ops.set(key, JSON.toJSONString(value), expired, TimeUnit.SECONDS); + } + + @Override + public T get(String key, Class clazz) { + return JSON.parseObject(get(key), clazz); + } + + @Override + public String get(String key) { + return (String) redisTemplate.opsForValue().get(queryKey(key)); + } + + @Override + public boolean containsKeyPattern(String key) { + key = queryKey(key); + Set keys = redisTemplate.keys(key + "*"); + return !CollectionUtils.isEmpty(keys); + } + + @Override + public boolean hasKey(String key) { + key = queryKey(key); + return redisTemplate.hasKey(key).booleanValue(); + } + + @Override + public long getExpire(String key) { + key = queryKey(key); + return redisTemplate.getExpire(key).longValue(); + } + + @Override + public boolean del(String key) { + key = queryKey(key); + return redisTemplate.delete(key); + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/AES.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/AES.java new file mode 100644 index 0000000..8ab8de2 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/AES.java @@ -0,0 +1,82 @@ +package com.mt.wms.core.utils; + +import java.security.AlgorithmParameters; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Security; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import org.bouncycastle.jce.provider.BouncyCastleProvider; + +/** + *

+ *

+ * + * @author Mr.ZhangShi + * @version 1.0 + * @date 2020/10/9 + */ +public class AES { + + public static boolean initialized = false; + + /** + * AES解密 + * + * @param content + * 密文 + * @return + * @throws InvalidAlgorithmParameterException + * @throws NoSuchProviderException + */ + public byte[] decrypt(byte[] content, byte[] keyByte, byte[] ivByte) throws InvalidAlgorithmParameterException { + initialize(); + try { + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding"); + Key sKeySpec = new SecretKeySpec(keyByte, "AES"); + // 初始化 + cipher.init(Cipher.DECRYPT_MODE, sKeySpec, generateIV(ivByte)); + byte[] result = cipher.doFinal(content); + return result; + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (NoSuchPaddingException e) { + e.printStackTrace(); + } catch (InvalidKeyException e) { + e.printStackTrace(); + } catch (IllegalBlockSizeException e) { + e.printStackTrace(); + } catch (BadPaddingException e) { + e.printStackTrace(); + } catch (NoSuchProviderException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + public static void initialize() { + if (initialized) + return; + Security.addProvider(new BouncyCastleProvider()); + initialized = true; + } + + // 生成iv + public static AlgorithmParameters generateIV(byte[] iv) throws Exception { + AlgorithmParameters params = AlgorithmParameters.getInstance("AES"); + params.init(new IvParameterSpec(iv)); + return params; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/BarcodeUtil.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/BarcodeUtil.java new file mode 100644 index 0000000..dfc5b60 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/BarcodeUtil.java @@ -0,0 +1,87 @@ +package com.mt.wms.core.utils; + + +import org.apache.commons.lang.StringUtils; +import org.krysalis.barcode4j.impl.code39.Code39Bean; +import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider; +import org.krysalis.barcode4j.tools.UnitConv; + +import java.awt.image.BufferedImage; +import java.io.*; + +/** + * 条形码生成工具类 + */ +public class BarcodeUtil { + + /** + * 生成文件 + * + * @param msg 条形码 + * @param path 生成文件位置 + * @return + */ + public static File generateFile(String msg, String uploadPath, String path) { + File file = new File(uploadPath); + if (!file.exists()) { + // 目录不存在则创建 + file.mkdirs(); + } + + try { + generate(msg, new FileOutputStream(new File(path))); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + return file; + } + + /** + * 生成字节 + * + * @param msg 条形码 + * @return + */ + public static byte[] generate(String msg) { + ByteArrayOutputStream ous = new ByteArrayOutputStream(); + generate(msg, ous); + return ous.toByteArray(); + } + + /** + * 生成到流 + * + * @param msg 条形码 + * @param ous 生成的流 + */ + public static void generate(String msg, OutputStream ous) { + if (StringUtils.isEmpty(msg) || ous == null) { + return; + } + Code39Bean bean = new Code39Bean(); + // 精细度 + final int dpi = 150; + // module宽度 + final double moduleWidth = UnitConv.in2mm(1.0f / dpi); + // 配置对象 + bean.setModuleWidth(moduleWidth); + bean.setWideFactor(3); + bean.doQuietZone(false); + + String format = "image/png"; + try { + + // 输出到流 + BitmapCanvasProvider canvas = new BitmapCanvasProvider(ous, format, dpi, + BufferedImage.TYPE_BYTE_BINARY, false, 0); + // 生成条形码 + bean.generateBarcode(canvas, msg); + + // 结束绘制 + canvas.finish(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/BeanUtils.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/BeanUtils.java new file mode 100644 index 0000000..6a9d9b5 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/BeanUtils.java @@ -0,0 +1,67 @@ +package com.mt.wms.core.utils; + +import com.alibaba.fastjson.JSON; +import com.mt.wms.core.exception.ApiException; +import org.springframework.util.CollectionUtils; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +import static java.util.stream.Collectors.toList; + +/** + * Bean 工具类 + */ +public class BeanUtils { + /** + * 使用{@link org.springframework.beans.BeanUtils#copyProperties(Object, Object, String...)}拷贝 + * + * @param list 源对象列表 + * @param targetClass 目标对象类型 + * @param ignoreProperties 忽略字段 + * @param 源对象 + * @param 目标对象 + * @return 目标对象列表 + */ + public static List copyList(List list, Class targetClass, String... ignoreProperties) { + if (CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + return list.stream().map((t) -> { + try { + R r; + //如果包含builder方法则为使用lombok.Builder注解的类,该注解只在编译期间有效,编译后的class中无法获取该注解 + try { + Method builder = targetClass.getDeclaredMethod("builder"); + Object invoke = builder.invoke(null, null); + r = (R) invoke.getClass().getDeclaredMethod("build").invoke(invoke); + } catch (NoSuchMethodException e) { + r = targetClass.newInstance(); + } + org.springframework.beans.BeanUtils.copyProperties(t, r, ignoreProperties); + return r; + } catch (Exception e) { + e.printStackTrace(); + throw new ApiException("对象拷贝异常"); + } + }).collect(toList()); + } + + /** + * 使用{@link JSON#parseArray(String, Class)}拷贝 + * + * @param list 源对象列表 + * @param targetClass 目标对象类型 + * @param 源对象 + * @param 目标对象 + * @return 目标对象列表 + */ + public static List copyListWithJson(List list, Class targetClass) { + if (CollectionUtils.isEmpty(list)) { + return new ArrayList<>(); + } + return JSON.parseArray(JSON.toJSONString(list), targetClass); + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/ByteAndHex.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/ByteAndHex.java new file mode 100644 index 0000000..1c1f162 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/ByteAndHex.java @@ -0,0 +1,64 @@ +package com.mt.wms.core.utils; + +/** + * @Author wangzheng + * @Date 2019-11-30 + * @since 1.1 + */ +public class ByteAndHex { + /** + * 字节数组转16进制 + * + * @param bytes 需要转换的byte数组 + * @return 转换后的Hex字符串 + */ + public static String bytesToHex(byte[] bytes) { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < bytes.length; i++) { + String hex = Integer.toHexString(bytes[i] & 0xFF); + if (hex.length() < 2) { + sb.append(0); + } + sb.append(hex); + } + return sb.toString(); + } + + /** + * hex字符串转byte数组 + * + * @param inHex 待转换的Hex字符串 + * @return 转换后的byte数组结果 + */ + public static byte[] hexToBytes(String inHex) { + int hexlen = inHex.length(); + byte[] result; + if (hexlen % 2 == 1) { + //奇数 + hexlen++; + result = new byte[(hexlen / 2)]; + inHex = "0" + inHex; + } else { + //偶数 + result = new byte[(hexlen / 2)]; + } + int j = 0; + for (int i = 0; i < hexlen; i += 2) { + result[j] = hexToByte(inHex.substring(i, i + 2)); + j++; + } + return result; + } + + + /** + * Hex字符串转byte + * + * @param inHex 待转换的Hex字符串 + * @return 转换后的byte + */ + public static byte hexToByte(String inHex) { + return (byte) Integer.parseInt(inHex, 16); + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java new file mode 100644 index 0000000..521cdab --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.utils; + +/** + *

+ * 编号生成帮助类 + * 以2+8+6形式生成(2位编号类型前缀+8位年月日+6位自增序列号 ) + * 2位编号类型前缀定义如下⤵ + * 1x:患者相关编号以 '1' 开头,(病例号:10 ) + * 2x:订单相关编号以 '2' 开头,如订单编号=20 + * 3x: 支付相关编号以 '3' 开头,如系统内部支付订单号=30 + * (未完待续...) + *

+ * + * @author FanYi + * @date 2019-01-03 + * @since 1.0 + */ +public class CodeGeneratorHelper { + + /** + * 订单编号 + */ + public static final String ORDER_CODE = "ORDER_CODE"; + + + /** + * 生成订单编号 + * + * @return 订单编号 + */ + public static String getOrderCode() { + return IDGenerator.gen("20", "yyyyMMdd", 6, ORDER_CODE); + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/DateUtil.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/DateUtil.java new file mode 100644 index 0000000..ff21471 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/DateUtil.java @@ -0,0 +1,1213 @@ +package com.mt.wms.core.utils; + +import com.mt.wms.core.base.IErrorCode; +import org.apache.commons.collections.map.HashedMap; +import org.apache.commons.lang3.StringUtils; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.*; + +/** + *

Title:跟时间有关的便利方法 DateUtil.java

+ */ +public class DateUtil { + /** + * 一秒中的等价毫秒数 + */ + public static final long SECOND = 1000; + /** + * 一分钟的等价毫秒数 + */ + public static final long MINUTE = 60 * SECOND; + /** + * 一小时的等价毫秒数 + */ + public static final long HOUR = 60 * MINUTE; + /** + * 一天的等价毫秒数 + */ + public static final long DAY = 24 * HOUR; + /** + * 半小时的等价毫秒数 + */ + public static final long HALF_HOUR = HOUR / 2; + + /** + * 格式化日期(yyyyMM) + */ + public static final String MONTH_DATEPATTERN = "yyyyMM"; + + /** + * 格式化日期(yyyyMMdd) + */ + public static final String SHORT_DATEPATTERN = "yyyyMMdd"; + /** + * 格式化日期(yyyy-MM-dd hh:mm:ss) + */ + public static final String DEFAULT_DATEPATTERN = "yyyy-MM-dd hh:mm:ss"; + /** + * 格式化日期(yyyy-MM-dd HH:mm:ss) + */ + public static final String DEFAULT_DATESFM = "yyyy-MM-dd HH:mm:ss"; + /** + * 格式化日期(yyyy-MM-dd HH:mm) + */ + public static final String DEFAULT_MINUS = "yyyy-MM-dd HH:mm"; + /** + * 格式化日期(yyyy-MM-dd) + */ + public static final String SAMPLE_DATEPATTERN = "yyyy-MM-dd"; + + public static final String YEAR_DATEPATTERN = "yyyy"; + /** + * 格式化日期(yyyyMMdd) + */ + public static final String SHORT_DATE_PATTERN = "yyyyMMdd"; + /** + * 格式化日期(yyyy年MM月dd日) + */ + public static final String SHORT_CHAR_DATE_PATTERN = "yyyy年MM月dd日"; + /** + * 格式化日期(HHmmss) + */ + public static final String StR_PATTERN_HHMMSS = "HHmmss"; + /** + * 格式化时间(HH:mm:ss) + */ + public static final String StR_PATTERN_HHMMSS1 = "HH:mm:ss"; + public static final String StR_ISO8601 = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + /** + * 格式:yyyyMMdd,8位 + */ + public static final String PATTERN_NUM_DATE = "yyyyMMdd"; + /** + * 格式:yyyyMMddHHmmss,14位 + */ + public static final String PATTERN_NUM_SEC = "yyyyMMddHHmmss"; + /** + * 格式:yyyyMMddHHmmssSSS,17位 + */ + public static final String PATTERN_NUM_MS = "yyyyMMddHHmmssSSS"; + + public static final String PATTERN_NUM_MS_ELSE = "yyyy/MM/dd HH:mm:ss"; + /** + * 格式化日期(yyyyMMddHHmmss) + */ + public static String STR_PATTERN = "yyyyMMddHHmmss"; + + public DateUtil() { + } + + public static String defaultFormat(Date date) { + return new SimpleDateFormat(SAMPLE_DATEPATTERN).format(date); + } + + /** + * 获取今天凌晨的0分0秒这个时间 + */ + public static Date getDayBegin() { + + Calendar c = Calendar.getInstance(); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + c.set(Calendar.MILLISECOND, 0); + return c.getTime(); + } + + public static boolean isTowTimeAvailable(LocalDateTime time1,LocalDateTime time2){ + if(time1 == null || time2 == null){ + return false; + } + if(time1.compareTo(time2)>0 ){ + return false; + } + return true; + } + + /** + * 获取昨天凌晨的0分0秒这个时间 + */ + public static Date getYesterdayDayBegin() { + + Calendar c = Calendar.getInstance(); + c.add(Calendar.DAY_OF_MONTH, -1); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + return c.getTime(); + } + + /** + * 获取指定日期凌晨的0分0秒这个时间 + * + * @param date + * @return + */ + public static Date getBegin(Date date) { + String dateStr = DateUtil.shortDateString(date, SHORT_DATE_PATTERN); + Date dayBegin = DateUtil.shortStringToDate(dateStr, SHORT_DATE_PATTERN); + return dayBegin; + } + + /** + * 判断是否是周末。是则返回true,否则返回false + */ + public static boolean isWeekEnd() { + Calendar cal = Calendar.getInstance(); + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { + return true; + } + return false; + } + + /** + * 判断是否是星期一,是则返回true,否则返回false + */ + public static boolean isWeekStart() { + Calendar cal = Calendar.getInstance(); + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) { + return true; + } + return false; + } + + /** + * 判断是否是一号,是则返回true,否则返回false + */ + public static boolean isMonthStart() { + Calendar cal = Calendar.getInstance(); + if (cal.get(Calendar.DAY_OF_MONTH) == 1) { + return true; + } + return false; + } + + /** + * 判断是否是月末,是则返回true,否则返回false + */ + public static boolean isMonthEnd() { + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.DAY_OF_MONTH, 1); + if (cal.get(Calendar.DAY_OF_MONTH) == 1) { + return true; + } + return false; + } + + /** + * @return 返回明天凌晨0点0分0秒 + */ + public static Date getNextDay() { + return getNextHour(0); + } + + /** + * @return 返回指定时间(x点整)最靠近的时间, 如果今天已经过了那个时间, 则返回明天的那个时间 + * 否则返回今天的那个整点时间 + */ + public static Date getNextHour(int hour) { + return getNextTime(hour, 0); + } + + /** + * @param hour 几点 + * @param min 几分 + * @return 获得指定时间(x点y分)最靠近的时间, 如果今天已经过了那个时间, 则返回明天的那个时间 + * 否则返回今天的那个时间 + */ + public static Date getNextTime(int hour, int min) { + Calendar calendar = Calendar.getInstance(); + if (calendar.get(Calendar.HOUR_OF_DAY) > hour) { + calendar.add(Calendar.DATE, 1); + } else if (calendar.get(Calendar.HOUR_OF_DAY) == hour && + calendar.get(Calendar.MINUTE) >= min) { + calendar.add(Calendar.DATE, 1); + } + + calendar.set(Calendar.HOUR_OF_DAY, hour); + calendar.set(Calendar.MINUTE, min); + calendar.set(Calendar.SECOND, 0); + return calendar.getTime(); + } + + /** + * 获取指定的日期 + * + * @param year 年 + * @param month 月 + * @param day 日 + * @param hour 小时 + * @param min 分 + * @return + */ + public static Date getTime(int year, int month, int day, int hour, int min) { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.YEAR, year); + calendar.set(Calendar.MONTH, month - 1); + calendar.set(Calendar.DATE, day); + calendar.set(Calendar.HOUR_OF_DAY, hour); + calendar.set(Calendar.MINUTE, min); + calendar.set(Calendar.SECOND, 0); + return calendar.getTime(); + } + + /** + * 获取月初的时间 + * + * @return + */ + public static Date getMonthBenin() { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.DATE, 1); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + return calendar.getTime(); + } + + /** + * 获取当前月份+month月初时间,时间为 00:00:00 + * + * @return + */ + public static Date getNextMonthBeginTime(int month) { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, month); + calendar.set(Calendar.DAY_OF_MONTH, 0); + calendar.set(Calendar.HOUR, 12); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + return calendar.getTime(); + } + + /** + * 获取相继几天的时间 + * + * @param before + * @return + */ + public static Date getDayBefore(int before) { + return getDayBefore(null, before); + } + + public static Date getDayBefore(Date date, int before) { + Calendar calendar = Calendar.getInstance(); + if (date != null) { + calendar.setTime(date); + } + + calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - before); + return calendar.getTime(); + } + + /** + * 获取date之前或之后number天的日期 + * + * @param date + * @param number 正数 当前日期之后 负数:当前日期之前 + * @return + */ + public static Date getAfterOrBeforeDay(Date date, int number) { + Calendar calendar = Calendar.getInstance(); + if (date != null) { + calendar.setTime(date); + } + calendar.add(Calendar.DAY_OF_MONTH, number); + return calendar.getTime(); + } + + /** + * 获取当前日期之前或之后number天的日期 + * + * @param date + * @param number 正数 当前日期之后 负数:当前日期之前 + * @return + */ + public static Date getAfterOrBeforeDay(int number) { + return getAfterOrBeforeDay(new Date(), number); + } + + public static String shortDateString(Date date) { + if (date == null) { + return ""; + } + SimpleDateFormat sdf = new SimpleDateFormat(SAMPLE_DATEPATTERN); + return sdf.format(date); + } + + /** + * 按照格式返回日期字符串 + * + * @param date + * @param format (如:yyyyMMdd ) + * @return + */ + public static String shortDateString(Date date, String format) { + if (date == null) { + return ""; + } + SimpleDateFormat sdf = new SimpleDateFormat(format); + return sdf.format(date); + } + + /** + * 根据时间字串和格式化标准进行格式化 + * + * @param dateStr {String} 时间字串 + * @param format {String} 格式化标准 【exam:'yyyy-MM-dd hh:mm:ss'】 + * @return {java.util.Date} + */ + public static Date shortStringToDate(String dateStr, String format) { + Date date = null; + + if (null == dateStr) { + date = new Date(); + } else { + try { + SimpleDateFormat sdf = new SimpleDateFormat(format); + date = sdf.parse(dateStr); + } catch (ParseException e) { + e.printStackTrace(); + } + } + return date; + } + + public static Date shortStringToDate(String dateStr) { + return shortStringToDate(dateStr, SAMPLE_DATEPATTERN); + } + + public static Date shortStringToDateFormat(String dateStr, String format) { + return shortStringToDate(dateStr, format); + } + + /** + * 将不同类型的日期格式转成yyyy-MM-dd格式字符串 + * + * @param date + * @param format (如:yyyyMMdd ) + * @return + */ + public static String shortDateString(String date, String format) { + if (date == null) { + return ""; + } +// SimpleDateFormat sdf = new SimpleDateFormat(format); + return shortDateString(shortStringToDate(date, format)); + } + + /** + * 计算2个日期的间隔的秒数 + * + * @param d1 + * @param d2 + * @return + */ + public static long elapsedSecond(Date d1, Date d2) { + long d = Math.abs(d1.getTime() - d2.getTime()); + return d / 1000; + } + + /** + * 计算2个日期间隔的分钟数 + * + * @param d1 + * @param d2 + * @return + */ + public static long elapsedMinute(Date d1, Date d2) { + return elapsedSecond(d1, d2) / 60; + } + + /** + * 计算2个日期间隔的小时数 + * + * @param d1 + * @param d2 + * @return + */ + public static long elapsedhour(Date d1, Date d2) { + return elapsedMinute(d1, d2) / 60; + } + + public static long elapsedMonth(Date d1, Date d2) { + return elapsedDay(d1, d2) / 30; + } + + /** + * 计算2个日期间隔的天数 + * + * @param d1 + * @param d2 + * @return + */ + public static int elapsedDay(Date d1, Date d2) { + return (int) elapsedhour(d1, d2) / 24; + } + + /** + * 计算2个日期间隔的年数 + * + * @param d1 + * @param d2 + * @return + */ + public static Double elapsedYear(Date d1, Date d2) { + return new Double(elapsedDay(d1, d2) / 365.0); + } + + /** + * 获取当前月-number的日期 + * + * @param number + * @return + */ + public static Date getDateBeforeOfMonth(int number) { + Calendar now = Calendar.getInstance(); + now.setTime(new Date()); + now.set(Calendar.MONTH, now.get(Calendar.MONTH) - number); + return now.getTime(); + } + + public static String simpleFormat(Date date) { + return new SimpleDateFormat(SHORT_DATE_PATTERN).format(date); + } + + /** + * 获取当前月-number的日期 + * + * @param number + * @return + */ + public static Date getDateBeforeOfMonth(Date date, int number) { + Calendar now = Calendar.getInstance(); + now.setTime(date); + now.set(Calendar.MONTH, now.get(Calendar.MONTH) - number); + return now.getTime(); + } + + /** + * 获取当前月+number的日期 + * + * @param month + * @return + */ + public static Date getDateAfterOfMonth(int month) { + Calendar now = Calendar.getInstance(); + now.setTime(new Date()); + now.set(Calendar.MONTH, now.get(Calendar.MONTH) + month); + return now.getTime(); + } + + /** + * 获取月+number的日期 + * + * @param month + * @return + */ + public static Date getDateAfterOfMonth(Date date, int month) { + Calendar now = Calendar.getInstance(); + now.setTime(date); + now.set(Calendar.MONTH, now.get(Calendar.MONTH) + month); + return now.getTime(); + } + + /** + * 获取当前年+number的日期 + * + * @param year + * @return + */ + public static Date getDateAfterOfYear(int year) { + Calendar now = Calendar.getInstance(); + now.setTime(new Date()); + now.set(Calendar.YEAR, now.get(Calendar.YEAR) + year); + return now.getTime(); + } + + /** + * 获取年+number的日期 + * + * @param year + * @return + */ + public static Date getDateAfterOfYear(Date date, int year) { + Calendar now = Calendar.getInstance(); + now.setTime(date); + now.set(Calendar.YEAR, now.get(Calendar.YEAR) + year); + return now.getTime(); + } + + /** + * 获得2个日期之间的时间间隔 + * + * @param da1(起始日期 格式:yyyy yyyyMM yyyyMMdd) + * @param da2(截止日期) + * @return + */ + public static String getTimeBetweenDates(String da1, String da2) { + String str = ""; + if (StringUtils.isEmpty(da1) || StringUtils.isEmpty(da2) || !StringUtils.isNumeric(da1) || !StringUtils.isNumeric(da2) || "19000101".equals(da1)) { + return "--"; + } + Date now = new Date(); + int years = 0; + int months = 0; + if (da1.length() == 4 || da2.length() == 4) { + String dateStr1 = da1.substring(0, 4); + String dateStr2 = da2.substring(0, 4); + years = Integer.valueOf(dateStr2) - Integer.valueOf(dateStr1); + str = years + "年"; + } else if (da1.length() == 6 || da2.length() == 6) { + String yearStr1 = da1.substring(0, 4); + String yearStr2 = da2.substring(0, 4); + years = Integer.valueOf(yearStr2) - Integer.valueOf(yearStr1); + String monthStr1 = da1.substring(4, 6); + String monthStr2 = da2.substring(4, 6); + months = Integer.valueOf(monthStr2) - Integer.valueOf(monthStr1); + if (months < 0) { + years = years - 1; + months = months + 12; + } + if (years > 0) { + str = years + "年"; + } + if (months > 0) { + str = str + months + "月"; + } + } else { + str = getTimeBetweenDates(shortStringToDate(da1, "yyyyMMdd"), shortStringToDate(da2, "yyyyMMdd")); + } + return str; + } + //LocalDateTime -> Date + public static Date asDate(LocalDateTime localDateTime) { + return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + } + + /** + * 验证两个时间段是否存在交集 + * leftStart 选中开始时间 + * leftEnd 选中结束时间 + * + * rightStart 待比较开始时间 + * rightEnd 待比较结束时间 + * + * return true (存在交集) + * return false (不存在交集) + * + * */ + public static boolean timeCoincides(LocalDateTime leftStart,LocalDateTime leftEnd,LocalDateTime rightStart,LocalDateTime rightEnd){ + + /* 开始时间 */ + Date leftStartDate = asDate(leftStart); + /* 结束时间 */ + Date leftEndDate = asDate(leftEnd); + /*比较的时间段*/ + Date rightStartDate = asDate(rightStart); + Date rightEndDate = asDate(rightEnd); + /*判断*/ + if (((leftStartDate.getTime() >= rightStartDate.getTime()) + && leftStartDate.getTime() < rightEndDate.getTime()) + || ((leftStartDate.getTime() > rightStartDate.getTime()) + && leftStartDate.getTime() <= rightEndDate.getTime()) + || ((rightStartDate.getTime() >= leftStartDate.getTime()) + && rightStartDate.getTime() < leftEndDate.getTime()) + || ((rightStartDate.getTime() > leftStartDate.getTime()) + && rightStartDate.getTime() <= leftEndDate.getTime())) { + return true; + } + return false; + } + + /** + * 获得2个日期之间的时间间隔(如:1年124天) + * + * @param da1 + * @param da2 + * @return + */ + public static String getTimeBetweenDates(Date da1, Date da2) { + String str = ""; + if (da1 == null || da2 == null || "19000101".equals(da1)) { + return "--"; + } + if (da1.getTime() > da2.getTime()) { + return getTimeBetweenDates(da2, da1); + } else { + int year1 = da1.getYear(); + int year2 = da2.getYear(); + if (year1 == year2) { + int days = elapsedDay(da1, da2); + str = days + "天"; + } else { + int years = year2 - year1 - 1; + Date date1 = new Date(); + date1.setYear(da1.getYear()); + date1.setMonth(11); + date1.setDate(31); + int days1 = elapsedDay(da1, date1); + Date date2 = new Date(); + date2.setYear(da2.getYear()); + date2.setMonth(0); + date2.setDate(1); + int days2 = elapsedDay(date2, da2) + 1; + int days = days1 + days2; + if (days >= 365) { + days = days - 365; + years++; + } + if (years > 0) { + str = years + "年"; + } + if (days > 0) { + str = str + days + "天"; + } + + } + + } + return str; + } + + /** + * 获取前几个季度的日期 + * + * @return + */ + public static List getQuarter(int length, int number) { + List list = new ArrayList(); + String[] dateStr = {"0331", "0630", "0930", "1231"}; + Calendar cal = Calendar.getInstance(); + int year = cal.get(Calendar.YEAR); + int quarter = cal.get(Calendar.MONTH) / 3 + 1; + quarter = quarter - number; + //jack change 2012.1.4 + while (quarter <= 0) { + quarter = quarter + 4; + year = year - 1; + } + + for (int i = 0; i < length; i++) { + if (quarter == 1) { + quarter = 4; + year -= 1; + } else { + quarter -= 1; + } + list.add(year + dateStr[quarter - 1]); + } + return list; + } + + /** + * 取上季度末日期 + * + * @param quarterDay + * @return + */ + public static String getLastQuarterDay(String quarterDay) { + if ("0331".equals(quarterDay.substring(4))) { + int year = Integer.valueOf(quarterDay.substring(0, 4)).intValue(); + return String.valueOf(year - 1) + "1231"; + } else if ("0630".equals(quarterDay.substring(4))) { + return quarterDay.substring(0, 4) + "0331"; + } else if ("0930".equals(quarterDay.substring(4))) { + return quarterDay.substring(0, 4) + "0630"; + } else if ("1231".equals(quarterDay.substring(4))) { + return quarterDay.substring(0, 4) + "0930"; + } + return null; + } + + + /** + * 计算年龄 + * + * @param birthday 生日日期 + * @return {int} + */ + public static int getAge(Date birthday) { + Calendar cal = Calendar.getInstance(); + String date = getDateTimeByPattern(SHORT_DATE_PATTERN); + Date currentDate = strToDate(date); + if (currentDate.before(birthday)) { + throw new IllegalArgumentException( + "出生日期大于当前时间!"); + } + int yearNow = cal.get(Calendar.YEAR); + int monthNow = cal.get(Calendar.MONTH) + 1; + int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH); + cal.setTime(birthday); + int yearBirth = cal.get(Calendar.YEAR); + int monthBirth = cal.get(Calendar.MONTH) + 1; + int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH); + int age = yearNow - yearBirth; + if (monthNow <= monthBirth) { + if (monthNow == monthBirth) { + if (dayOfMonthNow < dayOfMonthBirth) { + age--; + } + } else { + age--; + } + } + return age; + } + + /** + * @param datePattern + * @return + */ + public static String formatNowDate(String datePattern) { + if (datePattern == null) { + datePattern = "yyyy-MM-dd"; + } + SimpleDateFormat df = new SimpleDateFormat(datePattern); + return df.format(new Date()); + } + + public static String thisYearStart() { + Calendar cal = Calendar.getInstance(); + String date = cal.get(Calendar.YEAR) + "0101"; + return date; + } + + + /** + * 得到日期的前或者后几小时 + * + * @param iHour 如果要获得前几小时日期,该参数为负数; + * 如果要获得后几小时日期,该参数为正数 + * @return Date 返回参数curDate定义日期的前或者后几小时 + * @see Calendar#add(int, int) + */ + public static Date getDateBeforeOrAfterHours(Date curDate, int iHour) { + Calendar cal = Calendar.getInstance(); + if (curDate != null) { + cal.setTime(curDate); + } + cal.add(Calendar.HOUR_OF_DAY, iHour); + return cal.getTime(); + } + + public static List financeQuaterList(String year) { + List list = new ArrayList(); + list.add(year + "0331"); + list.add(year + "0630"); + list.add(year + "0930"); + list.add(year + "1231"); + return list; + } + + //获得周五的日期 + public static Date getFriday(Date date) { + Calendar c = Calendar.getInstance(); + c.setTime(date); + c.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY); + return c.getTime(); + } + + /** + * 时间转换 + * + * @param d + * @param fmt + * @return + */ + public static Date parseDate(String d, String fmt) { + SimpleDateFormat sdf = new SimpleDateFormat(fmt); + try { + return sdf.parse(d); + } catch (ParseException e) { + e.printStackTrace(); + return null; + } + } + + public static Date addDay(Date date, int day) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + day); + return calendar.getTime(); + } + + /** + * 获取相继几天的时间 + * + * @param before + * @return + */ + public static Date getDayBofore(int before) { + return getDayBofore(null, before); + } + + public static Date getDayBofore(Date date, int before) { + Calendar calendar = Calendar.getInstance(); + if (date != null) { + calendar.setTime(date); + } + + calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - before); + return calendar.getTime(); + } + + /** + * 得到日期的前或者后几分钟 + * + * @param min 如果要获得前几分钟时间,该参数为负数; + * 如果要获得后几分钟时间,该参数为正数 + * @return Date 返回参数curDate定义日期的前或者后几分钟 + * @see Calendar#add(int, int) + */ + public static Date getDateBeforeOrAfterMinute(Date curDate, int min) { + Calendar cal = Calendar.getInstance(); + if (curDate != null) { + cal.setTime(curDate); + } + cal.add(Calendar.MINUTE, min); + return cal.getTime(); + } + + /** + * 得到日期的前或者后几秒钟 + * + * @param second 如果要获得前几秒钟时间,该参数为负数; + * 如果要获得后几秒钟时间,该参数为正数 + * @return Date 返回参数curDate定义日期的前或者后几秒钟 + * @see Calendar#add(int, int) + */ + public static Date getDateBeforeOrAfterSecond(Date curDate, int second) { + Calendar cal = Calendar.getInstance(); + if (curDate != null) { + cal.setTime(curDate); + } + cal.add(Calendar.SECOND, second); + return cal.getTime(); + } + + /** + * 得到当前的的年 + * + * @return 当前的年 + */ + public static int getCurrentYear() { + Calendar calendar = Calendar.getInstance(); + return calendar.get(Calendar.YEAR); + } + + /** + * 根据日期得到当前季度数 + * + * @param date format yyyyMMdd + * @return 1:一季度;2:二季度;3:三季度;4:四季度 ;0:无 + */ + public static int getSeasonNum(String date) { + String month = date.substring(4, 6); + if ("01".equals(month) || "02".equals(month) || "03".equals(month)) { + return 1; + } else if ("04".equals(month) || "05".equals(month) || "06".equals(month)) { + return 2; + } else if ("07".equals(month) || "08".equals(month) || "09".equals(month)) { + return 3; + } else if ("10".equals(month) || "11".equals(month) || "12".equals(month)) { + return 4; + } + return 0; + } + + /** + * 取得某个年份某个季度的季末日期 + * + * @param year 年份 + * @param season 季度数 + * @return 季末日期,如果无,返回null + */ + public static String getSeasonEndDate(int year, int season) { + if (season == 1) { + return year + "0331"; + } else if (season == 2) { + return year + "0630"; + } else if (season == 3) { + return year + "0930"; + } else if (season == 4) { + return year + "1231"; + } + + return null; + } + + /** + * 根据日期取得当前季度季末日期 + * + * @param date format: yyyyMMdd + * @return String 若无,返回null + */ + public static String getCurSeasonEndDate(String date) { + String year = date.substring(0, 4); + String month = date.substring(4, 6); + if ("01".equals(month) || "02".equals(month) || "03".equals(month)) { + return year + "0331"; + } else if ("04".equals(month) || "05".equals(month) || "06".equals(month)) { + return year + "0630"; + } else if ("07".equals(month) || "08".equals(month) || "09".equals(month)) { + return year + "0930"; + } else if ("10".equals(month) || "11".equals(month) || "12".equals(month)) { + return year + "1231"; + } + return null; + } + + /** + * Return an ISO 8601 combined date and time string for specified date/time + * + * @param date Date + * @return String with format "yyyy-MM-dd'T'HH:mm:ss'Z'" + */ + public static String getISO8601StringFromDate(Date date) { + DateFormat dateFormat = new SimpleDateFormat(StR_ISO8601, Locale.US); + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + return dateFormat.format(date); + } + + + public static String dateToString(Date date) { + DateFormat dateFormat = new SimpleDateFormat(DEFAULT_MINUS, Locale.US); + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + return dateFormat.format(date); + } + + /** + * 获取当前时间,精确到秒 + * 时间格式为yyyyMMddHHmmss + * + * @return String + * 精确到秒的当前时间 + */ + public static String getCurrentDateTime() { + return getDateTimeByPattern(PATTERN_NUM_SEC); + } + + public static String getCurrentDateTimeElse() { + return getDateTimeByPattern(DEFAULT_DATESFM); + } + + public static String getDateTimeElse() { + return getDateTimeByPattern(SHORT_DATEPATTERN); + } + + public static void main(String[] args) { + System.out.println(getDateTimeElse()); + } + public static String getCurrentDateTimeNow() { + return getDateTimeByPattern(SAMPLE_DATEPATTERN); + } + + public static String getCurrentDate() { + return getDateTimeByPattern(SHORT_DATE_PATTERN); + } + + public static String getCurrentMonth() { + return getDateTimeByPattern(MONTH_DATEPATTERN); + } + + public static String getCurrentYearElse() { + return getDateTimeByPattern(YEAR_DATEPATTERN); + } + + /** + * 获取当前时间,精确到毫秒 + * 时间格式为yyyyMMddHHmmssSSS + * + * @return String + * 精确到毫秒的当前时间 + */ + public static String getCurrentDateTimeMs() { + return getDateTimeByPattern(PATTERN_NUM_MS); + } + + /** + * 依据传入的时间格式获取当前时间 + * 比如传入的是yyyyMMdd,则获取的是精确到天的当前时间 + * 比如传入的是yyyyMMddHHmmss,则获取的是精确到秒的当前时间 + * + * @param pattern 时间格式字符串 + * @return String + * 符合要求的时间 + */ + public static String getDateTimeByPattern(String pattern) { + SimpleDateFormat sdf = new SimpleDateFormat(pattern); + return sdf.format(new Date()); + } + + /* + * 获取当前时间的前一天 + */ + public static Date getBeforeDate(Date date) { + Date dNow = new Date(); //当前时间 + Date dBefore = new Date(); + Calendar calendar = Calendar.getInstance(); //得到日历 + calendar.setTime(dNow);//把当前时间赋给日历 + calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天 + dBefore = calendar.getTime(); //得到前一天的时间 + return dBefore; + } + + public static String getDate(Date date) { + return new SimpleDateFormat(SHORT_DATE_PATTERN).format(date); + } + + /** + * 把yyyymmdd的字符串转化为yyyy-mm-dd格式的日期 + * + * @param str + * @return + */ + public static Date strToDate(String str) { + if (null == str || "".equals(str) || str.length() < 1) { + return new Date(); + } + StringBuffer sb = new StringBuffer(); + String y = str.substring(0, 4); + String m = str.substring(4, 6); + String d = str.substring(6, 8); + sb.append(y).append("-").append(m).append("-").append(d); + return shortStringToDate(sb.toString()); + } + + /** + * TODO 获取当月的第一天或最后一天 + * + * @param a=0,b=1 当月第一天 + * @param a=1,b=0 当月最后一天 + * @return + * @author lsy + * 2017年2月28日 上午10:49:31 + */ + public static String monthFirstOrLast(int a, int b) { + Calendar cale = Calendar.getInstance(); + cale.add(Calendar.MONTH, a); + cale.set(Calendar.DAY_OF_MONTH, b); + return shortDateString(cale.getTime()); + } + + + // 计算天数 + public static int dateBetween(Date early, Date late) { + Calendar calst = Calendar.getInstance(); + Calendar caled = Calendar.getInstance(); + calst.setTime(early); + caled.setTime(late); + // 设置时间为0时 + calst.set(Calendar.HOUR_OF_DAY, 0); + calst.set(Calendar.MINUTE, 0); + calst.set(Calendar.SECOND, 0); + caled.set(Calendar.HOUR_OF_DAY, 0); + caled.set(Calendar.MINUTE, 0); + caled.set(Calendar.SECOND, 0); + // 得到两个日期相差的天数 + int days = ((int) (caled.getTime().getTime() / 1000) - (int) (calst.getTime().getTime() / 1000)) / 3600 / 24; + return days; + } + + public static int daysBetween(String smdate, String bdate) throws Exception { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Calendar cal = Calendar.getInstance(); + cal.setTime(sdf.parse(smdate)); + long time1 = cal.getTimeInMillis(); + cal.setTime(sdf.parse(bdate)); + long time2 = cal.getTimeInMillis(); + long between_days = (time2 - time1) / (1000 * 3600 * 24); + + return Integer.parseInt(String.valueOf(between_days)); + } + + /** + * 判断两个时间段是否存在公共部门 + * + * @param bto + * @param oto + * @param sto + * @param edo + * @return + */ + public static Map getAlphalDate(String bto, String oto, String sto, String edo) throws Exception { + Map map = new HashedMap(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + // 标准时间 + Date bt = sdf.parse(bto); + Date ot = sdf.parse(oto); + // 目标时间 + Date st = sdf.parse(sto); + Date ed = sdf.parse(edo); + long btlong = Math.min(bt.getTime(), ot.getTime());// 开始时间 + long otlong = Math.max(bt.getTime(), ot.getTime());// 结束时间 + long stlong = Math.min(st.getTime(), ed.getTime());// 开始时间 + long edlong = Math.max(st.getTime(), ed.getTime());// 结束时间 + // 具体算法如下 + // 首先看是否有包含关系 + if ((stlong >= btlong && stlong <= otlong) || (edlong >= btlong && edlong <= otlong)) { + // 一定有重叠部分 + long sblong = stlong >= btlong ? stlong : btlong; + long eblong = otlong >= edlong ? edlong : otlong; + map.put("success", "true"); + map.put("startTime", sdf.format(sblong)); + map.put("endTime", sdf.format(eblong)); + } else { + map.put("success", "false"); + } + return map; + } + + /** + * 获取月末时间 + * + * @param time + * @return + * @throws Exception + */ + public static String getMaxMonthDate(String time) throws Exception { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(dateFormat.parse(time)); + calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); + return dateFormat.format(calendar.getTime()); + } + + /** + * 获取某年第一天日期 + * + * @param year 年份 + * @return Date + */ + public static Date getYearFirst(int year) { + Calendar calendar = Calendar.getInstance(); + calendar.clear(); + calendar.set(Calendar.YEAR, year); + Date currYearFirst = calendar.getTime(); + return currYearFirst; + } + + /** + * 获取某年最后一天日期 + * + * @param year 年份 + * @return Date + */ + public static Date getYearLast(int year) { + Calendar calendar = Calendar.getInstance(); + calendar.clear(); + calendar.set(Calendar.YEAR, year); + calendar.roll(Calendar.DAY_OF_YEAR, -1); + Date currYearLast = calendar.getTime(); + + return currYearLast; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/ExcelExportUtil.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/ExcelExportUtil.java new file mode 100644 index 0000000..2d4591b --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/ExcelExportUtil.java @@ -0,0 +1,164 @@ +package com.mt.wms.core.utils; + +import cn.afterturn.easypoi.excel.ExcelImportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.ImportParams; +import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; +import com.mt.wms.core.exception.ApiException; +import org.apache.poi.ss.usermodel.Workbook; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.List; + +/** + *

+ * Excel导出工具类 + *

+ * + * @author Mr.ZhangShi + * @date 2019/3/7 + * @since 1.0 + */ +public class ExcelExportUtil { + + private static String[] IEBrowserSignals = {"MSIE", "Trident", "Edge"}; + + /** + * 判断是否是IE浏览器 + * + * @param request + * @return + */ + public static boolean isMSBrowser(HttpServletRequest request) { + String userAgent = request.getHeader("User-Agent"); + for (String signal : IEBrowserSignals) { + if (userAgent.contains(signal)) return true; + } + return false; + } + + + /** + * 03版本Excel导出 + * + * @param title + * @param sheet + * @param pojoClass + * @param datas + * @param response + */ + public static void exportHssfExcel(String title, String sheet, Class pojoClass, Collection datas, HttpServletRequest request, HttpServletResponse response) { + Workbook workbook = cn.afterturn.easypoi.excel.ExcelExportUtil.exportExcel(new ExportParams(title, sheet, ExcelType.HSSF), pojoClass, datas); + try { + response.setContentType("APPLICATION/OCTET-STREAM"); + response.setHeader("Content-disposition", "attachment;filename=" + getNormalCodeFileName("数据导出结果.xls", request)); + write(workbook, response.getOutputStream()); + } catch (IOException var4) { + var4.printStackTrace(); + } + } + + /** + * 07版本Excel导出 + * + * @param title + * @param sheet + * @param pojoClass + * @param datas + * @param response + */ + public static void exportXssfExcel(String title, String sheet, Class pojoClass, Collection datas, HttpServletRequest request, HttpServletResponse response) { + Workbook workbook = cn.afterturn.easypoi.excel.ExcelExportUtil.exportExcel(new ExportParams(title, sheet, ExcelType.XSSF), pojoClass, datas); + try { + response.setContentType("APPLICATION/OCTET-STREAM"); + response.setHeader("Content-disposition", "attachment;filename=" + getNormalCodeFileName("数据导出结果.xlsx", request)); + write(workbook, response.getOutputStream()); + } catch (IOException var4) { + var4.printStackTrace(); + } + } + + /** + * @Description: 导出没有表名的excel + * @Param: [title, sheet, pojoClass, datas, request, response] + * @return: void + * @Author: tqq + * @Date: 2019/9/23 15:31 + */ + public static void exportXssfExcelNotT(String title, String sheet, Class pojoClass, Collection datas, HttpServletRequest request, HttpServletResponse response) { + ExportParams exportParams = new ExportParams(); + exportParams.setCreateHeadRows(true); + // exportParams.setTitle(title); + exportParams.setSheetName(sheet); + exportParams.setType(ExcelType.XSSF); + Workbook workbook = cn.afterturn.easypoi.excel.ExcelExportUtil.exportExcel(exportParams, pojoClass, datas); + try { + response.setContentType("APPLICATION/OCTET-STREAM"); + response.setHeader("Content-disposition", "attachment;filename=" + getNormalCodeFileName("数据导出结果.xlsx", request)); + write(workbook, response.getOutputStream()); + } catch (IOException var4) { + var4.printStackTrace(); + } + } + + public static String getNormalCodeFileName(String fileName, HttpServletRequest request) { + try { + if (isMSBrowser(request)) { + + fileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()); + } else { + fileName = new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); + } + } catch (UnsupportedEncodingException e) { + throw new ApiException(e); + } + return fileName; + } + + + public static List importExcel(String filePath, Integer titleRows, Integer headerRows, Class pojoClass) { + if (StringUtils.isBlank(filePath)) { + return null; + } + try { + ImportParams params = new ImportParams(); + params.setTitleRows(titleRows); + params.setHeadRows(headerRows); + List list = null; + list = ExcelImportUtil.importExcel(new File(filePath), pojoClass, params); + return list; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static void write(Workbook wb, OutputStream out) { + try { + if (null != out) { + wb.write(out); + out.flush(); + } + } catch (IOException var11) { + var11.printStackTrace(); + } finally { + if (null != out) { + try { + out.close(); + } catch (IOException var10) { + var10.printStackTrace(); + } + } + + } + + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/ExcelImportUtil.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/ExcelImportUtil.java new file mode 100644 index 0000000..bce384a --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/ExcelImportUtil.java @@ -0,0 +1,139 @@ +package com.mt.wms.core.utils; + +import cn.afterturn.easypoi.excel.entity.ImportParams; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.InputStream; +import java.util.List; +import java.util.NoSuchElementException; + +/** + *

+ * excel导入工具类 + *

+ * + * @author Mr.ZhangShi + * @version 1.0 + * @date 2019/10/17 + */ +public class ExcelImportUtil { + + /** + * excel默认文件导入 + * @param file 文件 + * @param pojoClass 导出实体的class + * @param + * @return + */ + public static List importExcel(File file, Class pojoClass) { + return importExcel(file, pojoClass, 0, 1, 0, 0, 1, false, false, null); + } + + /** + * excel默认流导入 + * @param inputstream 流 + * @param pojoClass 导出实体的class + * @param + * @return + * @throws Exception + */ + public static List importExcel(InputStream inputstream, Class pojoClass) throws Exception { + return importExcel(inputstream, pojoClass, 0, 1, 0, 0, 1, false, false, null); + } + + /** + * excel文件导入 + * @param file 文件 + * @param pojoClass 导出实体的class + * @param titleRows 表格标题行数,默认0 + * @param headRows 表头行数,默认1 + * @param startRows 字段真正值和列标题之间的距离 默认0 + * @param startSheetIndex 开始读取的sheet位置,默认为0 + * @param sheetNum 上传表格需要读取的sheet 数量,默认为1 + * @param needSave 是否需要保存上传的Excel + * @param needVerify 是否需要校验上传的Excel + * @param saveUrl 保存上传的Excel目录 + * @param + * @return + */ + public static List importExcel(File file, Class pojoClass, int titleRows, int headRows, int startRows, int startSheetIndex, int sheetNum, boolean needSave, boolean needVerify, + String saveUrl) { + ImportParams params = new ImportParams(); + params.setTitleRows(titleRows); + params.setHeadRows(headRows); + params.setStartRows(startRows); + params.setStartSheetIndex(startSheetIndex); + params.setSheetNum(sheetNum); + params.setNeedSave(needSave); + params.setNeedVerify(needVerify); + params.setSaveUrl(saveUrl); + return cn.afterturn.easypoi.excel.ExcelImportUtil.importExcel(file, pojoClass, params); + } + + /** + * excel文件导入 + * @param file 文件 + * @param titleRows 表格标题行数,默认0 + * @param headerRows 表头行数,默认1 + * @param startSheetNum 开始读取的sheet位置,默认为0,,第一sheet是从0开始的 + * @param sheetNum 上传表格需要读取的sheet 数量,默认为1 + * @param pojoClass 导出实体的class + * @param + * @return + */ + public static List importExcel(MultipartFile file, + Integer titleRows, + Integer headerRows, + Integer startSheetNum, + Integer sheetNum, + Class pojoClass) { + if (file == null) { + return null; + } + ImportParams params = new ImportParams(); + params.setTitleRows(titleRows); + params.setHeadRows(headerRows); + params.setStartSheetIndex(startSheetNum); + params.setSheetNum(sheetNum); + params.setKeyIndex(null); + List list = null; + try { + list = cn.afterturn.easypoi.excel.ExcelImportUtil.importExcel(file.getInputStream(), pojoClass, params); + } catch (NoSuchElementException e) { + throw new RuntimeException("excel文件不能为空"); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + return list; + } + + /** + * excel流导入 + * @param inputstream 流 + * @param pojoClass 导出实体的class + * @param titleRows 表格标题行数,默认0 + * @param headRows 表头行数,默认1 + * @param startRows 字段真正值和列标题之间的距离 默认0 + * @param startSheetIndex 开始读取的sheet位置,默认为0 + * @param sheetNum 上传表格需要读取的sheet 数量,默认为1 + * @param needSave 是否需要保存上传的Excel + * @param needVerify 是否需要校验上传的Excel + * @param saveUrl 保存上传的Excel目录 + * @param + * @return + */ + public static List importExcel(InputStream inputstream, Class pojoClass, int titleRows, int headRows, int startRows, int startSheetIndex, int sheetNum, boolean needSave, boolean needVerify, + String saveUrl) throws Exception{ + ImportParams params = new ImportParams(); + params.setTitleRows(titleRows); + params.setHeadRows(headRows); + params.setStartRows(startRows); + params.setStartSheetIndex(startSheetIndex); + params.setSheetNum(sheetNum); + params.setNeedSave(needSave); + params.setNeedVerify(needVerify); + params.setSaveUrl(saveUrl); + return cn.afterturn.easypoi.excel.ExcelImportUtil.importExcel(inputstream, pojoClass, params); + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/FileUtil.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/FileUtil.java new file mode 100644 index 0000000..286bb29 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/FileUtil.java @@ -0,0 +1,206 @@ +package com.mt.wms.core.utils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.*; + +/** + * Created by cnpc on 2016/12/9. + * e-mail:jrn1012@petrochina.com.cn qq:475572229 + */ +public class FileUtil { + + private static Logger logger = LoggerFactory.getLogger(FileUtil.class); + + /** + * 删除文件夹里面的所有文件 + * + * @param path 文件夹路径 如 c:/fqf + */ + public static void delAllFile(String path) { + File file = new File(path); + if (!file.exists()) { + return; + } + if (!file.isDirectory()) { + return; + } + String[] tempList = file.list(); + File temp = null; + for (int i = 0; i < tempList.length; i++) { + if (path.endsWith(File.separator)) { + temp = new File(path + tempList[i]); + } else { + temp = new File(path + File.separator + tempList[i]); + } + if (temp.isFile()) { + temp.delete(); + } + if (temp.isDirectory()) { + // 先删除文件夹里面的文件 + delAllFile(path + "/" + tempList[i]); + // 再删除空文件夹 + delFolder(path + "/" + tempList[i]); + } + } + } + + /** + * 删除文件夹 + * + * @param folderPath 文件夹路径及名称 如c:/fqf + */ + public static void delFolder(String folderPath) { + try { + // 删除完里面所有内容 + delAllFile(folderPath); + String filePath = folderPath; + filePath = filePath.toString(); + File myFilePath = new File(filePath); + // 删除空文件夹 + myFilePath.delete(); + + } catch (Exception e) { + e.printStackTrace(); + + } + } + + /** + * 复制单个文件 + * + * @param oldPath 源文件路径 + * @param newPath 复制后路径 + * @return 文件大小 + */ + public static int copyFile(String oldPath, String newPath) { + try { + int bytesum = 0; + int byteread = 0; + File oldfile = new File(oldPath); + if (oldfile.exists()) { + //读入原文件 + InputStream inStream = new FileInputStream(oldPath); + FileOutputStream fs = new FileOutputStream(newPath); + byte[] buffer = new byte[1444]; + int length; + while ((byteread = inStream.read(buffer)) != -1) { + //字节数 文件大小 + bytesum += byteread; + System.out.println(bytesum); + fs.write(buffer, 0, byteread); + } + inStream.close(); + fs.close(); + } + return bytesum; + } catch (Exception e) { + System.out.println("复制单个文件操作出错"); + e.printStackTrace(); + return 0; + } + } + + /** + * 复制文件流到新的文件 + * + * @param inStream 文件流 + * @param file 新文件 + * @return 是否复制成功 + */ + public static boolean copyInputStreamToFile(final InputStream inStream, File file) throws IOException { + int bytesum = 0; + int byteread = 0; + byte[] buffer = new byte[1024]; + FileOutputStream fs = new FileOutputStream(file); + while ((byteread = inStream.read(buffer)) != -1) { + //字节数 文件大小 + bytesum += byteread; + fs.write(buffer, 0, byteread); + } + inStream.close(); + fs.close(); + return true; + } + + /** + * 删除指定路径下的文件 + * + * @param filePathAndName 文件路径 + */ + public static void delFile(String filePathAndName) { + try { + String filePath = filePathAndName; + filePath = filePath.toString(); + File myDelFile = new File(filePath); + if (myDelFile.exists()) { + myDelFile.delete(); + } + + } catch (Exception e) { + logger.error("删除文件操作出错"); + e.printStackTrace(); + } + + } + + /** + * 文件重命名 + * + * @param path 文件目录 + * @param oldname 原来的文件名 + * @param newname 新文件名 + */ + public static void renameFile(String path, String oldname, String newname) { + if (!oldname.equals(newname)) { + //新的文件名和以前文件名不同时,才有必要进行重命名 + File oldfile = new File(path + "/" + oldname); + File newfile = new File(path + "/" + newname); + if (!oldfile.exists()) { + //重命名文件不存在 + return; + } + //若在该目录下已经有一个文件和新文件名相同,则不允许重命名 + if (newfile.exists()) { + logger.info(newname + "已经存在!"); + } else { + oldfile.renameTo(newfile); + } + } else { + logger.info("新文件名和旧文件名相同..."); + } + } + + /** + * Java文件操作 获取文件扩展名 + * + * @param filename + * @return String + */ + public static String getExtensionName(String filename) { + if ((filename != null) && (filename.length() > 0)) { + int dot = filename.lastIndexOf('.'); + if ((dot > -1) && (dot < (filename.length() - 1))) { + return filename.substring(dot + 1); + } + } + return filename; + } + + /** + * Java文件操作 获取不带扩展名的文件名 + * + * @param filename + * @return String + */ + public static String getFileNameNoEx(String filename) { + if ((filename != null) && (filename.length() > 0)) { + int dot = filename.lastIndexOf('.'); + if ((dot > -1) && (dot < (filename.length()))) { + return filename.substring(0, dot); + } + } + return filename; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java new file mode 100644 index 0000000..917f248 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java @@ -0,0 +1,130 @@ +/** + * Copyright (C) 2016-2017 Hangzhou Elabcare Co. Ltd. + * All right reserved. + * + * @author: Simon.lee + * date: 2017-09-26 14:43 + */ +package com.mt.wms.core.utils; + +import okhttp3.*; +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContexts; +import org.apache.http.ssl.TrustStrategy; +import org.apache.http.util.EntityUtils; + +import javax.net.ssl.SSLContext; +import java.io.IOException; +import java.nio.charset.Charset; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +/** + * 使用 OKhttp 请求 Api 数据 + */ +public class HttpClient { + + private static final MediaType JSON = MediaType.parse("application/json;charset=utf-8"); + + public static String httpGet(String url) throws IOException { + OkHttpClient httpClient = new OkHttpClient(); + Request request = new Request.Builder() + .url(url) + .build(); + Response response = httpClient.newCall(request).execute(); + // 返回的是string 类型,json的mapper可以直接处理 + return response.body().string(); + } + + public static String httpPost(String url, String json) throws IOException { + OkHttpClient httpClient = new OkHttpClient(); + RequestBody requestBody = RequestBody.create(JSON, json); + Request request = new Request.Builder() + .url(url) + .post(requestBody) + .build(); + Response response = httpClient.newCall(request).execute(); + return response.body().string(); + } + + public static String httpPost(String postUrl, String soapXml, String token) throws Exception { + String retStr = ""; + // 创建HttpClientBuilder + HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); + // HttpClient + CloseableHttpClient closeableHttpClient = httpClientBuilder.build(); + HttpPost httpPost = new HttpPost(postUrl); + httpPost.setHeader("Content-type", "application/json; charset=utf-8"); + if (StringUtils.isNotEmpty(token)) { + httpPost.setHeader("X-Authorization", "Bearer " + token); + httpPost.setHeader("x-requested-with", "XMLHttpRequest"); + } + StringEntity data = new StringEntity(soapXml, + Charset.forName("UTF-8")); + httpPost.setEntity(data); + CloseableHttpResponse response = closeableHttpClient + .execute(httpPost); + HttpEntity httpEntity = response.getEntity(); + if (httpEntity != null) { + // 打印响应内容 + retStr = EntityUtils.toString(httpEntity, "UTF-8"); + } + // 释放资源 + closeableHttpClient.close(); + return StringEscapeUtils.unescapeHtml4(retStr); + } + + public static String httpExpressPost(String postUrl, String soapXml, String token) throws Exception { + String retStr = ""; + // 创建HttpClientBuilder + HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); + // HttpClient + CloseableHttpClient closeableHttpClient = getIgnoeSSLClient(); + HttpPost httpPost = new HttpPost(postUrl); + httpPost.setHeader("Content-type", "application/json; charset=utf-8"); + httpPost.setHeader("token", token); + StringEntity data = new StringEntity(soapXml, + Charset.forName("UTF-8")); + httpPost.setEntity(data); + CloseableHttpResponse response = closeableHttpClient + .execute(httpPost); + HttpEntity httpEntity = response.getEntity(); + if (httpEntity != null) { + // 打印响应内容 + retStr = EntityUtils.toString(httpEntity, "UTF-8"); + } + // 释放资源 + closeableHttpClient.close(); + return StringEscapeUtils.unescapeHtml4(retStr); + } + + /** + * 获取忽略证书验证的client + * + * @return + * @throws Exception + */ + + public static CloseableHttpClient getIgnoeSSLClient() throws Exception { + SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() { + @Override + public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { + return true; + } + }).build(); + + //创建httpClient + CloseableHttpClient client = HttpClients.custom().setSSLContext(sslContext). + setSSLHostnameVerifier(new NoopHostnameVerifier()).build(); + return client; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/IDGenerator.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/IDGenerator.java new file mode 100644 index 0000000..8855792 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/IDGenerator.java @@ -0,0 +1,213 @@ +package com.mt.wms.core.utils; + +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * id生成器,使用redis自增接口实现 + * TODO 待完善 + * + * @author jiff + * @date 2018-12-1 + * @since 1.0 + */ +@Component +public class IDGenerator { + private RedisTemplate redisTemplate; + private static IDGenerator idGenerator; + + /** + * 4位年格式 + */ + public static final String PATTERN_YYYY = "yyyy"; + /** + * 6位年月格式 + */ + public static final String PATTERN_YYYYMM = "yyyyMM"; + /** + * 8位年月日格式 + */ + public static final String PATTERN_YYYYMMDD = "yyyyMMdd"; + /** + * 10位年月日时格式 + */ + public static final String PATTERN_YYYYMMDDHH = "yyyyMMddHH"; + /** + * 12位年月日时分格式 + */ + public static final String PATTERN_YYYYMMDDHHMM = "yyyyMMddHHmm"; + + + /** + * 最大序列号长度 + */ + private static final int MAX_SEQUENCE_LENGTH = 20; + /** + * 最大随机数长度 + */ + private static final int MAX_RANDOM_LENGTH = 10; + /** + * 序列命名空间 + */ + private static final String KEY_PREFIX_SEQUENCE = "SEQUENCE_"; + private static final Map commonDateFormats = new HashMap<>(); + private static final List sequenceFormats = new ArrayList<>(); + + static { + commonDateFormats.put(PATTERN_YYYY, new SimpleDateFormat(PATTERN_YYYY)); + commonDateFormats.put(PATTERN_YYYYMM, new SimpleDateFormat( + PATTERN_YYYYMM)); + commonDateFormats.put(PATTERN_YYYYMMDD, new SimpleDateFormat( + PATTERN_YYYYMMDD)); + commonDateFormats.put(PATTERN_YYYYMMDDHH, new SimpleDateFormat( + PATTERN_YYYYMMDDHH)); + commonDateFormats.put(PATTERN_YYYYMMDDHHMM, new SimpleDateFormat( + PATTERN_YYYYMMDDHHMM)); + StringBuilder sequencePattern = new StringBuilder(MAX_SEQUENCE_LENGTH); + for (int i = 0; i < MAX_SEQUENCE_LENGTH; i++) { + sequencePattern.append("0"); + sequenceFormats.add(new DecimalFormat(sequencePattern.toString())); + } + } + + @Autowired(required = false) + public void setRedisTemplate(RedisTemplate redisTemplate) { + RedisSerializer stringSerializer = new StringRedisSerializer(); + //设置序列化Key的实例化对象 + redisTemplate.setKeySerializer(stringSerializer); + //设置序列化Value的实例化对象 + redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); + redisTemplate.setHashKeySerializer(stringSerializer); + redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer()); + redisTemplate.setStringSerializer(stringSerializer); + redisTemplate.afterPropertiesSet(); + this.redisTemplate = redisTemplate; + } + + @PostConstruct + private void init() { + idGenerator = this; + idGenerator.redisTemplate = this.redisTemplate; + } + + /** + * 生成主键 + * + * @param sequenceName 序列名 + * @return 主键 + */ + public static long gen(String sequenceName) { + return idGenerator.redisTemplate.opsForValue().increment( + KEY_PREFIX_SEQUENCE + sequenceName, 1); + } + + /** + * 生成主键 + * + * @param prefix 前缀,为空或null时则不使用前缀 + * @param pattern 时间戳格式,为空或null时不使用时间戳,已定义5种格式:{@link #PATTERN_YYYY}、{@link #PATTERN_YYYYMM}、{@link #PATTERN_YYYYMMDD}、{@link #PATTERN_YYYYMMDDHH}、{@link #PATTERN_YYYYMMDDHHMM}、 + * @param sequenceLength 序列长度,大于0时有效,否则使用序列原始值,最多{@value #MAX_SEQUENCE_LENGTH}位,超过{@value #MAX_SEQUENCE_LENGTH}默认为{@value #MAX_SEQUENCE_LENGTH}位 + * @param sequenceName 序列名,为空或null时则不生成序列值 + * @return prefix+timestamp+sequence + */ + public static String gen(String prefix, String pattern, int sequenceLength, + String sequenceName) { + return gen(prefix, pattern, sequenceLength, sequenceName, 0); + } + + /** + * 生成主键 + * + * @param prefix 前缀,为空或null时则不使用前缀 + * @param pattern 时间戳格式,为空或null时不使用时间戳,已定义5种格式:{@link #PATTERN_YYYY}、{@link #PATTERN_YYYYMM}、{@link #PATTERN_YYYYMMDD}、{@link #PATTERN_YYYYMMDDHH}、{@link #PATTERN_YYYYMMDDHHMM}、 + * @param sequenceLength 序列长度,大于0时有效,否则使用序列原始值,最多{@value #MAX_SEQUENCE_LENGTH}位,超过{@value #MAX_SEQUENCE_LENGTH}默认为{@value #MAX_SEQUENCE_LENGTH}位 + * @param sequenceName 序列名,为空或null时则不生成序列值 + * @param randomLength 随机数长度,大于0时有效,最多{@value #MAX_RANDOM_LENGTH}位,超过{@value #MAX_RANDOM_LENGTH}默认为{@value #MAX_RANDOM_LENGTH}位 + * @return prefix+timestamp+sequence+random + */ + public static String gen(String prefix, String pattern, int sequenceLength, + String sequenceName, int randomLength) { + StringBuilder ids = new StringBuilder(); + if (!isEmpty(prefix)) { + ids.append(prefix); + } + String timestamp = null; + if (!isEmpty(pattern)) { + timestamp = getFormattedDate(pattern); + } + if (timestamp != null) { + ids.append(timestamp); + } + if (!isEmpty(sequenceName)) { + long sequence = gen(sequenceName); + if (sequenceLength > 0) { + if (sequenceLength > MAX_SEQUENCE_LENGTH) { + sequenceLength = MAX_SEQUENCE_LENGTH; + } + String formatSequence = sequenceFormats.get(sequenceLength - 1) + .format(sequence); + if (formatSequence.length() > sequenceLength) { + formatSequence = formatSequence.substring(formatSequence + .length() - sequenceLength); + } + ids.append(formatSequence); + } else { + ids.append(sequence); + } + } + //随机数长度大于0时添加随机数 + if (randomLength > 0) { + String random = RandomStringUtils.randomNumeric(randomLength); + ids.append(random); + } + return ids.toString(); + } + + private static String getFormattedDate(String pattern) { + SimpleDateFormat sdf = commonDateFormats.get(pattern); + if (sdf == null) { + try { + sdf = new SimpleDateFormat(pattern); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (sdf == null) { + return null; + } + java.util.Date now = new java.util.Date(); + return sdf.format(now); + } + + private static boolean isEmpty(String str) { + if (str == null || str.trim().isEmpty()) { + return true; + } + return false; + } + + public static void main(String[] args) { + for (int i = 0; i < 100; i++) { + System.out.println(RandomStringUtils.randomNumeric(1)); + System.out.println(RandomStringUtils.randomNumeric(2)); + System.out.println(RandomStringUtils.randomNumeric(4)); + } + System.out.println(new DecimalFormat("00").format(103)); + System.out.println(new DecimalFormat("000").format(13)); + + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/IPAddressParseUtil.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/IPAddressParseUtil.java new file mode 100644 index 0000000..313523f --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/IPAddressParseUtil.java @@ -0,0 +1,209 @@ +package com.mt.wms.core.utils; + +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSONException; +import com.alibaba.fastjson.JSONObject; +import lombok.Data; + +import javax.servlet.http.HttpServletRequest; +import java.io.*; +import java.net.URL; +import java.nio.charset.Charset; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + *

+ * ip地址解析工具类 + *

+ * + * @author Mr.ZhangShi + * @date 2019/1/22 + * @since 1.0 + */ +public class IPAddressParseUtil { + + /** + * 百度地图AK + */ + private final static String BAIDU_DI_TU_AK = "nbnrq7DlVZTXffRVPEUeKpiqzqelCkjB"; + + /** + * 获取真实ip地址 + * + * @param request + * @return + */ + public static String getIpAddr(HttpServletRequest request) { + String ip = request.getHeader("x-forwarded-for"); + if (!checkIP(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (!checkIP(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (!checkIP(ip)) { + ip = request.getHeader("X-Real-IP"); + } + if (!checkIP(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (!checkIP(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (!checkIP(ip)) { + ip = request.getRemoteAddr(); + } + return ip; + } + + private static boolean checkIP(String ip) { + if (ip == null || ip.length() == 0 || "unkown".equalsIgnoreCase(ip) + || ip.split(".").length != 4) { + return false; + } + return true; + } + + /** + * 根据request获取地理位置信息 + * + * @param request + * @return 返回地址信息对象 + * @throws JSONException + * @throws IOException + */ + public static Address getAddress(HttpServletRequest request) throws JSONException, IOException { + return getAddress(HttpUtil.getClientIP(request)); + } + + public static String getProvince(String IP) throws JSONException, IOException { + //这里调用百度的ip定位api服务 详见 http://api.map.baidu.com/lbsapi/cloud/ip-location-api.htm + JSONObject json = readJsonFromUrl("http://api.map.baidu.com/location/ip?ak=" + BAIDU_DI_TU_AK + "&ip=" + IP); + String status = json.get("status").toString(); + if (!"0".equals(status)) { + return null; + } + return ((JSONObject) ((JSONObject) json.get("content")).get("address_detail")).get("province").toString(); + } + + /** + * 根据ip地址获取地理位置信息 + * + * @param ip + * @return 返回地址信息对象 + * @throws JSONException + * @throws IOException + */ + public static Address getAddress(String ip) throws JSONException, IOException { + JSONObject json = readJsonFromUrl("http://ip.taobao.com/service/getIpInfo.php?ip=" + ip); + + /* 获取到的json对象: + * { + * "code":0, + * "data":{ + * "ip":"36.27.93.185","country":"中国","area":"","region":"浙江","city":"杭州","county":"XX","isp":"电信","country_id":"CN","area_id":"","region_id":"330000","city_id":"330100","county_id":"xx","isp_id":"100017" + * } + * } + */ + if (json == null) { + return null; + } + // code + String status = json.get("code").toString(); + if (!"0".equals(status)) { + return null; + } + // 获取json对象里的data对象 + return json.getObject("data", Address.class); + } + + /** + * 地址id校验 + * + * @param addressId + * @return + */ + public static boolean addressIdVerify(String addressId) { + if (StringUtils.isEmpty(addressId)) { + return false; + } + String regex = "\\d{6}"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(addressId); + return matcher.find(); + } + + private static String readAll(Reader rd) throws IOException { + StringBuilder sb = new StringBuilder(); + int cp; + while ((cp = rd.read()) != -1) { + sb.append((char) cp); + } + return sb.toString(); + } + + public static JSONObject readJsonFromUrl(String url) throws IOException, JSONException { + InputStream is = null; + try { + is = new URL(url).openStream(); + BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); + String jsonText = readAll(rd); + JSONObject json = JSONObject.parseObject(jsonText); + return json; + } finally { + //关闭输入流 + if (is != null) { + is.close(); + } + } + } + + @Data + public static class Address { + + /** + * 真实ip + */ + private String ip; + + /** + * 国家 + */ + private String country; + + /** + * 区域 + */ + private String area; + + /** + * 地区、省 + */ + private String region; + + /** + * 地市 + */ + private String city; + + /** + * 县 + */ + private String county; + + private String isp; + + private String country_id; + + private String area_id; + + private String region_id; + + private String city_id; + + private String county_id; + + private String isp_id; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/LocalDateTimeUtils.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/LocalDateTimeUtils.java new file mode 100644 index 0000000..e4c33fd --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/LocalDateTimeUtils.java @@ -0,0 +1,232 @@ +package com.mt.wms.core.utils; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.Period; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalUnit; +import java.util.Date; + +/** + * Java8中的时间类 + **/ +public class LocalDateTimeUtils { + + /** + * Date 转 LocalDateTime + * + * @param date date对象 + * @return + */ + public static LocalDateTime convertDateToLDT(Date date) { + return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()); + } + + /** + * LocalDateTime 转 Date + * + * @param time LocalDateTime对象 + * @return + */ + public static Date convertLDTToDate(LocalDateTime time) { + return Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); + } + + /** + * 获取指定日期的毫秒 + * + * @param time LocalDateTime对象 + * @return + */ + public static Long getMilliByTime(LocalDateTime time) { + return time.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); + } + + /** + * 获取指定日期的秒 + * + * @param time LocalDateTime对象 + * @return + */ + public static Long getSecondsByTime(LocalDateTime time) { + return time.atZone(ZoneId.systemDefault()).toInstant().getEpochSecond(); + } + + /** + * LocalDateTime 转 String + * + * @param time LocalDateTime对象 + * @param pattern 时间格式 例:yyyy-MM-dd + * @return + */ + public static String formatTime(LocalDateTime time, String pattern) { + return time.format(DateTimeFormatter.ofPattern(pattern)); + } + + /** + * String 转 LocalDateTime + * + * @param pattern 时间格式 例:yyyy-MM-dd + * @param timeString 时间 + * @return + */ + public static LocalDateTime StringToLocalDateTime(String pattern, String timeString) { + return LocalDateTime.parse(timeString, DateTimeFormatter.ofPattern(pattern)); + } + + /** + * 获取当前时间的指定格式 + * + * @param pattern 时间格式 例:yyyy-MM-dd + * @return + */ + public static String formatNow(String pattern) { + return formatTime(LocalDateTime.now(), pattern); + } + + /** + * 日期加上一个数,根据field不同加不同值,field为ChronoUnit.* + * + * @param time LocalDateTime对象 + * @param number 时间个数 + * @param field 时间单位(年、月、日) + * @return + */ + public static LocalDateTime plus(LocalDateTime time, long number, TemporalUnit field) { + return time.plus(number, field); + } + + /** + * 日期减去一个数,根据field不同减不同值,field参数为ChronoUnit.* + * + * @param time LocalDateTime对象 + * @param number 时间个数 + * @param field 时间单位(年、月、日) + * @return + */ + public static LocalDateTime minu(LocalDateTime time, long number, TemporalUnit field) { + return time.minus(number, field); + } + + /** + * 获取两个日期的差 field参数为ChronoUnit.* + * + * @param startTime + * @param endTime + * @param field 单位(年月日时分秒) + * @return + */ + public static long betweenTwoTime(LocalDateTime startTime, LocalDateTime endTime, ChronoUnit field) { + Period period = Period.between(LocalDate.from(startTime), LocalDate.from(endTime)); + if (field == ChronoUnit.YEARS) { + return period.getYears(); + } + if (field == ChronoUnit.MONTHS) { + return period.getYears() * 12 + period.getMonths(); + } + return field.between(startTime, endTime); + } + + /** + * 获取一天的开始时间 + * + * @param time LocalDateTime对象 + * @return + */ + public static LocalDateTime getDayStart(LocalDateTime time) { + return time.withHour(0) + .withMinute(0) + .withSecond(0) + .withNano(0); + } + + /** + * 获取一天的结束时间 + * + * @param time + * @return + */ + public static LocalDateTime getDayEnd(LocalDateTime time) { + return time.withHour(23) + .withMinute(59) + .withSecond(59) + .withNano(999999999); + } + + /** + * 与当前时间进行比较 + * @param time str时间 + * @param pattern 日期格式 + * @return time >= now() ? true :false + */ + public static boolean strTimeCompareNow(String time, String pattern){ + return time.compareTo(LocalDateTime.now().format(DateTimeFormatter.ofPattern(pattern))) >= 0; + } + + /** + * string LocalDate类型进行增减(只支持年月日) + * @param strLocalDate 时间 + * @param number 时间数 + * @param field 增减时间单位 + * @return + */ + public static String strLocalDatePlusMinus(String strLocalDate, long number, ChronoUnit field){ + LocalDate localDate = LocalDate.parse(strLocalDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")); + LocalDate alterLocalDate; + if (number > 0) { + alterLocalDate = localDate.plus(number, field); + } else { + alterLocalDate = localDate.minus(number, field); + } + return alterLocalDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + } + + /** + * 获取两个LocalDate时间差 + * @param startDate + * @param endDate + * @param field + * @return + */ + public static long betweenTwoTime(LocalDate startDate, LocalDate endDate, ChronoUnit field) { + Period period = Period.between(startDate, endDate); + if (field == ChronoUnit.YEARS) { + return period.getYears(); + } + if (field == ChronoUnit.MONTHS) { + return period.getYears() * 12 + period.getMonths(); + } + return field.between(startDate, endDate); + } + + + /** + * 测试 + * + * @param args + */ + public static void main(String[] args) { + LocalDateTime start = LocalDateTime.of(1993, 10, 13, 11, 11); + LocalDateTime end = LocalDateTime.of(1994, 11, 13, 13, 13); + //根据ChronoUnit.* 返回相应的时间差值 + System.out.println("年:" + LocalDateTimeUtils.betweenTwoTime(start, end, ChronoUnit.YEARS)); + System.out.println("月:" + LocalDateTimeUtils.betweenTwoTime(start, end, ChronoUnit.MONTHS)); + System.out.println("日:" + LocalDateTimeUtils.betweenTwoTime(start, end, ChronoUnit.DAYS)); + System.out.println("半日:" + LocalDateTimeUtils.betweenTwoTime(start, end, ChronoUnit.HALF_DAYS)); + System.out.println("小时:" + LocalDateTimeUtils.betweenTwoTime(start, end, ChronoUnit.HOURS)); + System.out.println("分钟:" + LocalDateTimeUtils.betweenTwoTime(start, end, ChronoUnit.MINUTES)); + System.out.println("秒:" + LocalDateTimeUtils.betweenTwoTime(start, end, ChronoUnit.SECONDS)); + System.out.println("毫秒:" + LocalDateTimeUtils.betweenTwoTime(start, end, ChronoUnit.MILLIS)); + + //增加二十分钟 + System.out.println(LocalDateTimeUtils.plus(LocalDateTime.now(), 20, ChronoUnit.MINUTES)); + //增加两年 + System.out.println(LocalDateTimeUtils.formatTime(LocalDateTimeUtils.plus(LocalDateTime.now(), 2, ChronoUnit.YEARS), "yyyy年MM月dd日 HH:mm")); + + System.out.println(LocalDateTimeUtils.getDayStart(LocalDateTime.now())); + System.out.println(LocalDateTimeUtils.getDayEnd(LocalDateTime.now())); + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/LockHelper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/LockHelper.java new file mode 100644 index 0000000..209e274 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/LockHelper.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.utils; + +import com.mt.wms.core.constants.RedisConstant; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; + +/** + * 分布式锁帮助类
+ * 详细文档请查看分布式锁和同步器 + *

+ *

+ * // 加锁以后10秒钟自动解锁
+ * // 无需调用unlock方法手动解锁
+ * lock.lock(10, TimeUnit.SECONDS);
+ *
+ * // 尝试加锁,最多等待100秒,上锁以后10秒自动解锁
+ * boolean res = lock.tryLock(100, 10, TimeUnit.SECONDS);
+ * if (res) {
+ *    try {
+ *      ...
+ *    } finally {
+ *        lock.unlock();
+ *    }
+ * }
+ * 
+ *

+ * + * @author jiff + * @date 2019-08-25 + * @since 1.0 + */ +@Component +public class LockHelper { + /** + * 订单锁前缀:{@value} + */ + private static final String ORDER_LOCK = RedisConstant.LOCK_PREFIX + "order:"; + private static final String FUND_LOCK = RedisConstant.LOCK_PREFIX + "fund:"; + private static final String SCHEDULER_LOCK = RedisConstant.LOCK_PREFIX + "scheduler:"; + /** + * ip转地址任务调度锁:{@value} + */ + private static final String IP_TO_ADDRESS_SCHEDULER_LOCK = SCHEDULER_LOCK + "ip_to_address"; + /** + * uu跑腿定时提交订单任务锁 + */ + private static final String UUPT_SUBMIT_ORDER_SCHEDULER_LOCK = SCHEDULER_LOCK + "uupt_submit_order"; + + private RedissonClient redissonClient; + private static LockHelper lockHelper; + + @Autowired(required = false) + public void setRedissonClient(RedissonClient redissonClient) { + this.redissonClient = redissonClient; + } + + @PostConstruct + private void init() { + lockHelper = this; + lockHelper.redissonClient = this.redissonClient; + } + + /** + * 获取联锁 + * + * @param locks 同时加锁的集合 + * @return + */ + public static RLock getMultiLock(RLock... locks) { + return lockHelper.redissonClient.getMultiLock(locks); + } + + /** + * 获取红锁 + * + * @param locks 同时加锁的集合 + * @return + */ + public static RLock getRedLock(RLock... locks) { + return lockHelper.redissonClient.getRedLock(locks); + } + + /** + * 获取订单锁 + * + * @param id 订单id + * @return + */ + public static RLock getOrderLock(Long id) { + return lockHelper.redissonClient.getLock(ORDER_LOCK + id); + } + + /** + * 获取资金账户锁 + * + * @param id 账户id + * @return + */ + public static RLock getFundLock(Long id) { + return lockHelper.redissonClient.getLock(FUND_LOCK + id); + } + + /** + * 获取ip转地址任务调度锁 + * + * @return + */ + public static RLock getIpToAddressSchedulerLock() { + return lockHelper.redissonClient.getLock(IP_TO_ADDRESS_SCHEDULER_LOCK); + } + + /** + * uu跑腿定时提交订单任务锁 + * @return + */ + public static RLock getUuptSubmitOrderSchedulerLock(){ + return lockHelper.redissonClient.getLock(UUPT_SUBMIT_ORDER_SCHEDULER_LOCK); + } + + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/MD5Util.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/MD5Util.java new file mode 100644 index 0000000..b8aaa57 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/MD5Util.java @@ -0,0 +1,84 @@ +package com.mt.wms.core.utils; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * MD5加密 + * + * @author yangyang.jiang + * @create 2018-11-06 22:04 + **/ +public class MD5Util { + /** + * md5加密 + * + * @param str + * @return + */ + public static String md5(String str) { + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(str.getBytes()); + byte[] byteDigest = md.digest(); + int i; + StringBuffer buf = new StringBuffer(""); + for (int offset = 0; offset < byteDigest.length; offset++) { + i = byteDigest[offset]; + if (i < 0) { + i += 256; + } + if (i < 16) { + buf.append("0"); + } + buf.append(Integer.toHexString(i)); + } + // 32位加密 + return buf.toString(); + // 16位的加密 + // return buf.toString().substring(8, 24); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + return null; + } + } + + public static void main(String[] args) { + System.out.println(MD5Util.md5("123456")); + } + + private static String byteArrayToHexString(byte b[]) { + StringBuffer resultSb = new StringBuffer(); + for (int i = 0; i < b.length; i++) { + resultSb.append(byteToHexString(b[i])); + } + return resultSb.toString(); + } + + private static String byteToHexString(byte b) { + int n = b; + if (n < 0) { + n += 256; + } + int d1 = n / 16; + int d2 = n % 16; + return hexDigits[d1] + hexDigits[d2]; + } + + public static String MD5Encode(String origin, String charsetname) { + String resultString = null; + try { + resultString = new String(origin); + MessageDigest md = MessageDigest.getInstance("MD5"); + if (charsetname == null || "".equals(charsetname)) { + resultString = byteArrayToHexString(md.digest(resultString.getBytes())); + } else { + resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname))); + } + } catch (Exception exception) { + } + return resultString; + } + + private static final String hexDigits[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"}; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/PDF2Img.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/PDF2Img.java new file mode 100644 index 0000000..c20cd65 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/PDF2Img.java @@ -0,0 +1,76 @@ +package com.mt.wms.core.utils; + +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.rendering.ImageType; +import org.apache.pdfbox.rendering.PDFRenderer; +import org.apache.pdfbox.tools.imageio.ImageIOUtil; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * pdf转图片 + */ +public class PDF2Img { + /** + * pdf转图片 + * + * @param file 要转换的pdf文件 + * @return 转换之后的BufferedImage集合(图片个数取决于pdf页码个数) + */ + public static List> changePdfToImg(String instructiopath, String basePath) throws Exception { + List> mapList = new ArrayList<>(); + File file = new File(instructiopath); + PDDocument doc = null; + int pageCount = 0; + int pdfDPI = 500;//图片质量 + try { + doc = PDDocument.load(file); + pageCount = doc.getNumberOfPages(); + System.out.println(pageCount); + PDFRenderer pdfRenderer = new PDFRenderer(doc); + File fileDir = new File(basePath); + if (!fileDir.exists()) { + // 目录不存在则创建 + fileDir.mkdirs(); + } + for (int i = 0; i < pageCount; i++) { + Map map = new HashMap<>(); + String random18Str = DateUtil.getCurrentDateTime() + RandomCodeGenerator.numericCode(4); + BufferedImage bim = pdfRenderer.renderImageWithDPI(i, pdfDPI, + ImageType.RGB); + // suffix in filename will be used as the file format + ImageIOUtil.writeImage(bim, basePath + "/" + random18Str + + ".jpg", pdfDPI); + map.put("filePath", basePath + "/" + random18Str + ".jpg"); + map.put("fileName", random18Str); + mapList.add(map); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (doc != null) { + try { + doc.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return mapList; + } + + public static void main(String[] args) { + try { + changePdfToImg("C:\\Users\\admin\\Desktop\\156512992382046445.pdf", "C:\\Users\\admin\\Desktop\\"); + } catch (Exception e) { + + } + } +} \ No newline at end of file diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/PasswordUtil.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/PasswordUtil.java new file mode 100644 index 0000000..f4651b4 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/PasswordUtil.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.utils; + + +import org.apache.commons.codec.digest.DigestUtils; + +/** + * @author jiff + * @date 2019-07-19 + * @since 1.0 + */ +public class PasswordUtil { + + private PasswordUtil() { + } + + /** + * 加密后的密码 + * + * @param password 原始密码 + * @param nonce 加密字符串 + * @return 加密后的密码 + */ + public static String encode(String password, String nonce) { + return DigestUtils.md5Hex(password + nonce); + } + + /** + * 生成加密字符串 + * + * @return 加密字符串 + */ + public static String genNonce() { + return RandomCodeGenerator.alphanumericCode(16); + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/QrcodeUtils.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/QrcodeUtils.java new file mode 100644 index 0000000..a5e88bf --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/QrcodeUtils.java @@ -0,0 +1,180 @@ +package com.mt.wms.core.utils; + +import com.github.binarywang.utils.qrcode.BufferedImageLuminanceSource; +import com.github.binarywang.utils.qrcode.MatrixToImageWriter; +import com.github.binarywang.utils.qrcode.MatrixToLogoImageConfig; +import com.google.common.base.Charsets; +import com.google.common.collect.Maps; +import com.google.zxing.*; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.HybridBinarizer; +import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.MappedByteBuffer; +import java.nio.channels.FileChannel; +import java.nio.channels.FileChannel.MapMode; +import java.nio.file.Files; +import java.util.Map; + +/** + *
+ * Created by Binary Wang on 2017-01-05.
+ * @author binarywang(Binary Wang)
+ * 
+ */ +public class QrcodeUtils { + private static final int DEFAULT_LENGTH = 400;// 生成二维码的默认边长,因为是正方形的,所以高度和宽度一致 + private static final String FORMAT = "jpg";// 生成二维码的格式 + + private static Logger logger = LoggerFactory.getLogger(QrcodeUtils.class); + + /** + * 根据内容生成二维码数据 + * + * @param content 二维码文字内容[为了信息安全性,一般都要先进行数据加密] + * @param length 二维码图片宽度和高度 + */ + private static BitMatrix createQrcodeMatrix(String content, int length) { + Map hints = Maps.newEnumMap(EncodeHintType.class); + // 设置字符编码 + hints.put(EncodeHintType.CHARACTER_SET, Charsets.UTF_8.name()); + // 指定纠错等级 + hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); + + try { + return new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, length, length, hints); + } catch (Exception e) { + logger.warn("内容为:【" + content + "】的二维码生成失败!", e); + return null; + } + + } + + /** + * 根据指定边长创建生成的二维码 + * + * @param content 二维码内容 + * @param length 二维码的高度和宽度 + * @param logoFile logo 文件对象,可以为空 + * @return 二维码图片的字节数组 + */ + public static byte[] createQrcode(String content, int length, File logoFile, MatrixToLogoImageConfig matrixToLogoImageConfig) { + if (logoFile != null && !logoFile.exists()) { + throw new IllegalArgumentException("请提供正确的logo文件!"); + } + + BitMatrix qrCodeMatrix = createQrcodeMatrix(content, length); + if (qrCodeMatrix == null) { + return null; + } + try { + File file = Files.createTempFile("qrcode_", "." + FORMAT).toFile(); + logger.debug(file.getAbsolutePath()); + + MatrixToImageWriter.writeToFile(qrCodeMatrix, FORMAT, file); + if (logoFile != null) { + // 添加logo图片, 此处一定需要重新进行读取,而不能直接使用二维码的BufferedImage 对象 + BufferedImage img = ImageIO.read(file); + overlapImage(img, FORMAT, file.getAbsolutePath(), logoFile, matrixToLogoImageConfig); + } + + return toByteArray(file); + } catch (Exception e) { + logger.warn("内容为:【" + content + "】的二维码生成失败!", e); + return null; + } + } + + /** + * 创建生成默认高度(400)的二维码图片 + * 可以指定是否贷logo + * + * @param content 二维码内容 + * @param logoFile logo 文件对象,可以为空 + * @return 二维码图片的字节数组 + */ + public static byte[] createQrcode(String content, File logoFile, MatrixToLogoImageConfig matrixToLogoImageConfig) { + return createQrcode(content, DEFAULT_LENGTH, logoFile, matrixToLogoImageConfig); + } + + /** + * 将文件转换为字节数组, + * 使用MappedByteBuffer,可以在处理大文件时,提升性能 + * + * @param file 文件 + * @return 二维码图片的字节数组 + */ + private static byte[] toByteArray(File file) { + try (FileChannel fc = new RandomAccessFile(file, "r").getChannel();) { + MappedByteBuffer byteBuffer = fc.map(MapMode.READ_ONLY, 0, fc.size()).load(); + byte[] result = new byte[(int) fc.size()]; + if (byteBuffer.remaining() > 0) { + byteBuffer.get(result, 0, byteBuffer.remaining()); + } + return result; + } catch (Exception e) { + logger.warn("文件转换成byte[]发生异常!", e); + return null; + } + } + + /** + * 将logo添加到二维码中间 + * + * @param image 生成的二维码图片对象 + * @param imagePath 图片保存路径 + * @param logoFile logo文件对象 + * @param format 图片格式 + */ + private static void overlapImage(BufferedImage image, String format, String imagePath, File logoFile, + MatrixToLogoImageConfig logoConfig) throws IOException { + try { + BufferedImage logo = ImageIO.read(logoFile); + Graphics2D g = image.createGraphics(); + // 考虑到logo图片贴到二维码中,建议大小不要超过二维码的1/5; + int width = image.getWidth() / logoConfig.getLogoPart(); + int height = image.getHeight() / logoConfig.getLogoPart(); + // logo起始位置,此目的是为logo居中显示 + int x = (image.getWidth() - width) / 2; + int y = (image.getHeight() - height) / 2; + // 绘制图 + g.drawImage(logo, x, y, width, height, null); + + // 给logo画边框 + // 构造一个具有指定线条宽度以及 cap 和 join 风格的默认值的实心 BasicStroke + g.setStroke(new BasicStroke(logoConfig.getBorder())); + g.setColor(logoConfig.getBorderColor()); + g.drawRect(x, y, width, height); + + g.dispose(); + // 写入logo图片到二维码 + ImageIO.write(image, format, new File(imagePath)); + } catch (Exception e) { + throw new IOException("二维码添加logo时发生异常!", e); + } + } + + /** + * 解析二维码 + * + * @param file 二维码文件内容 + * @return 二维码的内容 + */ + public static String decodeQrcode(File file) throws IOException, NotFoundException { + BufferedImage image = ImageIO.read(file); + LuminanceSource source = new BufferedImageLuminanceSource(image); + Binarizer binarizer = new HybridBinarizer(source); + BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer); + Map hints = Maps.newEnumMap(DecodeHintType.class); + hints.put(DecodeHintType.CHARACTER_SET, Charsets.UTF_8.name()); + return new MultiFormatReader().decode(binaryBitmap, hints).getText(); + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/RandomCodeGenerator.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/RandomCodeGenerator.java new file mode 100644 index 0000000..c02f173 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/RandomCodeGenerator.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.utils; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.RandomUtils; + +/** + * 随机码生成器,使用{@link RandomUtils}和{@link RandomStringUtils}生成随机码 + * + * @author jiff + * @date 2018-12-06 + * @since 1.0 + */ +public class RandomCodeGenerator { + /** + * 数字随机码 + * + * @param length 随机码长度 + * @return 随机码 + */ + public static int numericCode(int length) { + return RandomUtils.nextInt((int) Math.pow(10, length - 1), + (int) Math.pow(10, length)); + } + + /** + * 字母随机码 + * + * @param length 随机码长度 + * @return 随机码 + */ + public static String alphabeticCode(int length) { + return RandomStringUtils.randomAlphabetic(length); + } + + /** + * 字母数字混合随机码 + * + * @param length 随机码长度 + * @return 随机码 + */ + public static String alphanumericCode(int length) { + return RandomStringUtils.randomAlphanumeric(length); + } + + public static void main(String[] args) { + for (int i = 0; i < 100; i++) { + System.out.println(RandomStringUtils.randomNumeric(6)); + System.out.println(RandomStringUtils.random(6, + "abcdefghijkmnpqrstuvwxyz")); + System.out.println(numericCode(8)); + } + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/RotateImageUtil.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/RotateImageUtil.java new file mode 100644 index 0000000..ac21944 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/RotateImageUtil.java @@ -0,0 +1,91 @@ +package com.mt.wms.core.utils; + + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.File; + + +/** + *

+ * 图片旋转工具类 + *

+ * + * @author Mr.ZhangShi + * @version 1.0 + * @date 2019/11/15 + */ +public class RotateImageUtil { + + /** + * 对图片进行旋转 + * + * @param src 被旋转图片 + * @param angel 旋转角度 只能顺时针旋转 + * @return 旋转后的图片 + */ + public static BufferedImage Rotate(Image src, int angel) { + int src_width = src.getWidth(null); + int src_height = src.getHeight(null); + // 计算旋转后图片的尺寸 + Rectangle rect_des = CalcRotatedSize(new Rectangle(new Dimension( + src_width, src_height)), angel); + BufferedImage res = null; + res = new BufferedImage(rect_des.width, rect_des.height, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = res.createGraphics(); + // 进行转换 + g2.translate((rect_des.width - src_width) / 2, + (rect_des.height - src_height) / 2); + g2.rotate(Math.toRadians(angel), src_width / 2, src_height / 2); + + g2.drawImage(src, null, null); + return res; + } + + /** + * 计算旋转后的图片 + * + * @param src 被旋转的图片 + * @param angel 旋转角度 + * @return 旋转后的图片 + */ + public static Rectangle CalcRotatedSize(Rectangle src, int angel) { + // 如果旋转的角度大于90度做相应的转换 + if (angel >= 90) { + if (angel / 90 % 2 == 1) { + int temp = src.height; + src.height = src.width; + src.width = temp; + } + angel = angel % 90; + } + + double r = Math.sqrt(src.height * src.height + src.width * src.width) / 2; + double len = 2 * Math.sin(Math.toRadians(angel) / 2) * r; + double angel_alpha = (Math.PI - Math.toRadians(angel)) / 2; + double angel_dalta_width = Math.atan((double) src.height / src.width); + double angel_dalta_height = Math.atan((double) src.width / src.height); + + int len_dalta_width = (int) (len * Math.cos(Math.PI - angel_alpha + - angel_dalta_width)); + int len_dalta_height = (int) (len * Math.cos(Math.PI - angel_alpha + - angel_dalta_height)); + int des_width = src.width + len_dalta_width * 2; + int des_height = src.height + len_dalta_height * 2; + return new Rectangle(new Dimension(des_width, des_height)); + } + + public static void main(String[] args) { + try { + File file = new File("C:\\Users\\Mr.Zhang\\Pictures\\Saved Pictures\\2.jpg"); + BufferedImage image = ImageIO.read(file); + BufferedImage des1 = RotateImageUtil.Rotate(image, 90); + ImageIO.write(des1, "jpg",file); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/SpringContextUtil.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/SpringContextUtil.java new file mode 100644 index 0000000..67bf3ea --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/SpringContextUtil.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.utils; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.lang.Nullable; +import org.springframework.stereotype.Component; + +import java.util.Locale; + +/** + * 获取bean的工具类,可用于在线程里面获取bean + * + * @author jiff + * @date 2018-11-30 + * @since 1.0 + */ +@Component +public class SpringContextUtil implements ApplicationContextAware { + + private static ApplicationContext context = null; + + + /** + * @param applicationContext + * @throws BeansException + * @see ApplicationContextAware#setApplicationContext(ApplicationContext) + */ + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + context = applicationContext; + } + + + /** + * @param name bean名称 + * @param 返回bean的类型 + * @return bean + */ + public static T getBean(String name) { + return (T) context.getBean(name); + } + + /** + * @param name bean名称 + * @param requiredType bean类型 + * @param bean类型 + * @return bean + */ + public static T getBean(String name, @Nullable Class requiredType) { + return context.getBean(name, requiredType); + } + + /** + * @param requiredType bean类型 + * @param bean类型 + * @return bean + */ + public static T getBean(Class requiredType) { + return context.getBean(requiredType); + } + + /** + * 国际化消息 + * + * @param key 消息键值 + * @param args 消息需要的参数 + * @return 消息 + */ + public static String getMessage(String key, @Nullable Object[] args) { + return context.getMessage(key, args, Locale.getDefault()); + } + + /** + * 获取当前环境 + * + * @return 当前环境:dev、test、pro + */ + public static String getActiveProfile() { + return context.getEnvironment().getActiveProfiles()[0]; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/StringUtils.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/StringUtils.java new file mode 100644 index 0000000..d61cb3a --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/StringUtils.java @@ -0,0 +1,329 @@ +package com.mt.wms.core.utils; + +import org.apache.commons.lang.text.StrBuilder; + +import java.util.Collection; +import java.util.Map; + +public class StringUtils extends org.apache.commons.lang3.StringUtils { + /** + * 空字符串 + */ + private static final String NULLSTR = ""; + + /** + * 下划线 + */ + private static final char SEPARATOR = '_'; + + /** + * 获取参数不为空值 + * + * @param value defaultValue 要判断的value + * @return value 返回值 + */ + public static T nvl(T value, T defaultValue) { + return value != null ? value : defaultValue; + } + + /** + * * 判断一个Collection是否为空, 包含List,Set,Queue + * + * @param coll 要判断的Collection + * @return true:为空 false:非空 + */ + public static boolean isEmpty(Collection coll) { + return isNull(coll) || coll.isEmpty(); + } + + /** + * * 判断一个Collection是否非空,包含List,Set,Queue + * + * @param coll 要判断的Collection + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Collection coll) { + return !isEmpty(coll); + } + + /** + * * 判断一个对象数组是否为空 + * + * @param objects 要判断的对象数组 + * * @return true:为空 false:非空 + */ + public static boolean isEmpty(Object[] objects) { + return isNull(objects) || (objects.length == 0); + } + + /** + * * 判断一个对象数组是否非空 + * + * @param objects 要判断的对象数组 + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Object[] objects) { + return !isEmpty(objects); + } + + /** + * * 判断一个Map是否为空 + * + * @param map 要判断的Map + * @return true:为空 false:非空 + */ + public static boolean isEmpty(Map map) { + return isNull(map) || map.isEmpty(); + } + + /** + * * 判断一个Map是否为空 + * + * @param map 要判断的Map + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Map map) { + return !isEmpty(map); + } + + /** + * * 判断一个字符串是否为空串 + * + * @param str String + * @return true:为空 false:非空 + */ + public static boolean isEmpty(String str) { + return isNull(str) || NULLSTR.equals(str.trim()); + } + + /** + * * 判断一个字符串是否为非空串 + * + * @param str String + * @return true:非空串 false:空串 + */ + public static boolean isNotEmpty(String str) { + return !isEmpty(str); + } + + /** + * * 判断一个对象是否为空 + * + * @param object Object + * @return true:为空 false:非空 + */ + public static boolean isNull(Object object) { + return object == null; + } + + /** + * * 判断一个对象是否非空 + * + * @param object Object + * @return true:非空 false:空 + */ + public static boolean isNotNull(Object object) { + return !isNull(object); + } + + /** + * * 判断一个对象是否是数组类型(Java基本型别的数组) + * + * @param object 对象 + * @return true:是数组 false:不是数组 + */ + public static boolean isArray(Object object) { + return isNotNull(object) && object.getClass().isArray(); + } + + /** + * 去空格 + */ + public static String trim(String str) { + return (str == null ? "" : str.trim()); + } + + /** + * 截取字符串 + * + * @param str 字符串 + * @param start 开始 + * @return 结果 + */ + public static String substring(final String str, int start) { + if (str == null) { + return NULLSTR; + } + + if (start < 0) { + start = str.length() + start; + } + + if (start < 0) { + start = 0; + } + if (start > str.length()) { + return NULLSTR; + } + + return str.substring(start); + } + + /** + * 截取字符串 + * + * @param str 字符串 + * @param start 开始 + * @param end 结束 + * @return 结果 + */ + public static String substring(final String str, int start, int end) { + if (str == null) { + return NULLSTR; + } + + if (end < 0) { + end = str.length() + end; + } + if (start < 0) { + start = str.length() + start; + } + + if (end > str.length()) { + end = str.length(); + } + + if (start > end) { + return NULLSTR; + } + + if (start < 0) { + start = 0; + } + if (end < 0) { + end = 0; + } + + return str.substring(start, end); + } + + /** + * 驼峰首字符小写 + */ + public static String uncapitalize(String str) { + int strLen; + if (str == null || (strLen = str.length()) == 0) { + return str; + } + return new StrBuilder(strLen).append(Character.toLowerCase(str.charAt(0))).append(str.substring(1)).toString(); + } + + /** + * 下划线转驼峰命名 + */ + public static String toUnderScoreCase(String s) { + if (s == null) { + return null; + } + StringBuilder sb = new StringBuilder(); + boolean upperCase = false; + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + + boolean nextUpperCase = true; + + if (i < (s.length() - 1)) { + nextUpperCase = Character.isUpperCase(s.charAt(i + 1)); + } + + if ((i > 0) && Character.isUpperCase(c)) { + if (!upperCase || !nextUpperCase) { + sb.append(SEPARATOR); + } + upperCase = true; + } else { + upperCase = false; + } + + sb.append(Character.toLowerCase(c)); + } + + return sb.toString(); + } + + /** + * 是否包含字符串 + * + * @param str 验证字符串 + * @param strs 字符串组 + * @return 包含返回true + */ + public static boolean inStringIgnoreCase(String str, String... strs) { + if (str != null && strs != null) { + for (String s : strs) { + if (str.equalsIgnoreCase(trim(s))) { + return true; + } + } + } + return false; + } + + /** + * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld + * + * @param name 转换前的下划线大写方式命名的字符串 + * @return 转换后的驼峰式命名的字符串 + */ + public static String convertToCamelCase(String name) { + StringBuilder result = new StringBuilder(); + // 快速检查 + if (name == null || name.isEmpty()) { + // 没必要转换 + return ""; + } else if (!name.contains("_")) { + // 不含下划线,仅将首字母大写 + return name.substring(0, 1).toUpperCase() + name.substring(1); + } + // 用下划线将原始字符串分割 + String[] camels = name.split("_"); + for (String camel : camels) { + // 跳过原始字符串中开头、结尾的下换线或双重下划线 + if (camel.isEmpty()) { + continue; + } + // 首字母大写 + result.append(camel.substring(0, 1).toUpperCase()); + result.append(camel.substring(1).toLowerCase()); + } + return result.toString(); + } + + public static String getRandom18Str() { + String random18Str = ""; + random18Str = (System.currentTimeMillis() + "" + Math + .floor(Math.random() * 100000)); + random18Str = random18Str.substring(0, random18Str.indexOf(".")); + if (null != random18Str && 18 == random18Str.length()) { + return random18Str; + } else { + return getRandom18Str(); + } + } + + private static final String RANDOM_STR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + + private static final java.util.Random RANDOM = new java.util.Random(); + + public static String getRandomStr(int len) { + if (len <= 0) { + len = 16; + } + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < len; i++) { + sb.append(RANDOM_STR.charAt(RANDOM.nextInt(RANDOM_STR.length()))); + } + return sb.toString(); + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/TreeUtil.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/TreeUtil.java new file mode 100644 index 0000000..3cf84b3 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/TreeUtil.java @@ -0,0 +1,76 @@ +package com.mt.wms.core.utils; + +import com.mt.wms.core.base.ITree; + +import java.util.ArrayList; +import java.util.List; + +/** + * 集合转树形对象 + * + * @author jiff + * @date 2018-12-1 + * @since 1.0 + */ +public final class TreeUtil { + + + /** + * 使用递归方法建树 + * + * @param list 列表数据 + * @param rootIds 指定根ID,默认为0 + * @param 数据类型,必须继承{@link ITree}接口 + * @return 树形列表 + */ + public static List toTree(List list, Long... rootIds) { + return toTree(list, true, rootIds); + } + + /** + * 使用递归方法建树 + * + * @param list 列表数据 + * @param ignoreTrunkChecked 是否忽略树干节点选中状态,true:忽略,否则返回实际选中状态,用于前端展示半选状态不需要返回树干节点状态 + * @param rootIds 指定根ID,默认为0 + * @param 数据类型,必须继承{@link ITree}接口 + * @return 树形列表 + */ + public static List toTree(List list, boolean ignoreTrunkChecked, Long... rootIds) { + Long rootId = 0L; + if (rootIds != null && rootIds.length > 0) { + rootId = rootIds[0]; + } + List trees = new ArrayList<>(); + for (T t : list) { + if (rootId.equals(t.getParentId())) { + trees.add(findChildren(t, list, ignoreTrunkChecked)); + } + } + return trees; + } + + /** + * 递归查找子节点 + * + * @param parent 父节点 + * @param list 列表数据 + * @param + * @return 父节点 + */ + private static T findChildren(T parent, List list, boolean ignoreTrunkChecked) { + for (T t : list) { + if (parent.getId().equals(t.getParentId())) { + if (parent.getChildren() == null) { + parent.setChildren(new ArrayList()); + } + parent.getChildren().add(findChildren(t, list, ignoreTrunkChecked)); + } + } + //当前节点包含子节点则把选中状态设置为false,树干节点状态根据叶子节点来确认 + if (ignoreTrunkChecked && parent.getChildren() != null && !parent.getChildren().isEmpty()) { + parent.setChecked(false); + } + return parent; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/WechatQRCodeUtil.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/WechatQRCodeUtil.java new file mode 100644 index 0000000..ee608c5 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/WechatQRCodeUtil.java @@ -0,0 +1,87 @@ +package com.mt.wms.core.utils; + +import com.alibaba.fastjson.JSONObject; +import com.mt.wms.core.exception.ApiException; + +import java.io.IOException; + +/** + *

+ * 微信带参二维码工具类 + *

+ * + * @author Mr.ZhangShi + * @date 2019/4/9 + * @since 1.0 + */ +public class WechatQRCodeUtil { + + /** + * 获取access_token + */ + private static final String GET_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={APPID}&secret={SECRET}"; + + /** + * 获取ticket + */ + private static final String GET_QRCODE_URL = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={TOKEN}"; + + /** + * 换取二维码 + */ + private static final String QR_CODE_URL = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={TICKET}"; + + public static String getAccessToken(String appId, String secret) { + if (StringUtils.isAnyEmpty(appId, secret)){ + throw new ApiException(new NullPointerException()); + } + String accessToken = null; + String url = GET_ACCESS_TOKEN_URL.replace("{APPID}", appId).replace("{SECRET}", secret); + try { + String jsonStr = HttpClient.httpGet(url); + if (StringUtils.isNotEmpty(jsonStr)) { + accessToken = JSONObject.parseObject(jsonStr).get("access_token").toString(); + } + } catch (IOException e) { + throw new ApiException(e); + } + return accessToken; + } + + private static String getTicket(String accessToken, Object scene){ + if (StringUtils.isEmpty(accessToken) || scene == null){ + throw new ApiException(new NullPointerException()); + } + String ticket = null; + String url = GET_QRCODE_URL.replace("{TOKEN}", accessToken); + String param; + if (scene instanceof Integer) { + param = "{\"action_name\": \"QR_LIMIT_SCENE\", \"action_info\": {\"scene\": {\"scene_id\": "+ scene + "}}}"; + } else { + param = "{\"action_name\": \"QR_LIMIT_STR_SCENE\", \"action_info\": {\"scene\": {\"scene_str\": "+ scene.toString() + "}}}"; + } + try { + String jsonStr = HttpClient.httpPost(url, param); + if (StringUtils.isNotEmpty(jsonStr)) { + System.out.println("二维码申请成功:" + jsonStr); + ticket = JSONObject.parseObject(jsonStr).get("ticket").toString(); + } + } catch (IOException e) { + throw new ApiException(e); + } + return ticket; + } + + public static String getQrCodePictureUrl(String appId, String secret, Object scene) { + String ticket = getTicket(getAccessToken(appId, secret), scene); + if (StringUtils.isNotEmpty(ticket)) { + return QR_CODE_URL.replace("{TICKET}", ticket); + } + return null; + } + + public static void main(String[] args) { + System.out.println(getQrCodePictureUrl("wx54c4b46cfc8a9aba", "5ba1210f044a20cdc9bfbc59b582c259", 1154)); + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/WubiUtil.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/WubiUtil.java new file mode 100644 index 0000000..4fae32a --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/WubiUtil.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.utils; + +/** + *

+ * 汉字转五笔 + *

+ * + * @author FanYi + * @date 2018-11-27 + * @since 1.0 + */ +public class WubiUtil { + private static String[] WB = new String[]{ + "A鞴鞲鞣鞫鞯鞔鞒鞑鞅靼銎跫綦翳蛩颟鹳鹋鸫鸢慝觐觋贳瓯戡檠迓甙忒弋撖摁廾蘼蘖蘩蘅蘧藿藜藁藓薰薷薹薅薜薮蕹薏薇薨薤蕻蕲蕃瞢蕺蕞蕤蕨蕈蕙蓼蓿蔻蕖蔺蔟蔹蓰蔸甍蔌蓣蓥蒗蒴蒹蒡蓠蒺蒿蓊蓓蒽蓦蓐蓍蓁葭萱蒎蒌葶葩葆萼葸蒉葺蒈蒇葳葙葚葑葜菡菰萦菀菅菪菹菸萃萏菟菔萆萑萸萜菖菽菝萋萘堇菘菥萁菁莼莺莨莞莘荻莸荽莩莶荼莅莜莓莪莠莴莳荸莰荮荭荪荬荩茛荨荥荦茳茺茭荠茗荀荟荃荇荏茯荞莛茱茴茼莒茈荜荛荑茜苕苠茕茔茆茚茑苓苻茌苘苒苴苜茇茏苤苷茉苡芤苎苄芟芪芡芴芩苁苌苋芮芷芘苣苊苈芰芾芸芫芙芗芑芎芄芨芊芏艿艽艹鄞郾邛劐蒯赜匾匮匦叵匚廿茁著芝蒸斟蔗蘸藻葬匝蕴苑芋荧营萤莹英荫茵艺颐医药尧燕雅牙芽鸦薛靴蓄芯薪邪鞋萧巷项匣熙昔芜巫卧蔚萎苇藤萄苔蓑蒜苏斯薯蔬世式甚芍苫莎散萨若蕊茹荣蓉茸戎惹鹊颧区擎芹勤莲荔莉蕾勒劳蓝莱葵匡苦恐苛勘菌巨菊鞠敬警茎荆靳芥藉戒节蕉匠蒋荐茧荚蓟基惑或获荤茄切翘鞘巧蔷其七欺期蒲菩葡莆萍苹匹蓬藕殴鸥欧孽蔫匿慕募幕暮墓某莫蘑摹蔑藐苗蒙萌茂茅莽茫芒蔓落萝芦菱黄荒划花葫菏荷邯菇苟共贡汞巩恭功攻工葛革戈甘芬匪菲芳范藩贰董东蒂荡葱茨臣茶茬草藏苍蔡菜菠鞭蔽蓖苯薄苞靶芭鞍艾蔼", + "B粜蚩颞聩聒聍聆聃耵骘孢孓孑屮隳凵勐鄹隰隗隍隈陴陲陬陧陟陔陉陂阼阽阪阱阡阢阝卺亟丞阻子孜坠职阵障陨院隅隐阴也耶阳逊限陷险隙卫陀陶孙祟隧随隋陕阮孺娶取了辽聊联孔聚阶降际聘陪聂陌孟陆陋陇隆陵函孩孤耿隔附防耳堕队陡耽聪除出耻承陈陛隘阿", + "C鍪蟊蝥颡矜皴鹬鹜甬瞀怼炱毵骧骥骣骢骠骟骝骛骖骓骒骐骊骈骅骁骀驿驺驸驷驵婺逡迨迳巯畚弁厶邰刭驻骤蚤允驭豫预予又勇恿以矣验驯熊戏驼驮通台双驶圣骚桑叁柔劝驱垒骏驹颈劲骄艰鸡骑骗能难牟矛马骆骡驴欢骇观对叠邓怠驰骋叉参驳巴", + "D鬣鬟鬓鬏鬈髹髭髻髫髯髦髡髟魇蹙趸翡舂蜚蜃虿耱耨耩耧耦耥耢耠耜耖耔耒鹩鹕鹌鸸鸪瓠礴礞礤礓磴礅磲磉磙磔碥碹碲碣碡碜碇碚碓碛硪硌硇硐硗硖硭硎砩砣砬砥砼砟砻砺砹砝砜砭斫砑砘砗砉砀矸矶恧恝焘斐飙欹腴挈臧戛彗尴尬尥尢匏耷奁夼劢酆劂剞刳赝靥厮厥厣厝厍仄嘏左奏鬃砖砧丈在砸耘愿原郁右友有尤硬页雁砚厌艳奄研压戌雄硝厢咸夏厦袭矽硒戊威万碗厅套碳态太泰碎肆硕爽耍戍寿石盛砷奢砂三辱确犬秦历砾励厉厘磊奎盔矿夸克磕砍厩韭兢礁硷碱慧灰磺牵砌契奇戚破砒碰硼砰裴耪碾奈耐面迈码碌垄聋龙硫磷胡厚耗夯硅顾故古辜龚耕感奉丰奋非矾而厄夺碟碉碘大达磋存磁蠢唇春础厨成辰厂碴厕布泵奔辈悲碑磅帮邦百耙碍", + "E雎貔貘貅貊貂豸豕繇鹞燹膦臁膻臊朦臌膪膣滕膑膈媵塍腧腭腽腼腩腠腱腚腙腓腌腈脲脘脬脞脶豚脒朕胼胲脎脍胭胴胱胫胝朐胗胍胙胂胛胪胩胨胧肷肭肫肱肽朊肼肜肟刖虢爰戤孚尕邈彡豳奚垡郛鼐助逐肘肿脂肢胀脏孕月用臃盈臆胰腋舀遥腰悬须胸腥胁腺县膝腕妥脱腿腆腾膛胎舜甩受胜膳腮乳脸肋腊胯爵脚胶及肌且腔脐脾鹏朋膨胚胖脓腻脑乃膜觅貌脉貉股胳肛肝腹腑脯服肤肺肥肪肚胆脆肠彩采膊脖豹胞膀肮胺爱", + "F鼋霾霰霭霪霎霏霈霁霆雯雳雩謦赭赧趱趑趔趄赳麴翥裘箐罄螫颢颉顸耋鹁盍瞽磬悫恚熹觳毂彀耄觏觌赍贲耆甏戟辇韬韫嫠遘逵逑懿鼙馨墀墚墉墁塬塥堠塄堙堞堀埭埽堍堋埝埤埸埯埴垸埒埙埚埘埕垠垴垧埏垲垌垤垭坳坶坭坨坻坼垆坫垅坩坂圻坜圯圮圹圳圪圬圩酃邗卦啬孛亓兀亍走专煮志址直支震真者赵增载哉栽运云越远袁垣元域雨壹堰严盐雪需墟幸协孝霄献现霞喜雾坞无斡未违韦顽土填替趟塘坦坛坍塔塌索寺霜士示十声赦墒丧韧壤却去趣趋求雷老垃坤亏款块垮坑壳坷考坎堪刊均救境井进劫截教嘉吉圾击魂卉墙乾起埔坡坪霹坯彭培霓南霉卖埋露零霖坏壶赫郝壕翰韩过圭规鼓垢埂赶干赴夫封坟坊二垛墩堆堵都动颠地堤戴寸矗翅赤城趁朝超场才裁埠勃博雹霸坝埃", + "G餮餍鳌鏊靓豉豇麸纛翮蠹螯虺聱鹉鹂忑欤敕赉戬戋軎殪殡殛殚殍殓殒殄殇殂殁獒橐瓒璩璨璞璋璇璁璀璎璜瑾瑭瑷瑙瑕瑗瑜瑁琚琛琬琮琰琨琥琦瑛琪琏珲珞珧珩琊顼珙珥珈珉珀玳玷珑珂珏玟玢玮玑玎骜遨逦逋忝墼垩鄢郦郅郏邳邴剌芈噩孬鬲亘丕卅丐琢赘珠致至殖政正整臻珍盏责枣遭再玉与盂于迂夷一瑶殃焉亚殉邢形型刑下五武吾王玩豌歪瓦屯吞天琐速素死束殊事蚀珊瑟瑞融球琼青琴裂列两璃丽理琅赖来开玖静晋柬歼颊夹棘霍惠妻平琵琶弄囊末灭玫麦玛琉玲琳烈还环画互瑚瑰更副甫敷否珐恶顿毒逗豆靛到殆带歹刺曹残蚕不玻丙表碧逼甭班斑熬敖", + "H虍瞿龌龊龉龈龇龆龅龃龀訾觜鹾粲虔颦颥鸬瞵瞰瞠瞟瞑瞌睽瞍睿睥睢睨睚睃睇睑睐眸眵眦眭眙眈眇盹眍眄盱砦忐氍觑觇赀攴遽壑矍卣乩丨紫桌卓瞩止睁贞战占瞻眨虞眼眩虚些瞎凸瞳眺瞬睡叔上龋眶肯卡具旧睛睫瞧歧颇频皮盼虐睦目瞄眠眯瞒虑虏卤颅卢龄虎睹督鼎盯点瞪此雌瞅齿柴餐睬步卜彪", + "I鲨鲎鎏鋈裟淼泶沓懑氅挲尜娑逍灞灏瀵瀹瀛瀣瀚濯濠濞濮濡濂澶澹澧濉濑潺潼潲潸澌澍澉漩漉漪潴潋漶漯滹漕漤潇潆潢溟滂溏滏溴滗溷溻溽溧溥滢漭滠溘溱滟湄渥渲湔湓溆湟溲湫湎湮渫涮渌涫渖淙淝淦渑淠涿渎淞淅淇渚浣浼浠浜涔涓浞涠涞浯涑洳浔浒浏洚洵洮浍洫洎洙洄洇浈浃洌洧洹泾泯泓沱泮泫泺泖泠沲泗泱泸泷沭泔泐沩沆汶汴汩汨沌沔沐沅沣汊汜汔氵喾凼黉鼗渍滓淄滋注洲治滞汁浙兆沼涨掌漳湛沾渣泽澡源渊浴誉渔渝淤游油涌泳淫溢沂液耀漾洋演淹涯汛学汹兴泻泄肖小淆消削湘涎洗汐溪污沃涡温渭潍汪湾洼湍涂汀添涕淘逃滔涛烫淌棠堂汤潭滩汰溯水漱淑湿省渗沈深涉少裳尚赏汕沙涩洒润汝溶染雀渠泅清沁潦粱梁涟沥漓泪涝浪滥澜溃渴浚觉沮举酒浸津洁浇江涧溅渐尖济脊汲激活混浑汇辉浅潜洽泣汽沏柒漆瀑浦婆泼漂澎沛泡潘派湃沤浓泞涅溺泥淖漠沫渺泌没漫满洛沦滦滤潞漏流溜淋劣涣淮滑沪湖洪鸿涸河浩汉汗涵海光灌沽沟港溉涪浮汾沸泛法洱渡洞淀滇涤滴党当淡淬淳滁池澄沉尘澈潮敞常尝测沧泊渤波滨濒澳", + "J蠼蠛蠊蟾蠓蠖蟮蟠蟪蟛蟀蟑蟓蟋螳螵螬蟥螃螗螭螅螈蟆蟒螨螓蝙蝤蝼蝣蝓螋蝮蝌蝰蝠蝻蝾蝽蜢螂蜿蜷蜩蜱蜴蝈蜾蜮蜥蜞蜻蜣蜉蜍蜊蜈蛸蛑蛘蛟蛴蛞蜓蛐蛳蛭蛲蛱蚴蛏蛉蚯蚱蚺蚰蛎蚵蛄蚶蚓蚪蚣蚧蚝蚬蚋蚍蚨虻虼虮虬煦曩曦曜曛暾暝暧暌暄晷晗晡晖晏晁晔晟昵昱昴曷炅昀昕昃杲昙昊旰旯戥韪暹遢夥勖刂禺昨最蛀蛛蜘照昭早晕曰遇愚蛹映影蝇易蚁曳野蜒蚜星蝎歇晓显贤暇虾晰晤蜗蚊旺晚蛙蜕题剔帅墅竖曙暑是时师肾申蛇晌晒蠕日蛆晴晾量里览蜡昆颗景晶紧鉴坚监晦蛔晃蝗曝暖螟明冕盟昧冒曼蚂螺临蝴虹旱果滚归蛊蛤蜂遏蛾蝶电旦虫匙晨畅昌蝉暴蚌昂暗", + "K饕鼍黾躞躜躐躔躏躅蹴蹯蹼蹶蹰蹊蹒蹑蹂蹁蹉踱踽踵踹蹀踺踯踣踮踬踟踝踔跽踉跤跻跹跣跸跷跬跆跛跏跎跞跚跗跖跄趺趼趿趵颚鹭鹗戢璐囔嚯嚓嚅噼噻噫噱噤嚆噔噌噜噙噢噍嘬噗嘹噘嘭嘧嘀嗾嘣嘤嘁嘌嘈嘞嗤嗵嗨嗍嗌嗳嗲嗥嗯嗄嗝嗦嗔嗬嗫嗑嘟嗉嗷嗪喙喔喽嗟喑嗖啾喟喁喈喹喱喃嗒喋啜唰唳啷啶啵啖唷唼啐唿啕啁啭啉喵喏啧唪唧唑唏唣唢哳唔哽唠哧唛哞哏哝咤咪咩哜哚哙哌咿咻哕咣呲哔哓咦咧哒咴哂咭哐咝呦呶咄咛咚呤呱呷咔咂吲吣呙呗吡呃呖呔呓呒呋吆吖吒叻叨叩叽叱卟郢嘴足踪啄嘱咒忠盅中只趾吱咋喳噪躁咱郧跃员喻吁咏踊哟吟邑遗叶噎咬唁咽哑呀勋喧嘘嗅兄啸嚣哮响吓吸嘻吴呜嗡吻喂味唯哇唾吐听跳嚏啼蹄踢叹踏蹋唆虽嗽嗣嘶顺吮噬嗜史呻哨啥嗓嚷哩啦喇旷跨哭口吭啃咳咯咖喀鹃踞距咀叫嚼践呛遣器品啤喷呸跑咆趴啪呕哦啮呢呐哪鸣吗嘛骂吕路咙另唤患哗唬呼吼喉哄哼嘿喝呵号嚎喊哈贵跪剐咕跟嘎噶咐吩吠啡鄂跺哆蹲吨叮跌吊叼蹬蹈呆蹿吹串喘川躇踌吃逞呈吵嘲唱蹭踩哺别鄙蹦跋吧叭唉哎啊", + "L黯黪黥黩黢黟黠黝黜錾袈罾羁罹罱罴罨詈罟罡罘疃畹畛畈畋畎畀町辚辘辏辎辍辋辄辂辁轾轼轺轹轷轸轶轵轳轲轱轭轫椠嬲迦圜圉圊圄囿囹囫囵囡囝囗勰哿罪浊转轴置辙罩辗斩轧暂圆园辕因鸭轩辖胃畏围团图田四思蜀署输软圈囚轻辆连力累困界较轿驾架甲加辑畸回堑黔畦圃毗畔男默墨皿逻罗轮略轰黑贺国辊轨固辅辐罚恩囤畴车边办罢", + "M髑髌髋髂髅髀髁骼骺骶鹘骷骰骱罂颛鹦殳飚飕飓飑胄觊赙赕赇赈赆赅贻贶遄迥巅嶷嶝嶙嶂嵴嵩嵊嵫嵝嵯嵛嵬崽崴崾嵘崆崞崤崮崦崧崃崂峥峋峤峒峄岷峁岣岫岬岽岢岵岜岚岑岘岈岖岐岍屺岌幡幞幛幔幄帷帼帻帱帔帙帏兕夙罔冂剀刿赚贮周峙帜帧账帐崭赠贼则赃峪屿邮由婴屹鸯央岩崖峡巍网彤同帖贴炭岁髓赎赊赡删山肉冉曲岿凯峻巾见贱几贿幌凰峭嵌岂崎赔帕内帽赂岭骸骨购岗刚冈赋幅凤风峰贩凡帆峨剁朵赌雕典迪丹崔赐幢崇册财贬崩贝败凹盎岸", + "N鐾羿襞胥疋鹨鹛愍熨擘甓檗璧嬖羼屦屣孱屙屐咫尻遐戕爿懵懔憷憧憔憬慵慊愫愎愀惴愣愕愦愠悴惚惆惘惝悱悻惬悛悌悒悃悝悭悚悖恽恪恂恺恻恹恸怡怿怊怫怩怍怏怛怦怵怙忸忭忪怆怅忾忤忡怄忮怃忏忖忉忄嵋崛奘巽乜昼怔展憎悦羽愉忧翌翼异忆乙已迅恤性惺心忻屑懈习犀惜悟屋慰尉尾惟惋臀屠恬屉惕巳司刷属书疏收恃屎虱尸慎慑屈情怜懒愧快慷慨剧惧局居惊尽届忌悸己悔恢恍惶怯悄恰屏譬屁劈怕懦尿尼恼悯民眉忙慢买屡履戮慌怀恒恨悍憾憨惯怪敢改愤飞发惰恫懂刁殿惦翟悼导蛋惮翠戳丑尺迟忱层惨惭怖避臂壁辟必懊", + "O糨糗糅糈糍糌糇糁粽粼粞粝粑敉籼黼黻黹灬爝燧燔燠熠熵熳熘煺煸煊煅煨煜煳焱焯焖焓焐烊烨炫炷烀炻炝炖炜炀遴燮郯邺剡籽灼烛粘炸燥灶凿糟业焰炎烟烯熄烷烃糖烁数烧煽熔燃炔料燎粮炼粒类烙烂烤炕糠炬炯粳精烬火烩煌粕炮糯米迷煤炉娄焕糊烘焊糕烽粪粉烦断灯粹粗锤炊炽炒糙灿炳焙爆", + "P衤窳窭皲襻襦襁褶褫褴褊褛褓褙褡裰裾裨裼褚裱裥裣裎裢裉袼袷裆袢袂衿衽衲衩窨窬窠窦窕窈窆窀穹穸鸩禳禧禚禊禅祺祧祯祠祗祢祚祓祜祛祉祆祀礻邃逭辶謇蹇寰褰寮寤搴骞甯宸宥宓宕宄宀廴郓冥冢冖剜祖宗字祝宙窒之寨窄宅宰灾冤裕寓宇寅宜揖窑宴穴宣袖写宵祥宪窝宛完袜褪突袒它宿宋守视室实审神社衫赛塞褥冗容裙穷寝寥帘礼牢窥宽裤窟寇空客军究窘襟窖家寂寄祸豁窃窍祁祈袍农宁寞幂密蜜寐裸禄窿宦宏鹤褐罕寒害冠官褂寡宫割富袱福额定祷窜窗穿初宠衬察补宾被宝袄案安", + "Q鳢鳟鳝鳜鳙鳗鳕鳔鳓鳐鳏鳎鳍鳋鳊鳇鳆鳅鳄鲽鲼鲻鲺鲷鲶鲵鲴鲳鲲鲱鲰鲮鲭鲫鲩鲧鲦鲥鲣鲢鲡鲠鲟鲛鲚鲕鲔鲒鲑鲐鲋稣鲈鲇鲆鲅鲂鱿鑫觯觫觥觚觞觖斛袅鹱鸱鸲锺镳镲镱镯镬镫镪镩镨镧镦镥镤镢镡镝镟镞镛镙镘镗镖镔镓镒镏镎镌镉镆镅镄锵镂锿锾锼锸锷锶锴锲锱锬锩锫锪锢锟锞锝锛锘锖锕锔锓锒锏锎锍锊锉锇锆锂锃铿铽铼铹铷铵铴铳铯铮铫铩铪铨铧铥铤铢铠铟铞铛铘铙铗铖铕铒铑铐铎铍铌铋铊铉铈铄钿钽钼钺钹钸钷钶钴钲钰钯钬钭钪钫钤钣钜钛钚钕钗钔钐钏钍钌钊钋钇钆钅盥眢欷肴橥桀枭玺邂遛逖迩馕馔馓馑馐馍馊馇馄馀饽饷饴饬饫饪饩饨饧饣夤飧舛獾獯獬獠獗獍獐猱猸猬猥猹猢猕猝猞猊猡猓猗狻狺猃狳猁狷狴狲狩狯狨狒狍狎狁狃犸犷犴犰犭弑鬯劬奂刍郗郇郄邸邬凫匐訇匍勹刎刈氐爻丌钻邹锥铸猪皱钟炙争狰镇针锗詹铡匀钥怨猿鸳狱鱼犹铀迎印饮银逸铱旬锈匈凶猩锌蟹销象镶馅鲜锨狭铣夕希锡勿乌钨危外鸵兔铜铁锑獭锁饲氏饰狮勺煞刹杀色鳃锐饶然卿镣链镰吏鲤狸镭乐狼馈狂钧句锯狙灸久镜鲸锦金解饺角狡铰饯键钾急饥昏钦锹欠钳钱铅钎铺刨钮狞镍镊鸟馁钠名铭勉免猛锰镁贸卯铆锚猫馒锣卵铝鲁留馏铃猎猾狐忽猴狠锅龟逛馆够狗勾钩铬镐钢钙负孵锋饭犯钒饵尔儿饿多钝锻镀独兜锭钉钓甸狄岛错匆触雏锄钞猖铲馋猜铂钵狈钡鲍饱包镑", + "R魑魍魈魉魃魅踅絷罅缶蜇颀鹎鸷瓞皤皓皎皈敫氲氪氤氩氡氚氙氘氕搿掰贽遑逅攮攥攉擢擤擗擐擀撺撙撸撷摺摭撄摞搡搦搌搠搛搋摅掾揆摒揎揞揄揿揠揸揲掼掮捩掊掬捭掴掎捺捱揶掭捃捋挹拶挢拮拗拚拊抻抟扪扌郫邾卮揍拙捉撞撰拽爪抓拄朱质制掷挚指执拯挣振蛰哲折找招摘扎择皂攒岳援拥殷抑掖摇邀氧扬掩押欣卸携挟掀舞捂握挝皖挽挖拓托拖推投捅挺挑提掏搪探摊抬挞所损擞搜撕拴摔抒授手势逝誓拭拾失摄捎擅扫搔撒揉扔热扰攘缺泉邱丘氰氢擒撂撩擂捞揽拦拉扩括捆魁挎扣抠控拷抗扛看揩掘抉攫撅捐据拒拘揪近斤捷接揭搅捡拣技挤挥皇撬抢扦掐气扑迫魄乒拼撇披批捧抨抛乓排拍爬挪扭牛拧捏捻撵年拈拟挠氖拇抹摸抿描抡掠氯掳搂拢拎换护后捍撼氦鬼罐拐挂瓜拱搁搞皋缸抚氟拂扶氛返反扼掇遁盾抖迭掉垫掂抵的捣挡氮掸担打搭挫措搓撮摧捶揣搐抽斥持撑掣撤扯抄掺搀拆搽插操擦捕帛搏拨播兵摈膘卑报抱拌扮扳搬拜摆白把拔扒捌翱按氨皑挨", + "S醺醴醵醯醮醭醪醣醢醑醍醐醅醌酹酴酲酾酽酯酩酰酡酢酤酏酎酐酊覃皙懋檫檩檐檑橼橘樨樽橹檎樵橛樾橄槲樘樗槭樯槿榍槠榕槟槁榱槔榭榫榻榧榛楹楣楦榉槎榈榇槌椴楸榀楫榄楝楂楠椹楱椐棣楗椁椋棰椤棹椟棼楮棂桫梓桷桴梏梵栩桉桧桁桦桕栝梃桤桄桢桎桡桠栳栲柽柁栎柢枸柃栀柝枳柚枵柙栌枰柩栊柘栉柰杼杷枋枞枨杵枧枘杳杪枇枥杩杈杞杓杌鄄剽柞醉棕酌椎桩柱株植枝枕甄杖樟栈榨栅札酝榆酉樱椅椰要样杨酗朽杏醒械楔校橡想相檄西析梧桅枉椭桶酮桐梯桃檀酞梭酸粟酥松栓树述术梳枢柿梢杉森榷醛权栗李楞棱酪榔栏婪框酷枯可棵柯楷禁杰桔酵椒槛检贾枷极机桥橇枪棋栖朴票瓢飘棚配攀柠酿木模棉醚梦檬酶梅枚麓楼柳榴林桓槐横核杭酣棍柜桂棺构梗根格歌哥杠柑杆概覆枫焚酚樊杜栋顶丁档村醋醇椿椽楚橱酬橙郴查槽材柄彬标本杯棒榜梆板柏", + "T齄鼾鼽黧鳘雒艨艟艚艏艋艉艄舾舴舳舻舸舫舨舯舭舣舢舡衄臬籀籁簸簦簪簟簋簖簏篼篾簌篪篦篥篚篝篌篁篑箴箫箢箜箪箅箨箝箬箸箧箦筱筲筢筻筮筠筝筌筵筅筚筘笞笾笳笤笥笠笱笮笙笪笸筇笏笫笊笕笄笃笈竽竺舐螽鹄鸹穰馥黏穑稷稹稔稞稂稃嵇稆秫秣秭秕雉矬矧眚憩愆歃牖牒牍攵氆氇毽毳毪犒犏犍犋犄牿牾牯牦牝昝榘逶逄迤迮迕夂衢徼徵徭徨徜徙徕後徉徇徂彷彳岙鄱郜籴汆劓睾毓胤囟夭乇丿纂租自篆筑竹舟重种稚秩智知征毡乍怎造赞粤御禹釉役移秧衍延衙循熏血选徐秀行衅笑向箱香舷衔先系悉息稀牺务物午我稳魏委微往颓徒秃透筒艇廷条舔甜特躺毯笋穗算艘私税黍释适矢剩升牲甥生身射舌稍扇筛入壬躯秋利篱黎犁梨篮筐筷科靠矩咎径筋街秸矫舰箭简笺稼季籍箕积稽秽徽簧乔签迁千迄乞片篇篷磐盘徘牌穆牧牡敏秒秘每么毛箩乱律篓笼徊乎衡很和禾航管乖刮箍躬各告稿篙秆竿复符逢繁翻番乏筏鹅舵躲短犊冬丢第笛敌等得德稻待答篡簇囱辞垂船处臭筹愁稠秤惩程乘称彻长策舱簿舶箔秉币彼笔鼻笨惫备版般稗笆奥矮", + "U鲞蹩翦粢羲羰羯羧羟羝竦翊癯癫癖癜癔癞癍瘳瘾癃瘵瘿瘰瘭癀瘠瘢瘼瘛瘙瘕瘘瘥瘊瘗瘌瘅瘀瘐痿痼痱瘃痧痫痤痦痨痣痍痖痂痃疰疱痄疸疴疳疣疬疝疠疖疔疒鹣鹚鹈鹇蠲戆恣恙飒歆旮甑瓿猷槊桊孳妾遒丬阚阙阗阖阕阒阏阍阌阋阊阈阆阄阃闾闼闶闵闳闱闫闩啻鄯鄣邶凇冼冽冱冫衮兖夔冁馘遵尊总姿资咨兹着准状壮妆装痔郑症疹瘴彰章站闸曾韵阅痈音益毅意疫冶养痒羊疡彦沿阎颜阉丫癣羞新辛效翔羡闲问闻瘟头痛童剃誊疼痰瘫遂塑送朔兽瘦首韶商善闪闰瘸券拳痊酋亲疗凉立痢冷兰阑辣阔况竣决卷眷疽疚净竞竟靖痉疥竭郊交酱奖桨浆将将姜减剪兼煎间冀疾羌歉前凄普剖瓶瞥痞疲旁叛判疟凝逆闹闽闷门美六瘤凌羚凛豢痪痕阂闺关羹阁疙羔赣盖冯疯阀兑端痘斗冻凋奠递弟帝盗道郸单瘩瘁凑次瓷慈疵闯疮冲痴阐产差部并病冰瘪憋鳖辫辩辨弊敝闭痹迸背北半瓣疤癌", + "V鼷鼹鼯鼬鼢暨艮舄舁臾鸠聿肀邕甾巛驽孥孀嬷嬗嬉嫜嫘嫦嫖嫱嫣媸嫔嫒媲嫫媾婷媛媪胬婵婢娼婕婊婧婀娓娣娴娲娉娌姹姘姣姝娆娅姗妯妲姒妤妞妫姊妗妣妪妩妍妃妁弩彐邋逯帑叟劭馗帚召杂娱尹姻姨姚妖巡寻婿絮旭姓嫌媳婉丸娃退迢她肃恕鼠始婶娠邵嫂如妊刃忍群隶姥恳垦郡君娟舅臼九姐剿娇建奸嫁妓既嫉即姬婚毁女怒努奴娘妮嫩奶娜那姆妙娩媚妹媒妈录灵好姑妇妨娥妒嫡刀逮巢剥", + "W黛雠隽隼隹翕翎衾颔颌鹪鹆鸺畲龛恁爨煲歙毹牮觎瓴戗璺岱坌郐兮龠俎佥佘氽仝儋儇僮僦僬僭儆僖傺傩傧傥偻偬偎偈偕偃偾倨倥倌倜俾倭倮倏倬俳偌倩俸俟俑俜俣俚俅俪俨俦侔侬佼侪佻佾侏侃侉侑佴佶伽伲佗佟佝佚攸佧佞伫伉伧伥仵佤伢仳伛仞仫仡仨仂仉仃亻劁坐作做佐仔追住众仲侄值侦仗债欲愈逾俞余舆佑悠优佣亿倚仪伊依爷仰佯叙修休信斜像仙侠侮伍瓮翁位伪伟途偷停体倘贪他僳俗颂怂耸似伺舒售侍仕使食什伸舍伤傻僧伞儒仍任人仁全倾禽侵僚敛俩俐例傈儡佬傀侩俊倔倦俱仅今介借侥焦僵剑健件俭价假佳祭伎集货伙会俏侨仟企仆凭贫偏僻盆佩偶您念你倪拿命们仑伦侣令领伶赁鳞邻化华候侯盒合何含刽癸谷估公供个鸽父阜付傅斧釜俯俘伏佛忿份分仿伐俄段侗爹佃低凳登倒但袋贷代傣催促丛从创传储仇侈倡偿豺岔侧仓伯饼便倍堡保傍伴颁佰爸八傲俺", + "X飨糸蠡颍鸶鸨犟畿幺缵缳缲缱缰缯缭缬缫缪缧缦缥缤缣缢缡缟缛缜缙缗缒缑缏缌缋缈缇缃缂缁绾绻绺绶缍绲绱绯绮绫绨绡绠绛绗绔绐绌绋绉绂绁绀纾纰纭纩纨纥纣纡纟鬻弼艴弭弪彘彖辔匕组纵综缀粥终纸旨织张绽约缘幼幽颖缨引绎肄彝疑绚续绪绣乡线弦纤细毋纹纬维统绦缩绥丝绳绅绍缮纱弱绒纫绕顷练缆绝绢纠经结皆绞缴疆缄纪继级缉绩绘强纽纳母缅绵弥络纶绿缕幻缓弧红弘贯弓给纲缚弗缝纷费纺缎缔弹绰纯绸弛缠编毖毙毕比绷绑绊", + "Y麟麝鏖麒麋麈麇麂縻麾麽饔銮綮翩颏颃鹫鹧鹑鸾憝扉扈扃戽戾旖旒旎旌旃旄旆於斓齑膂肓昶栾娈膺廪廨廛廑廒赓庳庾庵庹庠庥庖庋庑庀奕弈壅塾劾邡邙邝谶谵谳谲谯谮谫谪谧谥谡谠谟谝谘谛谙谖谕谔谒谑谏谌谇谄谂谀诿诼诹诶诳诰诮诩诨诤诠诟诜诙诘诖诔诓诒诎诏诋诃诂讷讵讴讪讧讦讠羸蠃嬴禀裒脔亵袤亳亠丶座诅族卒谆庄主诛诸诌州衷证诊这遮肇斋诈育语诱永雍庸赢应鹰译谊议诣义裔亦衣夜谣谚言讶讯训询玄旋畜序许谢谐享详襄席误诬紊文谓为妄忘望亡弯庭亭讨唐谈谭诉诵讼说谁衰庶熟孰试市识诗施设认让瓤庆请廖谅亮良恋廉离朗郎廊谰廓库课刻亢康诀就京谨诫讲肩记计剂讥迹诲讳谎敲谴谦讫弃启旗齐谱评烹庞诺亩谋魔摩磨谬庙谜糜靡氓盲谩蛮麻论孪挛峦率旅鹿庐刘吝话户亨毫豪亥裹郭诡广雇庚膏高该讣腐府讽废诽放访房方讹敦度读订谍调店底诞词床充诚颤谗诧斌遍卞变扁庇褒谤哀", + "!@#%…&*()—;:”'?《》,。、~={}','|"}; + + public static String getWBCode(String str) { + StringBuffer result = new StringBuffer(); + //用char循环取得每一个String的 字符 + for (int i = 0; i < str.length(); i++) { + char temp1 = str.charAt(i); + int asciicode = (int) temp1; + //如果是254以内的ASCII 表示是西文字母和字符,直接显示,无需翻译 + if (asciicode >= 1 && asciicode <= 254) { + result.append(temp1); + } else { + //循环遍历汉字五笔的字库(按照五笔首字符字符分组) + for (int j = 0; j < WB.length; j++) { + char[] dbTmp = WB[j].toCharArray(); + //循环遍历每个英文字母的字库 + for (int k = 1; k < dbTmp.length; k++) { + //找到 + if ((int) temp1 == (int) dbTmp[k]) { + //如果在WB最后一行,表明是中文标点符号,直接显示,否则显示对应的五笔首字母(该行的第1个字符) + if (j == WB.length - 1) { + result.append(dbTmp[k]); + } else { + result.append(dbTmp[0]); + } + break; + } + } + } + } + } + return result.toString(); + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/WxDecodeUtil.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/WxDecodeUtil.java new file mode 100644 index 0000000..3be2a27 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/WxDecodeUtil.java @@ -0,0 +1,57 @@ +package com.mt.wms.core.utils; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.codec.binary.Base64; + + +/** + *

+ * 微信解密工具类 + *

+ * + * @author Mr.ZhangShi + * @version 1.0 + * @date 2020/10/9 + */ +public class WxDecodeUtil { + + private static final String WATERMARK = "watermark"; + private static final String APPID = "appid"; + /** + * 解密数据 + * @return + * @throws Exception + */ + public static String decrypt(String appId, String encryptedData, String sessionKey, String iv){ + String result = ""; + try { + AES aes = new AES(); + byte[] resultByte = aes.decrypt(Base64.decodeBase64(encryptedData), Base64.decodeBase64(sessionKey), Base64.decodeBase64(iv)); + if(null != resultByte && resultByte.length > 0){ + result = new String(WxPKCS7Encoder.decode(resultByte)); + JSONObject jsonObject = JSONObject.parseObject(result); + String decryptAppid = jsonObject.getJSONObject(WATERMARK).getString(APPID); + if(!appId.equals(decryptAppid)){ + result = ""; + } + } + } catch (Exception e) { + result = ""; + e.printStackTrace(); + } + return result; + } + + + public static void main(String[] args) throws Exception{ + String appId = "wxf7c523e6ffb6e7b4"; + String encryptedData = "j4mV+NynEPT4wmxqgNeF29b6CCz2DfBiXQzahJksc6yuDPn7W85h2zIV+SQFJR0u+EMJa37mncYgWl5uo0x9EHHZeq/5cYgNnI5LPtGbTyA8i+uk2wLhXYfZpAhX5ZDFDEX3svnXgU78PUlRHzqF+MAWcJjlP00V7IhKZGdESR8gyusY9JsINxKlbhrZOsFmFWzKOR8ZU9x8mlJmtIj2pw=="; + String sessionKey = "bNPKpLTmv2TgHViEGgyHOg=="; + String iv = "AUtk2XZB/6F8hTErDUeLGg=="; + String jsonStr = decrypt(appId, encryptedData, sessionKey, iv); + + System.out.println(jsonStr); + String phoneNumber = com.alibaba.fastjson.JSONObject.parseObject(jsonStr).getString("phoneNumber"); + System.out.println(phoneNumber); + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/WxPKCS7Encoder.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/WxPKCS7Encoder.java new file mode 100644 index 0000000..3a17675 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/WxPKCS7Encoder.java @@ -0,0 +1,67 @@ +package com.mt.wms.core.utils; + +import java.nio.charset.Charset; +import java.util.Arrays; + +/** + *

+ *

+ * + * @author Mr.ZhangShi + * @version 1.0 + * @date 2020/10/9 + */ +public class WxPKCS7Encoder { + + private static final Charset CHARSET = Charset.forName("utf-8"); + private static final int BLOCK_SIZE = 32; + + /** + * 获得对明文进行补位填充的字节. + * + * @param count + * 需要进行填充补位操作的明文字节个数 + * @return 补齐用的字节数组 + */ + public static byte[] encode(int count) { + // 计算需要填充的位数 + int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE); + if (amountToPad == 0) { + amountToPad = BLOCK_SIZE; + } + // 获得补位所用的字符 + char padChr = chr(amountToPad); + String tmp = new String(); + for (int index = 0; index < amountToPad; index++) { + tmp += padChr; + } + return tmp.getBytes(CHARSET); + } + + /** + * 删除解密后明文的补位字符 + * + * @param decrypted + * 解密后的明文 + * @return 删除补位字符后的明文 + */ + public static byte[] decode(byte[] decrypted) { + int pad = decrypted[decrypted.length - 1]; + if (pad < 1 || pad > 32) { + pad = 0; + } + return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad); + } + + /** + * 将数字转化成ASCII码对应的字符,用于对明文进行补码 + * + * @param a + * 需要转化的数字 + * @return 转化得到的字符 + */ + public static char chr(int a) { + byte target = (byte) (a & 0xFF); + return (char) target; + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/ZipUtils.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/ZipUtils.java new file mode 100644 index 0000000..d4b89a1 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/ZipUtils.java @@ -0,0 +1,150 @@ +package com.mt.wms.core.utils; + +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.util.List; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +/** + *

+ * 压缩文件的工具类(zip压缩) + *

+ * + * @author Mr.ZhangShi + * @date 2019/3/14 + * @since 1.0 + */ +public class ZipUtils { + + private ZipUtils() { + } + + public static void doCompress(String srcFile, String zipFile) throws IOException { + doCompress(new File(srcFile), new File(zipFile)); + } + + /** + * 文件压缩 + * + * @param srcFile 目录或者单个文件 + * @param zipFile 压缩后的ZIP文件 + */ + public static void doCompress(File srcFile, File zipFile) throws IOException { + ZipOutputStream out = null; + try { + out = new ZipOutputStream(new FileOutputStream(zipFile)); + doCompress(srcFile, out); + } catch (Exception e) { + throw e; + } finally { + out.close(); + } + } + + public static void doCompress(String filelName, ZipOutputStream out) throws IOException { + doCompress(new File(filelName), out); + } + + /** + * 支持单个文件自定义文件名压缩( + * + * @param filePath 文件路径 + * @param fileName 文件名 + * @param out + * @throws IOException + */ + public static void doCompress(String filePath, String fileName, ZipOutputStream out) throws IOException { + ZipUtils.doZip(new File(filePath), fileName, out, ""); + } + + public static void doCompress(File file, ZipOutputStream out) throws IOException { + doCompress(file, out, ""); + } + + public static void doCompress(File inFile, ZipOutputStream out, String dir) throws IOException { + if (inFile.isDirectory()) { + File[] files = inFile.listFiles(); + if (files != null && files.length > 0) { + for (File file : files) { + String name = inFile.getName(); + if (!"".equals(dir)) { + name = dir + "/" + name; + } + ZipUtils.doCompress(file, out, name); + } + } + } else { + ZipUtils.doZip(inFile, out, dir); + } + } + + public static void doZip(File inFile, ZipOutputStream out, String dir) throws IOException { + doZip(inFile, "", out, dir); + } + + public static void doZip(File inFile, String fileName, ZipOutputStream out, String dir) throws IOException { + String entryName; + if (StringUtils.isEmpty(fileName)) { + fileName = inFile.getName(); + } + if (StringUtils.isNotEmpty(dir)) { + entryName = dir + "/" + fileName; + } else { + entryName = fileName; + } + ZipEntry entry = new ZipEntry(entryName); + out.putNextEntry(entry); + + int len = 0; + byte[] buffer = new byte[1024]; + FileInputStream fis = new FileInputStream(inFile); + while ((len = fis.read(buffer)) > 0) { + out.write(buffer, 0, len); + out.flush(); + } + out.closeEntry(); + fis.close(); + } + + public static void zipFile(HttpServletResponse response, List> list) throws Exception { + ZipOutputStream out = null; + response.setContentType("APPLICATION/OCTET-STREAM"); + response.setHeader("Content-Disposition", "attachment; filename=" + new String(("医诺云检" + DateUtil.getCurrentDateTimeNow() + ".zip").getBytes("GBK"), "ISO8859_1")); + //设置压缩流:直接写入response,实现边压缩边下载 + ZipOutputStream zipos = null; + try { + zipos = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream())); + zipos.setMethod(ZipOutputStream.DEFLATED);//设置压缩方法 + } catch (Exception e) { + e.printStackTrace(); + } + DataOutputStream os = null; + //循环将文件写入压缩流 + for (Map map : list) { + String filePath = map.get("fileUrl").toString(); + String fileName = map.get("fileName").toString(); + File file = new File(filePath);//要下载文件的路径 + try { + //添加ZipEntry,并ZipEntry中写入文件流 + //这里,加上i是防止要下载的文件有重名的导致下载失败 + zipos.putNextEntry(new ZipEntry(fileName)); + os = new DataOutputStream(zipos); + InputStream is = new FileInputStream(file); + byte[] b = new byte[100]; + int length = 0; + while ((length = is.read(b)) != -1) { + os.write(b, 0, length); + } + is.close(); + zipos.closeEntry(); + } catch (Exception e) { + e.printStackTrace(); + } + } + os.flush(); + os.close(); + zipos.close(); + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/validator/constraints/Enum.java b/6.program/wms-core/src/main/java/com/mt/wms/core/validator/constraints/Enum.java new file mode 100644 index 0000000..e2de062 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/validator/constraints/Enum.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.validator.constraints; + +import com.mt.wms.core.base.IEnum; + +import javax.validation.Constraint; +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; +import javax.validation.Payload; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import static java.lang.annotation.ElementType.*; + +/** + * 枚举验证器注解 + *

+ * 当验证值为null时默认返回验证成功,如果需要验证null请再加相关的验证器。 + *

+ * + * @author jiff + * @date 2018/11/7 + * @since 1.0 + */ +@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE}) +@Retention(RetentionPolicy.RUNTIME) +@Constraint(validatedBy = {Enum.EnumValidator.class}) +@Documented +public @interface Enum { + String message() default ""; + + Class[] groups() default {}; + + Class[] payload() default {}; + + /** + * 给定的枚举类型必须继承{@link IEnum} + * + * @return 枚举数组 + */ + Class[] target() default {}; + + + /** + * 枚举验证器 + * + * @author jiff + * @date 2018/11/7 + * @since 1.0 + */ + class EnumValidator implements ConstraintValidator { + + /** + * 枚举类 + */ + private Class[] cls; + + @Override + public void initialize(Enum constraintAnnotation) { + cls = constraintAnnotation.target(); + } + + @Override + public boolean isValid(Object value, ConstraintValidatorContext context) { + if (value == null) { + return true; + } + if (cls.length > 0) { + for (Class cl : cls) { + try { + if (cl.isEnum() && IEnum.class.isAssignableFrom(cl)) { + //枚举类验证 + Object[] objects = cl.getEnumConstants(); + Method method = cl.getMethod("getValue"); + for (Object object : objects) { + Object code = method.invoke(object, null); + if (value.equals(code)) { + return true; + } + } + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } else { + return true; + } + return false; + } + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/validator/constraints/Password.java b/6.program/wms-core/src/main/java/com/mt/wms/core/validator/constraints/Password.java new file mode 100644 index 0000000..a956003 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/validator/constraints/Password.java @@ -0,0 +1,118 @@ +package com.mt.wms.core.validator.constraints; + +import com.mt.wms.core.base.IEnum; + +import javax.validation.Constraint; +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; +import javax.validation.Payload; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static java.lang.annotation.ElementType.*; + +/** + *

+ * 密码验证器 + *

+ * + * @author Mr.ZhangShi + * @date 2019/7/19 + * @since 1.0 + */ +@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE}) +@Retention(RetentionPolicy.RUNTIME) +@Constraint(validatedBy = {Password.PasswordValidator.class}) +@Documented +public @interface Password { + + String message() default ""; + + Class[] groups() default {}; + + Class[] payload() default {}; + + Password.PasswordFormat format() default PasswordFormat.NUMBER; + + class PasswordValidator implements ConstraintValidator { + + private String pattern; + + @Override + public void initialize(Password constraintAnnotation) { + pattern = constraintAnnotation.format().getValue(); + } + + @Override + public boolean isValid(Object value, ConstraintValidatorContext context) { + if (value == null || value.toString().length() < 6) { + return false; + } + Pattern regex = Pattern.compile(pattern); + Matcher matcher = regex.matcher(value.toString()); + return matcher.find(); + } + } + + enum PasswordFormat implements IEnum { + + /** + * 只包含数字 + */ + NUMBER("^?\\d+$", "只包含数字"), + + /** + * 同时包含数字和字母 + */ + NUMBER_LETTER("^(?![a-zA-z]+$)(?!\\d+$)(?![!@#$%^&*]+$)[a-zA-Z\\d!@#$%^&*]+$", "同时包含数字和字母"), + + /** + * 同时包含数字字母特殊字符 + */ + NUMBER_LETTER_CHAR("^^(?![a-zA-z]+$)(?!\\d+$)(?![~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?-]+$)(?![a-zA-z\\d]+$)(?![~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?-]+$)(?![\\d~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?-]+$)[a-zA-Z\\d~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?-]+$" + , "同时包含数字字母特殊字符"), + ; + + private final String value; + private final String label; + private final String remark; + + PasswordFormat(final String value, final String label) { + this(value, label, null); + } + + PasswordFormat(final String value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + @Override + public String getValue() { + return value; + } + + /** + * @return 标签名 + */ + @Override + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + @Override + public String getRemark() { + return remark; + } + } +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/validator/groups/AddGroup.java b/6.program/wms-core/src/main/java/com/mt/wms/core/validator/groups/AddGroup.java new file mode 100644 index 0000000..ae68963 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/validator/groups/AddGroup.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.validator.groups; + +/** + * 新增数据验证组 + * + * @author jiff + * @date 2018/11/7 + * @since 1.0 + */ +public interface AddGroup { +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/validator/groups/PageGroup.java b/6.program/wms-core/src/main/java/com/mt/wms/core/validator/groups/PageGroup.java new file mode 100644 index 0000000..0820333 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/validator/groups/PageGroup.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.validator.groups; + +/** + * 分页查询数据验证组 + * + * @author jiff + * @date 2018/11/20 + * @since 1.0 + */ +public interface PageGroup { +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/validator/groups/UpdateGroup.java b/6.program/wms-core/src/main/java/com/mt/wms/core/validator/groups/UpdateGroup.java new file mode 100644 index 0000000..35f89d1 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/validator/groups/UpdateGroup.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.validator.groups; + +/** + * 更新数据验证组 + * + * @author jiff + * @date 2018/11/7 + * @since 1.0 + */ +public interface UpdateGroup { +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/CommonVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/CommonVo.java new file mode 100644 index 0000000..ed3ea9a --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/CommonVo.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.vo; + +import com.mt.wms.core.base.BaseVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.time.LocalDateTime; + +/** + * 公共视图对象 + * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@ApiModel("公共视图对象") +public class CommonVo extends BaseVo { + + /** + * 启用状态:0 、停用,1、启用 + */ + @ApiModelProperty(value = "启用状态:0 、停用,1、启用", example = "1", position = Integer.MAX_VALUE - 1) + private Integer enabled; + /** + * 备注 + */ + @ApiModelProperty(value = "备注", position = Integer.MAX_VALUE - 1) + private String remark; + + + /** + * 创建人 + */ + @ApiModelProperty(value = "创建人", example = "1", position = Integer.MAX_VALUE) + private Long creator; + + /** + * 创建人姓名 + */ + @ApiModelProperty(value = "创建人姓名", example = "ulabcare", position = Integer.MAX_VALUE) + private String creatorName; + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间", position = Integer.MAX_VALUE) + private LocalDateTime createTime; + + /** + * 更新人 + */ + @ApiModelProperty(value = "更新人", example = "1", position = Integer.MAX_VALUE) + private Long updater; + + /** + * 更新人姓名 + */ + @ApiModelProperty(value = "更新人姓名", example = "ulabcare", position = Integer.MAX_VALUE) + private String updaterName; + + /** + * 更新时间 + */ + @ApiModelProperty(value = "更新时间", position = Integer.MAX_VALUE) + private LocalDateTime updateTime; + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/DictDataVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/DictDataVo.java new file mode 100644 index 0000000..3096801 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/DictDataVo.java @@ -0,0 +1,24 @@ +package com.mt.wms.core.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/7/6 + * @since 1.0 + */ +@ApiModel("字典值对象") +@Data +public class DictDataVo { + @ApiModelProperty("字典编码") + private String code; + + @ApiModelProperty("字典名称") + private String name; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/IdListVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/IdListVo.java new file mode 100644 index 0000000..daac2cd --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/IdListVo.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.vo; + +import com.mt.wms.core.base.BaseVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.util.List; + + +/** + * 主键列表对象 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel("主键列表视图对象") +public class IdListVo extends BaseVo { + @ApiModelProperty(value = "主键列表", required = true, example = "[1]", notes = "根据实际接口返回不同对象的主键列表") + private List ids; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/IdVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/IdVo.java new file mode 100644 index 0000000..688430f --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/IdVo.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.vo; + +import com.mt.wms.core.base.BaseVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + + +/** + * 主键对象 + * + * @author jiff + * @date 2018/11/7 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel("主键视图对象") +public class IdVo extends BaseVo { + @ApiModelProperty(value = "主键", required = true, example = "1", notes = "根据实际接口返回不同对象的主键") + private Long id; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/LoginUserVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/LoginUserVo.java new file mode 100644 index 0000000..3103417 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/LoginUserVo.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.vo; + +import com.mt.wms.core.base.BaseVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * 登录用户视图对象 + * + * @author jiff + * @date 2018/11/13 + * @since 1.0 + */ +@Builder +@Data +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "登录用户视图对象", description = "用于获取当前登录用户信息") +public class LoginUserVo extends BaseVo { + @ApiModelProperty(value = "合作伙伴ID,合作伙伴用户返回该值", example = "1") + private Long partnerId; + @ApiModelProperty(value = "合作伙伴名称,合作伙伴用户返回该值", example = "一诺检验") + private String partnerName; + @ApiModelProperty(value = "医院ID,医院用户返回该值", example = "1") + private Long hospitalId; + @ApiModelProperty(value = "医院名称,医院用户返回该值", example = "浙一") + private String hospitalName; + @ApiModelProperty(value = "组织ID", required = true, example = "1") + private Long orgId; + @ApiModelProperty(value = "组织名称", required = true, example = "一诺检验") + private String orgName; + @ApiModelProperty(value = "用户ID", required = true, example = "1") + private Long userId; + @ApiModelProperty(value = "手机号码", required = true, example = "13588441519") + private String mobile; + @ApiModelProperty(value = "用户名称", example = "jiff") + private String userName; + + /** + * 工号 + */ + @ApiModelProperty(value = "工号", example = "1") + private String code; + /** + * 性别(1女,2男) + */ + @ApiModelProperty(value = "性别(1女,2男)", example = "1") + private Integer sex; + /** + * 头像 + */ + @ApiModelProperty(value = "头像", example = "1") + private String portrait; + @ApiModelProperty(value = "用户菜单") + private List menus; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/MenuResourceVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/MenuResourceVo.java new file mode 100644 index 0000000..1f0345d --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/MenuResourceVo.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.vo; + +import com.mt.wms.core.enums.HttpMethodEnum; +import com.mt.wms.core.enums.ResourceCategoryEnum; +import com.mt.wms.core.validator.constraints.Enum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + *

+ * 菜单资源视图对象 + *

+ * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "菜单资源视图对象", description = "用于查询菜单资源信息") +public class MenuResourceVo extends CommonVo implements PageVo.ConvertVo { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键", required = true, example = "1") + private Long id; + + /** + * 资源ID + */ + @ApiModelProperty(value = "资源ID", required = true, example = "1") + @NotNull(message = "资源ID不能为空") + private Long resourceId; + + /** + * 服务ID + */ + @ApiModelProperty(value = "服务ID", required = true, example = "1") + @NotNull(message = "服务ID不能为空") + private Long serviceId; + + /** + * 名称 + */ + @ApiModelProperty(value = "名称", required = true, example = "新增资源") + @NotBlank(message = "名称不能为空") + private String name; + + /** + * 请求地址,可以用于前端ajax调用,后端用于做权限控制 + */ + @ApiModelProperty(value = "url", required = true, example = "/platform-upms/resource/add") + @NotBlank(message = "请求地址不能为空") + private String url; + + /** + * 请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE + */ + @ApiModelProperty(value = "请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE", required = true, example = "post") + @NotBlank(message = "请求方法不能为空") + @Enum(message = "非法的请求类型", target = {HttpMethodEnum.class}) + private String method; + + /** + * 子系统:0、common,1、platform,2、partner,3、hospital,4、patient + */ + @ApiModelProperty("子系统:0、common,1、platform,2、partner,3、hospital,4、patient") + private Integer subsystem; + + /** + * 分类:0、common,1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "分类:0、common,1、pc,2、app,3、wechat,4、miniapp", required = true, example = "0") + @NotNull(message = "资源类型不能为空") + @Enum(message = "非法的资源类型", target = {ResourceCategoryEnum.class}) + private Integer category; + + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/MenuVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/MenuVo.java new file mode 100644 index 0000000..298db62 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/MenuVo.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.vo; + +import com.mt.wms.core.base.ITree; +import com.mt.wms.core.enums.MenuCategoryEnum; +import com.mt.wms.core.enums.MenuTypeEnum; +import com.mt.wms.core.validator.constraints.Enum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + *

+ * 菜单表 + *

+ * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "菜单视图对象", description = "用于查询菜单信息") +public class MenuVo extends CommonVo implements PageVo.ConvertVo, ITree { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键", required = true, example = "1") + private Long id; + + /** + * 父菜单ID + */ + @ApiModelProperty(value = "父菜单ID", required = true, example = "0") + @NotNull(message = "父菜单ID不能为空") + private Long parentId; + + /** + * 父菜单名称 + */ + @ApiModelProperty(value = "父菜单名称,再获取单个菜单信息时会返回", required = false, example = "系统管理") + private String parentName; + + /** + * 菜单编码 + */ + @ApiModelProperty(value = "菜单编码", example = "menu") + private String code; + + /** + * 菜单名称 + */ + @ApiModelProperty(value = "菜单名称", required = true, example = "菜单管理") + @NotBlank(message = "菜单名称不能为空") + private String name; + + /** + * 菜单图标 + */ + @ApiModelProperty("菜单图标") + private String icon; + + /** + * 链接地址,可以是页面地址,也可以是函数事件 + */ + @ApiModelProperty("链接地址,可以是页面地址,也可以是函数事件") + private String href; + + /** + * 请求地址,可以用于前端ajax调用,后端用于做权限控制 + */ + @ApiModelProperty("请求地址,可以用于前端ajax调用,后端用于做权限控制") + private String url; + + /** + * 请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE + */ + @ApiModelProperty(value = "请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE", example = "post") + private String method; + + /** + * 权限,可以有多个,用逗号分隔,可用于第三方权限框架扩展 + */ + @ApiModelProperty("权限,可以有多个,用逗号分隔,可用于第三方权限框架扩展") + private String permission; + + /** + * 分类:1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "分类:1、pc,2、app,3、wechat,4、miniapp", required = true, example = "1") + @NotNull(message = "菜单分类不能为空") + @Enum(message = "非法的菜单分类", target = {MenuCategoryEnum.class}) + private Integer category; + + + /** + * 类型:1、module,2、menu,3、button + */ + @ApiModelProperty(value = "类型:1、module,2、menu,3、button", required = true, example = "1") + @NotNull(message = "菜单类型不能为空") + @Enum(message = "非法的菜单类型", target = {MenuTypeEnum.class}) + private Integer type; + + /** + * 显示顺序 + */ + @ApiModelProperty(value = "显示顺序", example = "1") + private Integer orderNum; + + /** + * 角色是否分配该菜单:true、已分配,false、未分配 + */ + @ApiModelProperty(value = "角色是否分配该菜单:true、已分配,false、未分配,用于根据角色获取所有菜单", required = false, example = "true") + private boolean checked; + + /** + * 子列表 + */ + @ApiModelProperty(value = "子列表,用于获取菜单树时才有数据", required = false) + private List children; + + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/PageVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/PageVo.java new file mode 100644 index 0000000..3b9c9d4 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/PageVo.java @@ -0,0 +1,132 @@ +package com.mt.wms.core.vo; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.mt.wms.core.base.BaseVo; +import com.mt.wms.core.exception.ApiException; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.beans.BeanUtils; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +/** + * 分页vo转换类 + * 对象转换默认自动转换,也可以自定义转换:重写PageVo.ConvertVo接口默认方法即可 + * + * @author Mr.ZhangShi + * @date 2018/11/1 14:27 + */ +@Data +@ApiModel("分页视图对象") +public class PageVo extends BaseVo { + + /** + * 数据 + */ + @ApiModelProperty("数据") + private List records; + + /** + * 总数 + */ + @ApiModelProperty("总数") + private long total; + + /** + * 总页数 + */ + @ApiModelProperty("总页数") + private long pages; + + /** + * 每页记录数 + */ + @ApiModelProperty("每页记录数") + private long size; + + /** + * 当前页 + */ + @ApiModelProperty("当前页") + private long current; + + public PageVo(IPage page, Class cls) { + this.total = page.getTotal(); + this.pages = page.getPages(); + this.size = page.getSize(); + this.current = page.getCurrent(); + if (CollectionUtils.isNotEmpty(page.getRecords())) { + posConvertVos(page.getRecords(), cls); + } + } + + /** + * pojoList转化为voList + * + * @param pos 原对象列表 + * @param voClass 目标对象class + * @param 原对象 + */ + public void posConvertVos(List pos, Class voClass) { + this.records = new ArrayList<>(); + try { + for (R po : pos) { + T vo = newInstance(voClass); + vo.convertPoToVo(po); + records.add(vo); + } + } catch (Exception e) { + throw new ApiException("对象转换异常", e); + } + } + + /** + * 实例化 + * + * @param voClass + * @return + */ + private T newInstance(Class voClass) { + try { + T vo; + //如果包含builder方法则为使用lombok.Builder注解的类,该注解只在编译期间有效,编译后的class中无法获取该注解 + try { + Method builder = voClass.getDeclaredMethod("builder"); + Object invoke = builder.invoke(null, null); + vo = (T) invoke.getClass().getDeclaredMethod("build").invoke(invoke); + } catch (NoSuchMethodException e) { + vo = voClass.newInstance(); + } + return vo; + } catch (Exception e) { + throw new ApiException("对象拷贝异常", e); + } + } + + public interface ConvertVo { + + /** + * 自定义转换 + * + * @param po + */ + default void convertPoToVo(Object po) { + defaultConvertPoToVo(po, this); + } + } + + /** + * 默认对象转换方法 + * + * @param po 原对象 + * @param vo 目标对象 + */ + private static void defaultConvertPoToVo(Object po, Object vo) { + BeanUtils.copyProperties(po, vo); + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/R.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/R.java new file mode 100644 index 0000000..24279b0 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/R.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.vo; + +import com.mt.wms.core.errorcode.ApiErrorCode; +import com.mt.wms.core.base.IErrorCode; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * 处理结果类 + * + * @param 返回的数据类型 + * @author jiff + * @date 2018/11/7 + * @since 1.0 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@ToString +@ApiModel("处理结果类") +@Accessors +public class R implements Serializable { + @NonNull + @ApiModelProperty(value = "结果码", example = "0") + private int code = IErrorCode.CODE_SUCCESSFUL; + @ApiModelProperty(value = "结果说明", example = "成功") + private String msg; + @ApiModelProperty(value = "业务数据") + private T data; + + public R code(int code) { + this.code = code; + return this; + } + + public R msg(String msg) { + this.msg = msg; + return this; + } + + public R data(T data) { + this.data = data; + return this; + } + + public boolean ok() { + return code == IErrorCode.CODE_SUCCESSFUL; + } + + public static R failed() { + return failed("系统错误!"); + } + + public static R failed(String msg) { + return failed(ApiErrorCode.FAILED.getCode(), msg); + } + + public static R failed(int code, String msg) { + return failed(code, msg, null); + } + + public static R failed(int code, String msg, T data) { + return r(code == ApiErrorCode.SUCCESSFUL.getCode() ? ApiErrorCode.FAILED.getCode() : code, msg, data); + } + + public static R failed(IErrorCode errorCode) { + return r(errorCode, null); + } + + public static R r(IErrorCode errorCode, T data) { + return r(errorCode.getCode(), errorCode.getMsg(), data); + } + + public static R r(int code, String msg, T data) { + return new R().code(code).msg(msg).data(data); + } + + public static R unauthorized() { + return failed(ApiErrorCode.UNAUTHORIZED); + } + + public static R forbidden() { + return failed(ApiErrorCode.FORBIDDEN); + } + + public static R ok(T data) { + return new R().data(data); + } + + public static R ok(String msg, T data) { + return new R().msg(msg).data(data); + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/SelectVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/SelectVo.java new file mode 100644 index 0000000..d1fb2f6 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/SelectVo.java @@ -0,0 +1,27 @@ +package com.mt.wms.core.vo; + +import com.mt.wms.core.base.BaseVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/7/6 + * @since 1.0 + */ +@ApiModel("下拉选择列表对象") +@EqualsAndHashCode(callSuper = true) +@Data +public class SelectVo extends BaseVo { + @ApiModelProperty("key值,用于传给后端") + private Object k; + + @ApiModelProperty("value值,用于前端显示") + private Object v; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/SmsSignCodeVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/SmsSignCodeVo.java new file mode 100644 index 0000000..70bb440 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/SmsSignCodeVo.java @@ -0,0 +1,28 @@ +package com.mt.wms.core.vo; + +import com.mt.wms.core.base.BaseVo; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * + *

+ * + * @author FanYi + * @date 2020/4/28 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class SmsSignCodeVo extends BaseVo { + private Long sceneId; + + private String signName; + + private String templateCode; + + private Integer templateType; + + private String templateContent; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/TokenVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/TokenVo.java new file mode 100644 index 0000000..cebb4ab --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/TokenVo.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.vo; + +import com.mt.wms.core.base.BaseVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + + +/** + * 会话令牌对象 + * + * @author jiff + * @date 2018/11/7 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel(value = "会话令牌对象", description = "") +public class TokenVo extends BaseVo { + @ApiModelProperty(value = "会话令牌", example = "1", notes = "后续接口需要通过http请求头携带该令牌") + private String token; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/UserMenuVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/UserMenuVo.java new file mode 100644 index 0000000..530c0f0 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/UserMenuVo.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.vo; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.mt.wms.core.base.BaseVo; +import com.mt.wms.core.base.ITree; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * 用户菜单视图对象 + * + * @author jiff + * @date 2018-11-27 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "用户菜单视图对象", description = "用户返回登录用户的菜单树") +public class UserMenuVo extends BaseVo implements ITree { + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键", required = true, example = "1") + private Long id; + + /** + * 父菜单ID + */ + @ApiModelProperty(value = "父菜单ID", required = true, example = "0", position = 1) + @JsonProperty("pid") + private Long parentId; + + /** + * 菜单编码 + */ + @ApiModelProperty(value = "菜单编码", example = "menu", position = 2) + @JsonProperty("c") + private String code; + + /** + * 菜单名称 + */ + @ApiModelProperty(value = "菜单名称", required = true, example = "菜单管理", position = 3) + @JsonProperty("n") + private String name; + + /** + * 菜单图标 + */ + @ApiModelProperty(value = "菜单图标", example = "menu.png", position = 4) + @JsonProperty("i") + private String icon; + + /** + * 链接地址,可以是页面地址,也可以是函数事件 + */ + @ApiModelProperty(value = "链接地址,可以是页面地址,也可以是函数事件", example = "menu.html", position = 5) + @JsonProperty("h") + private String href; + + /** + * 类型:1、module,2、menu,3、button + */ + @ApiModelProperty(value = "类型:1、module,2、menu,3、button", required = true, example = "1", position = 6) + @JsonProperty("t") + private Integer type; + + /** + * 显示顺序 + */ + @ApiModelProperty(value = "显示顺序", example = "1", position = 7) + @JsonProperty("o") + private Integer orderNum; + + + /** + * 子列表 + */ + @ApiModelProperty(value = "子列表,用于获取菜单树时才有数据", required = false, position = 9) + @JsonProperty("l") + private List children; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/vo/WhetherVo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/WhetherVo.java new file mode 100644 index 0000000..ba970ed --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/vo/WhetherVo.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.core.vo; + +import com.mt.wms.core.base.BaseVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.experimental.Accessors; + + +/** + * 是否对象 + * + * @author jiff + * @date 2018/11/11 + * @since 1.0 + */ +@Data +@Accessors(chain = true) +@Builder +@ApiModel("是否对象") +public class WhetherVo extends BaseVo { + @ApiModelProperty(value = "是否:true、是,false、否", required = true, example = "true") + private Boolean whether; +} diff --git a/6.program/wms-core/src/main/resources/Messages.properties b/6.program/wms-core/src/main/resources/Messages.properties new file mode 100644 index 0000000..912a380 --- /dev/null +++ b/6.program/wms-core/src/main/resources/Messages.properties @@ -0,0 +1,5 @@ +# +# Copyright (c) 2018. +# http://www.ulabcare.com +# +#typeMismatch.sysUserParam.birthday=\u751F\u65E5\u683C\u5F0F\u9519\u8BEF \ No newline at end of file diff --git a/6.program/wms-core/src/main/resources/Messages_zh_CN.properties b/6.program/wms-core/src/main/resources/Messages_zh_CN.properties new file mode 100644 index 0000000..096a0f2 --- /dev/null +++ b/6.program/wms-core/src/main/resources/Messages_zh_CN.properties @@ -0,0 +1,10 @@ +# +# Copyright (c) 2018. +# http://www.ulabcare.com +# +typeMismatch.sysUserParam.birthday=\u751F\u65E5\u683C\u5F0F\u9519\u8BEF +beanUtils.copyList.error=\u5BF9\u8C61\u62F7\u8D1D\u5F02\u5E38 +globalExceptionHandler.httpRequestMethodNotSupportedException=\u63A5\u53E3\u53EA\u5141\u8BB8[{0}]\u8BF7\u6C42\u65B9\u6CD5 +globalExceptionHandler.httpMediaTypeNotSupportedException=\u63A5\u53E3\u53EA\u5141\u8BB8[{0}]\u5A92\u4F53\u7C7B\u578B +globalExceptionHandler.httpMessageConversionException=\u63A5\u53E3\u8BF7\u6C42\u6D88\u606F\u8F6C\u6362\u5931\u8D25 +globalExceptionHandler.dataAccessException=\u6570\u636E\u5E93\u64CD\u4F5C\u5931\u8D25 \ No newline at end of file diff --git a/6.program/wms-core/src/main/resources/ValidationMessages.properties b/6.program/wms-core/src/main/resources/ValidationMessages.properties new file mode 100644 index 0000000..4c55b85 --- /dev/null +++ b/6.program/wms-core/src/main/resources/ValidationMessages.properties @@ -0,0 +1,4 @@ +# +# Copyright (c) 2018. +# http://www.ulabcare.com +# diff --git a/6.program/wms-core/src/main/resources/ValidationMessages_zh_CN.properties b/6.program/wms-core/src/main/resources/ValidationMessages_zh_CN.properties new file mode 100644 index 0000000..487bc92 --- /dev/null +++ b/6.program/wms-core/src/main/resources/ValidationMessages_zh_CN.properties @@ -0,0 +1,6 @@ +# +# Copyright (c) 2018. +# http://www.ulabcare.com +# +lis.validator.constraints.SexEnum.message=\u6027\u522B\u53EA\u80FD\u4E3A1\u62162 +lis.validator.constraints.NotBlank.name.message=\u59D3\u540D\u4E0D\u80FD\u4E3A\u7A7A \ No newline at end of file diff --git a/6.program/wms-empty/pom.xml b/6.program/wms-empty/pom.xml new file mode 100644 index 0000000..6cfdff8 --- /dev/null +++ b/6.program/wms-empty/pom.xml @@ -0,0 +1,21 @@ + + + + wms + com.mt + 1.0 + + 4.0.0 + + wms-empty + + + + com.mt + wms-core + + + + \ No newline at end of file diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EmptyController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EmptyController.java new file mode 100644 index 0000000..3d698c3 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EmptyController.java @@ -0,0 +1,99 @@ +package com.mt.wms.empty.controller; + +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.PageGroup; +import com.mt.wms.core.validator.groups.UpdateGroup; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.empty.params.EmptyParam; +import com.mt.wms.empty.params.EmptyQueryParam; +import com.mt.wms.empty.service.EmptyService; +import com.mt.wms.empty.vo.EmptyVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.groups.Default; +import java.util.List; + +/** + * @author jiff + * @date 2020/12/22 + * @since 1.0 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_BASE + "empty") +@Slf4j +@Api(value = "xx管理", tags = "xx", hidden = false) +public class EmptyController extends BaseController { + @Autowired + private EmptyService emptyService; + + @PostMapping(value = "get") + @ApiOperation(value = "获取xx") + private R get(@Validated @RequestBody IdParam idParam) { + return emptyService.get(idParam); + } + + @PostMapping(value = "list") + @ApiOperation(value = "获取xx列表") + private R> list(@Validated({Default.class}) @RequestBody EmptyQueryParam emptyQueryParam) { + return emptyService.list(emptyQueryParam); + } + + @PostMapping(value = "page") + @ApiOperation(value = "获取分页xx") + private R> page(@Validated({PageGroup.class, Default.class}) @RequestBody EmptyQueryParam emptyQueryParam) { + return emptyService.page(emptyQueryParam); + } + + @PostMapping(value = "tree") + @ApiOperation(value = "获取xx树列表") + private R> tree(@Validated({Default.class}) @RequestBody EmptyQueryParam emptyQueryParam) { + return emptyService.tree(emptyQueryParam); + } + + @PostMapping(value = "add") + @ApiOperation(value = "新增") + private R add(@Validated({AddGroup.class, Default.class}) @RequestBody EmptyParam emptyParam) { + return emptyService.add(emptyParam); + } + + @PostMapping(value = "update") + @ApiOperation(value = "更新") + private R update(@Validated({UpdateGroup.class, Default.class}) @RequestBody EmptyParam emptyParam) { + return emptyService.update(emptyParam); + } + + @PostMapping(value = "enabled") + @ApiOperation(value = "启停xx") + private R enabled(@Validated @RequestBody EnabledParam enabledParam) { + return emptyService.enabled(enabledParam); + } + + @PostMapping(value = "delete") + @ApiOperation(value = "删除xx") + private R delete(@Validated @RequestBody IdParam idParam) { + return emptyService.delete(idParam); + } + + @PostMapping(value = "batchDelete") + @ApiOperation(value = "批量删除xx") + private R delete(@Validated @RequestBody IdListParam idListParam) { + return emptyService.delete(idListParam); + } + +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/mapper/EmptyMapper.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/mapper/EmptyMapper.java new file mode 100644 index 0000000..cecd502 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/mapper/EmptyMapper.java @@ -0,0 +1,28 @@ +package com.mt.wms.empty.mapper; + +import com.mt.wms.empty.vo.EmptyVo; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * xxmapper类 + * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@Repository +public interface EmptyMapper { + + /** + * 获取xx列表 + * + * @param id ID + * @param category 分类 + * @return xx列表 + */ + List listBy(@Param("id") Long id, @Param("category") Integer category); + +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/EmptyParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/EmptyParam.java new file mode 100644 index 0000000..e437d2d --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/EmptyParam.java @@ -0,0 +1,40 @@ +package com.mt.wms.empty.params; + +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.groups.UpdateGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @author jiff + * @date 2020/12/22 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "xx参数对象", description = "用于新增和更新xx信息") +public class EmptyParam extends BaseParam { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键,更新时需要填写", example = "1") + @NotNull(message = "xxID不能为空", groups = {UpdateGroup.class}) + private Long id; + + /** + * xx名称 + */ + @ApiModelProperty(value = "xx名称", required = true, example = "xx管理") + @NotBlank(message = "xx名称不能为空") + private String name; +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/EmptyQueryParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/EmptyQueryParam.java new file mode 100644 index 0000000..cf4d969 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/EmptyQueryParam.java @@ -0,0 +1,27 @@ +package com.mt.wms.empty.params; + +import com.mt.wms.core.params.BasePageParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @author jiff + * @date 2020/12/22 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "xx查询参数", description = "用于查询xx信息") +public class EmptyQueryParam extends BasePageParam { + + /** + * xx名称 + */ + @ApiModelProperty(value = "xx名称", required = false, example = "xx管理") + private String name; + +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/EmptyService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/EmptyService.java new file mode 100644 index 0000000..bee7c82 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/EmptyService.java @@ -0,0 +1,95 @@ +package com.mt.wms.empty.service; + +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.empty.params.EmptyParam; +import com.mt.wms.empty.params.EmptyQueryParam; +import com.mt.wms.empty.vo.EmptyVo; + +import java.util.List; + +/** + * xx服务 + * + * @author jiff + * @date 2020/12/22 + * @since 1.0 + */ +public interface EmptyService { + /** + * 获取xx + * + * @param idParam 主键参数 + * @return xx + */ + R get(IdParam idParam); + + /** + * 获取xx列表 + * + * @param emptyQueryParam xx查询参数 + * @return xx列表 + */ + R> list(EmptyQueryParam emptyQueryParam); + + /** + * 获取xx分页列表 + * + * @param emptyQueryParam xx查询参数 + * @return xx分页列表 + */ + R> page(EmptyQueryParam emptyQueryParam); + + /** + * 获取xx树列表 + * + * @param emptyQueryParam xx查询参数 + * @return xx树列表 + */ + R> tree(EmptyQueryParam emptyQueryParam); + + /** + * 新增xx + * + * @param emptyParam xx参数 + * @return 主键 + */ + R add(EmptyParam emptyParam); + + /** + * 更新xx + * + * @param emptyParam xx参数 + * @return 主键 + */ + R update(EmptyParam emptyParam); + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + R enabled(EnabledParam enabledParam); + + /** + * 删除xx + * + * @param idParam 主键参数 + * @return 主键 + */ + R delete(IdParam idParam); + + /** + * 批量删除xx + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + R delete(IdListParam idListParam); +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/EmptyServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/EmptyServiceImpl.java new file mode 100644 index 0000000..ceafae4 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/EmptyServiceImpl.java @@ -0,0 +1,128 @@ +package com.mt.wms.empty.service.impl; + +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.empty.params.EmptyParam; +import com.mt.wms.empty.params.EmptyQueryParam; +import com.mt.wms.empty.service.EmptyService; +import com.mt.wms.empty.vo.EmptyVo; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * xx服务实现类 + * + * @author jiff + * @date 2020/12/22 + * @since 1.0 + */ +@Service +@Transactional +public class EmptyServiceImpl extends BaseService implements EmptyService { + /** + * 获取xx + * + * @param idParam 主键参数 + * @return xx + */ + @Override + public R get(IdParam idParam) { + return null; + } + + /** + * 获取xx列表 + * + * @param emptyQueryParam xx查询参数 + * @return xx列表 + */ + @Override + public R> list(EmptyQueryParam emptyQueryParam) { + return null; + } + + /** + * 获取xx分页列表 + * + * @param emptyQueryParam xx查询参数 + * @return xx分页列表 + */ + @Override + public R> page(EmptyQueryParam emptyQueryParam) { + return null; + } + + /** + * 获取xx树列表 + * + * @param emptyQueryParam xx查询参数 + * @return xx树列表 + */ + @Override + public R> tree(EmptyQueryParam emptyQueryParam) { + return null; + } + + /** + * 新增xx + * + * @param emptyParam xx参数 + * @return 主键 + */ + @Override + public R add(EmptyParam emptyParam) { + return null; + } + + /** + * 更新xx + * + * @param emptyParam xx参数 + * @return 主键 + */ + @Override + public R update(EmptyParam emptyParam) { + return null; + } + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + @Override + public R enabled(EnabledParam enabledParam) { + return null; + } + + /** + * 删除xx + * + * @param idParam 主键参数 + * @return 主键 + */ + @Override + public R delete(IdParam idParam) { + return null; + } + + /** + * 批量删除xx + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + @Override + public R delete(IdListParam idListParam) { + return null; + } +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/EmptyVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/EmptyVo.java new file mode 100644 index 0000000..2d98cdf --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/EmptyVo.java @@ -0,0 +1,46 @@ +package com.mt.wms.empty.vo; + +import com.mt.wms.core.base.BaseVo; +import com.mt.wms.core.base.ITree; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * TODO 根据实际情况是否需要实现ITree接口 + * + * @author jiff + * @date 2020/12/22 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "xx视图对象", description = "用于查询xx信息") +public class EmptyVo extends BaseVo implements PageVo.ConvertVo, ITree { + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键", required = true, example = "1") + @NotNull(message = "ID不能为空") + private Long id; + /** + * 父xxID + */ + @ApiModelProperty(value = "父xxID", example = "0") + @NotNull(message = "父xx不能为空") + private Long parentId; + /** + * 子列表 + */ + @ApiModelProperty(value = "子列表,用于获取xx树时才有数据", required = false) + private List children; +} diff --git a/6.program/wms-gateway/pom.xml b/6.program/wms-gateway/pom.xml new file mode 100644 index 0000000..e8305c7 --- /dev/null +++ b/6.program/wms-gateway/pom.xml @@ -0,0 +1,90 @@ + + + + wms + com.mt + 1.0 + + 4.0.0 + + wms-gateway + + + + + org.springframework.boot + spring-boot-starter-web + + + com.mt + wms-common + + + com.mt + wms-core + + + com.mt + wms-passport + + + com.mt + wms-upms + + + + io.springfox + springfox-swagger-ui + + + io.springfox + springfox-swagger2 + + + com.github.xiaoymin + knife4j-spring-boot-starter + 2.0.8 + + + com.github.xiaoymin + knife4j-spring-ui + 2.0.8 + + + + + wms-gateway + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + org.springframework.boot + spring-boot-maven-plugin + + + com.mt.wms.gateway.MesGatewayApplication + + + + + + + src/main/resources + true + + **/*.yml + **/*.xml + + + + + + \ No newline at end of file diff --git a/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/MesGatewayApplication.java b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/MesGatewayApplication.java new file mode 100644 index 0000000..742eba7 --- /dev/null +++ b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/MesGatewayApplication.java @@ -0,0 +1,41 @@ +package com.mt.wms.gateway; +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +import com.mt.wms.core.EnableMesCore; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.scheduling.annotation.EnableScheduling; + +/** + * 服务网关 + * + * @author FanYi + * @date 2020/07/01 + * @since 1.0 + */ +@SpringBootApplication(exclude = {}) +@ComponentScan(basePackages = { + "com.mt.wms.gateway", + "com.mt.wms.common", + "com.mt.wms.passport", + "com.mt.wms.upms" + +}) +@ServletComponentScan("com.mt.wms.gateway.filter") +@EnableDiscoveryClient +//@EnableFeignClients +@RefreshScope +@EnableMesCore +@EnableScheduling +public class MesGatewayApplication { + public static void main(String[] args) { + SpringApplication.run(MesGatewayApplication.class, args); + } +} diff --git a/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/config/GatewayConfig.java b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/config/GatewayConfig.java new file mode 100644 index 0000000..1879f44 --- /dev/null +++ b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/config/GatewayConfig.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.gateway.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +/** + * 服务网关配置 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@ConfigurationProperties("wms.gateway") +@Validated +@Data +@Component +public class GatewayConfig { + @NotNull + @Valid + private List ignoreAuths = new ArrayList<>(); + +} diff --git a/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/config/RouteConfig.java b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/config/RouteConfig.java new file mode 100644 index 0000000..438b7ef --- /dev/null +++ b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/config/RouteConfig.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.gateway.config; + + +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.web.cors.reactive.CorsUtils; +import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.server.WebFilter; +import org.springframework.web.server.WebFilterChain; +import reactor.core.publisher.Mono; + +/** + * 路由配置 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@Configuration +@Slf4j +public class RouteConfig { + private static final String ALLOWED_HEADERS = "Content-Type, authorization, credential, token, X-Requested-With"; + private static final String ALLOWED_METHODS = "*"; + private static final String ALLOWED_ORIGIN = "*"; + private static final String ALLOWED_EXPOSE = "*"; + private static final String MAX_AGE = "18000L"; + + @Bean + public WebFilter corsFilter() { + return (ServerWebExchange exchange, WebFilterChain chain) -> { + ServerHttpRequest request = exchange.getRequest(); + if (CorsUtils.isCorsRequest(request)) { + ServerHttpResponse response = exchange.getResponse(); + HttpHeaders headers = response.getHeaders(); + headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, ALLOWED_ORIGIN); + headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, ALLOWED_METHODS); + headers.add(HttpHeaders.ACCESS_CONTROL_MAX_AGE, MAX_AGE); + headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, ALLOWED_HEADERS); + headers.add(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, ALLOWED_EXPOSE); + headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"); + if (request.getMethod() == HttpMethod.OPTIONS) { + response.setStatusCode(HttpStatus.OK); + return Mono.empty(); + } + } + return chain.filter(exchange); + }; + } +} diff --git a/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/config/SwaggerConfig.java b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/config/SwaggerConfig.java new file mode 100644 index 0000000..32165f1 --- /dev/null +++ b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/config/SwaggerConfig.java @@ -0,0 +1,63 @@ +package com.mt.wms.gateway.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +/** + * 服务网关swagger配置 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@Configuration +@EnableSwagger2 +public class SwaggerConfig { + @Bean + public Docket passportApi() { + return new Docket(DocumentationType.SWAGGER_2).groupName("wms-passport") + .apiInfo(apiInfo("passport", "统一认证接口")) + .select() + .apis(RequestHandlerSelectors.basePackage("com.mt.wms.passport")) + .paths(PathSelectors.any()) + .build(); + } + + @Bean + public Docket commonApi() { + return new Docket(DocumentationType.SWAGGER_2).groupName("wms-common") + .apiInfo(apiInfo("common", "公共接口")) + .select() + .apis(RequestHandlerSelectors.basePackage("com.mt.wms.common")) + .paths(PathSelectors.any()) + .build(); + } + + @Bean + public Docket upmsApi() { + return new Docket(DocumentationType.SWAGGER_2).groupName("wms-upms") + .apiInfo(apiInfo("upms", "通用权限接口")) + .select() + .apis(RequestHandlerSelectors.basePackage("com.mt.wms.upms")) + .paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo(String title, String description) {// 创建API的基本信息,这些信息会在Swagger UI中进行显示 + return new ApiInfoBuilder() + .title(title) + .description(description) + .termsOfServiceUrl("http://www.mt.com") + .contact(new Contact("jiff", "", "jiff@ulabcare.com")) + .version("1.0") + .build(); + } +} diff --git a/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/config/WebMvcConfiguration.java b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/config/WebMvcConfiguration.java new file mode 100644 index 0000000..d31901e --- /dev/null +++ b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/config/WebMvcConfiguration.java @@ -0,0 +1,20 @@ +package com.mt.wms.gateway.config; + +import com.mt.wms.core.config.CommonConfig; +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@RequiredArgsConstructor +@Configuration +public class WebMvcConfiguration extends WebMvcConfigurerAdapter { + + private final CommonConfig mCommonConfig; + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/common/**").addResourceLocations("file:" + mCommonConfig.getUploadPath()); + super.addResourceHandlers(registry); + } +} diff --git a/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/feign/PassportService.java b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/feign/PassportService.java new file mode 100644 index 0000000..ad6d543 --- /dev/null +++ b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/feign/PassportService.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.gateway.feign; + +import com.mt.wms.gateway.feign.fallback.PassportServiceFallback; +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.vo.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * 统一用户服务 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@FeignClient(value = "wms-passport", fallback = PassportServiceFallback.class) +public interface PassportService { + /** + * 请求资源鉴权 + * + * @param url 请求地址 + * @param method 请求方法 + * @return + */ + @PostMapping("authorization") + R authorization(@RequestParam("url") String url, @RequestParam("method") String method); +} diff --git a/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/feign/fallback/PassportServiceFallback.java b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/feign/fallback/PassportServiceFallback.java new file mode 100644 index 0000000..0bcb92a --- /dev/null +++ b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/feign/fallback/PassportServiceFallback.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.gateway.feign.fallback; + +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.vo.R; +import com.mt.wms.gateway.feign.PassportService; +import com.mt.wms.passport.controller.PassportController; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 统一用户服务失败回调实现 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@Service +@Slf4j +public class PassportServiceFallback implements PassportService { + @Autowired + PassportController passportController; + + @Override + public R authorization(String url, String method) { + return passportController.authorization(url, method); + } +} diff --git a/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/filter/CorsFilter.java b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/filter/CorsFilter.java new file mode 100644 index 0000000..897c697 --- /dev/null +++ b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/filter/CorsFilter.java @@ -0,0 +1,54 @@ +package com.mt.wms.gateway.filter; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpMethod; + +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * @author jiff + * @date 2019/11/27 + * @since 1.0 + */ +@Slf4j +@WebFilter(urlPatterns = "/*", filterName = "corsFilter") +public class CorsFilter implements Filter { + private static final String ALLOWED_HEADERS = "Content-Type, authorization, credential, token, X-Requested-With"; + private static final String ALLOWED_METHODS = "*"; + private static final String ALLOWED_ORIGIN = "*"; + private static final String ALLOWED_EXPOSE = "*"; + private static final String MAX_AGE = "18000L"; + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + + } + + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + HttpServletRequest httpRequest = ((HttpServletRequest) request); + HttpServletResponse httpServletResponse = (HttpServletResponse) response; + httpServletResponse.setHeader("Access-Control-Allow-Origin", ALLOWED_ORIGIN); + httpServletResponse.setHeader("Access-Control-Allow-Credentials", "true"); + httpServletResponse.setHeader("Access-Control-Allow-Methods", ALLOWED_METHODS); + httpServletResponse.setHeader("Access-Control-Max-Age", MAX_AGE); + httpServletResponse.setHeader("Access-Control-Allow-Headers", ALLOWED_HEADERS); + httpServletResponse.setHeader("Access-Control-Expose-Headers", ALLOWED_EXPOSE); + + if (httpRequest.getMethod().equalsIgnoreCase(HttpMethod.OPTIONS.name())) { + return; + } + chain.doFilter(request, response); + } + + + @Override + public void destroy() { + + } +} diff --git a/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/filter/GatewayFilter.java b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/filter/GatewayFilter.java new file mode 100644 index 0000000..876ab19 --- /dev/null +++ b/6.program/wms-gateway/src/main/java/com/mt/wms/gateway/filter/GatewayFilter.java @@ -0,0 +1,154 @@ +package com.mt.wms.gateway.filter; + +import com.alibaba.fastjson.JSON; +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.vo.R; +import com.mt.wms.gateway.config.GatewayConfig; +import com.mt.wms.gateway.feign.PassportService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; + +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author jiff + * @date 2019/11/27 + * @since 1.0 + */ +@Slf4j +@WebFilter(urlPatterns = "/*", filterName = "gatewayFilter") +public class GatewayFilter implements Filter { + @Autowired + @Lazy() + private PassportService passportService; + + @Autowired + @Lazy + private GatewayConfig gatewayConfig; + + private static final String GATEWAY_PREFIX = "/api"; + + /** + * Called by the web container to indicate to a filter that it is being + * placed into service. The servlet container calls the init method exactly + * once after instantiating the filter. The init method must complete + * successfully before the filter is asked to do any filtering work. + *

+ * The web container cannot place the filter into service if the init method + * either: + *

    + *
  • Throws a ServletException
  • + *
  • Does not return within a time period defined by the web + * container
  • + *
+ * + * @param filterConfig The configuration information associated with the + * filter instance being initialised + * @throws ServletException if the initialisation fails + */ + @Override + public void init(FilterConfig filterConfig) throws ServletException { + + } + + /** + * The doFilter method of the Filter is called by the container + * each time a request/response pair is passed through the chain due to a + * client request for a resource at the end of the chain. The FilterChain + * passed in to this method allows the Filter to pass on the request and + * response to the next entity in the chain. + *

+ * A typical implementation of this method would follow the following + * pattern:-
+ * 1. Examine the request
+ * 2. Optionally wrap the request object with a custom implementation to + * filter content or headers for input filtering
+ * 3. Optionally wrap the response object with a custom implementation to + * filter content or headers for output filtering
+ * 4. a) Either invoke the next entity in the chain using + * the FilterChain object (chain.doFilter()),
+ * 4. b) or not pass on the request/response pair to the + * next entity in the filter chain to block the request processing
+ * 5. Directly set headers on the response after invocation of the next + * entity in the filter chain. + * + * @param request The request to process + * @param response The response associated with the request + * @param chain Provides access to the next filter in the chain for this + * filter to pass the request and response to for further + * processing + * @throws IOException if an I/O error occurs during this filter's + * processing of the request + * @throws ServletException if the processing fails for any other reason + */ + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + HttpServletRequest httpRequest = ((HttpServletRequest) request); + String requestUri = httpRequest.getRequestURI(); + if (requestUri.startsWith(GATEWAY_PREFIX)) { + requestUri = requestUri.substring(GATEWAY_PREFIX.length()); + } + final String method = httpRequest.getMethod(); + //忽略鉴权的地址 + if (isIgnoreAuth(requestUri)) { + if (log.isDebugEnabled()) { + log.debug("忽略鉴权的地址={}", requestUri); + } + chain.doFilter(request, response); + return; + } + R r = passportService.authorization(requestUri, method); + + if (r != null && r.ok()) { + if (r.getData() != null) { + log.info("loginUser={}", JSON.toJSONString(r.getData())); + } + chain.doFilter(request, response); + } else { + r = r != null ? r : R.failed(); + response.setContentType("application/json;charset=UTF-8"); + response.setCharacterEncoding("UTF-8"); + response.getWriter().print(JSON.toJSONString(r)); + } + } + + /** + * Called by the web container to indicate to a filter that it is being + * taken out of service. This method is only called once all threads within + * the filter's doFilter method have exited or after a timeout period has + * passed. After the web container calls this method, it will not call the + * doFilter method again on this instance of the filter.
+ *
+ *

+ * This method gives the filter an opportunity to clean up any resources + * that are being held (for example, memory, file handles, threads) and make + * sure that any persistent state is synchronized with the filter's current + * state in memory. + */ + @Override + public void destroy() { + + } + + private boolean isIgnoreAuth(String requestUri) { + for (String ignore : gatewayConfig.getIgnoreAuths()) { + if (log.isDebugEnabled()) { + log.debug("ignore auth url is {}", ignore); + } + // 编译正则表达式,忽略大小写的写法 + Pattern pattern = Pattern.compile(ignore, Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(requestUri); + // 查找字符串中是否有匹配正则表达式的字符/字符串 + if (matcher.find()) { + return true; + } + } + return false; + } +} diff --git a/6.program/wms-gateway/src/main/resources/bootstrap.yml b/6.program/wms-gateway/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..f1b60bd --- /dev/null +++ b/6.program/wms-gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,7 @@ +server: + port: @gateway.server.port@ + +spring: + profiles: + active: @profileActive@ + diff --git a/6.program/wms-gateway/src/main/resources/config/application.yml b/6.program/wms-gateway/src/main/resources/config/application.yml new file mode 100644 index 0000000..4f5a514 --- /dev/null +++ b/6.program/wms-gateway/src/main/resources/config/application.yml @@ -0,0 +1,118 @@ +server: + port: @gateway.server.port@ +info: + version: @project.version@ + description: @project.description@ + name: '@project.name@' + + +spring: + session: + store-type: none + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + default-property-inclusion: non_null + redis: + # cluster: + # nodes: + # - localhost:6379 + host: @spring.redis.host@ + port: @spring.redis.port@ + password: @spring.redis.password@ + database: @spring.redis.database@ + + #开发工具 + devtools: + remote: + secret: @spring.devtools.remote.secret@ + restart: + additional-exclude: config/** + livereload: + enabled: @spring.devtools.remote.livereload.enabled@ + + #配置数据源 + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + url: @spring.datasource.url@ + username: @spring.datasource.username@ + password: @spring.datasource.password@ + hikari: + maximum-pool-size: 10 + minimum-idle: 1 + + +#mybaits-plus配置,修改主键类型,mapper.xml、type 别名等 +mybatis-plus: + mapper-locations: classpath*:/mapper/*Mapper.xml,classpath*:com/mt/wms/**/mapper/*Mapper.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.mt.wms.core.dal.entity + global-config: + # 数据库相关配置 + db-config: + #数据库类型 + db-type: mysql + #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID",ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; + id-type: assign_id + #字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" + field-strategy: not_empty + #驼峰下划线转换\ + table-underline: true + #数据库大写下划线转换 + #capital-mode: true + #逻辑删除配置 + logic-delete-value: 0 + logic-not-delete-value: 1 + logic-delete-field: valid + #刷新mapper 调试神器 + refresh: true + configuration: + map-underscore-to-camel-case: true + cache-enabled: true + + +#自定义配置 +wms: + #配置忽略认证鉴权的接口地址,此处配置的地址即不做认证也不做鉴权,因此调用的接口无法获取当前用户信息 + gateway: + ignoreAuths: + - /swagger-ui.html* + - /swagger-resources* + - /webjars/* + - /*/v2/api-docs + - /doc.html + - /favicon.ico + - /common/* + - /*/logout + - /*/login + - /*/wechatLogin + - /*/mobileLogin + + #公共配置 + common: + uploadPath: @wms.common.uploadPath@ + webHost: @wms.common.webHost@ + apiHost: @wms.common.apiHost@ + #短信配置 + smschannel: @wms.sms.channel@ + aliyun: + sms: + product: @wms.aliyun.sms.product@ + domain: @wms.aliyun.sms.domain@ + accessKeyId: @wms.aliyun.sms.accessKeyId@ + accessKeySecret: @wms.aliyun.sms.accessKeySecret@ + tencentcloud: + secretId: @wms.tencentcloud.secretId@ + secretKey: @wms.tencentcloud.secretKey@ + sms: + appId: @wms.tencentcloud.sms.appId@ + appKey: @wms.tencentcloud.sms.appKey@ + + #微信配置 + wechat: + mchId: 2020202020 + mchKey: 2020202020 + ma: + appId: 2020202020 + appSecret: 2020202020 diff --git a/6.program/wms-gateway/src/main/resources/logback.xml b/6.program/wms-gateway/src/main/resources/logback.xml new file mode 100644 index 0000000..5eba3ff --- /dev/null +++ b/6.program/wms-gateway/src/main/resources/logback.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/6.program/wms-gateway/src/main/resources/spy.properties b/6.program/wms-gateway/src/main/resources/spy.properties new file mode 100644 index 0000000..eb651f8 --- /dev/null +++ b/6.program/wms-gateway/src/main/resources/spy.properties @@ -0,0 +1,23 @@ +#3.2.1以上使用 +modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory +# 自定义日志打印 +logMessageFormat=com.p6spy.engine.spy.appender.CustomLineFormat +customLogMessageFormat=%(currentTime) | SQL耗时: %(executionTime) ms | 连接信息: %(category)-%(connectionId) | 执行语句: %(sqlSingleLine) +#日志输出到控制台 +appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger +# 使用日志系统记录 sql +#appender=com.p6spy.engine.spy.appender.Slf4JLogger +# 设置 p6spy driver 代理 +deregisterdrivers=true +# 取消JDBC URL前缀 +useprefix=true +# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset. +excludecategories=info,debug,result,commit,resultset +# 日期格式 +dateformat=yyyy-MM-dd HH:mm:ss +# 实际驱动 +driverlist=com.mysql.jdbc.Driver +# 是否开启慢SQL记录 +outagedetection=true +# 慢SQL记录标准 2 秒 +outagedetectioninterval=2 \ No newline at end of file diff --git a/6.program/wms-passport/pom.xml b/6.program/wms-passport/pom.xml new file mode 100644 index 0000000..cf823f0 --- /dev/null +++ b/6.program/wms-passport/pom.xml @@ -0,0 +1,55 @@ + + + + wms + com.mt + 1.0 + + 4.0.0 + + wms-passport + + + + com.mt + wms-core + + + com.mt + wms-upms + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + org.springframework.boot + spring-boot-starter-data-redis + + + org.springframework.session + spring-session-data-redis + + + + io.springfox + springfox-swagger2 + + + io.springfox + springfox-swagger-ui + + + + + nl.basjes.parse.useragent + yauaa + ${useragent.version} + + + + + \ No newline at end of file diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/config/PassportConfig.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/config/PassportConfig.java new file mode 100644 index 0000000..53406ef --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/config/PassportConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +/** + * 统一用户配置 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@ConfigurationProperties("wms.passport") +@Validated +@Data +@Component +public class PassportConfig { + /** + * 忽略认证的接口地址,此处配置的地址不做认证和鉴权处理,如果会话存在则返回当前用户信息 + */ + @NotNull + @Valid + private List ignoreAuthentications = new ArrayList<>(); + /** + * 忽略鉴权的接口地址,此处配置的地址只做认证不做鉴权,如果认证通过返回当前用户信息 + */ + @NotNull + @Valid + private List ignoreAuthorizations = new ArrayList<>(); + +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/config/WebSessionConfig.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/config/WebSessionConfig.java new file mode 100644 index 0000000..b1fb736 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/config/WebSessionConfig.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.config; + +import com.mt.wms.passport.resolver.CookieHeaderHttpSessionIdResolver; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; +import org.springframework.session.web.http.HttpSessionIdResolver; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 3 * 24 * 3600) +@AutoConfigureAfter(RedisAutoConfiguration.class) +@Slf4j +public class WebSessionConfig { + + + /** + * session策略,这里配置的是自定义同时支持Cookie和Header方式(有提供Header,Cookie等方式) + * + * @return + */ + @Bean + public HttpSessionIdResolver httpSessionIdResolver() { + return CookieHeaderHttpSessionIdResolver.token(); + } + +} + + + diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/constants/PassportConstant.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/constants/PassportConstant.java new file mode 100644 index 0000000..ee0f383 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/constants/PassportConstant.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.constants; + +/** + * @author jiff + * @date 2019-08-01 + * @since 1.0 + */ +public interface PassportConstant { + /** + * 内部临时令牌,用于漫游登录时创建会话 + */ + String PASSPORT_INNER_NONCE_TOKEN = "passportInnerNonceToken"; + /** + * 内部临时令牌有效期,单位秒 + */ + long PASSPORT_INNER_NONCE_TOKEN_EXPIRED = 3L; + /** + * 微信oauthCode获取openId保存到redis有效时间:{@value},单位秒 + */ + long WECHAT_OAUTH_CODE_EXPIRED = 5 * 60L; + + + /** + * 异常状态:0、正常,1、省份异常,2、地市异常,3、区县异常 + */ + int LOGIN_ABNORMAL_STATUS_NORMAL = 0; + int LOGIN_ABNORMAL_STATUS_PROVINCE = 1; + int LOGIN_ABNORMAL_STATUS_CITY = 2; + int LOGIN_ABNORMAL_STATUS_COUNTY = 3; + /** + * 手机号码是否激活:0、未激活,1、激活,根据是否使用过短信验证码登录确认是否激活状态 + */ + int MOBILE_ENABLED_VALID = 1; + int MOBILE_ENABLED_INVALID = 0; +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/controller/LogController.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/controller/LogController.java new file mode 100644 index 0000000..1530602 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/controller/LogController.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.controller; + +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.dto.LoginLogDto; +import com.mt.wms.core.vo.R; +import com.mt.wms.passport.service.LogService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author jiff + * @date 2019-07-20 + * @since 1.0 + */ +@RestController +@RequestMapping("log") +@Slf4j +@Validated +@Api(value = "日志接口", hidden = true) +public class LogController extends BaseController { + @Autowired + private LogService logService; + + @PostMapping("loginLog") + @ApiOperation(value = "保存登录日志", notes = "提供给内部调用,后续加上权限控制", hidden = true) + public R loginLog(@RequestBody LoginLogDto loginLogDto) { + return logService.saveLoginLog(loginLogDto); + } + +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/controller/PassportController.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/controller/PassportController.java new file mode 100644 index 0000000..6f6eb85 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/controller/PassportController.java @@ -0,0 +1,307 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.controller; + +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mt.wms.core.api.Assert; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.constants.RedisConstant; +import com.mt.wms.core.dto.ApiLogDto; +import com.mt.wms.core.dto.LoginLogDto; +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.dto.Permission; +import com.mt.wms.core.errorcode.ApiErrorCode; +import com.mt.wms.core.service.RedisService; +import com.mt.wms.core.vo.R; +import com.mt.wms.core.vo.TokenVo; +import com.mt.wms.passport.config.PassportConfig; +import com.mt.wms.passport.feign.PlatformUpmsService; +import com.mt.wms.passport.params.LoginParam; +import com.mt.wms.passport.params.MobileLoginParam; +import com.mt.wms.passport.service.LogService; +import com.mt.wms.passport.service.PassportService; +import com.mt.wms.passport.service.SessionService; +import com.mt.wms.passport.validator.groups.PasswordLoginGroup; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.session.FindByIndexNameSessionRepository; +import org.springframework.session.Session; +import org.springframework.util.AntPathMatcher; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpSession; +import javax.validation.groups.Default; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_PASSPORT) +@Slf4j +@Validated +@Api(value = "统一用户接口", description = "封装用户认证鉴权相关接口") +public class PassportController extends BaseController { + + private AntPathMatcher antPathMatcher = new AntPathMatcher(); + + + @Autowired + private PlatformUpmsService platformUpmsService; + @Autowired + private LogService logService; + + @Autowired + private SessionService sessionService; + + @Autowired + private PassportService passportService; + + @Autowired + private RedisService redisService; + + @Autowired + private FindByIndexNameSessionRepository sessionRepository; + + @Autowired + private PassportConfig passportConfig; + + @PostMapping("login") + @ApiOperation(value = "用户名密码登录", notes = "返回会话令牌") + public R login(@Validated({Default.class, PasswordLoginGroup.class}) @RequestBody LoginParam loginParam) { + if (log.isDebugEnabled()) { + log.debug("登录请求消息:{}", loginParam); + } + String mobile = loginParam.getMobile(); + String password = loginParam.getPassword(); + R r = null; + switch (loginParam.getUserType()) { + case LoginUser.USER_TYPE_PLATFORM: + r = platformUpmsService.login(mobile, password); + break; + default: + break; + } + if (r != null && r.ok()) { + return loginSuccessHandler(r.getData(), loginParam); + } + return failed(r == null ? "登录失败,用户名或密码错误!" : r.getMsg()); + } + + + @PostMapping("mobileLogin") + @ApiOperation(value = "短信验证码登录", notes = "返回会话令牌") + public R login(@Validated @RequestBody MobileLoginParam loginParam) { + if (log.isDebugEnabled()) { + log.debug("登录请求消息:{}", loginParam); + } + String mobile = loginParam.getMobile(); + String smsCode = loginParam.getSmsCode(); + String validSmsCode = redisService.get(RedisConstant.genSmsCodeKey(mobile)); + if (StringUtils.isNoneBlank(smsCode, validSmsCode) && smsCode.equals(validSmsCode)) { + redisService.del(RedisConstant.genSmsCodeKey(mobile)); + R r = null; + switch (loginParam.getUserType()) { + case LoginUser.USER_TYPE_PLATFORM: + r = platformUpmsService.getLoginUser(mobile); + break; + default: + break; + } + if (r != null && r.ok()) { + LoginUser loginUser = r.getData(); + //更新手机号码激活状态 + + LoginParam loginParam1 = LoginParam.builder().build(); + BeanUtils.copyProperties(loginParam, loginParam1); + return loginSuccessHandler(loginUser, loginParam1); + } else { + return failed(r == null ? "登录失败,手机号码或验证码错误!" : r.getMsg()); + } + } + return failed("登录失败,手机号码或验证码错误!"); + } + + + private R loginSuccessHandler(LoginUser loginUser, LoginParam loginParam) { + String unionId = null; + String openId = null; + String wechatAppId = loginParam.getWechatAppId(); + String oauthCode = loginParam.getOauthCode(); + int appType = loginParam.getAppType(); + Long passportUserId = loginUser.getPassportUserId(); + + + //当前登录用户信息存入session中 + HttpSession session = getHttpServletRequest().getSession(); + loginUser.setAppType(loginParam.getAppType()); + loginUser.setLoginType(LoginLogDto.LOGIN_TYPE_SELF); + loginUser.setWechatAppId(wechatAppId); + loginUser.setOpenId(openId); + session.setAttribute(LoginUser.HTTP_HEADER_NAME, JSON.toJSONString(loginUser)); + session.setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, loginUser.getMobile()); + //保存登录日志 + passportService.saveLoginLog(LoginLogDto.builder() + .sessionId(session.getId()) + .passportUserId(loginUser.getPassportUserId()) + .userId(loginUser.getUserId()) + .orgId(loginUser.getOrgId()) + .mobile(loginUser.getMobile()) + .userName(loginUser.getUserName()) + .userType(loginUser.getUserType()) + .appType(loginUser.getAppType()) + .appCode(loginUser.getAppCode()) + .ip(HttpUtil.getClientIP(getHttpServletRequest())) + .userAgent(getHttpServletRequest().getHeader(HttpHeaders.USER_AGENT)) + .loginType(loginUser.getLoginType()) + .loginTime(new Date()) + .action(LoginLogDto.ACTION_LOGIN) + .build()); + if (log.isDebugEnabled()) { + log.debug("登录成功:sessionId={}", session.getId()); + } + return R.ok("登录成功", TokenVo.builder().token(session.getId()).build()); + } + + + @PostMapping(value = "getLoginUser") + @ApiOperation(value = "获取登录用户", notes = "返回登录用户信息") + public R getLoginUserVo() { + LoginUser loginUser = getLoginUser(); + if (loginUser == null) { + return R.unauthorized(); + } + return successful(loginUser); + } + + @PostMapping("authorization") + @ApiOperation(value = "用户鉴权", notes = "返回登录用户信息", hidden = true) + public R authorization(@RequestParam String url, @RequestParam String method) { + if (log.isDebugEnabled()) { + log.debug("用户鉴权,url={},method={}", url, method); + } + Assert.notNull(ApiErrorCode.FAILED, url, method); + HttpSession session = getHttpServletRequest().getSession(false); + LoginUser loginUser = null; + if (session != null) { + String loginUserJson = (String) session.getAttribute(LoginUser.HTTP_HEADER_NAME); + if (StringUtils.isNotBlank(loginUserJson)) { + loginUser = JSON.parseObject(loginUserJson, LoginUser.class); + } + } + //如果忽略认证,则直接返回成功 + if (isIgnoreAuthentication(url)) { + //登录用户信息为空保存接口调用日志 + if (loginUser != null) { + passportService.saveApiLog(ApiLogDto.builder() + .sessionId(session.getId()) + .passportUserId(loginUser.getPassportUserId()) + .userId(loginUser.getUserId()) + .userName(loginUser.getUserName()) + .userType(loginUser.getUserType()) + .ip(HttpUtil.getClientIP(getHttpServletRequest())) + .userAgent(getHttpServletRequest().getHeader(HttpHeaders.USER_AGENT)) + .url(url).method(method) + .time(new Date()) + .build()); + } + return successful(loginUser); + } else if (loginUser == null) { + return R.unauthorized(); + } + + boolean hasPermission = false; + //忽略鉴权 + if (isIgnoreAuthorization(url)) { + hasPermission = true; + } else { + List permissions; + switch (loginUser.getUserType()) { + case LoginUser.USER_TYPE_PLATFORM: { + permissions = platformUpmsService.getPermissions(); + break; + } + default: + permissions = new ArrayList<>(); + break; + } + if (permissions != null) { + for (Permission permission : permissions) { + if (StringUtils.isNotEmpty(permission.getUrl()) && antPathMatcher.match(permission.getUrl(), url) + && method.equalsIgnoreCase(permission.getMethod())) { + hasPermission = true; + break; + } + } + } + } + passportService.saveApiLog(ApiLogDto.builder() + .sessionId(session.getId()) + .passportUserId(loginUser.getPassportUserId()) + .userId(loginUser.getUserId()) + .userName(loginUser.getUserName()) + .userType(loginUser.getUserType()) + .ip(HttpUtil.getClientIP(getHttpServletRequest())) + .userAgent(getHttpServletRequest().getHeader(HttpHeaders.USER_AGENT)) + .url(url).method(method) + .time(new Date()) + .build()); + if (hasPermission) { + return R.ok("鉴权成功", loginUser); + } else { + return R.forbidden(); + } + } + + /** + * 是否忽略认证 + * + * @param url 接口地址 + * @return + */ + private boolean isIgnoreAuthentication(String url) { + for (String ignore : passportConfig.getIgnoreAuthentications()) { + if (log.isDebugEnabled()) { + log.debug("ignore authentication url is {}", ignore); + } + if (antPathMatcher.match(ignore, url)) { + return true; + } + } + return false; + } + + /** + * 是否忽略鉴权 + * + * @param url 接口地址 + * @return + */ + private boolean isIgnoreAuthorization(String url) { + for (String ignore : passportConfig.getIgnoreAuthorizations()) { + if (log.isDebugEnabled()) { + log.debug("ignore authorization url is {}", ignore); + } + if (antPathMatcher.match(ignore, url)) { + return true; + } + } + return false; + } +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/controller/SessionController.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/controller/SessionController.java new file mode 100644 index 0000000..3f8b22b --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/controller/SessionController.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.controller; + +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.params.MobileParam; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.passport.params.BatchInvalidateSessionParam; +import com.mt.wms.passport.params.QueryLoginLogParam; +import com.mt.wms.passport.params.QuerySessionParam; +import com.mt.wms.passport.params.SessionParam; +import com.mt.wms.passport.service.SessionService; +import com.mt.wms.passport.vo.LoginLogVo; +import com.mt.wms.passport.vo.LoginSessionVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author jiff + * @date 2019-07-20 + * @since 1.0 + */ +@RestController +@RequestMapping("session") +@Slf4j +@Validated +@Api(value = "会话接口", description = "会话接口") +public class SessionController extends BaseController { + @Autowired + private SessionService sessionService; + + + @PostMapping("list") + @ApiOperation(value = "获取在线会话列表", notes = "获取在线会话列表") + public R> list(@RequestBody QuerySessionParam param) { + return sessionService.list(param); + } + + @PostMapping("listLog") + @ApiOperation(value = "获取会话日志列表", notes = "获取会话日志列表") + public R> listLog(@RequestBody QueryLoginLogParam param) { + return sessionService.listLog(param); + } + + @PostMapping(value = "invalidateSession") + @ApiOperation(value = "注销用户会话", notes = "返回被注销的用户会话ID") + public R invalidateSession(@RequestBody SessionParam param) { + return sessionService.invalidateSession(param); + } + + @PostMapping(value = "batchInvalidateSession") + @ApiOperation(value = "批量注销用户会话", notes = "返回被注销的用户会话ID") + public R> batchInvalidateSession(@RequestBody BatchInvalidateSessionParam param) { + return sessionService.batchInvalidateSession(param); + } + + @PostMapping(value = "invalidateSessionByMobile") + @ApiOperation(value = "注销用户会话", notes = "返回被注销的用户会话ID") + public R> invalidateSession(@RequestBody MobileParam param) { + return sessionService.invalidateSession(param); + } + + @PostMapping(value = "invalidateAllSession") + @ApiOperation(value = "注销所有平台用户会话", notes = "返回被注销的用户会话ID") + public R> invalidateSession() { + return sessionService.invalidateAllPlatformSession(); + } + + + @PostMapping(value = "getSession") + @ApiOperation(value = "获取登录用户", notes = "返回登录用户信息") + public R> getLoginSession(@RequestBody MobileParam param) { + return sessionService.getLoginSession(param); + } + +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/dto/WechatOauthCode2Token.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/dto/WechatOauthCode2Token.java new file mode 100644 index 0000000..4f747de --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/dto/WechatOauthCode2Token.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2020. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.dto; + +import com.mt.wms.core.base.BaseDto; +import lombok.*; +import lombok.experimental.Accessors; + +/** + * @author jiff + * @date 2020/3/26 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +@Builder +public class WechatOauthCode2Token extends BaseDto { + + private String openId; + + private String unionId; + + /** + * 公众号访问令牌 + */ + private String accessToken; + /** + * 小程序会话标识 + */ + private String sessionKey; + +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/InnerService.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/InnerService.java new file mode 100644 index 0000000..394eedb --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/InnerService.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.feign; + +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.vo.R; +import com.mt.wms.core.vo.TokenVo; +import com.mt.wms.passport.constants.PassportConstant; +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; + +/** + * @author jiff + * @date 2018-11-30 + * @since 1.0 + */ +@FeignClient(name = "lis-passport") +public interface InnerService { + + @PostMapping("/innerRoamLogin") + R login(@RequestHeader(PassportConstant.PASSPORT_INNER_NONCE_TOKEN) String token, @RequestBody LoginUser loginUser); +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/PlatformUpmsService.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/PlatformUpmsService.java new file mode 100644 index 0000000..ee6138a --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/PlatformUpmsService.java @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.feign; + +import com.mt.wms.passport.feign.fallback.PlatformUpmsServiceFallback; +import org.springframework.cloud.openfeign.FeignClient; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@FeignClient(name = "wms-platform-upms", fallback = PlatformUpmsServiceFallback.class) +public interface PlatformUpmsService extends UpmsService { +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/UpmsService.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/UpmsService.java new file mode 100644 index 0000000..a509955 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/UpmsService.java @@ -0,0 +1,88 @@ + +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ +package com.mt.wms.passport.feign; + +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.dto.Permission; +import com.mt.wms.core.utils.SpringContextUtil; +import com.mt.wms.core.vo.LoginUserVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.ModifyPasswordParam; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.io.Serializable; +import java.util.List; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public interface UpmsService { + /** + * 获取当前用户权限信息 + * + * @return 权限信息 + */ + @PostMapping("/upms/getPermissions") + List getPermissions(); + + /** + * 获取当前登录用户信息 + * + * @return 登录用户信息 + */ + @PostMapping("/upms/getLoginUser") + R getLoginUser(); + + /** + * 获取登录用户信息 + * + * @param mobile 手机号码 + * @return 登录用户信息 + */ + @PostMapping("/upms/getLoginUserByMobile") + R getLoginUser(@RequestParam("mobile") String mobile); + + /** + * 密码登录 + * + * @param mobile 手机号码 + * @param password 密码 + * @return 登录结果 + */ + @PostMapping("/upms/login") + R login(@RequestParam("mobile") String mobile, @RequestParam("password") String password); + + /** + * 修改密码 + * + * @param param 修改密码参数 + * @return 处理结果 + */ + @PostMapping("/upms/modifyPassword") + R modifyPassword(@RequestBody ModifyPasswordParam param); + + /** + * 退出登录 + * + * @return 处理结果 + */ + @PostMapping("/upms/logout") + R logout(); + + + /** + * 是否debug模式,开发模式允许使用缓存数据 + * + * @return true、false + */ + default boolean isDebug() { + return SpringContextUtil.getActiveProfile().equals("dev"); + } +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/fallback/InnerServiceFallback.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/fallback/InnerServiceFallback.java new file mode 100644 index 0000000..ffef44d --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/fallback/InnerServiceFallback.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.feign.fallback; + +import com.mt.wms.passport.feign.InnerService; +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.vo.R; +import com.mt.wms.core.vo.TokenVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author jiff + * @date 2018/11/30 + * @since 1.0 + */ +@Slf4j +@Service +public class InnerServiceFallback implements InnerService { + + + @Override + public R login(String token, LoginUser loginUser) { + return null; + } +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/fallback/PlatformUpmsServiceFallback.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/fallback/PlatformUpmsServiceFallback.java new file mode 100644 index 0000000..572f35b --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/feign/fallback/PlatformUpmsServiceFallback.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.feign.fallback; + +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.dto.Permission; +import com.mt.wms.core.vo.LoginUserVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.passport.feign.PlatformUpmsService; +import com.mt.wms.upms.params.ModifyPasswordParam; +import com.mt.wms.upms.service.UpmsService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpMethod; +import org.springframework.stereotype.Service; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@Slf4j +@Service +public class PlatformUpmsServiceFallback implements PlatformUpmsService { + @Autowired + private UpmsService upmsService; + + /** + * 获取当前用户权限信息 + * + * @return 权限信息 + */ + @Override + public List getPermissions() { + if (isDebug()) { + log.warn("平台通用权限管理服务不可用,使用缓存权限数据"); + List permissions = new ArrayList<>(); + permissions.add(Permission.builder().url("/**").method(HttpMethod.GET.name()).build()); + permissions.add(Permission.builder().url("/**").method(HttpMethod.POST.name()).build()); + return permissions; + } + return upmsService.getPermissions(); + } + + /** + * 获取当前登录用户信息 + * + * @return 登录用户信息 + */ + @Override + public R getLoginUser() { + if (isDebug()) { + log.warn("平台通用权限管理服务不可用,使用测试用户数据"); + return R.ok(LoginUserVo.builder().userId(1L).mobile("13588441519").userName("jiff") + .orgId(1L).build()); + } + return upmsService.getLoginUserVo(); + } + + /** + * 获取登录用户信息 + * + * @param mobile 手机号码 + * @return 登录用户信息 + */ + @Override + public R getLoginUser(String mobile) { + if (isDebug()) { + log.warn("平台通用权限管理服务不可用,使用测试用户数据"); + return R.ok(LoginUser.builder().userId(1L).mobile(mobile).userName("jiff") + .orgId(1L).userType(LoginUser.USER_TYPE_PLATFORM).build()); + } + return upmsService.getLoginUser(mobile); + } + + /** + * 密码登录 + * + * @param mobile 手机号码 + * @param password 密码 + * @return 登录结果 + */ + @Override + public R login(String mobile, String password) { + if (isDebug()) { + log.warn("平台通用权限管理服务不可用,使用测试用户数据"); + return R.ok(LoginUser.builder().userId(1L).mobile("13588441519").userName("jiff") + .orgId(1L).userType(LoginUser.USER_TYPE_PLATFORM).build()); + } + return upmsService.login(mobile, password); + } + + + /** + * 修改密码 + * + * @param param 修改密码参数 + * @return 处理结果 + */ + @Override + public R modifyPassword(ModifyPasswordParam param) { + return R.failed(); + } + + /** + * 退出登录 + * + * @return 处理结果 + */ + @Override + public R logout() { + return upmsService.logout(); + } +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/listener/SessionCreatedEventListener.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/listener/SessionCreatedEventListener.java new file mode 100644 index 0000000..5024aaa --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/listener/SessionCreatedEventListener.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.listener; + +import com.mt.wms.core.dto.LoginUser; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.ApplicationListener; +import org.springframework.session.Session; +import org.springframework.session.events.SessionCreatedEvent; +import org.springframework.stereotype.Component; + +/** + * @author jiff + * @date 2018-12-12 + * @since 1.0 + */ +@Slf4j +@Component +public class SessionCreatedEventListener implements ApplicationListener { + /** + * Handle an application event. + * + * @param event the event to respond to + */ + @Override + public void onApplicationEvent(SessionCreatedEvent event) { + String sessionId = event.getSessionId(); + Session session = event.getSession(); + log.info("创建会话[{}],用户信息:{}", sessionId, session.getAttribute(LoginUser.HTTP_HEADER_NAME)); + //session.setMaxInactiveInterval(Duration.ofSeconds(5L)); 无用设置 + } +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/listener/SessionExpiredEventListener.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/listener/SessionExpiredEventListener.java new file mode 100644 index 0000000..e73f807 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/listener/SessionExpiredEventListener.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.listener; + +import com.mt.wms.core.dto.LoginUser; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.ApplicationListener; +import org.springframework.session.Session; +import org.springframework.session.events.SessionExpiredEvent; +import org.springframework.stereotype.Component; + + +/** + * @author jiff + * @date 2018-12-12 + * @since 1.0 + */ +@Slf4j +@Component +public class SessionExpiredEventListener implements ApplicationListener { + + + /** + * Handle an application event. + * + * @param event the event to respond to + */ + @Override + public void onApplicationEvent(SessionExpiredEvent event) { + String sessionId = event.getSessionId(); + Session session = event.getSession(); + log.info("会话[{}]过期,用户信息:{}", sessionId, session.getAttribute(LoginUser.HTTP_HEADER_NAME)); + + } +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/BatchInvalidateSessionParam.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/BatchInvalidateSessionParam.java new file mode 100644 index 0000000..c832c6b --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/BatchInvalidateSessionParam.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author jiff + * @date 2019/7/20 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Builder +@ApiModel(value = "批量注销会话请求对象", description = "用于管理用户会话") +public class BatchInvalidateSessionParam extends BaseParam { + + @ApiModelProperty(value = "会话ID", required = true, example = "[1]") + @NotNull(message = "会话ID不能为空") + private List sessionIds; +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/LoginParam.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/LoginParam.java new file mode 100644 index 0000000..1c434d7 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/LoginParam.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.params; + +import com.mt.wms.core.enums.AppTypeEnum; +import com.mt.wms.core.enums.UserTypeEnum; +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.constraints.Enum; +import com.mt.wms.passport.validator.groups.WechatLoginGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @author jiff + * @date 2018/11/13 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Builder +@ApiModel("登录请求对象") +public class LoginParam extends BaseParam { + @ApiModelProperty(value = "应用类型:\n" + + "1、\tpc\n" + + "2、\tapp\n" + + "3、\twechat\n" + + "4、\tminiapp", required = true, example = "1") + @Enum(message = "非法的应用类型", target = {AppTypeEnum.class}) + @NotNull(message = "应用类型不能为空") + private int appType; + + + @ApiModelProperty(value = "用户类型:\n" + + "1、\t平台\n" + + "2、\t合作伙伴\n" + + "3、\t医院\n" + + "4、\t用户", required = true, example = "1") + @Enum(message = "非法的用户类型", target = {UserTypeEnum.class}) + @NotNull(message = "用户类型不能为空") + private Integer userType; + + + @ApiModelProperty(value = "用户名", required = true, example = "13588441519") + private String mobile; + + @ApiModelProperty(value = "密码", required = true, example = "123456") + private String password; + + @ApiModelProperty(value = "微信APPID", required = false, example = "13588441519") + @NotBlank(message = "微信APPID不能为空", groups = {WechatLoginGroup.class}) + private String wechatAppId; + @ApiModelProperty(value = "微信OAuthCode,用户获取微信用户openid", required = false, example = "13588441519") + private String oauthCode; + + @ApiModelProperty(value = "openId", required = true, example = "13588441519") + @NotBlank(message = "openId", groups = {WechatLoginGroup.class}) + private String openId; +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/MobileLoginParam.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/MobileLoginParam.java new file mode 100644 index 0000000..3a94720 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/MobileLoginParam.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.params; + +import com.mt.wms.core.enums.AppTypeEnum; +import com.mt.wms.core.enums.UserTypeEnum; +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.constraints.Enum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +/** + * @author jiff + * @date 2018/11/13 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Builder +@ApiModel(value = "短信验证码登录请求对象", description = "用于短信验证码登录") +public class MobileLoginParam extends BaseParam { + + @ApiModelProperty(value = "应用类型:\n" + + "1、\tpc\n" + + "2、\tapp\n" + + "3、\twechat\n" + + "4、\tminiapp", required = true, example = "3") + @NotNull(message = "用户类型不能为空") + @Enum(message = "非法的应用类型", target = {AppTypeEnum.class}) + private int appType; + + @ApiModelProperty(value = "用户类型:\n" + + "1、\tPC管理端\n" + + "2、\t移动端", required = true, example = "1") + @Enum(message = "非法的用户类型", target = {UserTypeEnum.class}) + @NotNull(message = "用户类型不能为空") + private Integer userType; + + @ApiModelProperty(value = "手机号码", required = true, example = "13588441519") + @NotBlank(message = "手机号码不能为空") + @Pattern(regexp = "^1[3456789]\\d{9}$", message = "手机号码格式不正确") + private String mobile; + + @ApiModelProperty(value = "短信验证码", required = true, example = "1234") + @Length(min = 4, max = 4, message = "短信验证码长度为4位") + private String smsCode; + + @ApiModelProperty(value = "微信APPID", required = false, example = "13588441519") + private String wechatAppId; + @ApiModelProperty(value = "微信OAuthCode,用户获取微信用户openid", required = false, example = "13588441519") + private String oauthCode; +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/QueryLoginLogParam.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/QueryLoginLogParam.java new file mode 100644 index 0000000..fc4cb35 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/QueryLoginLogParam.java @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.params; + +import com.mt.wms.core.enums.AppTypeEnum; +import com.mt.wms.core.enums.UserTypeEnum; +import com.mt.wms.core.params.BasePageParam; +import com.mt.wms.core.validator.constraints.Enum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 登录会话日志 + *

+ * + * @author jiff + * @since 2019-07-20 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel("查询会话日志请求对象") +public class QueryLoginLogParam extends BasePageParam { + + private static final long serialVersionUID = 1L; + + + /** + * 会话ID + */ + @ApiModelProperty("会话ID") + private String sessionId; + + /** + * 父会话ID,漫游登录时需要保存发起漫游用户的会话ID + */ + @ApiModelProperty("父会话ID,漫游登录时需要保存发起漫游用户的会话ID") + private String parentSessionId; + + /** + * 统一用户ID + */ + @ApiModelProperty("统一用户ID") + private Long passportUserId; + + /** + * 用户ID + */ + @ApiModelProperty("用户ID") + private Long userId; + + /** + * 合作伙伴ID,合作伙伴用户或者医院用户登录时会存储 + */ + @ApiModelProperty("合作伙伴ID,合作伙伴用户或者医院用户登录时会存储") + private Long partnerId; + + /** + * 医院ID + */ + @ApiModelProperty("医院ID") + private Long hospitalId; + + /** + * 组织ID + */ + @ApiModelProperty("组织ID") + private Long orgId; + + /** + * 手机号 + */ + @ApiModelProperty("手机号") + private String mobile; + + /** + * 用户名称 + */ + @ApiModelProperty("用户名称") + private String userName; + + /** + * 用户类型:1、平台用户,2、合作伙伴用户,3、医院用户,4、患者 + */ + @ApiModelProperty(value = "用户类型:1、平台用户,2、合作伙伴用户,3、医院用户,4、患者", example = "1") + @Enum(message = "非法的用户类型", target = {UserTypeEnum.class}) + private Integer userType; + + /** + * 应用类型:1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "应用类型:\n" + + "1、\tpc\n" + + "2、\tapp\n" + + "3、\twechat\n" + + "4、\tminiapp", required = false, example = "1") + @Enum(message = "非法的应用类型", target = {AppTypeEnum.class}) + private Integer appType; + + /** + * 应用编码:暂未使用 + */ + @ApiModelProperty("应用编码:暂未使用") + private Integer appCode; + + /** + * 登录类型:1、自主登录,2、漫游登录 + */ + @ApiModelProperty("登录类型:1、自主登录,2、漫游登录") + private Integer loginType; + + /** + * 退出类型:1、自主退出,2、管理退出,3,超时退出 + */ + @ApiModelProperty(value = "退出类型:1、自主退出,2、管理退出,3,超时退出", example = "1") + private Integer logoutType; + + /** + * 异常状态:0、正常,1、省份异常,2、地市异常,3、区县异常 + */ + @ApiModelProperty(value = "异常状态:0、正常,1、省份异常,2、地市异常,3、区县异常", example = "0") + private Integer abnormalStatus; + + /** + * 开始时间 + */ + @ApiModelProperty(value = "开始时间,格式:yyyy-MM-dd", example = "2019-08-01") + private String startTime; + + /** + * 结束时间 + */ + @ApiModelProperty(value = "结束时间,格式:yyyy-MM-dd", example = "2019-08-01") + private String endTime; + + /** + * 退出开始时间 + */ + @ApiModelProperty(value = "退出开始时间,格式:yyyy-MM-dd", example = "2019-08-01") + private String logoutStartTime; + + /** + * 退出结束时间 + */ + @ApiModelProperty(value = "退出结束时间,格式:yyyy-MM-dd", example = "2019-08-01") + private String logoutEndTime; + + /** + * 设备类型 + */ + @ApiModelProperty("设备类型") + private String deviceClass; + + /** + * 设备名称 + */ + @ApiModelProperty("设备名称") + private String deviceName; + + /** + * 设备品牌 + */ + @ApiModelProperty("设备品牌") + private String deviceBrand; + + /** + * 操作系统 + */ + @ApiModelProperty("操作系统") + private String os; + + /** + * 浏览器 + */ + @ApiModelProperty("浏览器") + private String browser; + + /** + * 省份 + */ + @ApiModelProperty("省份") + private String province; + + /** + * 地市 + */ + @ApiModelProperty("地市") + private String city; + + /** + * 区县 + */ + @ApiModelProperty("区县") + private String county; + + /** + * IP地址 + */ + @ApiModelProperty(value = "IP地址", example = "192.168.1.1") + private String ip; + + +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/QuerySessionParam.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/QuerySessionParam.java new file mode 100644 index 0000000..d68230c --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/QuerySessionParam.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.params; + +import com.mt.wms.core.enums.AppTypeEnum; +import com.mt.wms.core.enums.UserTypeEnum; +import com.mt.wms.core.params.BasePageParam; +import com.mt.wms.core.validator.constraints.Enum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 登录会话 + *

+ * + * @author jiff + * @since 2019-07-20 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel("查询会话请求对象") +public class QuerySessionParam extends BasePageParam { + + private static final long serialVersionUID = 1L; + + + /** + * 会话ID + */ + @ApiModelProperty("会话ID") + private String sessionId; + + /** + * 父会话ID,漫游登录时需要保存发起漫游用户的会话ID + */ + @ApiModelProperty("父会话ID,漫游登录时需要保存发起漫游用户的会话ID") + private String parentSessionId; + + + /** + * 统一用户ID + */ + @ApiModelProperty("统一用户ID") + private Long passportUserId; + + /** + * 用户ID + */ + @ApiModelProperty("用户ID") + private Long userId; + + /** + * 合作伙伴ID,合作伙伴用户或者医院用户登录时会存储 + */ + @ApiModelProperty("合作伙伴ID,合作伙伴用户或者医院用户登录时会存储") + private Long partnerId; + + /** + * 医院ID + */ + @ApiModelProperty("医院ID") + private Long hospitalId; + + /** + * 组织ID + */ + @ApiModelProperty("组织ID") + private Long orgId; + + /** + * 手机号 + */ + @ApiModelProperty("手机号") + private String mobile; + + /** + * 用户名称 + */ + @ApiModelProperty("用户名称") + private String userName; + + /** + * 用户类型:1、平台用户,2、合作伙伴用户,3、医院用户,4、患者 + */ + @ApiModelProperty(value = "用户类型:1、平台用户,2、合作伙伴用户,3、医院用户,4、患者", example = "1") + @Enum(message = "非法的用户类型", target = {UserTypeEnum.class}) + private Integer userType; + + /** + * 应用类型:1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "应用类型:\n" + + "1、\tpc\n" + + "2、\tapp\n" + + "3、\twechat\n" + + "4、\tminiapp", required = false, example = "1") + @Enum(message = "非法的应用类型", target = {AppTypeEnum.class}) + private Integer appType; + + /** + * 应用编码:暂未使用 + */ + @ApiModelProperty("应用编码:暂未使用") + private Integer appCode; + + /** + * 登录类型:1、自主登录,2、漫游登录 + */ + @ApiModelProperty("登录类型:1、自主登录,2、漫游登录") + private Integer loginType; + + /** + * 开始时间 + */ + @ApiModelProperty(value = "开始时间,格式:yyyy-MM-dd", example = "2019-08-01") + private String startTime; + + /** + * 结束时间 + */ + @ApiModelProperty(value = "结束时间,格式:yyyy-MM-dd", example = "2019-08-01") + private String endTime; + + + /** + * 设备类型 + */ + @ApiModelProperty("设备类型") + private String deviceClass; + + /** + * 设备名称 + */ + @ApiModelProperty("设备名称") + private String deviceName; + + /** + * 设备品牌 + */ + @ApiModelProperty("设备品牌") + private String deviceBrand; + + /** + * 操作系统 + */ + @ApiModelProperty("操作系统") + private String os; + + /** + * 浏览器 + */ + @ApiModelProperty("浏览器") + private String browser; + + /** + * 省份 + */ + @ApiModelProperty("省份") + private String province; + + /** + * 地市 + */ + @ApiModelProperty("地市") + private String city; + + /** + * 区县 + */ + @ApiModelProperty("区县") + private String county; + + + /** + * IP地址 + */ + @ApiModelProperty(value = "IP地址", example = "192.168.1.1") + private String ip; + + +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/SessionParam.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/SessionParam.java new file mode 100644 index 0000000..67d699c --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/params/SessionParam.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotNull; + +/** + * @author jiff + * @date 2019/7/20 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Builder +@ApiModel(value = "会话请求对象", description = "用于管理用户会话") +public class SessionParam extends BaseParam { + + @ApiModelProperty(value = "会话ID", required = true, example = "1") + @NotNull(message = "会话ID不能为空") + private String sessionId; +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/resolver/CookieHeaderHttpSessionIdResolver.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/resolver/CookieHeaderHttpSessionIdResolver.java new file mode 100644 index 0000000..48000e9 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/resolver/CookieHeaderHttpSessionIdResolver.java @@ -0,0 +1,164 @@ +/* + * Copyright 2014-2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mt.wms.passport.resolver; + +import org.springframework.session.web.http.CookieHttpSessionIdResolver; +import org.springframework.session.web.http.CookieSerializer; +import org.springframework.session.web.http.DefaultCookieSerializer; +import org.springframework.session.web.http.HttpSessionIdResolver; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Collections; +import java.util.List; + +/** + * A {@link HttpSessionIdResolver} that uses a header to resolve the session id. + * Specifically, this implementation will allow specifying a header name using + * {@link #CookieHeaderHttpSessionIdResolver(String)}. Convenience factory methods for creating + * instances that use common header names, such as "X-Auth-Token" and + * "Authentication-Info", are available as well. + *

+ * When a session is created, the HTTP response will have a response header of the + * specified name and the value of the session id. For example: + * + *

+ * HTTP/1.1 200 OK
+ * X-Auth-Token: f81d4fae-7dec-11d0-a765-00a0c91e6bf6
+ * 
+ *

+ * The client should now include the session in each request by specifying the same header + * in their request. For example: + * + *

+ * GET /messages/ HTTP/1.1
+ * Host: example.com
+ * X-Auth-Token: f81d4fae-7dec-11d0-a765-00a0c91e6bf6
+ * 
+ *

+ * When the session is invalidated, the server will send an HTTP response that has the + * header name and a blank value. For example: + * + *

+ * HTTP/1.1 200 OK
+ * X-Auth-Token:
+ * 
+ * + * @author Rob Winch + * @author Vedran Pavic + * @since 1.0 + */ +public class CookieHeaderHttpSessionIdResolver implements HttpSessionIdResolver { + + private static final String HEADER_TOKEN = "token"; + + private static final String HEADER_X_AUTH_TOKEN = "X-Auth-Token"; + + private static final String HEADER_AUTHENTICATION_INFO = "Authentication-Info"; + + private final String headerName; + + private static final String WRITTEN_SESSION_ID_ATTR = CookieHttpSessionIdResolver.class + .getName().concat(".WRITTEN_SESSION_ID_ATTR"); + + private CookieSerializer cookieSerializer = new DefaultCookieSerializer(); + + + /** + * Convenience factory to create {@link CookieHeaderHttpSessionIdResolver} that uses + * "X-Auth-Token" header. + * + * @return the instance configured to use "X-Auth-Token" header + */ + public static CookieHeaderHttpSessionIdResolver token() { + return new CookieHeaderHttpSessionIdResolver(HEADER_TOKEN); + } + + /** + * Convenience factory to create {@link CookieHeaderHttpSessionIdResolver} that uses + * "X-Auth-Token" header. + * + * @return the instance configured to use "X-Auth-Token" header + */ + public static CookieHeaderHttpSessionIdResolver xAuthToken() { + return new CookieHeaderHttpSessionIdResolver(HEADER_X_AUTH_TOKEN); + } + + /** + * Convenience factory to create {@link CookieHeaderHttpSessionIdResolver} that uses + * "Authentication-Info" header. + * + * @return the instance configured to use "Authentication-Info" header + */ + public static CookieHeaderHttpSessionIdResolver authenticationInfo() { + return new CookieHeaderHttpSessionIdResolver(HEADER_AUTHENTICATION_INFO); + } + + /** + * The name of the header to obtain the session id from. + * + * @param headerName the name of the header to obtain the session id from. + */ + public CookieHeaderHttpSessionIdResolver(String headerName) { + if (headerName == null) { + throw new IllegalArgumentException("headerName cannot be null"); + } + this.headerName = headerName; + } + + @Override + public List resolveSessionIds(HttpServletRequest request) { + String headerValue = request.getHeader(this.headerName); + + return headerValue != null ? Collections.singletonList(headerValue) + : this.cookieSerializer.readCookieValues(request); + } + + @Override + public void setSessionId(HttpServletRequest request, HttpServletResponse response, + String sessionId) { + response.setHeader(this.headerName, sessionId); + //cookie + if (sessionId.equals(request.getAttribute(WRITTEN_SESSION_ID_ATTR))) { + return; + } + request.setAttribute(WRITTEN_SESSION_ID_ATTR, sessionId); + this.cookieSerializer + .writeCookieValue(new CookieSerializer.CookieValue(request, response, sessionId)); + } + + @Override + public void expireSession(HttpServletRequest request, HttpServletResponse response) { + response.setHeader(this.headerName, ""); + //cookie + this.cookieSerializer.writeCookieValue(new CookieSerializer.CookieValue(request, response, "")); + } + + + /** + * Sets the {@link CookieSerializer} to be used. + * + * @param cookieSerializer the cookieSerializer to set. Cannot be null. + */ + public void setCookieSerializer(CookieSerializer cookieSerializer) { + if (cookieSerializer == null) { + throw new IllegalArgumentException("cookieSerializer cannot be null"); + } + this.cookieSerializer = cookieSerializer; + } + +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/LogService.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/LogService.java new file mode 100644 index 0000000..fbdff79 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/LogService.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.service; + +import com.mt.wms.core.dto.ApiLogDto; +import com.mt.wms.core.dto.LoginLogDto; +import com.mt.wms.core.vo.R; + +/** + * 日志服务 + * + * @author jiff + * @date 2019-07-20 + * @since 1.0 + */ +public interface LogService { + /** + * 保存登录日志 + * + * @param loginLogDto + * @return + */ + R saveLoginLog(LoginLogDto loginLogDto); + + /** + * 保存接口日志 + * + * @param apiLogDto + * @return + */ + R saveApiLog(ApiLogDto apiLogDto); +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/PassportService.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/PassportService.java new file mode 100644 index 0000000..64150c5 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/PassportService.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.service; + + +import com.mt.wms.core.dto.ApiLogDto; +import com.mt.wms.core.dto.LoginLogDto; +import com.mt.wms.core.dto.Permission; + +import java.util.List; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public interface PassportService { + List getAllPermission(); + + void saveLoginLog(LoginLogDto loginLogDto); + + void saveApiLog(ApiLogDto apiLogDto); + +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/SessionService.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/SessionService.java new file mode 100644 index 0000000..068affd --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/SessionService.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.service; + + +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.params.MobileParam; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.passport.params.BatchInvalidateSessionParam; +import com.mt.wms.passport.params.QueryLoginLogParam; +import com.mt.wms.passport.params.QuerySessionParam; +import com.mt.wms.passport.params.SessionParam; +import com.mt.wms.passport.vo.LoginLogVo; +import com.mt.wms.passport.vo.LoginSessionVo; + +import java.util.List; + +/** + * 会话服务 + * + * @author jiff + * @date 2019-07-20 + * @since 1.0 + */ +public interface SessionService { + /** + * 获取登录会话列表 + * + * @param param + * @return + */ + R> list(QuerySessionParam param); + + /** + * 获取登录会话日志列表 + * + * @param param + * @return + */ + R> listLog(QueryLoginLogParam param); + + /** + * 注销用户会话 + * + * @param param + * @return + */ + R invalidateSession(SessionParam param); + + /** + * 批量注销用户会话 + * + * @param param + * @return + */ + R> batchInvalidateSession(BatchInvalidateSessionParam param); + + /** + * 根据手机号码注销用户会话,该手机号码所有会话都注销 + * + * @param param + * @return + */ + R> invalidateSession(MobileParam param); + + /** + * 注销所有平台用户会话 + * + * @return + */ + R> invalidateAllPlatformSession(); + + /** + * 获取登录用户 + * + * @param param + * @return + */ + R> getLoginSession(MobileParam param); +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/impl/LogServiceImpl.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/impl/LogServiceImpl.java new file mode 100644 index 0000000..1dc0798 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/impl/LogServiceImpl.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2020. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.dal.entity.LoginLog; +import com.mt.wms.core.dal.entity.LoginSession; +import com.mt.wms.core.dal.entity.SysOrg; +import com.mt.wms.core.dal.service.LoginLogServiceBiz; +import com.mt.wms.core.dal.service.LoginSessionServiceBiz; +import com.mt.wms.core.dal.service.SysOrgServiceBiz; +import com.mt.wms.core.dto.ApiLogDto; +import com.mt.wms.core.dto.LoginLogDto; +import com.mt.wms.core.enums.UserTypeEnum; +import com.mt.wms.core.vo.R; +import com.mt.wms.passport.service.LogService; +import nl.basjes.parse.useragent.UserAgent; +import nl.basjes.parse.useragent.UserAgentAnalyzer; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.time.ZoneId; + +/** + * @author jiff + * @date 2019-07-20 + * @since 1.0 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class LogServiceImpl extends BaseService implements LogService { + @Autowired + private LoginSessionServiceBiz loginSessionServiceBiz; + @Autowired + private LoginLogServiceBiz loginLogServiceBiz; + @Autowired + private SysOrgServiceBiz sysOrgServiceBiz; + + + private UserAgentAnalyzer uaa = UserAgentAnalyzer + .newBuilder() + .withoutCache() + .hideMatcherLoadStats() + // .withField(UserAgent.OPERATING_SYSTEM_NAME) + .build(); + + /** + * 保存登录日志 + * + * @param loginLogDto + * @return + */ + @Override + public R saveLoginLog(LoginLogDto loginLogDto) { + int action = loginLogDto.getAction(); + //保存登录会话信息 + if (action == LoginLogDto.ACTION_LOGIN) { + LoginSession loginSession = loginSessionServiceBiz.getOne(new QueryWrapper().eq(LoginSession.SESSION_ID, loginLogDto.getSessionId()).last("LIMIT 1")); + if (loginSession == null) { + loginSession = new LoginSession(); + BeanUtils.copyProperties(loginLogDto, loginSession); + loginSession.setLoginTime(LocalDateTime.ofInstant(loginLogDto.getLoginTime().toInstant(), ZoneId.systemDefault())); + + if (ObjectUtils.allNotNull(loginLogDto.getOrgId())) { + if (loginLogDto.getUserType() == UserTypeEnum.PLATFORM.getValue()) { + SysOrg org = sysOrgServiceBiz.getById(loginLogDto.getOrgId()); + if (org != null) { + loginSession.setOrgName(org.getName()); + } + } + } + + UserAgent userAgent = uaa.parse(loginLogDto.getUserAgent()); + loginSession.setDeviceClass(userAgent.getValue(UserAgent.DEVICE_CLASS)) + .setDeviceName(userAgent.getValue(UserAgent.DEVICE_NAME)) + .setDeviceBrand(userAgent.getValue(UserAgent.DEVICE_BRAND)) + .setOs(userAgent.getValue(UserAgent.OPERATING_SYSTEM_NAME_VERSION)) + .setBrowser(userAgent.getValue(UserAgent.AGENT_NAME_VERSION)); + + loginSession.setCreator(loginLogDto.getUserId()) + .setCreatorName(loginLogDto.getUserName()) + .setCreateTime(LocalDateTime.now()); + loginSessionServiceBiz.save(loginSession); + } + } else { + //删除登录会话,保存登录日志 + LoginSession loginSession = loginSessionServiceBiz.getOne(new QueryWrapper().eq(LoginSession.SESSION_ID, loginLogDto.getSessionId()).last("LIMIT 1")); + if (loginSession != null) { + LoginLog loginLog = new LoginLog(); + BeanUtils.copyProperties(loginSession, loginLog); + loginLog.setLogoutType(loginLogDto.getLogoutType()) + .setLogoutTime(LocalDateTime.ofInstant(loginLogDto.getLogoutTime().toInstant(), ZoneId.systemDefault())) + .setLogoutIp(loginLogDto.getIp()) + .setLogoutUserAgent(loginLogDto.getUserAgent()); + if (loginLogDto.getLogoutType() == LoginLogDto.LOGOUT_TYPE_MANAGE) { + loginLog.setUpdater(loginLogDto.getUserId()) + .setUpdaterName(loginLogDto.getUserName()) + .setUpdateTime(LocalDateTime.now()); + } else { + loginLog.setUpdater(loginSession.getUserId()) + .setUpdaterName(loginSession.getUserName()) + .setUpdateTime(LocalDateTime.now()); + } + loginSessionServiceBiz.removeById(loginSession.getId()); + loginLogServiceBiz.save(loginLog); + } + } + return successful(null); + } + + /** + * 保存接口日志 + * + * @param apiLogDto + * @return + */ + @Override + public R saveApiLog(ApiLogDto apiLogDto) { + return null; + } +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/impl/PassportServiceImpl.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/impl/PassportServiceImpl.java new file mode 100644 index 0000000..4691703 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/impl/PassportServiceImpl.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.service.impl; + +import com.mt.wms.core.dto.ApiLogDto; +import com.mt.wms.core.dto.LoginLogDto; +import com.mt.wms.core.dto.Permission; +import com.mt.wms.passport.service.PassportService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +@Service +public class PassportServiceImpl implements PassportService { + @Autowired + private RedisTemplate redisTemplate; + + + @Override + public List getAllPermission() { + return null; + } + + @Override + public void saveLoginLog(LoginLogDto loginLogDto) { + } + + @Override + public void saveApiLog(ApiLogDto apiLogDto) { + } +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/impl/SessionServiceImpl.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/impl/SessionServiceImpl.java new file mode 100644 index 0000000..52a0737 --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/service/impl/SessionServiceImpl.java @@ -0,0 +1,270 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.service.impl; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.dal.entity.LoginLog; +import com.mt.wms.core.dal.entity.LoginSession; +import com.mt.wms.core.dal.entity.SysUser; +import com.mt.wms.core.dal.service.LoginLogServiceBiz; +import com.mt.wms.core.dal.service.LoginSessionServiceBiz; +import com.mt.wms.core.dal.service.SysUserServiceBiz; +import com.mt.wms.core.dto.LoginLogDto; +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.params.MobileParam; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.passport.params.BatchInvalidateSessionParam; +import com.mt.wms.passport.params.QueryLoginLogParam; +import com.mt.wms.passport.params.QuerySessionParam; +import com.mt.wms.passport.params.SessionParam; +import com.mt.wms.passport.service.PassportService; +import com.mt.wms.passport.service.SessionService; +import com.mt.wms.passport.vo.LoginLogVo; +import com.mt.wms.passport.vo.LoginSessionVo; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.session.FindByIndexNameSessionRepository; +import org.springframework.session.Session; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author jiff + * @date 2019-07-20 + * @since 1.0 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class SessionServiceImpl extends BaseService implements SessionService { + @Autowired + private LoginSessionServiceBiz loginSessionServiceBiz; + @Autowired + private LoginLogServiceBiz loginLogServiceBiz; + + @Autowired + private SysUserServiceBiz sysUserServiceBiz; + + @Autowired + private PassportService passportService; + @Autowired + private FindByIndexNameSessionRepository sessionRepository; + + + /** + * 获取登录会话列表 + * + * @param param + * @return + */ + @Override + public R> list(QuerySessionParam param) { + LoginUser loginUser = getLoginUser(); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(ObjectUtils.isNotNull(param.getSessionId()), LoginSession.SESSION_ID, param.getSessionId()) + .eq(ObjectUtils.isNotNull(param.getMobile()), LoginSession.MOBILE, param.getMobile()) + .eq(ObjectUtils.isNotNull(param.getUserType()), LoginSession.USER_TYPE, param.getUserType()) + .eq(ObjectUtils.isNotNull(param.getAppType()), LoginSession.APP_TYPE, param.getAppType()) + .eq(ObjectUtils.isNotNull(param.getLoginType()), LoginSession.LOGIN_TYPE, param.getLoginType()) + .eq(ObjectUtils.isNotNull(param.getIp()), LoginSession.IP, param.getIp()) + .eq(StringUtils.isNotBlank(param.getDeviceClass()), LoginSession.DEVICE_CLASS, param.getDeviceClass()) + .like(StringUtils.isNotBlank(param.getDeviceBrand()), LoginSession.DEVICE_BRAND, param.getDeviceBrand()) + .like(StringUtils.isNotBlank(param.getOs()), LoginSession.OS, param.getOs()) + .like(StringUtils.isNotBlank(param.getBrowser()), LoginSession.BROWSER, param.getBrowser()) + .like(StringUtils.isNotBlank(param.getUserName()), LoginSession.USER_NAME, param.getUserName()); + //LocalDate.parse不允许null,不能使用QueryWrapper#ge(boolean condition, R column, Object val) + if (StringUtils.isNotBlank(param.getStartTime())) { + wrapper.ge(LoginSession.LOGIN_TIME, LocalDate.parse(param.getStartTime(), DateTimeFormatter.ISO_LOCAL_DATE).atStartOfDay()); + } + if (StringUtils.isNotBlank(param.getEndTime())) { + wrapper.le(LoginSession.LOGIN_TIME, LocalDate.parse(param.getEndTime(), DateTimeFormatter.ISO_LOCAL_DATE).atTime(LocalTime.MAX)); + } + //根据登录时间倒序 + wrapper.orderByDesc(LoginSession.LOGIN_TIME); + IPage page = loginSessionServiceBiz.page(new Page<>(param.getCurrent(), param.getSize()), wrapper); + return successful(new PageVo<>(page, LoginSessionVo.class)); + } + + /** + * 获取登录会话日志列表 + * + * @param param + * @return + */ + @Override + public R> listLog(QueryLoginLogParam param) { + + LoginUser loginUser = getLoginUser(); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(ObjectUtils.isNotNull(param.getSessionId()), LoginLog.SESSION_ID, param.getSessionId()) + .eq(ObjectUtils.isNotNull(param.getMobile()), LoginLog.MOBILE, param.getMobile()) + .eq(ObjectUtils.isNotNull(param.getUserType()), LoginLog.USER_TYPE, param.getUserType()) + .eq(ObjectUtils.isNotNull(param.getAppType()), LoginLog.APP_TYPE, param.getAppType()) + .eq(ObjectUtils.isNotNull(param.getLoginType()), LoginLog.LOGIN_TYPE, param.getLoginType()) + .eq(ObjectUtils.isNotNull(param.getLogoutType()), LoginLog.LOGOUT_TYPE, param.getLogoutType()) + .eq(ObjectUtils.isNotNull(param.getIp()), LoginLog.IP, param.getIp()) + .eq(StringUtils.isNotBlank(param.getDeviceClass()), LoginLog.DEVICE_CLASS, param.getDeviceClass()) + .like(StringUtils.isNotBlank(param.getDeviceBrand()), LoginLog.DEVICE_BRAND, param.getDeviceBrand()) + .like(StringUtils.isNotBlank(param.getOs()), LoginLog.OS, param.getOs()) + .like(StringUtils.isNotBlank(param.getBrowser()), LoginLog.BROWSER, param.getBrowser()) + .like(StringUtils.isNotBlank(param.getUserName()), LoginLog.USER_NAME, param.getUserName()); + //LocalDate.parse不允许null,不能使用QueryWrapper#ge(boolean condition, R column, Object val) + //登录时间 + if (StringUtils.isNotBlank(param.getStartTime())) { + wrapper.ge(LoginLog.LOGIN_TIME, LocalDate.parse(param.getStartTime(), DateTimeFormatter.ISO_LOCAL_DATE).atStartOfDay()); + } + if (StringUtils.isNotBlank(param.getEndTime())) { + wrapper.le(LoginLog.LOGIN_TIME, LocalDate.parse(param.getEndTime(), DateTimeFormatter.ISO_LOCAL_DATE).atTime(LocalTime.MAX)); + } + //退出时间 + if (StringUtils.isNotBlank(param.getLogoutStartTime())) { + wrapper.ge(LoginLog.LOGOUT_TIME, LocalDate.parse(param.getLogoutStartTime(), DateTimeFormatter.ISO_LOCAL_DATE).atStartOfDay()); + } + if (StringUtils.isNotBlank(param.getLogoutEndTime())) { + wrapper.le(LoginLog.LOGOUT_TIME, LocalDate.parse(param.getLogoutEndTime(), DateTimeFormatter.ISO_LOCAL_DATE).atTime(LocalTime.MAX)); + } + //根据退出时间倒序 + wrapper.orderByDesc(LoginLog.LOGOUT_TIME); + IPage page = loginLogServiceBiz.page(new Page<>(param.getCurrent(), param.getSize()), wrapper); + return successful(new PageVo<>(page, LoginLogVo.class)); + } + + /** + * 注销用户会话 + * + * @param param + * @return + */ + @Override + public R invalidateSession(SessionParam param) { + LoginUser loginUser = getLoginUser(); + if (loginUser == null) { + return R.unauthorized(); + } + //记录退出时间 + passportService.saveLoginLog(LoginLogDto.builder() + .sessionId(param.getSessionId()) + .action(LoginLogDto.ACTION_LOGOUT) + .logoutType(LoginLogDto.LOGOUT_TYPE_MANAGE) + .logoutTime(new Date()) + .userId(loginUser.getUserId()) + .userName(loginUser.getUserName()) + .build()); + sessionRepository.deleteById(param.getSessionId()); + return successful(param.getSessionId()); + } + + /** + * 批量注销用户会话 + * + * @param param + * @return + */ + @Override + public R> batchInvalidateSession(BatchInvalidateSessionParam param) { + LoginUser loginUser = getLoginUser(); + if (loginUser == null) { + return R.unauthorized(); + } + for (String sessionId : param.getSessionIds()) { + //记录退出时间 + passportService.saveLoginLog(LoginLogDto.builder() + .sessionId(sessionId) + .action(LoginLogDto.ACTION_LOGOUT) + .logoutType(LoginLogDto.LOGOUT_TYPE_MANAGE) + .logoutTime(new Date()) + .userId(loginUser.getUserId()) + .userName(loginUser.getUserName()) + .build()); + sessionRepository.deleteById(sessionId); + } + return successful(param.getSessionIds()); + } + + /** + * 根据手机号码注销用户会话,该手机号码所有会话都注销 + * + * @param param + * @return + */ + @Override + public R> invalidateSession(MobileParam param) { + LoginUser loginUser = getLoginUser(); + if (loginUser == null) { + return R.unauthorized(); + } + List sessionIds = new ArrayList<>(); + Map sessions = sessionRepository.findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, param.getMobile()); + for (Session session : sessions.values()) { + //记录退出时间 + passportService.saveLoginLog(LoginLogDto.builder() + .sessionId(session.getId()) + .action(LoginLogDto.ACTION_LOGOUT) + .logoutType(LoginLogDto.LOGOUT_TYPE_MANAGE) + .logoutTime(new Date()) + .userId(loginUser.getUserId()) + .userName(loginUser.getUserName()) + .build()); + sessionRepository.deleteById(session.getId()); + sessionIds.add(session.getId()); + } + return successful(sessionIds); + } + + /** + * 注销所有平台用户会话 + * + * @return + */ + @Override + public R> invalidateAllPlatformSession() { + List sessionIds = new ArrayList<>(); + List users = sysUserServiceBiz.list(); + for (SysUser user : users) { + R> r = invalidateSession(MobileParam.builder().mobile(user.getMobile()).build()); + if (r.ok()) { + sessionIds.addAll(r.getData()); + } + } + return successful(sessionIds); + } + + + /** + * 获取登录用户 + * + * @param param + * @return + */ + @Override + public R> getLoginSession(MobileParam param) { + List loginUsers = new ArrayList<>(); + Map sessions = sessionRepository.findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, param.getMobile()); + for (Session session : sessions.values()) { + String loginUserJson = session.getAttribute(LoginUser.HTTP_HEADER_NAME); + if (StringUtils.isNotBlank(loginUserJson)) { + LoginUser loginUser = JSON.parseObject(loginUserJson, LoginUser.class); + loginUser.setSessionId(session.getId()); + loginUsers.add(loginUser); + } + } + return successful(loginUsers); + } + +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/validator/groups/PasswordLoginGroup.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/validator/groups/PasswordLoginGroup.java new file mode 100644 index 0000000..577136c --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/validator/groups/PasswordLoginGroup.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.validator.groups; + +/** + * 密码登录验证组 + * + * @author jiff + * @date 2019/3/29 + * @since 1.0 + */ +public interface PasswordLoginGroup { +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/validator/groups/WechatLoginGroup.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/validator/groups/WechatLoginGroup.java new file mode 100644 index 0000000..6df482b --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/validator/groups/WechatLoginGroup.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.validator.groups; + +/** + * 微信登录验证组 + * + * @author jiff + * @date 2019/3/29 + * @since 1.0 + */ +public interface WechatLoginGroup { +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/vo/LoginLogVo.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/vo/LoginLogVo.java new file mode 100644 index 0000000..7ffbcae --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/vo/LoginLogVo.java @@ -0,0 +1,279 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.mt.wms.core.vo.CommonVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.time.LocalDateTime; + +/** + *

+ * 登录日志表 + *

+ * + * @author jiff + * @since 2019-07-20 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel("登录日志视图对象") +public class LoginLogVo extends CommonVo implements PageVo.ConvertVo { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "id") + private Long id; + + /** + * 会话ID + */ + @ApiModelProperty("会话ID") + private String sessionId; + + /** + * 父会话ID,漫游登录时需要保存发起漫游用户的会话ID + */ + @ApiModelProperty("父会话ID,漫游登录时需要保存发起漫游用户的会话ID") + private String parentSessionId; + + /** + * 父用户名称 + */ + @ApiModelProperty("父用户名称") + private String parentUserName; + + /** + * 统一用户ID + */ + @ApiModelProperty("统一用户ID") + private Long passportUserId; + + /** + * 用户ID + */ + @ApiModelProperty("用户ID") + private Long userId; + + /** + * 合作伙伴ID,合作伙伴用户或者医院用户登录时会存储 + */ + @ApiModelProperty("合作伙伴ID,合作伙伴用户或者医院用户登录时会存储") + private Long partnerId; + + /** + * 医院ID + */ + @ApiModelProperty("医院ID") + private Long hospitalId; + + /** + * 组织ID + */ + @ApiModelProperty("组织ID") + private Long orgId; + + /** + * 手机号 + */ + @ApiModelProperty("手机号") + private String mobile; + + /** + * 用户名称 + */ + @ApiModelProperty("用户名称") + private String userName; + + /** + * 合作伙伴名称 + */ + @ApiModelProperty("合作伙伴名称") + private String partnerName; + + /** + * 医院名称 + */ + @ApiModelProperty("医院名称") + private String hospitalName; + + /** + * 组织名称 + */ + @ApiModelProperty("组织名称") + private String orgName; + + /** + * 用户类型:1、平台用户,2、合作伙伴用户,3、医院用户,4、患者 + */ + @ApiModelProperty("用户类型:1、平台用户,2、合作伙伴用户,3、医院用户,4、患者") + private Integer userType; + + /** + * 应用类型:1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty("应用类型:1、pc,2、app,3、wechat,4、miniapp") + private Integer appType; + + /** + * 应用编码:暂未使用 + */ + @ApiModelProperty("应用编码:暂未使用") + private Integer appCode; + + /** + * 登录类型:1、自主登录,2、漫游登录 + */ + @ApiModelProperty(value = "登录类型:1、自主登录,2、漫游登录", example = "1") + private Integer loginType; + + /** + * 退出类型:1、自主退出,2、管理退出,3,超时退出 + */ + @ApiModelProperty(value = "退出类型:1、自主退出,2、管理退出,3,超时退出", example = "1") + private Integer logoutType; + + /** + * 登录时间 + */ + @ApiModelProperty("登录时间") + private LocalDateTime loginTime; + + /** + * 退出时间 + */ + @ApiModelProperty("退出时间") + private LocalDateTime logoutTime; + + /** + * 设备类型 + */ + @ApiModelProperty("设备类型") + private String deviceClass; + + /** + * 设备名称 + */ + @ApiModelProperty("设备名称") + private String deviceName; + + /** + * 设备品牌 + */ + @ApiModelProperty("设备品牌") + private String deviceBrand; + + /** + * 操作系统 + */ + @ApiModelProperty("操作系统") + private String os; + + /** + * 浏览器 + */ + @ApiModelProperty("浏览器") + private String browser; + + /** + * 国家 + */ + @ApiModelProperty("国家") + private String country; + + /** + * 省份 + */ + @ApiModelProperty("省份") + private String province; + + /** + * 地市 + */ + @ApiModelProperty("地市") + private String city; + + /** + * 区县 + */ + @ApiModelProperty("区县") + private String county; + + + /** + * 地址 + */ + @ApiModelProperty("地址") + private String address; + + /** + * 精度 + */ + @ApiModelProperty("精度") + private String lng; + + /** + * 纬度 + */ + @ApiModelProperty("纬度") + private String lat; + + /** + * 网络服务提供商 + */ + @ApiModelProperty("网络服务提供商") + private String isp; + + /** + * IP地址 + */ + @ApiModelProperty("IP地址") + private String ip; + + /** + * 用户代理,存放用户登录时客户端信息 + */ + @ApiModelProperty("用户代理") + private String userAgent; + + /** + * 退出地址 + */ + @TableField("退出地址") + private String logoutAddress; + + /** + * 退出IP地址 + */ + @TableField("退出IP地址") + private String logoutIp; + + /** + * 退出用户代理,存放用户退出时客户端信息 + */ + @TableField("退出用户代理,存放用户退出时客户端信息") + private String logoutUserAgent; + + /** + * 异常状态:0、正常,1、省份异常,2、地市异常,3、区县异常 + */ + @ApiModelProperty(value = "异常状态:0、正常,1、省份异常,2、地市异常,3、区县异常", example = "0") + private Integer abnormalStatus; + + +} diff --git a/6.program/wms-passport/src/main/java/com/mt/wms/passport/vo/LoginSessionVo.java b/6.program/wms-passport/src/main/java/com/mt/wms/passport/vo/LoginSessionVo.java new file mode 100644 index 0000000..69a5fec --- /dev/null +++ b/6.program/wms-passport/src/main/java/com/mt/wms/passport/vo/LoginSessionVo.java @@ -0,0 +1,240 @@ +/* + * Copyright (c) 2019. + * http://www.ulabcare.com + */ + +package com.mt.wms.passport.vo; + +import com.mt.wms.core.vo.CommonVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.time.LocalDateTime; + +/** + *

+ * 登录会话 + *

+ * + * @author jiff + * @since 2019-07-20 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel("会话视图对象") +public class LoginSessionVo extends CommonVo implements PageVo.ConvertVo { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "id") + private Long id; + + /** + * 会话ID + */ + @ApiModelProperty("会话ID") + private String sessionId; + + /** + * 父会话ID,漫游登录时需要保存发起漫游用户的会话ID + */ + @ApiModelProperty("父会话ID,漫游登录时需要保存发起漫游用户的会话ID") + private String parentSessionId; + + /** + * 父用户名称 + */ + @ApiModelProperty("父用户名称") + private String parentUserName; + + /** + * 统一用户ID + */ + @ApiModelProperty("统一用户ID") + private Long passportUserId; + + /** + * 用户ID + */ + @ApiModelProperty("用户ID") + private Long userId; + + /** + * 合作伙伴ID,合作伙伴用户或者医院用户登录时会存储 + */ + @ApiModelProperty("合作伙伴ID,合作伙伴用户或者医院用户登录时会存储") + private Long partnerId; + + /** + * 医院ID + */ + @ApiModelProperty("医院ID") + private Long hospitalId; + + /** + * 组织ID + */ + @ApiModelProperty("组织ID") + private Long orgId; + + /** + * 手机号 + */ + @ApiModelProperty("手机号") + private String mobile; + + /** + * 用户名称 + */ + @ApiModelProperty("用户名称") + private String userName; + + /** + * 合作伙伴名称 + */ + @ApiModelProperty("合作伙伴名称") + private String partnerName; + + /** + * 医院名称 + */ + @ApiModelProperty("医院名称") + private String hospitalName; + + /** + * 组织名称 + */ + @ApiModelProperty("组织名称") + private String orgName; + + /** + * 用户类型:1、平台用户,2、合作伙伴用户,3、医院用户,4、患者 + */ + @ApiModelProperty("用户类型:1、平台用户,2、合作伙伴用户,3、医院用户,4、患者") + private Integer userType; + + /** + * 应用类型:1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty("应用类型:1、pc,2、app,3、wechat,4、miniapp") + private Integer appType; + + /** + * 应用编码:暂未使用 + */ + @ApiModelProperty("应用编码:暂未使用") + private Integer appCode; + + /** + * 登录类型:1、自主登录,2、漫游登录 + */ + @ApiModelProperty("登录类型:1、自主登录,2、漫游登录") + private Integer loginType; + + /** + * 登录时间 + */ + @ApiModelProperty("登录时间") + private LocalDateTime loginTime; + + /** + * 设备类型 + */ + @ApiModelProperty("设备类型") + private String deviceClass; + + /** + * 设备名称 + */ + @ApiModelProperty("设备名称") + private String deviceName; + + /** + * 设备品牌 + */ + @ApiModelProperty("设备品牌") + private String deviceBrand; + + /** + * 操作系统 + */ + @ApiModelProperty("操作系统") + private String os; + + /** + * 浏览器 + */ + @ApiModelProperty("浏览器") + private String browser; + + /** + * 国家 + */ + @ApiModelProperty("国家") + private String country; + + /** + * 省份 + */ + @ApiModelProperty("省份") + private String province; + + /** + * 地市 + */ + @ApiModelProperty("地市") + private String city; + + /** + * 区县 + */ + @ApiModelProperty("区县") + private String county; + + /** + * 地址 + */ + @ApiModelProperty("地址") + private String address; + + /** + * 精度 + */ + @ApiModelProperty("精度") + private String lng; + + /** + * 纬度 + */ + @ApiModelProperty("纬度") + private String lat; + + /** + * 网络服务提供商 + */ + @ApiModelProperty("网络服务提供商") + private String isp; + + /** + * IP地址 + */ + @ApiModelProperty("IP地址") + private String ip; + + /** + * 用户代理,存放用户登录时客户端信息 + */ + @ApiModelProperty("用户代理") + private String userAgent; + +} diff --git a/6.program/wms-upms/pom.xml b/6.program/wms-upms/pom.xml new file mode 100644 index 0000000..8dd0f83 --- /dev/null +++ b/6.program/wms-upms/pom.xml @@ -0,0 +1,51 @@ + + + + wms + com.mt + 1.0 + + 4.0.0 + + wms-upms + + + + com.mt + wms-core + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + org.springframework.cloud + spring-cloud-starter-netflix-hystrix + + + + + org.springframework.boot + spring-boot-devtools + + + + io.springfox + springfox-swagger2 + + + io.springfox + springfox-swagger-ui + + + + \ No newline at end of file diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/MenuController.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/MenuController.java new file mode 100644 index 0000000..afd5e59 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/MenuController.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.controller; + +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.PageGroup; +import com.mt.wms.core.validator.groups.UpdateGroup; +import com.mt.wms.core.vo.*; +import com.mt.wms.upms.params.MenuParam; +import com.mt.wms.upms.params.MenuQueryParam; +import com.mt.wms.upms.params.RoleMenuParam; +import com.mt.wms.upms.service.MenuService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.groups.Default; +import java.util.List; + +/** + * 平台菜单控制器 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_UPMS + "menu") +@Slf4j +@Api(value = "平台菜单管理", description = "平台菜单管理接口", hidden = false) +public class MenuController extends BaseController { + + @Autowired + private MenuService menuService; + + + @PostMapping(value = "get") + @ApiOperation(value = "获取菜单") + private R get(@Validated @RequestBody IdParam idParam) { + return menuService.get(idParam); + } + + @PostMapping(value = "list") + @ApiOperation(value = "获取菜单列表") + private R> list(@Validated @RequestBody MenuQueryParam menuQueryParam) { + return menuService.list(menuQueryParam); + } + + @PostMapping(value = "page") + @ApiOperation(value = "获取分页菜单") + private R> page(@Validated({PageGroup.class, Default.class}) @RequestBody MenuQueryParam menuQueryParam) { + return menuService.page(menuQueryParam); + } + + @PostMapping(value = "add") + @ApiOperation(value = "新增") + private R add(@Validated({AddGroup.class, Default.class}) @RequestBody MenuParam menuParam) { + return menuService.add(menuParam); + } + + @PostMapping(value = "update") + @ApiOperation(value = "更新") + private R update(@Validated({UpdateGroup.class, Default.class}) @RequestBody MenuParam menuParam) { + return menuService.update(menuParam); + } + + @PostMapping(value = "enabled") + @ApiOperation(value = "启停菜单") + private R enabled(@Validated @RequestBody EnabledParam enabledParam) { + return menuService.enabled(enabledParam); + } + + @PostMapping(value = "delete") + @ApiOperation(value = "删除菜单") + private R delete(@Validated @RequestBody IdParam idParam) { + return menuService.delete(idParam); + } + + @PostMapping(value = "saveRoleMenu") + @ApiOperation(value = "保存角色菜单") + private R saveRoleMenu(@Validated @RequestBody RoleMenuParam roleMenuParam) { + return menuService.saveRoleMenu(roleMenuParam); + } + + @PostMapping(value = "listByRole") + @ApiOperation(value = "获取角色菜单") + private R> listByRole(@Validated @RequestBody IdParam idParam) { + return menuService.listByRole(idParam); + } + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/MenuResourceController.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/MenuResourceController.java new file mode 100644 index 0000000..6d50361 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/MenuResourceController.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.controller; + +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.PageGroup; +import com.mt.wms.core.vo.*; +import com.mt.wms.upms.params.MenuResourceParam; +import com.mt.wms.upms.params.MenuResourceQueryParam; +import com.mt.wms.upms.service.MenuResourceService; +import com.mt.wms.upms.vo.ResourceVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.groups.Default; +import java.util.List; + +/** + * 平台菜单资源控制器 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_UPMS + "menuResource") +@Slf4j +@Api(value = "菜单资源管理", description = "平台菜单资源管理接口", hidden = false) +public class MenuResourceController extends BaseController { + @Autowired + private MenuResourceService menuResourceService; + + + @PostMapping(value = "listByMenu") + @ApiOperation(value = "获取菜单已关联的资源列表") + private R> listByMenu(@Validated({Default.class}) @RequestBody IdParam idParam) { + return menuResourceService.listByMenu(idParam); + } + + @PostMapping(value = "listWithMenu") + @ApiOperation(value = "获取菜单未关联的资源列表,根据菜单分类返回未关联的资源列表") + private R> listWithMenu(@Validated({Default.class}) @RequestBody MenuResourceQueryParam menuResourceQueryParam) { + return menuResourceService.listWithMenu(menuResourceQueryParam); + } + + @PostMapping(value = "pageWithMenu") + @ApiOperation(value = "获取菜单未关联的资源分页列表,根据菜单分类返回未关联的资源列表") + private R> pageWithMenu(@Validated({PageGroup.class, Default.class}) @RequestBody MenuResourceQueryParam menuResourceQueryParam) { + return menuResourceService.pageWithMenu(menuResourceQueryParam); + } + + @PostMapping(value = "add") + @ApiOperation(value = "新增菜单资源") + private R add(@Validated({AddGroup.class, Default.class}) @RequestBody MenuResourceParam menuResourceParam) { + return menuResourceService.add(menuResourceParam); + } + + + @PostMapping(value = "delete") + @ApiOperation(value = "删除菜单资源") + private R delete(@Validated @RequestBody IdParam idParam) { + return menuResourceService.delete(idParam); + } + + @PostMapping(value = "batchDelete") + @ApiOperation(value = "批量删除菜单资源") + private R delete(@Validated @RequestBody IdListParam idListParam) { + return menuResourceService.delete(idListParam); + } +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/MicroServiceController.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/MicroServiceController.java new file mode 100644 index 0000000..4bcd162 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/MicroServiceController.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.controller; + +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.PageGroup; +import com.mt.wms.core.validator.groups.UpdateGroup; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.ServiceParam; +import com.mt.wms.upms.params.ServiceQueryParam; +import com.mt.wms.upms.service.MicroServiceService; +import com.mt.wms.upms.vo.ServiceVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.groups.Default; +import java.util.List; + +/** + * 微服务控制器 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_UPMS +"microService") +@Slf4j +@Api(value = "微服务管理", description = "微服务管理接口", hidden = false) +public class MicroServiceController extends BaseController { + @Autowired + private MicroServiceService microServiceService; + + @PostMapping(value = "get") + @ApiOperation(value = "获取微服务") + private R get(@Validated @RequestBody IdParam idParam) { + return microServiceService.get(idParam); + } + + @PostMapping(value = "page") + @ApiOperation(value = "获取分页微服务列表") + private R> page(@Validated({PageGroup.class, Default.class}) @RequestBody ServiceQueryParam ServiceQueryParam) { + return microServiceService.page(ServiceQueryParam); + } + + @PostMapping(value = "list") + @ApiOperation(value = "获取微服务列表") + private R> list(@Validated({Default.class}) @RequestBody ServiceQueryParam ServiceQueryParam) { + return microServiceService.list(ServiceQueryParam); + } + + @PostMapping(value = "add") + @ApiOperation(value = "新增微服务") + private R add(@Validated({AddGroup.class, Default.class}) @RequestBody ServiceParam ServiceParam) { + return microServiceService.add(ServiceParam); + } + + @PostMapping(value = "update") + @ApiOperation(value = "更新微服务") + private R update(@Validated({UpdateGroup.class, Default.class}) @RequestBody ServiceParam ServiceParam) { + return microServiceService.update(ServiceParam); + } + + @PostMapping(value = "enabled") + @ApiOperation(value = "启停微服务") + private R enabled(@Validated @RequestBody EnabledParam enabledParam) { + return microServiceService.enabled(enabledParam); + } + + + @PostMapping(value = "delete") + @ApiOperation(value = "删除微服务") + private R delete(@Validated @RequestBody IdParam idParam) { + return microServiceService.delete(idParam); + } + + @PostMapping(value = "batchDelete") + @ApiOperation(value = "批量删除微服务") + private R delete(@Validated @RequestBody IdListParam idListParam) { + return microServiceService.delete(idListParam); + } +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/OrgController.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/OrgController.java new file mode 100644 index 0000000..c89871b --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/OrgController.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.controller; + +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.PageGroup; +import com.mt.wms.core.validator.groups.UpdateGroup; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.SysOrgParam; +import com.mt.wms.upms.params.SysOrgQueryParam; +import com.mt.wms.upms.service.OrgService; +import com.mt.wms.upms.vo.SysOrgVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.groups.Default; +import java.util.List; + +/** + * 平台组织控制器 + * + * @author jiff + * @date 2018/11/8 + * @since 1.0 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_UPMS +"org") +@Slf4j +@Api(value = "平台组织管理", description = "平台组织管理接口", hidden = false) +public class OrgController extends BaseController { + @Autowired + private OrgService orgService; + + @PostMapping(value = "get") + @ApiOperation(value = "获取组织") + private R get(@Validated @RequestBody IdParam idParam) { + return orgService.get(idParam); + } + + @PostMapping(value = "list") + @ApiOperation(value = "获取组织列表") + private R> list(@Validated({Default.class}) @RequestBody SysOrgQueryParam sysOrgQueryParam) { + return orgService.list(sysOrgQueryParam); + } + + @PostMapping(value = "page") + @ApiOperation(value = "获取分页组织") + private R> page(@Validated({PageGroup.class, Default.class}) @RequestBody SysOrgQueryParam sysOrgQueryParam) { + return orgService.page(sysOrgQueryParam); + } + + @PostMapping(value = "tree") + @ApiOperation(value = "获取组织树列表") + private R> tree(@Validated({Default.class}) @RequestBody SysOrgQueryParam sysOrgQueryParam) { + return orgService.tree(sysOrgQueryParam); + } + + @PostMapping(value = "add") + @ApiOperation(value = "新增") + private R add(@Validated({AddGroup.class, Default.class}) @RequestBody SysOrgParam sysOrgParam) { + return orgService.add(sysOrgParam); + } + + @PostMapping(value = "update") + @ApiOperation(value = "更新") + private R update(@Validated({UpdateGroup.class, Default.class}) @RequestBody SysOrgParam sysOrgParam) { + return orgService.update(sysOrgParam); + } + + @PostMapping(value = "enabled") + @ApiOperation(value = "启停组织") + private R enabled(@Validated @RequestBody EnabledParam enabledParam) { + return orgService.enabled(enabledParam); + } + + @PostMapping(value = "delete") + @ApiOperation(value = "删除组织") + private R delete(@Validated @RequestBody IdParam idParam) { + return orgService.delete(idParam); + } +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/PostController.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/PostController.java new file mode 100644 index 0000000..1088959 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/PostController.java @@ -0,0 +1,78 @@ +package com.mt.wms.upms.controller; + +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.UpdateGroup; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.SysPostParam; +import com.mt.wms.upms.service.PostService; +import com.mt.wms.upms.vo.SysPostVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import javax.validation.groups.Default; +import java.util.List; + +/** + * @Description: 合作伙伴岗位控制层 + * @Param: + * @return: + * @Author: tqq + * @Date: 2019/11/11 15:44 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_UPMS +"post") +@Slf4j +@Api(value = "岗位管理", description = "岗位管理接口") +public class PostController { + @Autowired + private PostService postService; + + @PostMapping(value = "get") + @ApiOperation(value = "通过id获取岗位信息") + private R get(@Valid @RequestBody IdParam idParam) { + return postService.get(idParam); + } + + @PostMapping(value = "tree") + @ApiOperation(value = "获取岗位树形结构信息") + private R> tree() { + return postService.tree(); + } + + @PostMapping(value = "add") + @ApiOperation(value = "新增岗位信息") + private R add(@Validated({AddGroup.class, Default.class}) @RequestBody SysPostParam sysPostParam) { + return postService.add(sysPostParam); + } + + @PostMapping(value = "update") + @ApiOperation(value = "修改岗位信息") + private R update(@Validated({UpdateGroup.class, Default.class}) @RequestBody SysPostParam sysPostParam) { + return postService.update(sysPostParam); + } + + @PostMapping(value = "enabled") + @ApiOperation(value = "启停岗位") + private R enabled(@Validated @RequestBody EnabledParam enabledParam) { + return postService.enabled(enabledParam); + } + + @PostMapping(value = "delete") + @ApiOperation(value = "删除岗位") + private R delete(@Valid @RequestBody IdParam idParam) { + return postService.delete(idParam); + } + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/ResourceController.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/ResourceController.java new file mode 100644 index 0000000..628a42d --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/ResourceController.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.controller; + +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.PageGroup; +import com.mt.wms.core.validator.groups.UpdateGroup; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.ResourceParam; +import com.mt.wms.upms.params.ResourceQueryParam; +import com.mt.wms.upms.service.ResourceService; +import com.mt.wms.upms.vo.ResourceVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.groups.Default; +import java.util.List; + +/** + * 平台资源控制器 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_UPMS +"resource") +@Slf4j +@Api(value = "平台资源管理", description = "平台资源管理接口", hidden = false) +public class ResourceController extends BaseController { + @Autowired + private ResourceService resourceService; + + @PostMapping(value = "get") + @ApiOperation(value = "获取资源") + private R get(@Validated @RequestBody IdParam idParam) { + return resourceService.get(idParam); + } + + @PostMapping(value = "page") + @ApiOperation(value = "获取分页资源列表") + private R> page(@Validated({PageGroup.class, Default.class}) @RequestBody ResourceQueryParam resourceQueryParam) { + return resourceService.page(resourceQueryParam); + } + + @PostMapping(value = "list") + @ApiOperation(value = "获取资源列表") + private R> list(@Validated({Default.class}) @RequestBody ResourceQueryParam resourceQueryParam) { + return resourceService.list(resourceQueryParam); + } + + @PostMapping(value = "add") + @ApiOperation(value = "新增资源") + private R add(@Validated({AddGroup.class, Default.class}) @RequestBody ResourceParam resourceParam) { + return resourceService.add(resourceParam); + } + + @PostMapping(value = "update") + @ApiOperation(value = "更新资源") + private R update(@Validated({UpdateGroup.class, Default.class}) @RequestBody ResourceParam resourceParam) { + return resourceService.update(resourceParam); + } + + @PostMapping(value = "enabled") + @ApiOperation(value = "启停资源") + private R enabled(@Validated @RequestBody EnabledParam enabledParam) { + return resourceService.enabled(enabledParam); + } + + + @PostMapping(value = "delete") + @ApiOperation(value = "删除资源") + private R delete(@Validated @RequestBody IdParam idParam) { + return resourceService.delete(idParam); + } + + @PostMapping(value = "batchDelete") + @ApiOperation(value = "批量删除资源") + private R delete(@Validated @RequestBody IdListParam idListParam) { + return resourceService.delete(idListParam); + } +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/RoleController.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/RoleController.java new file mode 100644 index 0000000..afddd91 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/RoleController.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.controller; + +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.PageGroup; +import com.mt.wms.core.validator.groups.UpdateGroup; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.SysRoleParam; +import com.mt.wms.upms.params.SysRoleQueryParam; +import com.mt.wms.upms.params.UserRoleParam; +import com.mt.wms.upms.service.RoleService; +import com.mt.wms.upms.vo.SysRoleVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.groups.Default; +import java.util.List; + +/** + * 平台角色控制器 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_UPMS +"role") +@Slf4j +@Api(value = "平台角色管理", description = "平台角色管理接口", hidden = false) +public class RoleController extends BaseController { + @Autowired + private RoleService roleService; + + @PostMapping(value = "get") + @ApiOperation(value = "获取角色") + private R get(@Validated @RequestBody IdParam idParam) { + return roleService.get(idParam); + } + + @PostMapping(value = "page") + @ApiOperation(value = "获取分页角色列表") + private R> page(@Validated({PageGroup.class, Default.class}) @RequestBody SysRoleQueryParam sysRoleQueryParam) { + return roleService.page(sysRoleQueryParam); + } + + @PostMapping(value = "list") + @ApiOperation(value = "获取角色列表") + private R> list(@Validated({Default.class}) @RequestBody SysRoleQueryParam sysRoleQueryParam) { + return roleService.list(sysRoleQueryParam); + } + + @PostMapping(value = "add") + @ApiOperation(value = "新增角色") + private R add(@Validated({AddGroup.class, Default.class}) @RequestBody SysRoleParam sysRoleParam) { + return roleService.add(sysRoleParam); + } + + @PostMapping(value = "update") + @ApiOperation(value = "更新角色") + private R update(@Validated({UpdateGroup.class, Default.class}) @RequestBody SysRoleParam sysRoleParam) { + return roleService.update(sysRoleParam); + } + + @PostMapping(value = "enabled") + @ApiOperation(value = "启停角色") + private R enabled(@Validated @RequestBody EnabledParam enabledParam) { + return roleService.enabled(enabledParam); + } + + @PostMapping(value = "delete") + @ApiOperation(value = "删除角色") + private R delete(@Validated @RequestBody IdParam idParam) { + return roleService.delete(idParam); + } + + @PostMapping(value = "batchDelete") + @ApiOperation(value = "批量删除角色") + private R delete(@Validated @RequestBody IdListParam idListParam) { + return roleService.delete(idListParam); + } + + @PostMapping(value = "saveUserRole") + @ApiOperation(value = "保存用户角色") + private R saveUserRole(@Validated @RequestBody UserRoleParam userRoleParam) { + return roleService.saveUserRole(userRoleParam); + } + + @PostMapping(value = "listByUser") + @ApiOperation(value = "获取用户角色") + private R> listByUser(@Validated @RequestBody IdParam idParam) { + return roleService.listByUser(idParam); + } + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/UpmsController.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/UpmsController.java new file mode 100644 index 0000000..c0647f4 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/UpmsController.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.controller; + +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.dto.Permission; +import com.mt.wms.core.vo.LoginUserVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.service.UpmsService; +import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.io.Serializable; +import java.util.List; + +/** + * 平台通用权限管理控制器,提供给内部服务调用 + * + * @author jiff + * @date 2018/11/7 + * @since 1.0 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_UPMS +"upms") +@Slf4j +@Api(value = "平台权限管理", description = "平台权限管理接口,提供给内部服务调用", hidden = true) +public class UpmsController extends BaseController { + @Autowired + private UpmsService upmsService; + + @PostMapping("login") + private R login(@RequestParam("mobile") String mobile, @RequestParam("password") String password) { + return upmsService.login(mobile, password); + } + + /** + * 退出登录 + * + * @return 处理结果 + */ + @PostMapping("logout") + private R logout() { + return upmsService.logout(); + } + + @PostMapping("getLoginUserByMobile") + private R getLoginUser(@RequestParam("mobile") String mobile) { + return upmsService.getLoginUser(mobile); + } + + @PostMapping(value = "getLoginUser") + private R getLoginUserVo() { + return upmsService.getLoginUserVo(); + } + + @PostMapping("getPermissions") + private List getPermissions() { + return upmsService.getPermissions(); + } + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/UserController.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/UserController.java new file mode 100644 index 0000000..66db8c4 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/controller/UserController.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.dal.entity.SysUser; +import com.mt.wms.core.dal.service.SysUserServiceBiz; +import com.mt.wms.core.enums.WhetherEnum; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.params.MobileParam; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.PageGroup; +import com.mt.wms.core.validator.groups.UpdateGroup; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.core.vo.WhetherVo; +import com.mt.wms.upms.params.*; +import com.mt.wms.upms.params.*; +import com.mt.wms.upms.service.UserService; +import com.mt.wms.upms.vo.SysUserVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import javax.validation.groups.Default; +import java.util.List; + +/** + * 平台用户控制器 + * + * @author jiff + * @date 2018/11/8 + * @since 1.0 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_UPMS + "user") +@Slf4j +@Api(value = "平台用户管理", description = "平台用户管理接口", hidden = false) +public class UserController extends BaseController { + @Autowired + private UserService userService; + @Autowired + private SysUserServiceBiz sysUserServiceBiz; + + @PostMapping("check") + @ApiOperation("检验手机号码是否存在") + private R checkMobile(@Valid @RequestBody MobileParam mobileParam) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(SysUser.MOBILE, mobileParam.getMobile()); + wrapper.eq(SysUser.VALID, WhetherEnum.YES.getValue()); + SysUser sysUser = sysUserServiceBiz.getOne(wrapper); + return successful(WhetherVo.builder().whether(sysUser != null).build()); + } + + @PostMapping(value = "get") + @ApiOperation(value = "获取用户") + private R get(@Validated @RequestBody IdParam idParam) { + return userService.get(idParam); + } + + @PostMapping(value = "page") + @ApiOperation(value = "获取分页用户列表") + private R> page(@Validated({PageGroup.class, Default.class}) @RequestBody SysUserQueryParam sysUserQueryParam) { + return userService.page(sysUserQueryParam); + } + + @PostMapping(value = "list") + @ApiOperation(value = "获取用户列表") + private R> list(@Validated({Default.class}) @RequestBody SysUserQueryParam sysUserQueryParam) { + return userService.list(sysUserQueryParam); + } + + @PostMapping(value = "add") + @ApiOperation(value = "新增用户") + private R add(@Validated({AddGroup.class, Default.class}) @RequestBody SysUserParam sysUserParam) { + return userService.add(sysUserParam); + } + + @PostMapping(value = "update") + @ApiOperation(value = "更新用户") + private R update(@Validated({UpdateGroup.class, Default.class}) @RequestBody SysUserParam sysUserParam) { + return userService.update(sysUserParam); + } + + @PostMapping(value = "enabled") + @ApiOperation(value = "启停用户") + private R enabled(@Validated @RequestBody EnabledParam enabledParam) { + return userService.enabled(enabledParam); + } + + @PostMapping(value = "modifyPassword") + @ApiOperation(value = "修改密码") + private R modifyPassword(@Validated @RequestBody ModifyPasswordParam modifyPasswordParam) { + return userService.modifyPassword(modifyPasswordParam); + } + + @PostMapping(value = "resetPassword") + @ApiOperation(value = "重置密码") + private R resetPassword(@Validated @RequestBody ResetPasswordParam resetPasswordParam) { + return userService.resetPassword(resetPasswordParam); + } + + @PostMapping(value = "findPassword") + @ApiOperation(value = "找回密码") + private R findPassword(@Validated @RequestBody FindPasswordParam findPasswordParam) { + return userService.findPassword(findPasswordParam); + } + + @PostMapping(value = "delete") + @ApiOperation(value = "删除用户") + private R delete(@Validated @RequestBody IdParam idParam) { + return userService.delete(idParam); + } + + @PostMapping(value = "batchDelete") + @ApiOperation(value = "批量删除用户") + private R delete(@Validated @RequestBody IdListParam idListParam) { + return userService.delete(idListParam); + } + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/mapper/MenuMapper.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/mapper/MenuMapper.java new file mode 100644 index 0000000..41b9251 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/mapper/MenuMapper.java @@ -0,0 +1,37 @@ +package com.mt.wms.upms.mapper; + +import com.mt.wms.core.vo.MenuVo; +import com.mt.wms.core.vo.UserMenuVo; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 菜单mapper类 + * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@Repository +public interface MenuMapper { + + /** + * 获取角色菜单列表 + * + * @param roleId 角色ID + * @param category 菜单分类 + * @return 菜单列表 + */ + List listByRole(@Param("roleId") Long roleId, @Param("category") Integer category); + + /** + * 获取用户菜单列表,先不考虑角色启停状态 + * + * @param userId 用户ID + * @param category 菜单分类 + * @return 菜单列表 + */ + List listByUser(@Param("userId") Long userId, @Param("category") Integer category); +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/mapper/ResourceMapper.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/mapper/ResourceMapper.java new file mode 100644 index 0000000..3ef95f2 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/mapper/ResourceMapper.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.mapper; + +import com.mt.wms.core.dto.Permission; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author jiff + * @date 2018/11/26 + * @since 1.0 + */ +@Repository("upmsResourceMapper") +public interface ResourceMapper { + /** + * 获取用户权限列表 + * + * @param userId 用户ID + * @param category 应用分类 + * @return 权限列表 + */ + List listByUser(@Param("userId") Long userId, @Param("category") Integer category); +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/mapper/RoleMapper.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/mapper/RoleMapper.java new file mode 100644 index 0000000..57c3020 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/mapper/RoleMapper.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.mapper; + +import com.mt.wms.upms.vo.SysRoleVo; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author jiff + * @date 2018/11/26 + * @since 1.0 + */ +@Repository +public interface RoleMapper { + /** + * 获取用户角色列表 + * + * @param userId 用户ID + * @return 用户角色列表 + */ + List listByUser(@Param("userId") Long userId); +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/mapper/UserMapper.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/mapper/UserMapper.java new file mode 100644 index 0000000..e917931 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/mapper/UserMapper.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.mt.wms.upms.params.SysUserQueryParam; +import com.mt.wms.upms.vo.SysUserVo; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author jiff + * @date 2018-12-10 + * @since 1.0 + */ +@Repository("upmsUserMapper") +public interface UserMapper { + /** + * 根据组织查询所管理的用户列表 + * + * @param sysUserQueryParam 用户查询参数 + * @return 用户列表 + */ + List listByOrg(@Param("queryParam") SysUserQueryParam sysUserQueryParam); + + /** + * 根据组织查询所管理的用户分页列表 + * + * @param page 分页信息 + * @param sysUserQueryParam 用户查询参数 + * @return 用户列表 + */ + List listByOrg(IPage page, @Param("queryParam") SysUserQueryParam sysUserQueryParam); + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/FindPasswordParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/FindPasswordParam.java new file mode 100644 index 0000000..a9cda67 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/FindPasswordParam.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; + +/** + * 找回密码请求参数对象 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Data +@Builder +@ApiModel(value = "找回密码请求参数对象", description = "用于找回用户自己的密码") +public class FindPasswordParam extends BaseParam { + + @ApiModelProperty(value = "手机号码", required = true, example = "13588441519") + @NotBlank(message = "手机号码不能为空") + @Pattern(regexp = "^1[3456789]\\d{9}$", message = "手机号码格式不正确") + private String mobile; + /** + * 短信验证码 + */ + @ApiModelProperty(value = "短信验证码", required = true, example = "123456", position = 1) + @NotBlank(message = "短信验证码不能为空") + private String smsCode; + /** + * 密码 + */ + @ApiModelProperty(value = "密码", required = true, example = "123456", position = 1) + @Length(min = 6, max = 20, message = "密码长度为6-20位") + private String password; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/MenuParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/MenuParam.java new file mode 100644 index 0000000..f76a7c7 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/MenuParam.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.enums.HttpMethodEnum; +import com.mt.wms.core.enums.MenuCategoryEnum; +import com.mt.wms.core.enums.MenuTypeEnum; +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.constraints.Enum; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.UpdateGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + *

+ * 菜单表 + *

+ * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "菜单", description = "用于新增和更新菜单信息") +public class MenuParam extends BaseParam { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键,更新时需要填写", example = "1") + @NotNull(message = "菜单ID不能为空", groups = {UpdateGroup.class}) + private Long id; + + /** + * 父菜单ID + */ + @ApiModelProperty(value = "父菜单ID", required = true, example = "0") + @NotNull(message = "父菜单ID不能为空", groups = {AddGroup.class}) + @Min(message = "父菜单ID不能小于0", value = 0, groups = {AddGroup.class}) + private Long parentId; + + /** + * 菜单编码 + */ + @ApiModelProperty(value = "菜单编码", example = "menu") + private String code; + + /** + * 菜单名称 + */ + @ApiModelProperty(value = "菜单名称", required = true, example = "菜单管理") + @NotBlank(message = "菜单名称不能为空") + private String name; + + /** + * 菜单图标 + */ + @ApiModelProperty("菜单图标") + private String icon; + + /** + * 链接地址,可以是页面地址,也可以是函数事件 + */ + @ApiModelProperty("链接地址,可以是页面地址,也可以是函数事件") + private String href; + + /** + * 请求地址,可以用于前端ajax调用,后端用于做权限控制 + */ + @ApiModelProperty("请求地址,可以用于前端ajax调用,后端用于做权限控制") + private String url; + + /** + * 请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE + */ + @ApiModelProperty(value = "请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE", example = "post") + @Enum(message = "非法的请求类型", target = {HttpMethodEnum.class}) + private String method; + + /** + * 权限,可以有多个,用逗号分隔,可用于第三方权限框架扩展 + */ + @ApiModelProperty("权限,可以有多个,用逗号分隔,可用于第三方权限框架扩展") + private String permission; + + /** + * 分类:1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "分类:1、pc,2、app,3、wechat,4、miniapp", required = true, example = "1") + @NotNull(message = "菜单分类不能为空", groups = {AddGroup.class}) + @Enum(message = "非法的菜单分类", target = {MenuCategoryEnum.class}, groups = {AddGroup.class}) + private Integer category; + + + /** + * 类型:1、module,2、menu,3、button + */ + @ApiModelProperty(value = "类型:1、module,2、menu,3、button", required = true, example = "1") + @NotNull(message = "菜单类型不能为空") + @Enum(message = "非法的菜单类型", target = {MenuTypeEnum.class}) + private Integer type; + + /** + * 显示顺序 + */ + @ApiModelProperty(value = "显示顺序", example = "1") + private Integer orderNum; + + /** + * 备注 + */ + @ApiModelProperty("备注") + private String remark; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/MenuQueryParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/MenuQueryParam.java new file mode 100644 index 0000000..7cfb1b2 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/MenuQueryParam.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.enums.MenuCategoryEnum; +import com.mt.wms.core.enums.MenuTypeEnum; +import com.mt.wms.core.params.BasePageParam; +import com.mt.wms.core.validator.constraints.Enum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 系统菜单 + *

+ * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@Data +@Builder +@ApiModel(value = "菜单查询参数", description = "用于查询菜单信息") +public class MenuQueryParam extends BasePageParam { + + /** + * 父菜单ID + */ + @ApiModelProperty(value = "父菜单ID", example = "0") + private Long parentId; + /** + * 菜单编码 + */ + @ApiModelProperty(value = "菜单编码", example = "menu") + private String code; + + /** + * 菜单名称 + */ + @ApiModelProperty(value = "菜单名称", required = false, example = "菜单管理") + private String name; + + /** + * 分类:1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "分类:1、pc,2、app,3、wechat,4、miniapp", required = false, example = "1") + @Enum(message = "非法的菜单分类", target = {MenuCategoryEnum.class}) + private Integer category; + + /** + * 类型:1、module,2、menu,3、button + */ + @ApiModelProperty(value = "类型:1、module,2、menu,3、button", required = false, example = "1") + @Enum(message = "非法的菜单类型", target = {MenuTypeEnum.class}) + private Integer type; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/MenuResourceParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/MenuResourceParam.java new file mode 100644 index 0000000..5699a73 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/MenuResourceParam.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.groups.AddGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.List; + +/** + *

+ * 菜单资源关系表 + *

+ * + * @author jiff + * @date 2018/11/27 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "菜单资源关系表", description = "用于新增菜单资源关系") +public class MenuResourceParam extends BaseParam { + + private static final long serialVersionUID = 1L; + + /** + * 菜单ID + */ + @ApiModelProperty(value = "菜单ID", required = true, example = "1") + @NotNull(message = "菜单ID不能为空") + private Long menuId; + + /** + * 资源ID列表 + */ + @ApiModelProperty(value = "资源ID列表", required = true, example = "[1]") + @NotNull(message = "资源ID列表不能为空", groups = {AddGroup.class}) + @Size(message = "资源ID列表不能为空", min = 1, groups = {AddGroup.class}) + private List resourceIds; + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/MenuResourceQueryParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/MenuResourceQueryParam.java new file mode 100644 index 0000000..fe7464d --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/MenuResourceQueryParam.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.params.BasePageParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + *

+ * 菜单资源查询参数 + *

+ * + * @author jiff + * @date 2018/12/12 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "菜单资源查询参数", description = "用于查询菜单资源关系") +public class MenuResourceQueryParam extends BasePageParam { + + private static final long serialVersionUID = 1L; + + /** + * 菜单ID + */ + @ApiModelProperty(value = "菜单ID", required = true, example = "1") + @NotNull(message = "菜单ID不能为空") + private Long menuId; + + /** + * 资源名称 + */ + @ApiModelProperty(value = "资源名称", required = false, example = "新增资源") + private String name; + + /** + * 请求地址,可以用于前端ajax调用,后端用于做权限控制 + */ + @ApiModelProperty(value = "请求地址,可以用于前端ajax调用,后端用于做权限控制", required = false, example = "/platform-upms/resource/add") + private String url; + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ModifyPasswordParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ModifyPasswordParam.java new file mode 100644 index 0000000..b31fc04 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ModifyPasswordParam.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.constraints.Password; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.hibernate.validator.constraints.Length; + +/** + * 修改密码请求参数对象 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel(value = "修改密码请求参数对象", description = "用于修改用户自己的密码") +public class ModifyPasswordParam extends BaseParam { + + /** + * 密码 + */ + @ApiModelProperty(value = "原密码", required = true, example = "123456", position = 1) + @Length(min = 6, max = 20, message = "原密码长度为6-20位") + private String password; + + /** + * 密码 + */ + @ApiModelProperty(value = "新密码", required = true, example = "123abc.", position = 2) + @Length(min = 6, max = 20, message = "新密码长度为6-20位") + @Password(format = Password.PasswordFormat.NUMBER_LETTER_CHAR, message = "密码必须同时包含数字、字母、特殊字符") + private String newPassword; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ResetPasswordParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ResetPasswordParam.java new file mode 100644 index 0000000..f29453c --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ResetPasswordParam.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.constraints.Password; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotNull; + +/** + * 重置密码请求参数对象 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel(value = "重置密码请求参数对象", description = "用于管理员重置其他用户密码") +public class ResetPasswordParam extends BaseParam { + + @NotNull(message = "用户ID不能为空") + @ApiModelProperty(value = "用户ID", required = true, example = "1") + private Long id; + + /** + * 密码 + */ + @ApiModelProperty(value = "密码", required = true, example = "123456", position = 2) + @Length(min = 6, max = 20, message = "密码长度为6-20位") + @Password(format = Password.PasswordFormat.NUMBER_LETTER_CHAR, message = "密码格式错误") + private String password; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ResourceParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ResourceParam.java new file mode 100644 index 0000000..6f0a436 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ResourceParam.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.enums.HttpMethodEnum; +import com.mt.wms.core.enums.ResourceCategoryEnum; +import com.mt.wms.core.enums.SubsystemEnum; +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.constraints.Enum; +import com.mt.wms.core.validator.groups.UpdateGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + *

+ * 资源表 + *

+ * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "资源表", description = "用于新增和更新资源信息") +public class ResourceParam extends BaseParam { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键,更新时需要填写", example = "1") + @NotNull(message = "资源ID不能为空", groups = {UpdateGroup.class}) + private Long id; + + /** + * 服务ID + */ + @ApiModelProperty(value = "服务ID", required = true, example = "1") + @NotNull(message = "服务ID不能为空") + private Long serviceId; + + /** + * 名称 + */ + @ApiModelProperty(value = "名称", required = true, example = "新增资源") + @NotBlank(message = "名称不能为空") + private String name; + + /** + * 请求地址,可以用于前端ajax调用,后端用于做权限控制 + */ + @ApiModelProperty(value = "请求地址,可以用于前端ajax调用,后端用于做权限控制", required = true, example = "/platform-upms/resource/add") + @NotBlank(message = "请求地址不能为空") + private String url; + + /** + * 请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE + */ + @ApiModelProperty(value = "请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE", required = true, example = "post") + @NotBlank(message = "请求方法不能为空") + @Enum(message = "非法的请求类型", target = {HttpMethodEnum.class}) + private String method; + + /** + * 子系统:0、common,1、platform,2、partner,3、 hospital,4、patient + */ + @ApiModelProperty(value = "子系统:0、common,1、platform,2、partner,3、 hospital,4、patient", required = true, example = "0") + @NotNull(message = "子系统类型不能为空") + @Enum(message = "非法的子系统类型", target = {SubsystemEnum.class}) + private Integer subsystem; + + /** + * 分类:0、common,1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "分类:0、common,1、pc,2、app,3、wechat,4、miniapp", required = true, example = "0") + @NotNull(message = "资源类型不能为空") + @Enum(message = "非法的资源分类", target = {ResourceCategoryEnum.class}) + private Integer category; + + /** + * 备注 + */ + @ApiModelProperty("备注") + private String remark; + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ResourceQueryParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ResourceQueryParam.java new file mode 100644 index 0000000..0a7de5a --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ResourceQueryParam.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.enums.HttpMethodEnum; +import com.mt.wms.core.enums.ResourceCategoryEnum; +import com.mt.wms.core.enums.SubsystemEnum; +import com.mt.wms.core.params.BasePageParam; +import com.mt.wms.core.validator.constraints.Enum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 资源 + *

+ * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel(value = "资源查询参数", description = "用于查询资源信息") +public class ResourceQueryParam extends BasePageParam { + + /** + * 服务ID + */ + @ApiModelProperty(value = "服务ID", required = false, example = "1") + private Long serviceId; + + /** + * 名称 + */ + @ApiModelProperty(value = "名称", required = false, example = "新增资源") + private String name; + + /** + * 请求地址,可以用于前端ajax调用,后端用于做权限控制 + */ + @ApiModelProperty(value = "请求地址,可以用于前端ajax调用,后端用于做权限控制", required = false, example = "/platform-upms/resource/add") + private String url; + + /** + * 请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE + */ + @ApiModelProperty(value = "请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE", required = false, example = "post") + @Enum(message = "非法的请求类型", target = {HttpMethodEnum.class}) + private String method; + + /** + * 子系统:0、common,1、platform,2、partner,3、 hospital,4、patient + */ + @ApiModelProperty(value = "子系统:0、common,1、platform,2、partner,3、 hospital,4、patient", required = false, example = "0") + @Enum(message = "非法的子系统类型", target = {SubsystemEnum.class}) + private Integer subsystem; + + /** + * 分类:0、common,1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "分类:0、common,1、pc,2、app,3、wechat,4、miniapp", required = true, example = "0") + @Enum(message = "非法的资源分类", target = {ResourceCategoryEnum.class}) + private Integer category; + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/RoleMenuParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/RoleMenuParam.java new file mode 100644 index 0000000..e6fef46 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/RoleMenuParam.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + *

+ * 角色菜单参数 + *

+ * + * @author jiff + * @date 2018/11/26 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "角色菜单参数", description = "用于新增和更新角色菜单信息") +public class RoleMenuParam extends BaseParam { + + private static final long serialVersionUID = 1L; + /** + * 角色ID + */ + @ApiModelProperty(value = "角色ID", required = true, example = "1") + @NotNull(message = "角色ID不能为空") + private Long roleId; + + @ApiModelProperty(value = "菜单主键列表", required = false, example = "[1]") + private List menuIds; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ServiceParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ServiceParam.java new file mode 100644 index 0000000..f387348 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ServiceParam.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.groups.UpdateGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + *

+ * 服务表 + *

+ * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "服务表", description = "用于新增和更新服务信息") +public class ServiceParam extends BaseParam { + + private static final long serialVersionUID = 1L; + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键,更新时需要填写", example = "1") + @NotNull(message = "服务ID不能为空", groups = {UpdateGroup.class}) + private Long id; + + /** + * 编码 + */ + @ApiModelProperty(value = "编码", required = true, example = "lis-passport") + @NotBlank(message = "编码不能为空") + private String code; + + /** + * 名称 + */ + @ApiModelProperty(value = "名称", required = true, example = "统一认证服务") + @NotBlank(message = "名称不能为空") + private String name; + + /** + * 备注 + */ + @ApiModelProperty("备注") + private String remark; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ServiceQueryParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ServiceQueryParam.java new file mode 100644 index 0000000..13d4538 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/ServiceQueryParam.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.params.BasePageParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 服务 + *

+ * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel(value = "服务查询参数", description = "用于查询服务信息") +public class ServiceQueryParam extends BasePageParam { + + + /** + * 编码 + */ + @ApiModelProperty(value = "编码", required = false, example = "lis-passport") + private String code; + + /** + * 名称 + */ + @ApiModelProperty(value = "名称", required = false, example = "统一认证服务") + private String name; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysOrgParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysOrgParam.java new file mode 100644 index 0000000..2831713 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysOrgParam.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2020. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.UpdateGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.Email; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + *

+ * 系统组织表 + *

+ * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "系统组织", description = "用于新增和更新组织信息") +public class SysOrgParam extends BaseParam { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键,更新时需要填写", example = "1") + @NotNull(message = "组织ID不能为空", groups = {UpdateGroup.class}) + private Long id; + + /** + * 父组织ID + */ + @ApiModelProperty(value = "父组织ID", required = true, example = "0") + @NotNull(message = "父组织不能为空", groups = {AddGroup.class}) + @Min(message = "父组织ID不能小于0", value = 0, groups = {AddGroup.class}) + private Long parentId; + + /** + * 名称 + */ + @ApiModelProperty(value = "名称", required = true, example = "销售部") + @NotBlank(message = "名称不能为空") + private String name; + + /** + * 联系人 + */ + @ApiModelProperty(value = "联系人", example = "jiff") + private String contact; + + /** + * 联系电话 + */ + @ApiModelProperty(value = "联系电话", example = "13588441519") + private String phone; + + /** + * 联系地址 + */ + @ApiModelProperty(value = "联系地址", example = "中国人工智能小镇") + private String address; + + /** + * 邮箱 + */ + @ApiModelProperty(value = "邮箱", example = "jiff@ulabcare.com") + @Email + private String email; + + /** + * 备注 + */ + @ApiModelProperty("备注") + private String remark; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysOrgQueryParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysOrgQueryParam.java new file mode 100644 index 0000000..6f8489e --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysOrgQueryParam.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.params.BasePageParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 系统组织 + *

+ * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel(value = "系统组织查询参数", description = "用于查询组织信息") +public class SysOrgQueryParam extends BasePageParam { + + /** + * 父组织ID + */ + @ApiModelProperty(value = "父组织ID, 没有指定父ID时则查询当前用户所能管理的所有组织,包括用户所在组织及所有子组织", example = "0") + private Long parentId; + /** + * 名称 + */ + @ApiModelProperty(value = "名称", required = false, example = "销售部", position = 1) + private String name; + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysPostParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysPostParam.java new file mode 100644 index 0000000..09bf511 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysPostParam.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2020. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.UpdateGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** +* @Description: 新增或者修改岗位入参 +* @Param: +* @return: +* @Author: tqq +* @Date: 2019/11/11 15:53 +*/ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "新增或者修改岗位入参", description = "用于新增和更新岗位信息") +public class SysPostParam extends BaseParam { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键,更新时需要填写", example = "1") + @NotNull(message = "岗位ID不能为空", groups = {UpdateGroup.class}) + private Long id; + + @ApiModelProperty(value = "父岗位ID(第一个岗位的上级岗位ID填0)", required = true, example = "0") + @NotNull(message = "父岗位ID不能为空", groups = {AddGroup.class}) + @Min(message = "父岗位ID不能小于0", value = 0, groups = {AddGroup.class}) + private Long parentId; + + @ApiModelProperty(value = "岗位编码", required = true, example = "manager") + @NotBlank(message = "岗位编码不能为空") + private String code; + + @ApiModelProperty(value = "岗位名称", required = true, example = "主管") + @NotBlank(message = "岗位名称不能为空") + private String name; + + @ApiModelProperty("备注") + private String remark; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysRoleParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysRoleParam.java new file mode 100644 index 0000000..3940910 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysRoleParam.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.enums.MenuCategoryEnum; +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.constraints.Enum; +import com.mt.wms.core.validator.groups.UpdateGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + *

+ * 系统角色表 + *

+ * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "系统角色", description = "用于新增和更新角色信息") +public class SysRoleParam extends BaseParam { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键,更新时需要填写", example = "1") + @NotNull(message = "角色ID不能为空", groups = {UpdateGroup.class}) + private Long id; + + /** + * 角色编码 + */ + @ApiModelProperty(value = "角色编码", required = true, example = "manager") + @NotBlank(message = "角色编码不能为空") + private String code; + + /** + * 角色名称 + */ + @ApiModelProperty(value = "角色名称", required = true, example = "管理员") + @NotBlank(message = "角色名称不能为空") + private String name; + + /** + * 分类:1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "分类:1、pc,2、app,3、wechat,4、miniapp", required = true, example = "1") + @NotNull(message = "角色分类不能为空") + @Enum(message = "非法的角色分类", target = {MenuCategoryEnum.class}) + private Integer category; + + /** + * 备注 + */ + @ApiModelProperty("备注") + private String remark; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysRoleQueryParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysRoleQueryParam.java new file mode 100644 index 0000000..41f7886 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysRoleQueryParam.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.enums.MenuCategoryEnum; +import com.mt.wms.core.params.BasePageParam; +import com.mt.wms.core.validator.constraints.Enum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 系统角色 + *

+ * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel(value = "系统角色查询参数", description = "用于查询角色信息") +public class SysRoleQueryParam extends BasePageParam { + + /** + * 角色编码 + */ + @ApiModelProperty(value = "角色编码", required = false, example = "manager") + private String code; + + /** + * 角色名称 + */ + @ApiModelProperty(value = "角色名称", required = false, example = "管理员") + private String name; + + /** + * 分类:1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "分类:1、pc,2、app,3、wechat,4、miniapp", required = false, example = "1") + @Enum(message = "非法的角色分类", target = {MenuCategoryEnum.class}) + private Integer category; + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysUserParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysUserParam.java new file mode 100644 index 0000000..046f2f2 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysUserParam.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.mt.wms.core.enums.SexEnum; +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.constraints.Enum; +import com.mt.wms.core.validator.constraints.Password; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.UpdateGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.hibernate.validator.constraints.Length; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.time.LocalDate; + +/** + *

+ * 系统用户 + *

+ * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel(value = "系统用户", description = "用于新增和更新用户信息") +public class SysUserParam extends BaseParam { + + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键,更新时需要填写", example = "1") + @NotNull(message = "用户ID不能为空", groups = {UpdateGroup.class}) + private Long id; + + /** + * 组织ID + */ + @ApiModelProperty(value = "组织ID", required = true, example = "1") + @NotNull(message = "组织ID不能为空") + private Long orgId; + + /** + * 系统用户手机号 + */ + @ApiModelProperty(value = "手机号", required = true, example = "13588441519", position = 1) + @NotBlank(message = "手机号码不能为空", groups = {AddGroup.class}) + @Pattern(regexp = "^1[3456789]\\d{9}$", message = "手机号码格式不正确", groups = {AddGroup.class}) + private String mobile; + + /** + * 密码 + */ + @ApiModelProperty(value = "密码,新增时需要填写", required = true, example = "123abc.", position = 2) + @Length(min = 6, max = 20, message = "密码长度为6-20位", groups = {AddGroup.class}) + @Password(format = Password.PasswordFormat.NUMBER_LETTER_CHAR, message = "密码必须同时包含数字、字母、特殊字符") + private String password; + + /** + * 工号 + */ + @ApiModelProperty(value = "工号", example = "10000", position = 3) + private String code; + + /** + * 姓名 + */ + @ApiModelProperty(value = "姓名", required = true, example = "jiff", position = 3) + @NotBlank(message = "{lis.validator.constraints.NotBlank.name.message}") + private String name; + + /** + * 生日 + */ + @ApiModelProperty(value = "生日", example = "2018-11-11") + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate birthday; + + /** + * 系统用户邮箱 + */ + @ApiModelProperty(value = "邮箱", example = "jiff@ulabcare.com") + @Email + private String email; + + /** + * 性别(1女,2男) + */ + @ApiModelProperty(value = "性别(1女,2男)", example = "1") + @Enum(message = "{lis.validator.constraints.SexEnum.message}", target = {SexEnum.class}) + private Integer sex; + + /** + * 备注 + */ + @ApiModelProperty(value = "备注", position = Integer.MAX_VALUE) + private String remark; + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysUserQueryParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysUserQueryParam.java new file mode 100644 index 0000000..7ec90d3 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/SysUserQueryParam.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.enums.SexEnum; +import com.mt.wms.core.enums.WhetherEnum; +import com.mt.wms.core.params.BasePageParam; +import com.mt.wms.core.validator.constraints.Enum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.Pattern; + +/** + *

+ * 系统用户 + *

+ * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Data +@Builder +@ApiModel(value = "系统用户查询参数", description = "用于查询用户信息") +public class SysUserQueryParam extends BasePageParam { + /** + * 组织ID + */ + @ApiModelProperty(value = "组织ID,没有指定组织ID时则查询当前用户所能管理的所有组织,包括用户所在组织及所有子组织", required = false, example = "1") + private Long orgId; + /** + * 是否只查询本组织用户 + */ + @ApiModelProperty(value = "是否只查询本组织用户(0、否,查询本组织及子组织用户,1、是,只查询本组织用户)", example = "0") + @Enum(message = "是否只查询本组织用户只允许0或1", target = {WhetherEnum.class}) + private Integer orgScope; + /** + * 系统用户手机号 + */ + @ApiModelProperty(value = "手机号", required = false, example = "13588441519", position = 1) + @Pattern(regexp = "^1[3456789]\\d{9}$", message = "手机号码格式不正确") + private String mobile; + /** + * 工号 + */ + @ApiModelProperty(value = "工号", example = "10000", position = 3) + private String code; + /** + * 姓名 + */ + @ApiModelProperty(value = "姓名", required = false, example = "jiff", position = 3) + private String name; + /** + * 性别(1女,2男) + */ + @ApiModelProperty(value = "性别(1女,2男)", example = "1", position = 5) + @Enum(message = "{lis.validator.constraints.SexEnum.message}", target = {SexEnum.class}) + private Integer sex; + + /** + * 家谱ID,格式:/rootId/.../grandfatherId/parentId/id + */ + @ApiModelProperty(value = "家谱ID,格式:/rootId/.../grandfatherId/parentId/id", example = "/0/1", hidden = true, notes = "内部使用,不展示给前端") + private String genealogyId; + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/UserRoleParam.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/UserRoleParam.java new file mode 100644 index 0000000..8a562e0 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/params/UserRoleParam.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + *

+ * 用户角色参数 + *

+ * + * @author jiff + * @date 2018/11/26 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "用户角色参数", description = "用于新增和更新用户角色信息") +public class UserRoleParam extends BaseParam { + + private static final long serialVersionUID = 1L; + /** + * 用户ID + */ + @ApiModelProperty(value = "用户ID", required = true, example = "1") + @NotNull(message = "用户ID不能为空") + private Long userId; + + @ApiModelProperty(value = "角色主键列表", required = false, example = "[1]") + private List roleIds; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/MenuResourceService.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/MenuResourceService.java new file mode 100644 index 0000000..c82454c --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/MenuResourceService.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service; + +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.*; +import com.mt.wms.upms.params.MenuResourceParam; +import com.mt.wms.upms.params.MenuResourceQueryParam; +import com.mt.wms.upms.vo.ResourceVo; + +import java.util.List; + +/** + * 菜单资源服务接口 + * + * @author jiff + * @date 2018/11/27 + * @since 1.0 + */ +public interface MenuResourceService { + /** + * 新增菜单资源 + * + * @param menuResourceParam 菜单资源参数 + * @return 主键 + */ + R add(MenuResourceParam menuResourceParam); + + /** + * 删除菜单资源 + * + * @param idParam 主键参数 + * @return 主键 + */ + R delete(IdParam idParam); + + /** + * 批量删除菜单资源 + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + R delete(IdListParam idListParam); + + /** + * 获取菜单资源列表 + * + * @param idParam 主键参数 + * @return 菜单资源列表 + */ + R> listByMenu(IdParam idParam); + + /** + * 获取资源列表 + * + * @param menuResourceQueryParam 查询参数 + * @return 资源列表 + */ + R> listWithMenu(MenuResourceQueryParam menuResourceQueryParam); + + /** + * 获取资源分页列表 + * + * @param menuResourceQueryParam 查询参数 + * @return 资源分页列表 + */ + R> pageWithMenu(MenuResourceQueryParam menuResourceQueryParam); + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/MenuService.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/MenuService.java new file mode 100644 index 0000000..8e8392f --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/MenuService.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service; + +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.*; +import com.mt.wms.upms.params.MenuParam; +import com.mt.wms.upms.params.MenuQueryParam; +import com.mt.wms.upms.params.RoleMenuParam; + +import java.util.List; + + +/** + * 菜单服务接口 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +public interface MenuService { + + /** + * 获取菜单 + * + * @param idParam 主键参数 + * @return 菜单 + */ + R get(IdParam idParam); + + /** + * 获取菜单列表 + * + * @param menuQueryParam 菜单查询参数 + * @return 菜单列表 + */ + R> list(MenuQueryParam menuQueryParam); + + /** + * 获取菜单分页列表 + * + * @param menuQueryParam 菜单查询参数 + * @return 菜单分页列表 + */ + R> page(MenuQueryParam menuQueryParam); + + /** + * 新增菜单 + * + * @param menuParam 菜单参数 + * @return 主键 + */ + R add(MenuParam menuParam); + + /** + * 更新菜单 + * + * @param menuParam 菜单参数 + * @return 主键 + */ + R update(MenuParam menuParam); + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + R enabled(EnabledParam enabledParam); + + /** + * 删除菜单 + * + * @param idParam 主键参数 + * @return 主键 + */ + R delete(IdParam idParam); + + /** + * 批量删除菜单 + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + R delete(IdListParam idListParam); + + /** + * 保存角色菜单 + * + * @param roleMenuParam 角色菜单参数 + * @return 主键列表 + */ + R saveRoleMenu(RoleMenuParam roleMenuParam); + + /** + * 获取菜单列表 + * + * @param idParam 主键参数 + * @return 菜单列表 + */ + R> listByRole(IdParam idParam); +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/MicroServiceService.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/MicroServiceService.java new file mode 100644 index 0000000..152207b --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/MicroServiceService.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service; + +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.ServiceParam; +import com.mt.wms.upms.params.ServiceQueryParam; +import com.mt.wms.upms.vo.ServiceVo; + +import java.util.List; + +/** + * 微服务服务接口 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +public interface MicroServiceService { + + /** + * 获取服务 + * + * @param idParam 主键参数 + * @return 服务 + */ + R get(IdParam idParam); + + /** + * 获取服务列表 + * + * @param serviceQueryParam 服务查询参数 + * @return 服务列表 + */ + R> list(ServiceQueryParam serviceQueryParam); + + /** + * 获取服务分页列表 + * + * @param serviceQueryParam 服务查询参数 + * @return 服务分页列表 + */ + R> page(ServiceQueryParam serviceQueryParam); + + /** + * 新增服务 + * + * @param serviceParam 服务参数 + * @return 主键 + */ + R add(ServiceParam serviceParam); + + /** + * 更新服务 + * + * @param serviceParam 服务参数 + * @return 主键 + */ + R update(ServiceParam serviceParam); + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + R enabled(EnabledParam enabledParam); + + /** + * 删除服务 + * + * @param idParam 主键参数 + * @return 主键 + */ + R delete(IdParam idParam); + + /** + * 批量删除服务 + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + R delete(IdListParam idListParam); +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/OrgService.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/OrgService.java new file mode 100644 index 0000000..f94133b --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/OrgService.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service; + +import com.mt.wms.upms.params.SysOrgParam; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.SysOrgQueryParam; +import com.mt.wms.upms.vo.SysOrgVo; + +import java.util.List; + +/** + * 组织服务接口 + * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +public interface OrgService { + /** + * 获取组织 + * + * @param idParam 主键参数 + * @return 组织 + */ + R get(IdParam idParam); + + /** + * 获取组织列表 + * + * @param sysOrgQueryParam 组织查询参数 + * @return 组织列表 + */ + R> list(SysOrgQueryParam sysOrgQueryParam); + + /** + * 获取组织分页列表 + * + * @param sysOrgQueryParam 组织查询参数 + * @return 组织分页列表 + */ + R> page(SysOrgQueryParam sysOrgQueryParam); + + /** + * 获取组织树列表 + * + * @param sysOrgQueryParam 组织查询参数 + * @return 组织树列表 + */ + R> tree(SysOrgQueryParam sysOrgQueryParam); + + /** + * 新增组织 + * + * @param sysOrgParam 组织参数 + * @return 主键 + */ + R add(SysOrgParam sysOrgParam); + + /** + * 更新组织 + * + * @param sysOrgParam 组织参数 + * @return 主键 + */ + R update(SysOrgParam sysOrgParam); + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + R enabled(EnabledParam enabledParam); + + /** + * 删除组织 + * + * @param idParam 主键参数 + * @return 主键 + */ + R delete(IdParam idParam); + + /** + * 批量删除组织 + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + R delete(IdListParam idListParam); +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/PostService.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/PostService.java new file mode 100644 index 0000000..9e9d9eb --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/PostService.java @@ -0,0 +1,61 @@ +package com.mt.wms.upms.service; + +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.SysPostParam; +import com.mt.wms.upms.vo.SysPostVo; + +import java.util.List; + +/*** + * 合作伙伴岗位接口 + */ +public interface PostService { + + /*** + * 通过id获取岗位信息 + * @param id + * @return + */ + R get(IdParam id); + + /*** + * 获取岗位树形结构信息 + * @return + */ + R> tree(); + + /*** + * 新增岗位信息 + * @param sysPostParam + * @return + */ + R add(SysPostParam sysPostParam); + + /*** + * 修改岗位信息 + * @param sysPostParam + * @return + */ + R update(SysPostParam sysPostParam); + + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + R enabled(EnabledParam enabledParam); + + /*** + * 删除岗位 + * @param id + * @return + */ + R delete(IdParam id); + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/ResourceService.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/ResourceService.java new file mode 100644 index 0000000..dc2642d --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/ResourceService.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service; + +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.ResourceParam; +import com.mt.wms.upms.params.ResourceQueryParam; +import com.mt.wms.upms.vo.ResourceVo; + +import java.util.List; + +/** + * 资源服务接口 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +public interface ResourceService { + + /** + * 获取资源 + * + * @param idParam 主键参数 + * @return 资源 + */ + R get(IdParam idParam); + + /** + * 获取资源列表 + * + * @param resourceQueryParam 资源查询参数 + * @return 资源列表 + */ + R> list(ResourceQueryParam resourceQueryParam); + + /** + * 获取资源分页列表 + * + * @param resourceQueryParam 资源查询参数 + * @return 资源分页列表 + */ + R> page(ResourceQueryParam resourceQueryParam); + + /** + * 新增资源 + * + * @param resourceParam 资源参数 + * @return 主键 + */ + R add(ResourceParam resourceParam); + + /** + * 更新资源 + * + * @param resourceParam 资源参数 + * @return 主键 + */ + R update(ResourceParam resourceParam); + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + R enabled(EnabledParam enabledParam); + + /** + * 删除资源 + * + * @param idParam 主键参数 + * @return 主键 + */ + R delete(IdParam idParam); + + /** + * 批量删除资源 + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + R delete(IdListParam idListParam); + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/RoleService.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/RoleService.java new file mode 100644 index 0000000..8f6dfe7 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/RoleService.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service; + +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.SysRoleParam; +import com.mt.wms.upms.params.SysRoleQueryParam; +import com.mt.wms.upms.params.UserRoleParam; +import com.mt.wms.upms.vo.SysRoleVo; + +import java.util.List; + +/** + * 角色服务接口 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +public interface RoleService { + /** + * 获取角色 + * + * @param idParam 主键参数 + * @return 角色 + */ + R get(IdParam idParam); + + /** + * 获取角色列表 + * + * @param sysRoleQueryParam 角色查询参数 + * @return 角色列表 + */ + R> list(SysRoleQueryParam sysRoleQueryParam); + + /** + * 获取角色分页列表 + * + * @param sysRoleQueryParam 角色查询参数 + * @return 角色分页列表 + */ + R> page(SysRoleQueryParam sysRoleQueryParam); + + /** + * 新增角色 + * + * @param sysRoleParam 角色参数 + * @return 主键 + */ + R add(SysRoleParam sysRoleParam); + + /** + * 更新角色 + * + * @param sysRoleParam 角色参数 + * @return 主键 + */ + R update(SysRoleParam sysRoleParam); + + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + R enabled(EnabledParam enabledParam); + + /** + * 删除角色 + * + * @param idParam 主键参数 + * @return 主键 + */ + R delete(IdParam idParam); + + /** + * 批量删除角色 + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + R delete(IdListParam idListParam); + + + /** + * 保存用户角色 + * + * @param userRoleParam 用户角色参数 + * @return 主键列表 + */ + R saveUserRole(UserRoleParam userRoleParam); + + /** + * 获取用户角色列表 + * + * @param idParam 主键参数 + * @return 角色列表 + */ + R> listByUser(IdParam idParam); +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/UpmsService.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/UpmsService.java new file mode 100644 index 0000000..a6cb5b5 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/UpmsService.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service; + +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.dto.Permission; +import com.mt.wms.core.vo.LoginUserVo; +import com.mt.wms.core.vo.R; + +import java.io.Serializable; +import java.util.List; + +/** + * 通用权限服务接口 + * + * @author jiff + * @date 2018-11-27 + * @since 1.0 + */ +public interface UpmsService { + /** + * 用户登录 + * + * @param mobile 手机号码 + * @param password 密码 + * @return 登录用户 + */ + R login(String mobile, String password); + + /** + * 退出登录 + * + * @return 处理结果 + */ + R logout(); + + /** + * 获取登录用户信息 + * + * @param mobile 手机号码 + * @return 登录用户 + */ + R getLoginUser(String mobile); + + /** + * 获取登录用户信息 + * + * @return 登录用户 + */ + R getLoginUserVo(); + + /** + * 获取用户权限列表 + * + * @return 权限列表 + */ + List getPermissions(); + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/UserService.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/UserService.java new file mode 100644 index 0000000..022ce49 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/UserService.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.*; +import com.mt.wms.upms.params.*; +import com.mt.wms.upms.vo.SysUserVo; + +import java.util.List; + +/** + * 用户服务接口 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +public interface UserService { + + /** + * 获取用户 + * + * @param idParam 主键参数 + * @return 用户 + */ + R get(IdParam idParam); + + /** + * 获取用户列表 + * + * @param sysUserQueryParam 用户查询参数 + * @return 用户列表 + */ + R> list(SysUserQueryParam sysUserQueryParam); + + /** + * 获取用户分页列表 + * + * @param sysUserQueryParam 用户查询参数 + * @return 用户分页列表 + */ + R> page(SysUserQueryParam sysUserQueryParam); + + /** + * 新增用户 + * + * @param sysUserParam 用户参数 + * @return 主键 + */ + R add(SysUserParam sysUserParam); + + /** + * 更新用户 + * + * @param sysUserParam 用户参数 + * @return 主键 + */ + R update(SysUserParam sysUserParam); + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + R enabled(EnabledParam enabledParam); + + /** + * 修改密码 + * + * @param modifyPasswordParam 修改密码参数 + * @return 主键 + */ + R modifyPassword(ModifyPasswordParam modifyPasswordParam); + + /** + * 重置密码 + * + * @param resetPasswordParam 重置密码参数 + * @return 主键 + */ + R resetPassword(ResetPasswordParam resetPasswordParam); + + /** + * 找回密码 + * + * @param findPasswordParam 找回密码参数 + * @return 主键 + */ + R findPassword(FindPasswordParam findPasswordParam); + + /** + * 删除用户 + * + * @param idParam 主键参数 + * @return 主键 + */ + R delete(IdParam idParam); + + /** + * 批量删除用户 + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + R delete(IdListParam idListParam); + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/MenuResourceServiceImpl.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/MenuResourceServiceImpl.java new file mode 100644 index 0000000..6831974 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/MenuResourceServiceImpl.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mt.wms.core.api.Assert; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.dal.entity.Resource; +import com.mt.wms.core.dal.entity.SysMenu; +import com.mt.wms.core.dal.entity.SysMenuResource; +import com.mt.wms.core.dal.service.ResourceServiceBiz; +import com.mt.wms.core.dal.service.SysMenuResourceServiceBiz; +import com.mt.wms.core.dal.service.SysMenuServiceBiz; +import com.mt.wms.core.enums.ResourceCategoryEnum; +import com.mt.wms.core.enums.SubsystemEnum; +import com.mt.wms.core.enums.WhetherEnum; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.*; +import com.mt.wms.upms.params.MenuResourceParam; +import com.mt.wms.upms.params.MenuResourceQueryParam; +import com.mt.wms.upms.service.MenuResourceService; +import com.mt.wms.upms.vo.ResourceVo; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 菜单资源服务接口实现类 + * + * @author jiff + * @date 2018-11-28 + * @since 1.0 + */ +@Service +@Transactional +public class MenuResourceServiceImpl extends BaseService implements MenuResourceService { + @Autowired + private SysMenuResourceServiceBiz sysMenuResourceServiceBiz; + @Autowired + private SysMenuServiceBiz sysMenuServiceBiz; + @Autowired + private ResourceServiceBiz resourceServiceBiz; + + /** + * 新增菜单资源 + * + * @param menuResourceParam 菜单资源参数 + * @return 主键 + */ + @Override + public R add(MenuResourceParam menuResourceParam) { + Long menuId = menuResourceParam.getMenuId(); + List resourceIds = menuResourceParam.getResourceIds(); + SysMenu menu = sysMenuServiceBiz.getById(menuId); + Assert.notNull("菜单不存在", menu); + Collection resources = resourceServiceBiz.listByIds(resourceIds); + if (resourceIds.size() != resources.size()) { + return failed("资源不存在"); + } + for (Resource resource : resources) { + Assert.fail(resource.getCategory() > 0 && !menu.getCategory().equals(resource.getCategory()), "菜单分类和资源分类不一致"); + } + //先过滤已有的菜单资源关系,再保存新增的菜单资源关系 + List menuResources = sysMenuResourceServiceBiz.list(new QueryWrapper().eq(SysMenuResource.MENU_ID, menuId)); + Map menuResourceMap = menuResources.stream().collect(Collectors.toMap(SysMenuResource::getResourceId, menuResource -> menuResource, (k1, k2) -> k1)); + resourceIds = resourceIds.stream().filter(id -> !menuResourceMap.containsKey(id)).collect(Collectors.toList()); + List addMenuResources = resourceIds.stream() + .map(resourceId -> setCommonField(new SysMenuResource().setMenuId(menuId).setResourceId(resourceId))) + .collect(Collectors.toList()); + sysMenuResourceServiceBiz.saveBatch(addMenuResources); + return successful(IdListVo.builder().ids(addMenuResources.stream().map(SysMenuResource::getId).collect(Collectors.toList())).build()); + } + + /** + * 删除菜单资源 + * + * @param idParam 主键参数 + * @return 主键 + */ + @Override + public R delete(IdParam idParam) { + sysMenuResourceServiceBiz.removeById(idParam.getId()); + return successful(IdVo.builder().id(idParam.getId()).build()); + } + + /** + * 批量删除菜单资源 + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + @Override + public R delete(IdListParam idListParam) { + sysMenuResourceServiceBiz.removeByIds(idListParam.getIds()); + return successful(IdListVo.builder().ids(idListParam.getIds()).build()); + } + + /** + * 获取菜单资源列表,返回菜单关联的资源列表 + * + * @param idParam 主键参数 + * @return 菜单资源列表 + */ + @Override + public R> listByMenu(IdParam idParam) { + //先查询菜单资源关系,再转换成Map,便于把资源列表转换成菜单资源列表 + List menuResources = sysMenuResourceServiceBiz.list(new QueryWrapper().eq(SysMenuResource.MENU_ID, idParam.getId())); + if (CollectionUtils.isEmpty(menuResources)) { + return successful(null); + } + Map menuResourceMap = menuResources.stream().collect(Collectors.toMap(SysMenuResource::getResourceId, menuResource -> menuResource, (k1, k2) -> k1)); + Collection resources = resourceServiceBiz.listByIds(menuResources.stream().map(SysMenuResource::getResourceId).collect(Collectors.toList())); + List menuResourceVos = resources.stream().map(resource -> { + MenuResourceVo menuResourceVo = MenuResourceVo.builder().build(); + BeanUtils.copyProperties(resource, menuResourceVo); + SysMenuResource menuResource = menuResourceMap.get(resource.getId()); + BeanUtils.copyProperties(menuResource, menuResourceVo); + return menuResourceVo; + }).collect(Collectors.toList()); + return successful(menuResourceVos); + } + + /** + * 获取资源列表,需要根据菜单分类返回未关联的资源列表 + * + * @param menuResourceQueryParam 查询参数 + * @return 资源列表 + */ + @Override + public R> listWithMenu(MenuResourceQueryParam menuResourceQueryParam) { + SysMenu menu = sysMenuServiceBiz.getById(menuResourceQueryParam.getMenuId()); + Assert.notNull("菜单不存在", menu); + List menuResources = sysMenuResourceServiceBiz.list(new QueryWrapper().eq(SysMenuResource.MENU_ID, menu.getId())); + Map menuResourceMap = menuResources.stream().collect(Collectors.toMap(SysMenuResource::getResourceId, menuResource -> menuResource, (k1, k2) -> k1)); + List allResources = resourceServiceBiz + .list(new QueryWrapper() + .eq(Resource.ENABLED, WhetherEnum.YES.getValue()) + .and(wrapper -> wrapper.eq(Resource.SUBSYSTEM, SubsystemEnum.COMMON.getValue()) + .or().eq(Resource.SUBSYSTEM, SubsystemEnum.PLATFORM.getValue())) + .and(wrapper -> wrapper.eq(Resource.CATEGORY, ResourceCategoryEnum.COMMON.getValue()) + .or().eq(Resource.CATEGORY, menu.getCategory())) + .like(StringUtils.isNotBlank(menuResourceQueryParam.getName()), Resource.NAME, menuResourceQueryParam.getName()) + .like(StringUtils.isNotBlank(menuResourceQueryParam.getUrl()), Resource.URL, menuResourceQueryParam.getUrl())); + List resources = allResources.stream().filter(resource -> !menuResourceMap.containsKey(resource.getId())).collect(Collectors.toList()); + List resourceVos = com.mt.wms.core.utils.BeanUtils.copyList(resources, ResourceVo.class); + return successful(resourceVos); + } + + /** + * 获取资源分页列表,需要根据菜单分类返回未关联的资源列表 + * + * @param menuResourceQueryParam 查询参数 + * @return 资源分页列表 + */ + @Override + public R> pageWithMenu(MenuResourceQueryParam menuResourceQueryParam) { + SysMenu menu = sysMenuServiceBiz.getById(menuResourceQueryParam.getMenuId()); + Assert.notNull("菜单不存在", menu); + List menuResources = sysMenuResourceServiceBiz.list(new QueryWrapper().eq(SysMenuResource.MENU_ID, menu.getId())); + IPage page = resourceServiceBiz + .page(new Page<>(menuResourceQueryParam.getCurrent(), menuResourceQueryParam.getSize()), new QueryWrapper() + .eq(Resource.ENABLED, WhetherEnum.YES.getValue()) + .and(wrapper -> wrapper.eq(Resource.SUBSYSTEM, SubsystemEnum.COMMON.getValue()) + .or().eq(Resource.SUBSYSTEM, SubsystemEnum.PLATFORM.getValue())) + .and(wrapper -> wrapper.eq(Resource.CATEGORY, ResourceCategoryEnum.COMMON.getValue()) + .or().eq(Resource.CATEGORY, menu.getCategory())) + .notIn(!CollectionUtils.isEmpty(menuResources), Resource.ID, menuResources.stream().map(SysMenuResource::getResourceId).collect(Collectors.toList())) + .like(StringUtils.isNotBlank(menuResourceQueryParam.getName()), Resource.NAME, menuResourceQueryParam.getName()) + .like(StringUtils.isNotBlank(menuResourceQueryParam.getUrl()), Resource.URL, menuResourceQueryParam.getUrl())); + return successful(new PageVo<>(page, ResourceVo.class)); + } + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/MenuServiceImpl.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/MenuServiceImpl.java new file mode 100644 index 0000000..9519fbe --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/MenuServiceImpl.java @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mt.wms.core.api.Assert; +import com.mt.wms.core.base.BaseSupport; +import com.mt.wms.core.dal.entity.SysMenu; +import com.mt.wms.core.dal.entity.SysMenuResource; +import com.mt.wms.core.dal.entity.SysRole; +import com.mt.wms.core.dal.entity.SysRoleMenu; +import com.mt.wms.core.dal.service.SysMenuResourceServiceBiz; +import com.mt.wms.core.dal.service.SysMenuServiceBiz; +import com.mt.wms.core.dal.service.SysRoleMenuServiceBiz; +import com.mt.wms.core.dal.service.SysRoleServiceBiz; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.utils.TreeUtil; +import com.mt.wms.core.vo.*; +import com.mt.wms.upms.mapper.MenuMapper; +import com.mt.wms.upms.params.MenuParam; +import com.mt.wms.upms.params.MenuQueryParam; +import com.mt.wms.upms.params.RoleMenuParam; +import com.mt.wms.upms.service.MenuService; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 菜单服务实现类 + * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@Service +@Transactional +public class MenuServiceImpl extends BaseSupport implements MenuService { + + @Autowired + private SysMenuServiceBiz sysMenuServiceBiz; + + @Autowired + private SysRoleMenuServiceBiz sysRoleMenuServiceBiz; + @Autowired + private SysMenuResourceServiceBiz sysMenuResourceServiceBiz; + @Autowired + private SysRoleServiceBiz sysRoleServiceBiz; + + @Autowired + private MenuMapper menuMapper; + + + /** + * 获取菜单 + * + * @param idParam + * @return + */ + @Override + public R get(IdParam idParam) { + SysMenu menu = sysMenuServiceBiz.getById(idParam.getId()); + Assert.notNull("菜单不存在", menu); + MenuVo sysMenuVo = MenuVo.builder().build(); + BeanUtils.copyProperties(menu, sysMenuVo); + //父菜单ID存在时,则返回父菜单名称 + if (menu.getParentId() > 0L) { + SysMenu parentMenu = sysMenuServiceBiz.getById(menu.getParentId()); + if (parentMenu != null) { + sysMenuVo.setParentName(parentMenu.getName()); + } + } + return successful(sysMenuVo); + } + + /** + * 获取菜单列表 + * + * @param menuQueryParam + * @return + */ + @Override + public R> list(MenuQueryParam menuQueryParam) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(ObjectUtils.isNotNull(menuQueryParam.getParentId()), SysMenu.PARENT_ID, menuQueryParam.getParentId()) + .eq(ObjectUtils.isNotNull(menuQueryParam.getCategory()), SysMenu.CATEGORY, menuQueryParam.getCategory()) + .eq(ObjectUtils.isNotNull(menuQueryParam.getType()), SysMenu.TYPE, menuQueryParam.getType()) + .eq(ObjectUtils.isNotNull(menuQueryParam.getEnabled()), SysMenu.ENABLED, menuQueryParam.getEnabled()) + .like(StringUtils.isNotBlank(menuQueryParam.getCode()), SysMenu.CODE, menuQueryParam.getCode()) + .like(StringUtils.isNotBlank(menuQueryParam.getName()), SysMenu.NAME, menuQueryParam.getName()); + List menus = sysMenuServiceBiz.list(wrapper); + List menuVos = com.mt.wms.core.utils.BeanUtils.copyList(menus, MenuVo.class); + return successful(menuVos); + } + + /** + * 获取分页菜单列表 + * + * @param menuQueryParam + * @return + */ + @Override + public R> page(MenuQueryParam menuQueryParam) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(ObjectUtils.isNotNull(menuQueryParam.getParentId()), SysMenu.PARENT_ID, menuQueryParam.getParentId()) + .eq(ObjectUtils.isNotNull(menuQueryParam.getCategory()), SysMenu.CATEGORY, menuQueryParam.getCategory()) + .eq(ObjectUtils.isNotNull(menuQueryParam.getType()), SysMenu.TYPE, menuQueryParam.getType()) + .eq(ObjectUtils.isNotNull(menuQueryParam.getEnabled()), SysMenu.ENABLED, menuQueryParam.getEnabled()) + .like(StringUtils.isNotBlank(menuQueryParam.getCode()), SysMenu.CODE, menuQueryParam.getCode()) + .like(StringUtils.isNotBlank(menuQueryParam.getName()), SysMenu.NAME, menuQueryParam.getName()); + IPage page = sysMenuServiceBiz.page(new Page<>(menuQueryParam.getCurrent(), menuQueryParam.getSize()), wrapper); + return successful(new PageVo<>(page, MenuVo.class)); + } + + /** + * 新增菜单 + * + * @param menuParam + * @return + */ + @Override + public R add(MenuParam menuParam) { + int parentMenuLevel = 0; + if (menuParam.getParentId() > 0L) { + SysMenu parentMenu = sysMenuServiceBiz.getById(menuParam.getParentId()); + Assert.notNull("父菜单不存在", parentMenu); + Assert.eq(parentMenu.getCategory(), menuParam.getCategory(), "菜单分类和父菜单分类不一致"); + parentMenuLevel = parentMenu.getLevel(); + } + SysMenu menu = new SysMenu(); + BeanUtils.copyProperties(menuParam, menu); + menu.setLevel(parentMenuLevel + 1); + setCommonField(menu); + sysMenuServiceBiz.save(menu); + return successful(IdVo.builder().id(menu.getId()).build()); + } + + /** + * 更新菜单 + * + * @param menuParam + * @return + */ + @Override + public R update(MenuParam menuParam) { + SysMenu menu = sysMenuServiceBiz.getById(menuParam.getId()); + Assert.notNull("菜单不存在", menu); + //暂时不允许修改父菜单和菜单分类,涉及到菜单层级计算和分类判断 + SysMenu updateMenu = new SysMenu(); + BeanUtils.copyProperties(menuParam, updateMenu, "parentId", "category"); + setUpdateCommonField(updateMenu); + sysMenuServiceBiz.updateById(updateMenu); + return successful(IdVo.builder().id(menu.getId()).build()); + } + + /** + * 启用停用 + * + * @param enabledParam + * @return + */ + @Override + public R enabled(EnabledParam enabledParam) { + SysMenu menu = new SysMenu().setId(enabledParam.getId()); + menu.setEnabled(enabledParam.getEnabled()); + setUpdateCommonField(menu); + sysMenuServiceBiz.updateById(menu); + return successful(IdVo.builder().id(menu.getId()).build()); + } + + /** + * 删除菜单 + * + * @param idParam + * @return + */ + @Override + public R delete(IdParam idParam) { + Assert.eqZero(sysRoleMenuServiceBiz.count(new QueryWrapper().eq(SysRoleMenu.MENU_ID, idParam.getId())), "菜单还关联角色"); + //删除菜单资源关系 + sysMenuResourceServiceBiz.remove(new QueryWrapper().eq(SysMenuResource.MENU_ID, idParam.getId())); + sysMenuServiceBiz.removeById(idParam.getId()); + return successful(IdVo.builder().id(idParam.getId()).build()); + } + + /** + * 批量删除菜单 + * + * @param idListParam + * @return + */ + @Override + public R delete(IdListParam idListParam) { + return null; + } + + /** + * 保存角色菜单 + * + * @param roleMenuParam 角色菜单参数 + * @return 主键列表 + */ + @Override + public R saveRoleMenu(RoleMenuParam roleMenuParam) { + Long roleId = roleMenuParam.getRoleId(); + SysRole role = sysRoleServiceBiz.getById(roleId); + Assert.notNull("角色不存在", role); + //检查设置的角色是否都存在 + List menuIds = roleMenuParam.getMenuIds(); + if (CollectionUtils.isNotEmpty(menuIds)) { + Collection menus = sysMenuServiceBiz.listByIds(menuIds); + if (menuIds.size() != menus.size()) { + return failed("菜单不存在"); + } + for (SysMenu menu : menus) { + Assert.eq(role.getCategory(), menu.getCategory(), "菜单分类和角色分类不一致"); + } + } + //先删除原有的角色菜单关系 + sysRoleMenuServiceBiz.remove(new QueryWrapper().eq(SysRoleMenu.ROLE_ID, roleId)); + if (CollectionUtils.isNotEmpty(menuIds)) { + List roleMenus = menuIds.stream() + .map(menuId -> setCommonField(new SysRoleMenu().setRoleId(roleId).setMenuId(menuId))) + .collect(Collectors.toList()); + sysRoleMenuServiceBiz.saveBatch(roleMenus); + return successful(IdListVo.builder().ids(roleMenus.stream().map(SysRoleMenu::getId).collect(Collectors.toList())).build()); + } + + return successful(null); + } + + /** + * 获取菜单列表 + * + * @param idParam 主键参数 + * @return 菜单列表 + */ + @Override + public R> listByRole(IdParam idParam) { + SysRole role = sysRoleServiceBiz.getById(idParam.getId()); + Assert.notNull("角色不存在", role); + List menuVos = menuMapper.listByRole(idParam.getId(), role.getCategory()); + return successful(TreeUtil.toTree(menuVos)); + } +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/MicroServiceServiceImpl.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/MicroServiceServiceImpl.java new file mode 100644 index 0000000..c114c02 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/MicroServiceServiceImpl.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mt.wms.core.api.Assert; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.dal.entity.Resource; +import com.mt.wms.core.dal.entity.Service; +import com.mt.wms.core.dal.service.ResourceServiceBiz; +import com.mt.wms.core.dal.service.ServiceServiceBiz; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.ServiceParam; +import com.mt.wms.upms.params.ServiceQueryParam; +import com.mt.wms.upms.service.MicroServiceService; +import com.mt.wms.upms.vo.ServiceVo; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 微服务服务实现类 + * + * @author jiff + * @date 2018/11/23 + * @since 1.0 + */ +@org.springframework.stereotype.Service +@Transactional +public class MicroServiceServiceImpl extends BaseService implements MicroServiceService { + @Autowired + private ServiceServiceBiz serviceServiceBiz; + @Autowired + private ResourceServiceBiz resourceServiceBiz; + + /** + * 获取服务 + * + * @param idParam 主键参数 + * @return 服务 + */ + @Override + public R get(IdParam idParam) { + Service service = serviceServiceBiz.getById(idParam.getId()); + Assert.notNull("服务不存在", service); + ServiceVo serviceVo = ServiceVo.builder().build(); + BeanUtils.copyProperties(service, serviceVo); + return successful(serviceVo); + } + + /** + * 获取服务列表 + * + * @param serviceQueryParam 服务查询参数 + * @return 服务列表 + */ + @Override + public R> list(ServiceQueryParam serviceQueryParam) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(ObjectUtils.isNotNull(serviceQueryParam.getEnabled()), Service.ENABLED, serviceQueryParam.getEnabled()) + .like(StringUtils.isNotBlank(serviceQueryParam.getName()), Service.NAME, serviceQueryParam.getName()) + .like(StringUtils.isNotBlank(serviceQueryParam.getCode()), Service.CODE, serviceQueryParam.getCode()); + List services = serviceServiceBiz.list(wrapper); + List serviceVos = com.mt.wms.core.utils.BeanUtils.copyList(services, ServiceVo.class); + return successful(serviceVos); + } + + /** + * 获取服务分页列表 + * + * @param serviceQueryParam 服务查询参数 + * @return 服务分页列表 + */ + @Override + public R> page(ServiceQueryParam serviceQueryParam) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(ObjectUtils.isNotNull(serviceQueryParam.getEnabled()), Service.ENABLED, serviceQueryParam.getEnabled()) + .like(StringUtils.isNotBlank(serviceQueryParam.getName()), Service.NAME, serviceQueryParam.getName()) + .like(StringUtils.isNotBlank(serviceQueryParam.getCode()), Service.CODE, serviceQueryParam.getCode()); + IPage page = serviceServiceBiz.page(new Page<>(serviceQueryParam.getCurrent(), serviceQueryParam.getSize()), wrapper); + return successful(new PageVo<>(page, ServiceVo.class)); + } + + /** + * 新增服务 + * + * @param serviceParam 服务参数 + * @return 主键 + */ + @Override + public R add(ServiceParam serviceParam) { + Service service = new Service(); + BeanUtils.copyProperties(serviceParam, service); + setCommonField(service); + serviceServiceBiz.save(service); + return successful(IdVo.builder().id(service.getId()).build()); + } + + /** + * 更新服务 + * + * @param serviceParam 服务参数 + * @return 主键 + */ + @Override + public R update(ServiceParam serviceParam) { + Service service = serviceServiceBiz.getById(serviceParam.getId()); + Assert.notNull("服务不存在", service); + Service updateService = new Service(); + BeanUtils.copyProperties(serviceParam, updateService); + setUpdateCommonField(updateService); + serviceServiceBiz.updateById(updateService); + return successful(IdVo.builder().id(service.getId()).build()); + } + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + @Override + public R enabled(EnabledParam enabledParam) { + Service service = serviceServiceBiz.getById(enabledParam.getId()); + Assert.notNull("服务不存在", service); + Service updateService = new Service().setId(enabledParam.getId()); + updateService.setEnabled(enabledParam.getEnabled()); + setUpdateCommonField(updateService); + serviceServiceBiz.updateById(updateService); + return successful(IdVo.builder().id(service.getId()).build()); + } + + /** + * 删除服务 + * + * @param idParam 主键参数 + * @return 主键 + */ + @Override + public R delete(IdParam idParam) { + Service service = serviceServiceBiz.getById(idParam.getId()); + Assert.notNull("服务不存在", service); + Assert.eqZero(resourceServiceBiz.count(new QueryWrapper().eq(Resource.SERVICE_ID, idParam.getId())), "该服务下还有资源"); + serviceServiceBiz.removeById(idParam.getId()); + return successful(IdVo.builder().id(service.getId()).build()); + } + + /** + * 批量删除服务 + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + @Override + public R delete(IdListParam idListParam) { + return null; + } +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/OrgServiceImpl.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/OrgServiceImpl.java new file mode 100644 index 0000000..174004e --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/OrgServiceImpl.java @@ -0,0 +1,297 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mt.wms.core.api.Assert; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.dal.entity.SysOrg; +import com.mt.wms.core.dal.entity.SysUser; +import com.mt.wms.core.dal.service.SysOrgServiceBiz; +import com.mt.wms.core.dal.service.SysUserServiceBiz; +import com.mt.wms.core.errorcode.ApiErrorCode; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.utils.TreeUtil; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.SysOrgParam; +import com.mt.wms.upms.params.SysOrgQueryParam; +import com.mt.wms.upms.service.OrgService; +import com.mt.wms.upms.vo.SysOrgVo; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 组织服务实现类 + *

+ * //TODO 需要完善区域限制,需要完善父组织修改功能 + *

+ * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@Service("upmsOrgService") +@Transactional +public class OrgServiceImpl extends BaseService implements OrgService { + @Autowired + private SysUserServiceBiz sysUserServiceBiz; + @Autowired + private SysOrgServiceBiz sysOrgServiceBiz; + + + /** + * 获取组织 + * + * @param idParam 主键参数 + * @return 组织 + */ + @Override + public R get(IdParam idParam) { + SysOrg sysOrg = sysOrgServiceBiz.getById(idParam.getId()); + Assert.notNull("组织不存在", sysOrg); + + if (!hasPermission(sysOrg)) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + SysOrgVo sysOrgVo = SysOrgVo.builder().build(); + BeanUtils.copyProperties(sysOrg, sysOrgVo); + return successful(sysOrgVo); + } + + + /** + * 获取组织列表 + * + * @param sysOrgQueryParam 组织查询参数 + * @return 组织列表 + */ + @Override + public R> list(SysOrgQueryParam sysOrgQueryParam) { + Long parentId = sysOrgQueryParam.getParentId(); + if (ObjectUtils.isNotNull(parentId) && !hasPermission(sysOrgServiceBiz.getById(parentId))) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + QueryWrapper wrapper = new QueryWrapper<>(); + //没有指定父ID时则查询当前用户所能管理的所有组织,包括用户所在组织及所有子组织 + if (ObjectUtils.isNull(parentId)) { + SysOrg parentOrg = sysOrgServiceBiz.getById(getLoginUser().getOrgId()); + wrapper.likeRight(SysOrg.GENEALOGY_ID, parentOrg.getGenealogyId()); + } + wrapper.eq(ObjectUtils.isNotNull(parentId), SysOrg.PARENT_ID, parentId) + .eq(ObjectUtils.isNotNull(sysOrgQueryParam.getEnabled()), SysOrg.ENABLED, sysOrgQueryParam.getEnabled()) + .like(StringUtils.isNotBlank(sysOrgQueryParam.getName()), SysOrg.NAME, sysOrgQueryParam.getName()); + List sysOrgs = sysOrgServiceBiz.list(wrapper); + List sysOrgVos = com.mt.wms.core.utils.BeanUtils.copyList(sysOrgs, SysOrgVo.class); + return successful(sysOrgVos); + } + + /** + * 获取组织分页列表 + * + * @param sysOrgQueryParam 组织查询参数 + * @return 组织分页列表 + */ + @Override + public R> page(SysOrgQueryParam sysOrgQueryParam) { + Long parentId = sysOrgQueryParam.getParentId(); + if (ObjectUtils.isNotNull(parentId) && !hasPermission(sysOrgServiceBiz.getById(parentId))) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + QueryWrapper wrapper = new QueryWrapper<>(); + //没有指定父ID时则查询当前用户所能管理的所有组织,包括用户所在组织及所有子组织 + if (ObjectUtils.isNull(parentId)) { + SysOrg parentOrg = sysOrgServiceBiz.getById(getLoginUser().getOrgId()); + wrapper.likeRight(SysOrg.GENEALOGY_ID, parentOrg.getGenealogyId()); + } + wrapper.eq(ObjectUtils.isNotNull(parentId), SysOrg.PARENT_ID, parentId) + .eq(ObjectUtils.isNotNull(sysOrgQueryParam.getEnabled()), SysOrg.ENABLED, sysOrgQueryParam.getEnabled()) + .like(StringUtils.isNotBlank(sysOrgQueryParam.getName()), SysOrg.NAME, sysOrgQueryParam.getName()); + IPage page = sysOrgServiceBiz.page(new Page<>(sysOrgQueryParam.getCurrent(), sysOrgQueryParam.getSize()), wrapper); + return successful(new PageVo<>(page, SysOrgVo.class)); + } + + /** + * 获取组织树列表 + * + * @param sysOrgQueryParam 组织查询参数 + * @return 组织树列表 + */ + @Override + public R> tree(SysOrgQueryParam sysOrgQueryParam) { + Long parentId = sysOrgQueryParam.getParentId(); + SysOrg parentOrg = null; + if (ObjectUtils.isNotNull(parentId)) { + parentOrg = sysOrgServiceBiz.getById(parentId); + if (!hasPermission(sysOrgServiceBiz.getById(parentId))) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + } + QueryWrapper wrapper = new QueryWrapper<>(); + //没有指定父ID时则查询当前用户所能管理的所有组织,包括用户所在组织及所有子组织 + if (ObjectUtils.isNull(parentId)) { + parentOrg = sysOrgServiceBiz.getById(getLoginUser().getOrgId()); + wrapper.likeRight(SysOrg.GENEALOGY_ID, parentOrg.getGenealogyId()); + } + wrapper.eq(ObjectUtils.isNotNull(parentId), SysOrg.PARENT_ID, parentId) + .eq(ObjectUtils.isNotNull(sysOrgQueryParam.getEnabled()), SysOrg.ENABLED, sysOrgQueryParam.getEnabled()) + .like(StringUtils.isNotBlank(sysOrgQueryParam.getName()), SysOrg.NAME, sysOrgQueryParam.getName()); + List sysOrgs = sysOrgServiceBiz.list(wrapper); + List sysOrgVos = com.mt.wms.core.utils.BeanUtils.copyList(sysOrgs, SysOrgVo.class); + return successful(TreeUtil.toTree(sysOrgVos, parentOrg.getParentId())); + } + + /** + * 新增组织 + * + * @param sysOrgParam 组织参数 + * @return 主键 + */ + @Override + public R add(SysOrgParam sysOrgParam) { + SysOrg parentOrg = sysOrgServiceBiz.getById(sysOrgParam.getParentId()); + if (parentOrg == null) { + return failed("父组织不存在"); + } + if (!hasPermission(parentOrg)) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + + SysOrg sysOrg = new SysOrg(); + BeanUtils.copyProperties(sysOrgParam, sysOrg); + //数据库不允许为空,先设置父组织的家谱ID + sysOrg.setGenealogyId(parentOrg.getGenealogyId()); + setCommonField(sysOrg); + sysOrgServiceBiz.save(sysOrg); + //设置家谱ID,格式:/rootId/.../grandfatherId/parentId/id + sysOrg.setGenealogyId(parentOrg.getGenealogyId() + "/" + sysOrg.getId()); + sysOrgServiceBiz.updateById(sysOrg); + return successful(IdVo.builder().id(sysOrg.getId()).build()); + } + + /** + * 更新组织 + * + * @param sysOrgParam 组织参数 + * @return 主键 + */ + @Override + public R update(SysOrgParam sysOrgParam) { + SysOrg sysOrg = sysOrgServiceBiz.getById(sysOrgParam.getId()); + Assert.notNull("组织不存在", sysOrg); + if (!hasPermission(sysOrg)) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + //父组织关系暂时不允许修改,先不验证 +// SysOrg parentOrg = sysOrgService.getById(sysOrgParam.getParentId()); +// Assert.notNull("父组织不存在", parentOrg); +// if (!hasPermission(parentOrg)) { +// return failed(ApiErrorCode.FORBIDDEN_DATA); +// } + + + SysOrg updateSysOrg = new SysOrg(); + BeanUtils.copyProperties(sysOrgParam, updateSysOrg, "parentId"); + setUpdateCommonField(updateSysOrg); + sysOrgServiceBiz.updateById(updateSysOrg); + return successful(IdVo.builder().id(sysOrg.getId()).build()); + } + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + @Override + public R enabled(EnabledParam enabledParam) { + SysOrg sysOrg = sysOrgServiceBiz.getById(enabledParam.getId()); + if (sysOrg == null) { + return failed("组织不存在"); + } + if (!hasPermission(sysOrg)) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + if (!enabledParam.getEnabled().equals(sysOrg.getEnabled())) { + SysOrg updateSysOrg = new SysOrg().setId(sysOrg.getId()); + updateSysOrg.setEnabled(enabledParam.getEnabled()); + setUpdateCommonField(updateSysOrg); + sysOrgServiceBiz.updateById(updateSysOrg); + } + return successful(IdVo.builder().id(sysOrg.getId()).build()); + } + + /** + * 删除组织 + * + * @param idParam 主键参数 + * @return 主键 + */ + @Override + public R delete(IdParam idParam) { + SysOrg sysOrg = sysOrgServiceBiz.getById(idParam.getId()); + if (sysOrg == null) { + return failed("组织不存在"); + } + if (sysUserServiceBiz.count(new QueryWrapper().eq(SysUser.ORG_ID, sysOrg.getId())) > 0) { + return failed("该组织下还有用户"); + } + //用家谱ID查询会包含当前要删除的组织,所以需要判断大于1时则还有子组织 + if (sysOrgServiceBiz.count(new QueryWrapper().likeRight(SysOrg.GENEALOGY_ID, sysOrg.getGenealogyId())) > 1) { + return failed("该组织下还有子组织"); + } + sysOrgServiceBiz.removeById(idParam.getId()); + return successful(IdVo.builder().id(sysOrg.getId()).build()); + } + + /** + * 批量删除组织 + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + @Override + public R delete(IdListParam idListParam) { + return null; + } + + + /** + * 判断登录用户是否有修改该组织的权限,主要基于登录用户和被修改组织是否归属同一组织或上下级组织关系 + * + * @param sysOrg 被修改的用户 + * @return true允许修改,否则不允许 + */ + private boolean hasPermission(SysOrg sysOrg) { + if (sysOrg == null) { + return false; + } + Long loginOrgId = getLoginUser().getOrgId(); + if (loginOrgId == null) { + return false; + } + SysOrg loginSysOrg = sysOrgServiceBiz.getById(loginOrgId); + if (loginSysOrg == null) { + return false; + } + if (StringUtils.isAnyBlank(sysOrg.getGenealogyId(), loginSysOrg.getGenealogyId())) { + return false; + } + return sysOrg.getGenealogyId().startsWith(loginSysOrg.getGenealogyId()); + } +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/PostServiceImpl.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/PostServiceImpl.java new file mode 100644 index 0000000..0b6f2a1 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/PostServiceImpl.java @@ -0,0 +1,107 @@ +package com.mt.wms.upms.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.dal.entity.SysPost; +import com.mt.wms.core.dal.entity.SysUserPost; +import com.mt.wms.core.dal.service.SysPostServiceBiz; +import com.mt.wms.core.dal.service.SysUserPostServiceBiz; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.utils.TreeUtil; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.SysPostParam; +import com.mt.wms.upms.service.PostService; +import com.mt.wms.upms.vo.SysPostVo; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/*** + * 合作伙伴岗位接口实现层 + */ +@Service +public class PostServiceImpl extends BaseService implements PostService { + @Autowired + private SysPostServiceBiz sysPostServiceBiz; + @Autowired + private SysUserPostServiceBiz sysUserPostServiceBiz; + + @Override + public R get(IdParam idParam) { + SysPostVo postVo = SysPostVo.builder().build(); + SysPost sysPost = sysPostServiceBiz.getById(idParam.getId()); + BeanUtils.copyProperties(sysPost, postVo); + return successful(postVo); + } + + @Override + public R> tree() { + List sysPosts = sysPostServiceBiz.list(); + List sysPostVos = com.mt.wms.core.utils.BeanUtils.copyList(sysPosts, SysPostVo.class); + return successful(TreeUtil.toTree(sysPostVos, 0L)); + } + + @Override + public R add(SysPostParam sysPostParam) { + //判断是否存在parentID为0 的根 + if (sysPostParam.getParentId() == 0 && sysPostServiceBiz.getOne(new QueryWrapper().eq(SysPost.PARENT_ID, sysPostParam.getParentId()).last("LIMIT 1")) != null) { + return R.failed("已存在根目录,请选择一个根目录"); + } + SysPost sysPost = new SysPost(); + BeanUtils.copyProperties(sysPostParam, sysPost); + setCommonField(sysPost); + sysPostServiceBiz.save(sysPost); + return successful(IdVo.builder().id(sysPost.getId()).build()); + } + + @Override + public R update(SysPostParam sysPostParam) { + SysPost sysPost = new SysPost(); + BeanUtils.copyProperties(sysPostParam, sysPost); + setUpdateCommonField(sysPost); + sysPostServiceBiz.updateById(sysPost); + return successful(IdVo.builder().id(sysPost.getId()).build()); + } + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + @Override + public R enabled(EnabledParam enabledParam) { + SysPost sysPost = sysPostServiceBiz.getById(enabledParam.getId()); + if (sysPost == null) { + return failed("岗位不存在"); + } + if (!enabledParam.getEnabled().equals(sysPost.getEnabled())) { + SysPost updateSysPost = new SysPost().setId(sysPost.getId()); + updateSysPost.setEnabled(enabledParam.getEnabled()); + setUpdateCommonField(updateSysPost); + sysPostServiceBiz.updateById(updateSysPost); + } + return successful(IdVo.builder().id(sysPost.getId()).build()); + } + + + @Override + public R delete(IdParam idParam) { + //判断是否已有用户 + if (sysUserPostServiceBiz.count(new QueryWrapper().eq(SysUserPost.POST_ID, idParam.getId())) > 0) { + return R.failed("岗位下存在用户,请先删除合作伙伴用户信息"); + } + //判断是否存在下级 + SysPost sysPost = sysPostServiceBiz.getOne(new QueryWrapper().eq(SysPost.PARENT_ID, idParam.getId()).last("LIMIT 1")); + if (sysPost != null) { + return R.failed("存在下级岗位,请先删除下级岗位"); + } + sysPostServiceBiz.removeById(idParam.getId()); + + return successful(IdVo.builder().id(idParam.getId()).build()); + } +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/ResourceServiceImpl.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/ResourceServiceImpl.java new file mode 100644 index 0000000..bb35436 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/ResourceServiceImpl.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mt.wms.core.api.Assert; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.dal.entity.Resource; +import com.mt.wms.core.dal.entity.SysMenuResource; +import com.mt.wms.core.dal.service.ResourceServiceBiz; +import com.mt.wms.core.dal.service.ServiceServiceBiz; +import com.mt.wms.core.dal.service.SysMenuResourceServiceBiz; +import com.mt.wms.core.enums.SubsystemEnum; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.params.ResourceParam; +import com.mt.wms.upms.params.ResourceQueryParam; +import com.mt.wms.upms.service.ResourceService; +import com.mt.wms.upms.vo.ResourceVo; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 资源服务实现类 + * + * @author jiff + * @date 2018/11/23 + * @since 1.0 + */ +@Service("upmsResourceService") +@Transactional +public class ResourceServiceImpl extends BaseService implements ResourceService { + @Autowired + private ResourceServiceBiz resourceServiceBiz; + @Autowired + private ServiceServiceBiz serviceServiceBiz; + @Autowired + private SysMenuResourceServiceBiz sysMenuResourceServiceBiz; + + /** + * 获取资源 + * + * @param idParam 主键参数 + * @return 资源 + */ + @Override + public R get(IdParam idParam) { + Resource resource = resourceServiceBiz.getById(idParam.getId()); + Assert.notNull("资源不存在", resource); + ResourceVo resourceVo = ResourceVo.builder().build(); + BeanUtils.copyProperties(resource, resourceVo); + return successful(resourceVo); + } + + /** + * 获取资源列表 + * + * @param resourceQueryParam 资源查询参数 + * @return 资源列表 + */ + @Override + public R> list(ResourceQueryParam resourceQueryParam) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(ObjectUtils.isNotNull(resourceQueryParam.getServiceId()), Resource.SERVICE_ID, resourceQueryParam.getServiceId()) + .eq(ObjectUtils.isNotNull(resourceQueryParam.getSubsystem()), Resource.SUBSYSTEM, resourceQueryParam.getSubsystem()) + .eq(ObjectUtils.isNotNull(resourceQueryParam.getCategory()), Resource.CATEGORY, resourceQueryParam.getCategory()) + .eq(ObjectUtils.isNotNull(resourceQueryParam.getEnabled()), Resource.ENABLED, resourceQueryParam.getEnabled()) + .eq(StringUtils.isNotBlank(resourceQueryParam.getMethod()), Resource.METHOD, resourceQueryParam.getMethod()) + .like(StringUtils.isNotBlank(resourceQueryParam.getName()), Resource.NAME, resourceQueryParam.getName()) + .like(StringUtils.isNotBlank(resourceQueryParam.getUrl()), Resource.URL, resourceQueryParam.getUrl()); + List resources = resourceServiceBiz.list(wrapper); + List resourceVos = com.mt.wms.core.utils.BeanUtils.copyList(resources, ResourceVo.class); + return successful(resourceVos); + } + + /** + * 获取资源分页列表 + * + * @param resourceQueryParam 资源查询参数 + * @return 资源分页列表 + */ + @Override + public R> page(ResourceQueryParam resourceQueryParam) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(ObjectUtils.isNotNull(resourceQueryParam.getServiceId()), Resource.SERVICE_ID, resourceQueryParam.getServiceId()) + .eq(ObjectUtils.isNotNull(resourceQueryParam.getSubsystem()), Resource.SUBSYSTEM, resourceQueryParam.getSubsystem()) + .eq(ObjectUtils.isNotNull(resourceQueryParam.getCategory()), Resource.CATEGORY, resourceQueryParam.getCategory()) + .eq(ObjectUtils.isNotNull(resourceQueryParam.getEnabled()), Resource.ENABLED, resourceQueryParam.getEnabled()) + .eq(StringUtils.isNotBlank(resourceQueryParam.getMethod()), Resource.METHOD, resourceQueryParam.getMethod()) + .like(StringUtils.isNotBlank(resourceQueryParam.getName()), Resource.NAME, resourceQueryParam.getName()) + .like(StringUtils.isNotBlank(resourceQueryParam.getUrl()), Resource.URL, resourceQueryParam.getUrl()); + IPage page = resourceServiceBiz.page(new Page<>(resourceQueryParam.getCurrent(), resourceQueryParam.getSize()), wrapper); + return successful(new PageVo<>(page, ResourceVo.class)); + } + + /** + * 新增资源 + * + * @param resourceParam 资源参数 + * @return 主键 + */ + @Override + public R add(ResourceParam resourceParam) { + Assert.notNull("服务不存在", serviceServiceBiz.getById(resourceParam.getServiceId())); + Resource resource = new Resource(); + BeanUtils.copyProperties(resourceParam, resource); + setCommonField(resource); + resourceServiceBiz.save(resource); + return successful(IdVo.builder().id(resource.getId()).build()); + } + + /** + * 更新资源 + * + * @param resourceParam 资源参数 + * @return 主键 + */ + @Override + public R update(ResourceParam resourceParam) { + Resource resource = resourceServiceBiz.getById(resourceParam.getId()); + Assert.notNull("资源不存在", resource); + Assert.notNull("服务不存在", serviceServiceBiz.getById(resourceParam.getServiceId())); + Resource updateResource = new Resource(); + BeanUtils.copyProperties(resourceParam, updateResource); + setUpdateCommonField(updateResource); + resourceServiceBiz.updateById(updateResource); + return successful(IdVo.builder().id(resource.getId()).build()); + } + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + @Override + public R enabled(EnabledParam enabledParam) { + Resource resource = resourceServiceBiz.getById(enabledParam.getId()); + Assert.notNull("资源不存在", resource); + Resource updateResource = new Resource().setId(enabledParam.getId()); + updateResource.setEnabled(enabledParam.getEnabled()); + setUpdateCommonField(updateResource); + resourceServiceBiz.updateById(updateResource); + return successful(IdVo.builder().id(resource.getId()).build()); + } + + /** + * 删除资源 + * + * @param idParam 主键参数 + * @return 主键 + */ + @Override + public R delete(IdParam idParam) { + Resource resource = resourceServiceBiz.getById(idParam.getId()); + Assert.notNull("资源不存在", resource); + if (resource.getSubsystem() == null || resource.getSubsystem().equals(SubsystemEnum.COMMON.getValue())) { + Assert.eqZero(sysMenuResourceServiceBiz.count(new QueryWrapper().eq(SysMenuResource.RESOURCE_ID, resource.getId())), "资源还关联菜单"); + } else if (resource.getSubsystem().equals(SubsystemEnum.PLATFORM.getValue())) { + Assert.eqZero(sysMenuResourceServiceBiz.count(new QueryWrapper().eq(SysMenuResource.RESOURCE_ID, resource.getId())), "资源还关联菜单"); + } + resourceServiceBiz.removeById(idParam.getId()); + return successful(IdVo.builder().id(resource.getId()).build()); + } + + /** + * 批量删除资源 + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + @Override + public R delete(IdListParam idListParam) { + return null; + } +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/RoleServiceImpl.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/RoleServiceImpl.java new file mode 100644 index 0000000..8319140 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/RoleServiceImpl.java @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mt.wms.core.api.Assert; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.dal.entity.SysRole; +import com.mt.wms.core.dal.entity.SysRoleMenu; +import com.mt.wms.core.dal.entity.SysUserRole; +import com.mt.wms.core.dal.service.*; +import com.mt.wms.core.enums.WhetherEnum; +import com.mt.wms.core.errorcode.ApiErrorCode; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.mapper.RoleMapper; +import com.mt.wms.upms.params.SysRoleParam; +import com.mt.wms.upms.params.SysRoleQueryParam; +import com.mt.wms.upms.params.UserRoleParam; +import com.mt.wms.upms.service.RoleService; +import com.mt.wms.upms.vo.SysRoleVo; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.RandomUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 角色服务实现类 + *

+ * //TODO 需要完善删除角色逻辑 + *

+ * + * @author jiff + * @date 2018/11/23 + * @since 1.0 + */ +@Service +@Transactional +public class RoleServiceImpl extends BaseService implements RoleService { + private final SysUserServiceBiz sysUserServiceBiz; + private final SysOrgServiceBiz sysOrgServiceBiz; + private final SysRoleServiceBiz sysRoleServiceBiz; + private final SysUserRoleServiceBiz sysUserRoleServiceBiz; + private final SysRoleMenuServiceBiz sysRoleMenuServiceBiz; + private final RoleMapper roleMapper; + + @Autowired + public RoleServiceImpl(SysUserServiceBiz sysUserServiceBiz, SysOrgServiceBiz sysOrgServiceBiz, SysRoleServiceBiz sysRoleServiceBiz, SysUserRoleServiceBiz sysUserRoleServiceBiz, SysRoleMenuServiceBiz sysRoleMenuServiceBiz, RoleMapper roleMapper) { + this.sysUserServiceBiz = sysUserServiceBiz; + this.sysOrgServiceBiz = sysOrgServiceBiz; + this.sysRoleServiceBiz = sysRoleServiceBiz; + this.sysUserRoleServiceBiz = sysUserRoleServiceBiz; + this.sysRoleMenuServiceBiz = sysRoleMenuServiceBiz; + this.roleMapper = roleMapper; + } + + /** + * 获取角色 + * + * @param idParam 主键参数 + * @return 角色 + */ + @Override + public R get(IdParam idParam) { + SysRole sysRole = sysRoleServiceBiz.getById(idParam.getId()); + Assert.notNull("角色不存在", sysRole); + SysRoleVo sysRoleVo = SysRoleVo.builder().build(); + BeanUtils.copyProperties(sysRole, sysRoleVo); + return successful(sysRoleVo); + } + + /** + * 获取角色列表 + * + * @param sysRoleQueryParam 角色查询参数 + * @return 角色列表 + */ + @Override + public R> list(SysRoleQueryParam sysRoleQueryParam) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(ObjectUtils.isNotNull(sysRoleQueryParam.getCategory()), SysRole.CATEGORY, sysRoleQueryParam.getCategory()) + .eq(ObjectUtils.isNotNull(sysRoleQueryParam.getEnabled()), SysRole.ENABLED, sysRoleQueryParam.getEnabled()) + .like(StringUtils.isNotBlank(sysRoleQueryParam.getCode()), SysRole.CODE, sysRoleQueryParam.getCode()) + .like(StringUtils.isNotBlank(sysRoleQueryParam.getName()), SysRole.NAME, sysRoleQueryParam.getName()); + List sysRoles = sysRoleServiceBiz.list(wrapper); + List sysRoleVos = com.mt.wms.core.utils.BeanUtils.copyList(sysRoles, SysRoleVo.class); + return successful(sysRoleVos); + } + + /** + * 获取角色分页列表 + * + * @param sysRoleQueryParam 角色查询参数 + * @return 角色分页列表 + */ + @Override + public R> page(SysRoleQueryParam sysRoleQueryParam) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(ObjectUtils.isNotNull(sysRoleQueryParam.getCategory()), SysRole.CATEGORY, sysRoleQueryParam.getCategory()) + .eq(ObjectUtils.isNotNull(sysRoleQueryParam.getEnabled()), SysRole.ENABLED, sysRoleQueryParam.getEnabled()) + .like(StringUtils.isNotBlank(sysRoleQueryParam.getCode()), SysRole.CODE, sysRoleQueryParam.getCode()) + .like(StringUtils.isNotBlank(sysRoleQueryParam.getName()), SysRole.NAME, sysRoleQueryParam.getName()); + IPage page = sysRoleServiceBiz.page(new Page<>(sysRoleQueryParam.getCurrent(), sysRoleQueryParam.getSize()), wrapper); + return successful(new PageVo<>(page, SysRoleVo.class)); + } + + /** + * 新增角色 + * + * @param sysRoleParam 角色参数 + * @return 主键 + */ + @Override + public R add(SysRoleParam sysRoleParam) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(SysRole.CODE, sysRoleParam.getCode()); + Assert.eqZero(sysRoleServiceBiz.count(wrapper), "角色编码已经存在"); + SysRole sysRole = new SysRole(); + BeanUtils.copyProperties(sysRoleParam, sysRole); + sysRole.setManagerFlag(WhetherEnum.NO.getValue()); + sysRole.setPreset(WhetherEnum.NO.getValue()); + setCommonField(sysRole); + sysRoleServiceBiz.save(sysRole); + return successful(IdVo.builder().id(sysRole.getId()).build()); + } + + /** + * 更新角色 + * + * @param sysRoleParam 角色参数 + * @return 主键 + */ + @Override + public R update(SysRoleParam sysRoleParam) { + SysRole sysRole = sysRoleServiceBiz.getById(sysRoleParam.getId()); + //修改角色编码需要检验新编码是否已存在 + if (!sysRole.getCode().equals(sysRoleParam.getCode())) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(SysRole.CODE, sysRoleParam.getCode()); + Assert.eqZero(sysRoleServiceBiz.count(wrapper), "角色编码已经存在"); + } + //修改角色分类需要检验角色是否已经关联菜单 + if (!sysRole.getCategory().equals(sysRoleParam.getCategory())) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(SysRoleMenu.ROLE_ID, sysRoleParam.getId()); + Assert.eqZero(sysRoleMenuServiceBiz.count(wrapper), "角色已关联菜单信息,不许修改角色分类"); + } + SysRole updateSysRole = new SysRole(); + BeanUtils.copyProperties(sysRoleParam, updateSysRole); + setUpdateCommonField(updateSysRole); + sysRoleServiceBiz.updateById(updateSysRole); + return successful(IdVo.builder().id(sysRole.getId()).build()); + } + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + @Override + public R enabled(EnabledParam enabledParam) { + SysRole sysRole = sysRoleServiceBiz.getById(enabledParam.getId()); + if (sysRole == null) { + return failed("角色不存在"); + } + if (!enabledParam.getEnabled().equals(sysRole.getEnabled())) { + SysRole updateSysRole = new SysRole().setId(sysRole.getId()); + updateSysRole.setEnabled(enabledParam.getEnabled()); + setUpdateCommonField(updateSysRole); + sysRoleServiceBiz.updateById(updateSysRole); + } + return successful(IdVo.builder().id(sysRole.getId()).build()); + } + + /** + * 删除角色 + * + * @param idParam 主键参数 + * @return 主键 + */ + @Override + public R delete(IdParam idParam) { + SysRole sysRole = sysRoleServiceBiz.getById(idParam.getId()); + if (sysRole == null) { + return failed("角色不存在"); + } + //检查角色下是否还有用户 + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq(SysUserRole.ROLE_ID, sysRole.getId()); + Assert.eqZero(sysUserRoleServiceBiz.count(wrapper), "该角色下还有用户"); + //删除角色菜单关系 + sysRoleMenuServiceBiz.remove(new QueryWrapper().eq(SysRoleMenu.ROLE_ID, idParam.getId())); + //使用更新方式删除,需要把code设置为历史code(后面跟随机数) + SysRole updateSysRole = new SysRole().setId(sysRole.getId()); + updateSysRole.setCode(sysRole.getCode() + "_" + RandomUtils.nextInt()); + updateSysRole.setValid(WhetherEnum.NO.getValue()); + setUpdateCommonField(updateSysRole); + sysRoleServiceBiz.updateById(updateSysRole); + //更新时逻辑删除字段没有更新,需要再调用一次删除操作 + sysRoleServiceBiz.removeById(updateSysRole.getId()); + return successful(IdVo.builder().id(sysRole.getId()).build()); + } + + /** + * 批量删除角色 + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + @Override + public R delete(IdListParam idListParam) { + return null; + } + + /** + * 保存用户角色 + * + * @param userRoleParam 用户角色参数 + * @return 主键列表 + */ + @Override + public R saveUserRole(UserRoleParam userRoleParam) { + Long userId = userRoleParam.getUserId(); + Assert.notNull(ApiErrorCode.USER_NON_EXISTENT, sysUserServiceBiz.getById(userId)); + //检查设置的角色是否都存在 + List roleIds = userRoleParam.getRoleIds(); + if (CollectionUtils.isNotEmpty(roleIds)) { + Collection roles = sysRoleServiceBiz.listByIds(roleIds); + if (roleIds.size() != roles.size()) { + return failed("角色不存在"); + } + } + //先删除原有的用户角色关系 + sysUserRoleServiceBiz.remove(new QueryWrapper().eq(SysUserRole.USER_ID, userId)); + if (CollectionUtils.isNotEmpty(roleIds)) { + List userRoles = roleIds.stream().map(roleId -> setCommonField(new SysUserRole().setUserId(userId).setRoleId(roleId))) + .collect(Collectors.toList()); + sysUserRoleServiceBiz.saveBatch(userRoles); + return successful(IdListVo.builder().ids(userRoles.stream().map(SysUserRole::getId).collect(Collectors.toList())).build()); + } + + return successful(null); + } + + /** + * 获取用户角色列表 + * + * @param idParam 主键参数 + * @return 角色列表 + */ + @Override + public R> listByUser(IdParam idParam) { + List sysRoleVos = roleMapper.listByUser(idParam.getId()); + return successful(sysRoleVos); + } +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/UpmsServiceImpl.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/UpmsServiceImpl.java new file mode 100644 index 0000000..708b25c --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/UpmsServiceImpl.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mt.wms.core.api.Assert; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.dal.entity.SysOrg; +import com.mt.wms.core.dal.entity.SysUser; +import com.mt.wms.core.dal.service.SysOrgServiceBiz; +import com.mt.wms.core.dal.service.SysUserServiceBiz; +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.dto.Permission; +import com.mt.wms.core.enums.WhetherEnum; +import com.mt.wms.core.errorcode.ApiErrorCode; +import com.mt.wms.core.utils.PasswordUtil; +import com.mt.wms.core.utils.TreeUtil; +import com.mt.wms.core.vo.LoginUserVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.core.vo.UserMenuVo; +import com.mt.wms.upms.mapper.MenuMapper; +import com.mt.wms.upms.mapper.ResourceMapper; +import com.mt.wms.upms.service.UpmsService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpMethod; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * 通用权限服务实现类 + * + * @author jiff + * @date 2018-11-27 + * @since 1.0 + */ +@Service +@Transactional +public class UpmsServiceImpl extends BaseService implements UpmsService { + private final SysUserServiceBiz sysUserServiceBiz; + private final SysOrgServiceBiz sysOrgServiceBiz; + private final MenuMapper menuMapper; + private final ResourceMapper resourceMapper; + + @Autowired + public UpmsServiceImpl(SysUserServiceBiz sysUserServiceBiz, SysOrgServiceBiz sysOrgServiceBiz, MenuMapper menuMapper, ResourceMapper resourceMapper) { + this.sysUserServiceBiz = sysUserServiceBiz; + this.sysOrgServiceBiz = sysOrgServiceBiz; + this.menuMapper = menuMapper; + this.resourceMapper = resourceMapper; + } + + /** + * 用户登录 + * + * @param mobile 手机号码 + * @param password 密码 + * @return 登录用户 + */ + @Override + public R login(String mobile, String password) { + Assert.notNull(ApiErrorCode.INVALID_PARAMETER, mobile, password); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(SysUser.MOBILE, mobile); + SysUser user = sysUserServiceBiz.getOne(wrapper); + if (user == null) { + return failed(ApiErrorCode.USER_NON_EXISTENT); + } + if (WhetherEnum.NO.getValue().equals(user.getEnabled())) { + return failed(ApiErrorCode.USER_DISABLED); + } + String userPassword = user.getPassword(); + if (userPassword.equals(PasswordUtil.encode(password, user.getNonceStr()))) { + return successful(LoginUser.builder() + .userId(user.getId()).mobile(user.getMobile()).userName(user.getName()) + .orgId(user.getOrgId()) + .userType(LoginUser.USER_TYPE_PLATFORM).build()); + } + return failed(ApiErrorCode.USER_NON_EXISTENT_OR_INVALID_PASSWORD); + } + + /** + * 退出登录 + * + * @return 处理结果 + */ + @Override + public R logout() { + return successful(null); + } + + /** + * 获取登录用户信息 + * + * @param mobile 手机号码 + * @return 登录用户 + */ + @Override + public R getLoginUser(String mobile) { + Assert.notNull(ApiErrorCode.INVALID_PARAMETER, mobile); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(SysUser.MOBILE, mobile); + SysUser user = sysUserServiceBiz.getOne(wrapper); + if (user == null) { + return failed(ApiErrorCode.USER_NON_EXISTENT); + } + if (WhetherEnum.NO.getValue().equals(user.getEnabled())) { + return failed(ApiErrorCode.USER_DISABLED); + } + return successful(LoginUser.builder() + .userId(user.getId()).mobile(user.getMobile()).userName(user.getName()) + .orgId(user.getOrgId()) + .userType(LoginUser.USER_TYPE_PLATFORM).build()); + } + + /** + * 获取登录用户信息 + * + * @return 登录用户 + */ + @Override + public R getLoginUserVo() { + LoginUser loginUser = getLoginUser(); + LoginUserVo loginUserVo = LoginUserVo.builder().build(); + BeanUtils.copyProperties(loginUser, loginUserVo); + SysOrg org = sysOrgServiceBiz.getById(loginUser.getOrgId()); + if (org != null) { + loginUserVo.setOrgName(org.getName()); + } + List userMenuVos = menuMapper.listByUser(loginUser.getUserId(), loginUser.getAppType()); + loginUserVo.setMenus(TreeUtil.toTree(userMenuVos)); + return successful(loginUserVo); + } + + /** + * 获取用户权限列表 + * + * @return 权限列表 + */ + @Override + public List getPermissions() { + //TODO 后续完善权限数据 + LoginUser loginUser = getLoginUser(); + List permissions = new ArrayList<>(); + permissions.add(Permission.builder().url("/**").method(HttpMethod.GET.name()).build()); + permissions.add(Permission.builder().url("/**").method(HttpMethod.POST.name()).build()); +// List permissions1 = resourceMapper.listByUser(loginUser.getUserId(), loginUser.getAppType()); + return permissions; + } +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/UserServiceImpl.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..9405e5e --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/service/impl/UserServiceImpl.java @@ -0,0 +1,409 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.dal.entity.SysOrg; +import com.mt.wms.core.dal.entity.SysUser; +import com.mt.wms.core.dal.entity.SysUserRole; +import com.mt.wms.core.dal.service.SysOrgServiceBiz; +import com.mt.wms.core.dal.service.SysUserRoleServiceBiz; +import com.mt.wms.core.dal.service.SysUserServiceBiz; +import com.mt.wms.core.enums.WhetherEnum; +import com.mt.wms.core.errorcode.ApiErrorCode; +import com.mt.wms.core.params.EnabledParam; +import com.mt.wms.core.params.IdListParam; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.utils.PasswordUtil; +import com.mt.wms.core.vo.IdListVo; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.mapper.UserMapper; +import com.mt.wms.upms.params.*; +import com.mt.wms.upms.service.UserService; +import com.mt.wms.upms.vo.SysUserVo; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.RandomUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * 用户服务实现类 + * + * @author jiff + * @date 2018/11/14 + * @since 1.0 + */ +@Slf4j +@Service("upmsUserService") +@Transactional +public class UserServiceImpl extends BaseService implements UserService { + @Autowired + private SysUserServiceBiz sysUserServiceBiz; + @Autowired + private SysOrgServiceBiz sysOrgServiceBiz; + + @Autowired + private SysUserRoleServiceBiz sysUserRoleServiceBiz; + + @Autowired + private UserMapper userMapper; + @Autowired + private MessageSource messageSource; + + + /** + * 获取用户 + * + * @param idParam 主键参数 + * @return 用户 + */ + @Override + public R get(IdParam idParam) { + SysUser sysUser = sysUserServiceBiz.getById(idParam.getId()); + if (sysUser == null) { + return failed(ApiErrorCode.USER_NON_EXISTENT); + } + if (!hasPermission(sysUser)) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + SysUserVo sysUserVo = SysUserVo.builder().build(); + BeanUtils.copyProperties(sysUser, sysUserVo); + + SysOrg org = sysOrgServiceBiz.getById(sysUser.getOrgId()); + if (org != null) { + sysUserVo.setOrgName(org.getName()); + } + return successful(sysUserVo); + } + + /** + * 获取用户列表 + * + * @param sysUserQueryParam 用户查询参数 + * @return 用户列表 + */ + @Override + public R> list(SysUserQueryParam sysUserQueryParam) { + SysOrg org = null; + if (sysUserQueryParam.getOrgId() != null) { + org = sysOrgServiceBiz.getById(sysUserQueryParam.getOrgId()); + if (!hasPermission(org)) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + } + //未指定组织使用当前登录用户所在组织 + if (org == null) { + org = sysOrgServiceBiz.getById(getLoginUser().getOrgId()); + } + //未限定只查询当前组织用户则使用家谱ID查询 + if (sysUserQueryParam.getOrgScope() == null || sysUserQueryParam.getOrgScope().equals(WhetherEnum.NO.getValue())) { + sysUserQueryParam.setGenealogyId(org.getGenealogyId()); + sysUserQueryParam.setOrgId(null); + } else { + sysUserQueryParam.setOrgId(org.getId()); + } + List sysUserVos = userMapper.listByOrg(sysUserQueryParam); + return successful(sysUserVos); + } + + /** + * 获取用户分页列表 + * + * @param sysUserQueryParam 用户查询参数 + * @return 用户分页列表 + */ + @Override + public R> page(SysUserQueryParam sysUserQueryParam) { + SysOrg org = null; + if (sysUserQueryParam.getOrgId() != null) { + org = sysOrgServiceBiz.getById(sysUserQueryParam.getOrgId()); + if (!hasPermission(org)) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + } + //未指定组织使用当前登录用户所在组织 + if (org == null) { + org = sysOrgServiceBiz.getById(getLoginUser().getOrgId()); + } + //未限定只查询当前组织用户则使用家谱ID查询 + if (sysUserQueryParam.getOrgScope() == null || sysUserQueryParam.getOrgScope().equals(WhetherEnum.NO.getValue())) { + sysUserQueryParam.setGenealogyId(org.getGenealogyId()); + sysUserQueryParam.setOrgId(null); + } else { + sysUserQueryParam.setOrgId(org.getId()); + } + IPage page = new Page<>(sysUserQueryParam.getCurrent(), sysUserQueryParam.getSize()); + List sysUserVos = userMapper.listByOrg(page, sysUserQueryParam); + page.setRecords(sysUserVos); + return successful(page); + } + + /** + * 新增用户 + * + * @param sysUserParam 用户参数 + * @return 主键 + */ + @Override + public R add(SysUserParam sysUserParam) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(SysUser.MOBILE, sysUserParam.getMobile()); + SysUser sysUser = sysUserServiceBiz.getOne(wrapper); + if (sysUser != null) { + return failed(ApiErrorCode.USER_EXISTENT); + } + SysOrg sysOrg = sysOrgServiceBiz.getById(sysUserParam.getOrgId()); + if (sysOrg == null) { + return failed("组织不存在"); + } + + //创建系统用户 + sysUser = new SysUser(); + BeanUtils.copyProperties(sysUserParam, sysUser); + sysUser.setAccount(sysUser.getMobile()); + String nonceStr = PasswordUtil.genNonce(); + String encodePassword = PasswordUtil.encode(sysUser.getPassword(), nonceStr); + sysUser.setPassword(encodePassword); + sysUser.setNonceStr(nonceStr); + + setCommonField(sysUser); + sysUserServiceBiz.save(sysUser); + + return successful(IdVo.builder().id(sysUser.getId()).build()); + } + + /** + * 更新用户 + * + * @param sysUserParam 用户参数 + * @return 主键 + */ + @Override + public R update(SysUserParam sysUserParam) { + SysUser sysUser = sysUserServiceBiz.getById(sysUserParam.getId()); + if (sysUser == null) { + return failed(ApiErrorCode.USER_NON_EXISTENT); + } + SysOrg sysOrg = sysOrgServiceBiz.getById(sysUserParam.getOrgId()); + if (sysOrg == null) { + return failed("组织不存在"); + } + if (!hasPermission(sysUser)) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + SysUser updateSysUser = new SysUser().setId(sysUser.getId()); + BeanUtils.copyProperties(sysUserParam, updateSysUser, "mobile", "password"); + setUpdateCommonField(updateSysUser); + sysUserServiceBiz.updateById(updateSysUser); + return successful(IdVo.builder().id(sysUser.getId()).build()); + } + + /** + * 启用停用 + * + * @param enabledParam 启停参数 + * @return 主键 + */ + @Override + public R enabled(EnabledParam enabledParam) { + SysUser sysUser = sysUserServiceBiz.getById(enabledParam.getId()); + if (sysUser == null) { + return failed(ApiErrorCode.USER_NON_EXISTENT); + } + if (!hasPermission(sysUser)) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + if (!enabledParam.getEnabled().equals(sysUser.getEnabled())) { + SysUser updateSysUser = new SysUser().setId(sysUser.getId()); + updateSysUser.setEnabled(enabledParam.getEnabled()); + setUpdateCommonField(updateSysUser); + sysUserServiceBiz.updateById(updateSysUser); + } + return successful(IdVo.builder().id(sysUser.getId()).build()); + } + + + /** + * 修改密码 + * + * @param modifyPasswordParam 修改密码参数 + * @return 主键 + */ + @Override + public R modifyPassword(ModifyPasswordParam modifyPasswordParam) { + SysUser sysUser = sysUserServiceBiz.getById(getLoginUser().getUserId()); + if (sysUser == null) { + return failed(ApiErrorCode.USER_NON_EXISTENT); + } + if (!sysUser.getPassword().equals(PasswordUtil.encode(modifyPasswordParam.getPassword(), sysUser.getNonceStr()))) { + return failed("原密码错误"); + } + + SysUser updateSysUser = new SysUser().setId(sysUser.getId()); + String nonceStr = PasswordUtil.genNonce(); + String encodePassword = PasswordUtil.encode(modifyPasswordParam.getNewPassword(), nonceStr); + updateSysUser.setPassword(encodePassword); + updateSysUser.setNonceStr(nonceStr); + setUpdateCommonField(updateSysUser); + sysUserServiceBiz.updateById(updateSysUser); + return successful(IdVo.builder().id(sysUser.getId()).build()); + } + + /** + * 重置密码 + * + * @param resetPasswordParam 重新密码参数 + * @return 主键 + */ + @Override + public R resetPassword(ResetPasswordParam resetPasswordParam) { + SysUser sysUser = sysUserServiceBiz.getById(resetPasswordParam.getId()); + if (sysUser == null) { + return failed(ApiErrorCode.USER_NON_EXISTENT); + } + if (!hasPermission(sysUser)) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + SysUser updateSysUser = new SysUser().setId(sysUser.getId()); + String nonceStr = PasswordUtil.genNonce(); + String encodePassword = PasswordUtil.encode(resetPasswordParam.getPassword(), nonceStr); + updateSysUser.setPassword(encodePassword); + updateSysUser.setNonceStr(nonceStr); + setUpdateCommonField(updateSysUser); + sysUserServiceBiz.updateById(updateSysUser); + return successful(IdVo.builder().id(sysUser.getId()).build()); + } + + /** + * 找回密码 + * + * @param findPasswordParam 找回密码参数 + * @return 主键 + */ + @Override + public R findPassword(FindPasswordParam findPasswordParam) { + return null; + } + + + /** + * 删除用户 + * + * @param idParam 主键参数 + * @return 主键 + */ + @Override + public R delete(IdParam idParam) { + SysUser sysUser = sysUserServiceBiz.getById(idParam.getId()); + if (sysUser == null) { + return failed(ApiErrorCode.USER_NON_EXISTENT); + } + if (!hasPermission(sysUser)) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + //删除用户角色关系 + sysUserRoleServiceBiz.remove(new QueryWrapper().eq(SysUserRole.USER_ID, sysUser.getId())); + //使用更新方式删除,需要把mobile设置为历史mobile(后面跟随机数) + SysUser updateSysUser = new SysUser().setId(sysUser.getId()); + updateSysUser.setMobile(sysUser.getMobile() + "_" + RandomUtils.nextInt()); + updateSysUser.setValid(WhetherEnum.NO.getValue()); + setUpdateCommonField(updateSysUser); + sysUserServiceBiz.updateById(updateSysUser); + //更新时逻辑删除字段没有更新,需要再调用一次删除操作 + sysUserServiceBiz.removeById(idParam.getId()); + return successful(IdVo.builder().id(sysUser.getId()).build()); + } + + /** + * 批量删除用户 + * + * @param idListParam 主键列表参数 + * @return 主键列表 + */ + @Override + public R delete(IdListParam idListParam) { + Collection sysUsers = sysUserServiceBiz.listByIds(idListParam.getIds()); + if (CollectionUtils.isEmpty(sysUsers)) { + return failed(ApiErrorCode.USER_NON_EXISTENT); + } + for (SysUser sysUser : sysUsers) { + if (!hasPermission(sysUser)) { + return failed(ApiErrorCode.FORBIDDEN_DATA); + } + } + List updateSysUsers = new ArrayList<>(sysUsers.size()); + for (SysUser sysUser : sysUsers) { + //删除用户角色关系 + sysUserRoleServiceBiz.remove(new QueryWrapper().eq(SysUserRole.USER_ID, sysUser.getId())); + //使用更新方式删除,需要把mobile设置为历史mobile(后面跟随机数) + SysUser updateSysUser = new SysUser().setId(sysUser.getId()); + updateSysUser.setMobile(sysUser.getMobile() + "_" + RandomUtils.nextInt()); + updateSysUser.setValid(WhetherEnum.NO.getValue()); + setUpdateCommonField(updateSysUser); + updateSysUsers.add(updateSysUser); + } + sysUserServiceBiz.updateBatchById(updateSysUsers); + //更新时逻辑删除字段没有更新,需要再调用一次删除操作 + sysUserServiceBiz.removeByIds(idListParam.getIds()); + return successful(IdListVo.builder().ids(idListParam.getIds()).build()); + } + + + /** + * 判断登录用户是否有修改该用户的权限,主要基于登录用户和被修改用户是否归属同一组织或上下级组织关系 + * + * @param sysUser 被修改的用户 + * @return true允许修改,否则不允许 + */ + private boolean hasPermission(SysUser sysUser) { + if (sysUser.getOrgId() == null) { + return false; + } + SysOrg sysOrg = sysOrgServiceBiz.getById(sysUser.getOrgId()); + if (sysOrg == null) { + return false; + } + return hasPermission(sysOrg); + } + + /** + * 判断登录用户是否有修改该组织的权限,主要基于登录用户和被修改组织是否归属同一组织或上下级组织关系 + * + * @param sysOrg 被修改的用户 + * @return true允许修改,否则不允许 + */ + private boolean hasPermission(SysOrg sysOrg) { + if (sysOrg == null) { + return false; + } + Long loginOrgId = getLoginUser().getOrgId(); + if (loginOrgId == null) { + return false; + } + SysOrg loginSysOrg = sysOrgServiceBiz.getById(loginOrgId); + if (loginSysOrg == null) { + return false; + } + if (StringUtils.isAnyBlank(sysOrg.getGenealogyId(), loginSysOrg.getGenealogyId())) { + return false; + } + return sysOrg.getGenealogyId().startsWith(loginSysOrg.getGenealogyId()); + } + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/MenuResourceVo.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/MenuResourceVo.java new file mode 100644 index 0000000..d1d3860 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/MenuResourceVo.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.vo; + +import com.mt.wms.core.enums.HttpMethodEnum; +import com.mt.wms.core.enums.ResourceCategoryEnum; +import com.mt.wms.core.validator.constraints.Enum; +import com.mt.wms.core.vo.CommonVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + *

+ * 菜单资源视图对象 + *

+ * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "菜单资源视图对象", description = "用于查询菜单资源信息") +public class MenuResourceVo extends CommonVo implements PageVo.ConvertVo { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键", required = true, example = "1") + private Long id; + + /** + * 资源ID + */ + @ApiModelProperty(value = "资源ID", required = true, example = "1") + @NotNull(message = "资源ID不能为空") + private Long resourceId; + + /** + * 服务ID + */ + @ApiModelProperty(value = "服务ID", required = true, example = "1") + @NotNull(message = "服务ID不能为空") + private Long serviceId; + + /** + * 名称 + */ + @ApiModelProperty(value = "名称", required = true, example = "新增资源") + @NotBlank(message = "名称不能为空") + private String name; + + /** + * 请求地址,可以用于前端ajax调用,后端用于做权限控制 + */ + @ApiModelProperty(value = "url", required = true, example = "/platform-upms/resource/add") + @NotBlank(message = "请求地址不能为空") + private String url; + + /** + * 请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE + */ + @ApiModelProperty(value = "请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE", required = true, example = "post") + @NotBlank(message = "请求方法不能为空") + @Enum(message = "非法的请求类型", target = {HttpMethodEnum.class}) + private String method; + + /** + * 子系统:0、common,1、platform,2、partner,3、hospital,4、patient + */ + @ApiModelProperty("子系统:0、common,1、platform,2、partner,3、hospital,4、patient") + private Integer subsystem; + + /** + * 分类:0、common,1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "分类:0、common,1、pc,2、app,3、wechat,4、miniapp", required = true, example = "0") + @NotNull(message = "资源类型不能为空") + @Enum(message = "非法的资源类型", target = {ResourceCategoryEnum.class}) + private Integer category; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/MenuVo.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/MenuVo.java new file mode 100644 index 0000000..4e84151 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/MenuVo.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.vo; + +import com.mt.wms.core.base.ITree; +import com.mt.wms.core.enums.MenuCategoryEnum; +import com.mt.wms.core.enums.MenuTypeEnum; +import com.mt.wms.core.validator.constraints.Enum; +import com.mt.wms.core.vo.CommonVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + *

+ * 菜单表 + *

+ * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "菜单视图对象", description = "用于查询菜单信息") +public class MenuVo extends CommonVo implements PageVo.ConvertVo, ITree { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键", required = true, example = "1") + private Long id; + + /** + * 父菜单ID + */ + @ApiModelProperty(value = "父菜单ID", required = true, example = "0") + @NotNull(message = "父菜单ID不能为空") + private Long parentId; + + /** + * 父菜单名称 + */ + @ApiModelProperty(value = "父菜单名称,再获取单个菜单信息时会返回", required = false, example = "系统管理") + private String parentName; + + /** + * 菜单编码 + */ + @ApiModelProperty(value = "菜单编码", example = "menu") + private String code; + + /** + * 菜单名称 + */ + @ApiModelProperty(value = "菜单名称", required = true, example = "菜单管理") + @NotBlank(message = "菜单名称不能为空") + private String name; + + /** + * 菜单图标 + */ + @ApiModelProperty("菜单图标") + private String icon; + + /** + * 链接地址,可以是页面地址,也可以是函数事件 + */ + @ApiModelProperty("链接地址,可以是页面地址,也可以是函数事件") + private String href; + + /** + * 请求地址,可以用于前端ajax调用,后端用于做权限控制 + */ + @ApiModelProperty("请求地址,可以用于前端ajax调用,后端用于做权限控制") + private String url; + + /** + * 请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE + */ + @ApiModelProperty(value = "请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE", example = "post") + private String method; + + /** + * 权限,可以有多个,用逗号分隔,可用于第三方权限框架扩展 + */ + @ApiModelProperty("权限,可以有多个,用逗号分隔,可用于第三方权限框架扩展") + private String permission; + + /** + * 分类:1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "分类:1、pc,2、app,3、wechat,4、miniapp", required = true, example = "1") + @NotNull(message = "菜单分类不能为空") + @Enum(message = "非法的菜单分类", target = {MenuCategoryEnum.class}) + private Integer category; + + + /** + * 类型:1、module,2、menu,3、button + */ + @ApiModelProperty(value = "类型:1、module,2、menu,3、button", required = true, example = "1") + @NotNull(message = "菜单类型不能为空") + @Enum(message = "非法的菜单类型", target = {MenuTypeEnum.class}) + private Integer type; + + /** + * 显示顺序 + */ + @ApiModelProperty(value = "显示顺序", example = "1") + private Integer orderNum; + + /** + * 角色是否分配该菜单:true、已分配,false、未分配 + */ + @ApiModelProperty(value = "角色是否分配该菜单:true、已分配,false、未分配,用于根据角色获取所有菜单", required = false, example = "true") + private boolean checked; + + /** + * 子列表 + */ + @ApiModelProperty(value = "子列表,用于获取菜单树时才有数据", required = false) + private List children; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/ResourceVo.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/ResourceVo.java new file mode 100644 index 0000000..c3a8ca9 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/ResourceVo.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.vo; + +import com.mt.wms.core.enums.HttpMethodEnum; +import com.mt.wms.core.enums.ResourceCategoryEnum; +import com.mt.wms.core.validator.constraints.Enum; +import com.mt.wms.core.vo.CommonVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + *

+ * 资源表 + *

+ * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "资源视图对象", description = "用于查询资源信息") +public class ResourceVo extends CommonVo implements PageVo.ConvertVo { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键", required = true, example = "1") + private Long id; + + /** + * 服务ID + */ + @ApiModelProperty(value = "服务ID", required = true, example = "1") + @NotNull(message = "服务ID不能为空") + private Long serviceId; + + /** + * 名称 + */ + @ApiModelProperty(value = "名称", required = true, example = "新增资源") + @NotBlank(message = "名称不能为空") + private String name; + + /** + * 请求地址,可以用于前端ajax调用,后端用于做权限控制 + */ + @ApiModelProperty(value = "url", required = true, example = "/platform-upms/resource/add") + @NotBlank(message = "请求地址不能为空") + private String url; + + /** + * 请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE + */ + @ApiModelProperty(value = "请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE", required = true, example = "post") + @NotBlank(message = "请求方法不能为空") + @Enum(message = "非法的请求类型", target = {HttpMethodEnum.class}) + private String method; + + /** + * 子系统:0、common,1、platform,2、partner,3、hospital,4、patient + */ + @ApiModelProperty("子系统:0、common,1、platform,2、partner,3、hospital,4、patient") + private Integer subsystem; + + /** + * 分类:0、common,1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "分类:0、common,1、pc,2、app,3、wechat,4、miniapp", required = true, example = "0") + @NotNull(message = "资源类型不能为空") + @Enum(message = "非法的资源类型", target = {ResourceCategoryEnum.class}) + private Integer category; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/ServiceVo.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/ServiceVo.java new file mode 100644 index 0000000..5dfa079 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/ServiceVo.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.vo; + +import com.mt.wms.core.vo.CommonVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 服务表 + *

+ * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "服务视图对象", description = "用于查询服务信息") +public class ServiceVo extends CommonVo implements PageVo.ConvertVo { + + private static final long serialVersionUID = 1L; + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键", required = true, example = "1") + private Long id; + + /** + * 编码 + */ + @ApiModelProperty(value = "编码", required = true, example = "lis-passport") + private String code; + + /** + * 名称 + */ + @ApiModelProperty(value = "名称", required = true, example = "统一认证服务") + private String name; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/SysOrgVo.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/SysOrgVo.java new file mode 100644 index 0000000..3351522 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/SysOrgVo.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.vo; + +import com.mt.wms.core.base.ITree; +import com.mt.wms.core.vo.CommonVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + *

+ * 系统组织表 + *

+ * + * @author jiff + * @date 2018/11/9 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "组织视图对象", description = "用于查询组织信息") +public class SysOrgVo extends CommonVo implements PageVo.ConvertVo, ITree { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键", required = true, example = "1") + @NotNull(message = "组织ID不能为空") + private Long id; + + /** + * 区域ID + */ + @ApiModelProperty(value = "区域ID", example = "0") + @NotNull(message = "区域不能为空") + private Long regionId; + /** + * 区域名称 + */ + @ApiModelProperty(value = "区域名称", example = "中国") + private String regionName; + + /** + * 父组织ID + */ + @ApiModelProperty(value = "父组织ID", example = "0") + @NotNull(message = "父组织不能为空") + private Long parentId; + + /** + * 家谱ID,格式:/rootId/.../grandfatherId/parentId/id + */ + @ApiModelProperty(value = "家谱ID,格式:/rootId/.../grandfatherId/parentId/id", example = "/0/1") + private String genealogyId; + + /** + * 名称 + */ + @ApiModelProperty(value = "名称", example = "销售部") + @NotBlank(message = "名称不能为空") + private String name; + + /** + * 联系人 + */ + @ApiModelProperty(value = "联系人", example = "jiff") + private String contact; + + /** + * 联系电话 + */ + @ApiModelProperty(value = "联系电话", example = "13588441519") + private String phone; + + /** + * 联系地址 + */ + @ApiModelProperty(value = "联系地址", example = "中国人工智能小镇") + private String address; + + /** + * 邮箱 + */ + @ApiModelProperty(value = "邮箱", example = "jiff@ulabcare.com") + @Email + private String email; + + /** + * 选中状态,true:选中,否则未选中 + */ + @ApiModelProperty(value = "选中状态,true:选中,否则未选中", example = "true") + private boolean checked; + + /** + * 子列表 + */ + @ApiModelProperty(value = "子列表,用于获取组织树时才有数据", required = false) + private List children; + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/SysPostVo.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/SysPostVo.java new file mode 100644 index 0000000..4372913 --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/SysPostVo.java @@ -0,0 +1,44 @@ +package com.mt.wms.upms.vo; + +import com.mt.wms.core.base.ITree; +import com.mt.wms.core.vo.CommonVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * @Description: 返回岗位对象 + * @Param: + * @return: + * @Author: tqq + * @Date: 2019/11/11 16:06 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "岗位对象 ", description = "用于返回岗位对象") +public class SysPostVo extends CommonVo implements PageVo.ConvertVo, ITree { + + private static final long serialVersionUID = 1L; + @ApiModelProperty(value = "主键") + private Long id; + @ApiModelProperty(value = "父岗位id") + private Long parentId; + @ApiModelProperty(value = "岗位编码") + private String code; + @ApiModelProperty(value = "岗位名称") + private String name; + @ApiModelProperty("备注") + private String remark; + + @ApiModelProperty(value = "子列表,用于获取岗位树时才有数据", required = false) + private List children; + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/SysRoleVo.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/SysRoleVo.java new file mode 100644 index 0000000..24f17be --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/SysRoleVo.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.vo; + +import com.mt.wms.core.enums.MenuCategoryEnum; +import com.mt.wms.core.validator.constraints.Enum; +import com.mt.wms.core.vo.CommonVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + *

+ * 系统角色表 + *

+ * + * @author jiff + * @date 2018/11/22 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "角色视图对象", description = "用于查询角色信息") +public class SysRoleVo extends CommonVo implements PageVo.ConvertVo { + + private static final long serialVersionUID = 1L; + + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键", required = true, example = "1") + private Long id; + + /** + * 角色编码 + */ + @ApiModelProperty(value = "角色编码", required = true, example = "manager") + @NotBlank(message = "角色编码不能为空") + private String code; + + /** + * 角色名称 + */ + @ApiModelProperty(value = "角色名称", required = true, example = "管理员") + @NotBlank(message = "角色名称不能为空") + private String name; + + /** + * 分类:1、pc,2、app,3、wechat,4、miniapp + */ + @ApiModelProperty(value = "分类:1、pc,2、app,3、wechat,4、miniapp", required = true, example = "1") + @NotNull(message = "角色分类不能为空") + @Enum(message = "非法的角色分类", target = {MenuCategoryEnum.class}) + private Integer category; + + + /** + * 管理角色标志:1 管理角色0 非管理角色,管理角色不允许修改角色菜单关系 + */ + @ApiModelProperty(value = "管理角色标志:1 管理角色0 非管理角色,管理角色不允许修改角色菜单关系", required = true, example = "0") + private Integer managerFlag; + + /** + * 预设角色标志:1 预设 0 非预设 + */ + @ApiModelProperty(value = "预设角色标志:1 预设 0 非预设", required = true, example = "0") + private Integer preset; + + /** + * 用户是否分配该角色:true、已分配,false、未分配 + */ + @ApiModelProperty(value = "用户是否分配该角色:true、已分配,false、未分配,用于根据用户获取所有角色", required = false, example = "true") + private boolean checked; + + +} diff --git a/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/SysUserVo.java b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/SysUserVo.java new file mode 100644 index 0000000..3a5373a --- /dev/null +++ b/6.program/wms-upms/src/main/java/com/mt/wms/upms/vo/SysUserVo.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.vo; + +import com.mt.wms.core.vo.CommonVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.time.LocalDate; + + +/** + *

+ * 系统用户表 + *

+ * + * @author jiff + * @date 2018/11/20 + * @since 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "用户视图对象", description = "用于查询用户信息", parent = CommonVo.class) +public class SysUserVo extends CommonVo implements PageVo.ConvertVo { + + + private static final long serialVersionUID = 1L; + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键", required = true, example = "1") + private Long id; + + + /** + * 统一用户ID + */ + @ApiModelProperty(value = "统一用户ID", required = true, example = "1") + private Long passportUserId; + + /** + * 组织ID + */ + @ApiModelProperty(value = "组织ID", required = true, example = "1") + private Long orgId; + /** + * 组织名称 + */ + @ApiModelProperty(value = "组织名称", required = true, example = "一诺检验") + private String orgName; + + /** + * 用户账号 + */ + @ApiModelProperty(value = "用户账号", example = "13588441519") + private String account; + + /** + * 系统用户手机号 + */ + @ApiModelProperty(value = "用户手机号", example = "13588441519") + private String mobile; + + + /** + * 工号 + */ + @ApiModelProperty(value = "工号", example = "10000") + private String code; + + /** + * 姓名 + */ + @ApiModelProperty(value = "姓名", example = "jiff") + private String name; + + /** + * 生日 + */ + @ApiModelProperty(value = "生日", example = "2018-11-11") + private LocalDate birthday; + + /** + * 系统用户邮箱 + */ + @ApiModelProperty(value = "用户邮箱", example = "jiff@ulabcare.com") + private String email; + + /** + * 性别(1女,2男) + */ + @ApiModelProperty(value = "性别(1女,2男)", example = "1") + private Integer sex; + + +} diff --git a/6.program/wms-upms/src/main/resources/Messages.properties b/6.program/wms-upms/src/main/resources/Messages.properties new file mode 100644 index 0000000..912a380 --- /dev/null +++ b/6.program/wms-upms/src/main/resources/Messages.properties @@ -0,0 +1,5 @@ +# +# Copyright (c) 2018. +# http://www.ulabcare.com +# +#typeMismatch.sysUserParam.birthday=\u751F\u65E5\u683C\u5F0F\u9519\u8BEF \ No newline at end of file diff --git a/6.program/wms-upms/src/main/resources/Messages_zh_CN.properties b/6.program/wms-upms/src/main/resources/Messages_zh_CN.properties new file mode 100644 index 0000000..3459753 --- /dev/null +++ b/6.program/wms-upms/src/main/resources/Messages_zh_CN.properties @@ -0,0 +1,5 @@ +# +# Copyright (c) 2018. +# http://www.ulabcare.com +# +typeMismatch.sysUserParam.birthday=\u751F\u65E5\u683C\u5F0F\u9519\u8BEF \ No newline at end of file diff --git a/6.program/wms-upms/src/main/resources/bootstrap.yml b/6.program/wms-upms/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..7629c3f --- /dev/null +++ b/6.program/wms-upms/src/main/resources/bootstrap.yml @@ -0,0 +1,20 @@ +info: + name: "@project.name@" + description: "@project.description@" + version: "@project.version@" +spring: + application: + name: lis-platform-upms + profiles: + active: @profileActive@ + cloud: + config: + enabled: @spring.cloud.config.enabled@ + label: ${spring.profiles.active} + profile: ${spring.profiles.active} + uri: @spring.cloud.config.uri@ + discovery: + enabled: false + service-id: wms-center-config + username: @spring.security.user.name@ + password: @spring.security.user.password@ \ No newline at end of file diff --git a/6.program/wms-upms/src/main/resources/logback.xml b/6.program/wms-upms/src/main/resources/logback.xml new file mode 100644 index 0000000..79b045b --- /dev/null +++ b/6.program/wms-upms/src/main/resources/logback.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/6.program/wms-upms/src/main/resources/mapper/MenuMapper.xml b/6.program/wms-upms/src/main/resources/mapper/MenuMapper.xml new file mode 100644 index 0000000..264051e --- /dev/null +++ b/6.program/wms-upms/src/main/resources/mapper/MenuMapper.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, + parent_id, + code, + name, + icon, + href, + url, + method, + permission, + category, + type, + level, + order_num, + enabled, + remark, + valid, + creator, + creator_name, + create_time, + updater, + updater_name, + update_time, + version + + + + + + + + diff --git a/6.program/wms-upms/src/main/resources/mapper/ResourceMapper.xml b/6.program/wms-upms/src/main/resources/mapper/ResourceMapper.xml new file mode 100644 index 0000000..72f6c96 --- /dev/null +++ b/6.program/wms-upms/src/main/resources/mapper/ResourceMapper.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, + service_id, + name, + url, + method, + subsystem, + category, + enabled, + remark, + valid, + creator, + creator_name, + create_time, + updater, + updater_name, + update_time, + version + + + + + + diff --git a/6.program/wms-upms/src/main/resources/mapper/RoleMapper.xml b/6.program/wms-upms/src/main/resources/mapper/RoleMapper.xml new file mode 100644 index 0000000..7cb45cf --- /dev/null +++ b/6.program/wms-upms/src/main/resources/mapper/RoleMapper.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, + code, + name, + category, + manager_flag, + preset, + enabled, + remark, + valid, + creator, + creator_name, + create_time, + updater, + updater_name, + update_time, + version + + + + + diff --git a/6.program/wms-upms/src/main/resources/mapper/UserMapper.xml b/6.program/wms-upms/src/main/resources/mapper/UserMapper.xml new file mode 100644 index 0000000..d4e5a1c --- /dev/null +++ b/6.program/wms-upms/src/main/resources/mapper/UserMapper.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, + org_id, + mobile, + password, + code, + name, + birthday, + email, + sex, + enabled, + remark, + valid, + creator, + creator_name, + create_time, + updater, + updater_name, + update_time, + version + + + + + + + diff --git a/6.program/wms-upms/src/test/java/com/mt/wms/upms/LisPlatformUpmsApplicationTest.java b/6.program/wms-upms/src/test/java/com/mt/wms/upms/LisPlatformUpmsApplicationTest.java new file mode 100644 index 0000000..4bacf40 --- /dev/null +++ b/6.program/wms-upms/src/test/java/com/mt/wms/upms/LisPlatformUpmsApplicationTest.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms; + +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * @author jiff + * @date 2018-12-11 + * @since 1.0 + */ +@RunWith(SpringRunner.class) +@SpringBootTest +public class LisPlatformUpmsApplicationTest { + +} \ No newline at end of file diff --git a/6.program/wms-upms/src/test/java/com/mt/wms/upms/controller/UpmsControllerTest.java b/6.program/wms-upms/src/test/java/com/mt/wms/upms/controller/UpmsControllerTest.java new file mode 100644 index 0000000..8bf7935 --- /dev/null +++ b/6.program/wms-upms/src/test/java/com/mt/wms/upms/controller/UpmsControllerTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.controller; + +import com.alibaba.fastjson.JSON; +import com.mt.wms.core.dto.LoginUser; +import com.mt.wms.core.dto.Permission; +import com.mt.wms.upms.LisPlatformUpmsApplicationTest; +import org.hamcrest.Matchers; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; + +import java.util.List; + +/** + * @author jiff + * @date 2018-12-11 + * @since 1.0 + */ + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class UpmsControllerTest extends LisPlatformUpmsApplicationTest { + @Autowired + private TestRestTemplate restTemplate; + + private HttpHeaders httpHeaders = new HttpHeaders(); + + @Before + public void setUp() { + httpHeaders.add(LoginUser.HTTP_HEADER_NAME, JSON.toJSONString(LoginUser.builder().userId(1L).userName("jiff") + .orgId(1L).userType(LoginUser.USER_TYPE_PLATFORM).build())); + } + + @Test + public void getPermissions() { + ParameterizedTypeReference> type = new ParameterizedTypeReference>() { + }; + ResponseEntity> responseEntity = restTemplate.exchange("/upms/getPermissions", HttpMethod.POST, new HttpEntity<>(httpHeaders), type); + Assert.assertThat(responseEntity.getBody().get(0).getUrl(), Matchers.notNullValue()); + } +} \ No newline at end of file diff --git a/6.program/wms-upms/src/test/java/com/mt/wms/upms/mapper/ResourceMapperTest.java b/6.program/wms-upms/src/test/java/com/mt/wms/upms/mapper/ResourceMapperTest.java new file mode 100644 index 0000000..bc26897 --- /dev/null +++ b/6.program/wms-upms/src/test/java/com/mt/wms/upms/mapper/ResourceMapperTest.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.mapper; + +import com.mt.wms.core.dto.Permission; +import com.mt.wms.core.enums.AppTypeEnum; +import com.mt.wms.upms.LisPlatformUpmsApplicationTest; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.Assert; + +import java.util.List; + +/** + * @author jiff + * @date 2018-12-11 + * @since 1.0 + */ +public class ResourceMapperTest extends LisPlatformUpmsApplicationTest { + @Autowired + private ResourceMapper resourceMapper; + + @Test + public void listByUser() { + List permissions = resourceMapper.listByUser(1l, AppTypeEnum.PC.getValue()); + Assert.notEmpty(permissions, "权限为空"); + } +} \ No newline at end of file diff --git a/6.program/wms-upms/src/test/java/com/mt/wms/upms/mapper/UserMapperTest.java b/6.program/wms-upms/src/test/java/com/mt/wms/upms/mapper/UserMapperTest.java new file mode 100644 index 0000000..73582df --- /dev/null +++ b/6.program/wms-upms/src/test/java/com/mt/wms/upms/mapper/UserMapperTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mt.wms.upms.LisPlatformUpmsApplicationTest; +import com.mt.wms.upms.params.SysUserQueryParam; +import com.mt.wms.upms.vo.SysUserVo; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +/** + * @author jiff + * @date 2018-12-11 + * @since 1.0 + */ +public class UserMapperTest extends LisPlatformUpmsApplicationTest { + @Autowired + private UserMapper userMapper; + + @Test + public void listByOrg() { + SysUserQueryParam queryParam = SysUserQueryParam.builder().genealogyId("/1").name("ff").sex(1).build(); + queryParam.setCurrent(1); + queryParam.setSize(10); + IPage page = new Page(queryParam.getCurrent(), queryParam.getSize()); + List sysUserVos = userMapper.listByOrg(page, queryParam); + page.setRecords(sysUserVos); + Assert.assertEquals(page.getRecords(), sysUserVos); + } + +} \ No newline at end of file diff --git a/6.program/wms-upms/src/test/java/com/mt/wms/upms/service/MenuResourceServiceTest.java b/6.program/wms-upms/src/test/java/com/mt/wms/upms/service/MenuResourceServiceTest.java new file mode 100644 index 0000000..a1905ed --- /dev/null +++ b/6.program/wms-upms/src/test/java/com/mt/wms/upms/service/MenuResourceServiceTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service; + +import com.mt.wms.upms.LisPlatformUpmsApplicationTest; +import com.mt.wms.upms.params.MenuResourceQueryParam; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.upms.vo.ResourceVo; +import lombok.extern.slf4j.Slf4j; +import org.hamcrest.Matchers; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @author jiff + * @date 2018-12-13 + * @since 1.0 + */ +@Slf4j +public class MenuResourceServiceTest extends LisPlatformUpmsApplicationTest { + @Autowired + private MenuResourceService menuResourceService; + + @Before + public void setUp() { + log.info("setUp"); + } + + @After + public void tearDown() { + log.info("tearDown"); + } + + @Test + public void pageWithMenu() { + MenuResourceQueryParam param = new MenuResourceQueryParam().setMenuId(1L); + param.setCurrent(1); + param.setSize(10); + R> r = menuResourceService.pageWithMenu(param); + Assert.assertThat(r.getData().getRecords(), Matchers.hasSize(1)); + r = menuResourceService.pageWithMenu(param.setMenuId(2L)); + Assert.assertThat(r.getData().getRecords(), Matchers.hasSize(2)); + } + + @Test + public void pageWithMenuByParam() { + MenuResourceQueryParam param = new MenuResourceQueryParam().setMenuId(1L).setName("获取"); + param.setCurrent(1); + param.setSize(10); + R> r = menuResourceService.pageWithMenu(param); + Assert.assertThat(r.getData().getRecords(), Matchers.hasSize(1)); + + r = menuResourceService.pageWithMenu(param.setMenuId(2L).setName(null).setUrl("add")); + Assert.assertThat(r.getData().getRecords(), Matchers.hasSize(1)); + } +} \ No newline at end of file diff --git a/6.program/wms-upms/src/test/java/com/mt/wms/upms/service/UpmsServiceTest.java b/6.program/wms-upms/src/test/java/com/mt/wms/upms/service/UpmsServiceTest.java new file mode 100644 index 0000000..b0d4aa0 --- /dev/null +++ b/6.program/wms-upms/src/test/java/com/mt/wms/upms/service/UpmsServiceTest.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.mt.wms.upms.service; + +import com.mt.wms.upms.LisPlatformUpmsApplicationTest; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @author jiff + * @date 2018-12-11 + * @since 1.0 + */ +public class UpmsServiceTest extends LisPlatformUpmsApplicationTest { + @Autowired + private UpmsService upmsService; + + public void getPermissions() { + upmsService.getPermissions(); + } +} \ No newline at end of file