From 71f991d73c1e7812f18e05e807f029342b9beb89 Mon Sep 17 00:00:00 2001 From: hongtianzai Date: Tue, 22 Feb 2022 10:11:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api-admin/pom.xml | 4 +- .../controller/sys/SysMenuController.java | 5 +- .../controller/sys/SysRoleController.java | 45 ++++++++++ .../controller/udplat/ThirdApiController.java | 5 +- .../udidl/admin/dao/sys/SysRoleMapper.java | 2 + .../dao/udplat/UdplatDistributorMapper.java | 3 +- .../dto/device/ProductGoodsMatchModel.java | 2 +- .../udidl/admin/dto/sys/MenuTreeModel.java | 4 + .../udidl/admin/dto/sys/SysMenuModel.java | 4 + .../udidl/admin/dto/sys/SysRoleModel.java | 30 +++++++ .../udidl/admin/dto/sys/SysRoleParam.java | 10 +++ .../udidl/admin/dto/sys/SysUserModel.java | 45 ++++++++++ .../udidl/admin/dto/sys/SysUserParam.java | 10 +++ .../udidl/admin/dto/udplat/UnitsParam.java | 2 +- .../glxp/udidl/admin/entity/sys/SysMenu.java | 62 ++----------- .../glxp/udidl/admin/entity/sys/SysRole.java | 47 ++-------- .../glxp/udidl/admin/entity/sys/SysUser.java | 62 ++----------- .../glxp/udidl/admin/req/ListPageRequest.java | 4 +- .../udidl/admin/res/PageSimpleResponse.java | 3 + .../DataSync/ProductInfoDlService.java | 86 ++++++++++++++++--- .../admin/service/sys/SysRoleService.java | 13 +++ .../service/sys/impl/SysRoleServiceImpl.java | 68 +++++++++++++++ .../mybatis/mapper/sys/SysMenuMapper.xml | 10 ++- .../mybatis/mapper/sys/SysRoleMapper.xml | 82 ++++++++++-------- .../mybatis/mapper/sys/SysUserMapper.xml | 22 +++-- .../mapper/udplat/UdplatHospitalMapper.xml | 2 +- .../mapper/udplat/UdplatManufactureMapper.xml | 2 +- api-common/pom.xml | 5 ++ .../glxp/udidl/common/res/BaseResponse.java | 8 +- 29 files changed, 426 insertions(+), 221 deletions(-) create mode 100644 api-admin/src/main/java/com/glxp/udidl/admin/controller/sys/SysRoleController.java create mode 100644 api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysRoleModel.java create mode 100644 api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysRoleParam.java create mode 100644 api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysUserModel.java create mode 100644 api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysUserParam.java create mode 100644 api-admin/src/main/java/com/glxp/udidl/admin/service/sys/SysRoleService.java create mode 100644 api-admin/src/main/java/com/glxp/udidl/admin/service/sys/impl/SysRoleServiceImpl.java diff --git a/api-admin/pom.xml b/api-admin/pom.xml index f678928..9ee12ae 100644 --- a/api-admin/pom.xml +++ b/api-admin/pom.xml @@ -150,11 +150,11 @@ knife4j-spring-boot-starter 2.0.2 --> - + diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/controller/sys/SysMenuController.java b/api-admin/src/main/java/com/glxp/udidl/admin/controller/sys/SysMenuController.java index 3883ea2..3c28a9e 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/controller/sys/SysMenuController.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/controller/sys/SysMenuController.java @@ -6,6 +6,7 @@ import com.glxp.udidl.admin.service.sys.SysMenuService; import com.glxp.udidl.common.res.BaseResponse; import org.springframework.beans.factory.annotation.Autowired; 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; @@ -22,12 +23,12 @@ public class SysMenuController { } @AuthRuleAnnotation("sys_menu_all") @PostMapping("/insert") - public BaseResponse insert(SysMenuModel model){ + public BaseResponse insert(@RequestBody SysMenuModel model){ return sysMenuService.insert(model); } @AuthRuleAnnotation("sys_menu_all") @PostMapping("update") - public BaseResponse update(SysMenuModel model){ + public BaseResponse update(@RequestBody SysMenuModel model){ return sysMenuService.update(model); } @AuthRuleAnnotation("sys_menu_all") diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/controller/sys/SysRoleController.java b/api-admin/src/main/java/com/glxp/udidl/admin/controller/sys/SysRoleController.java new file mode 100644 index 0000000..14b92da --- /dev/null +++ b/api-admin/src/main/java/com/glxp/udidl/admin/controller/sys/SysRoleController.java @@ -0,0 +1,45 @@ +package com.glxp.udidl.admin.controller.sys; + +import com.glxp.udidl.admin.annotation.AuthRuleAnnotation; +import com.glxp.udidl.admin.dto.sys.SysRoleModel; +import com.glxp.udidl.admin.dto.sys.SysRoleParam; +import com.glxp.udidl.admin.service.sys.SysRoleService; +import com.glxp.udidl.common.res.BaseResponse; +import org.springframework.beans.factory.annotation.Autowired; +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; + +@RestController +@RequestMapping("sys/role") +public class SysRoleController { + @Autowired + SysRoleService sysRoleService; + + @AuthRuleAnnotation("sys_role_all") + @PostMapping("/list") + public BaseResponse getList(@RequestBody SysRoleParam param){ + return sysRoleService.list(param); + } + @AuthRuleAnnotation("sys_role_all") + @PostMapping("/insert") + public BaseResponse insert(@RequestBody SysRoleModel model){ + return sysRoleService.insert(model); + } + @AuthRuleAnnotation("sys_role_all") + @PostMapping("update") + public BaseResponse update(@RequestBody SysRoleModel model){ + return sysRoleService.update(model); + } + @AuthRuleAnnotation("sys_role_all") + @PostMapping("/detail") + public BaseResponse detail(Integer id){ + return sysRoleService.detail(id); + } + @AuthRuleAnnotation("sys_role_all") + @PostMapping("/delete") + public BaseResponse delete(Integer id){ + return sysRoleService.delete(id); + } +} diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/controller/udplat/ThirdApiController.java b/api-admin/src/main/java/com/glxp/udidl/admin/controller/udplat/ThirdApiController.java index cc371bc..92b278d 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/controller/udplat/ThirdApiController.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/controller/udplat/ThirdApiController.java @@ -2,7 +2,9 @@ package com.glxp.udidl.admin.controller.udplat; import com.glxp.udidl.admin.annotation.AuthRuleAnnotation; import com.glxp.udidl.admin.dto.udplat.ProductParam; +import com.glxp.udidl.admin.dto.udplat.UnitsListModel; import com.glxp.udidl.admin.dto.udplat.UnitsParam; +import com.glxp.udidl.admin.res.PageSimpleResponse; import com.glxp.udidl.admin.service.udplat.UdplatDistributorService; import com.glxp.udidl.admin.service.udplat.UdplatGoodsService; import com.glxp.udidl.common.res.BaseResponse; @@ -12,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; + @Api(tags = "第三方接口") @RestController public class ThirdApiController { @@ -23,7 +26,7 @@ public class ThirdApiController { @ApiOperation("获取往来单位信息") @AuthRuleAnnotation("third_api_all") @PostMapping("/udiwms/erp/getUnits") - public BaseResponse getUnitsList(@RequestBody UnitsParam param){ + public BaseResponse> getUnitsList(@RequestBody UnitsParam param){ return udplatDistributorService.getUnitsList(param); } @ApiOperation("获取产品信息") diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/dao/sys/SysRoleMapper.java b/api-admin/src/main/java/com/glxp/udidl/admin/dao/sys/SysRoleMapper.java index 9246358..9b41cd8 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/dao/sys/SysRoleMapper.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/dao/sys/SysRoleMapper.java @@ -1,5 +1,6 @@ package com.glxp.udidl.admin.dao.sys; +import com.glxp.udidl.admin.dto.sys.SysRoleParam; import com.glxp.udidl.admin.entity.sys.SysRole; import org.apache.ibatis.annotations.Mapper; @@ -16,4 +17,5 @@ public interface SysRoleMapper { List selectAll(); int updateByPrimaryKey(SysRole record); + List list(SysRoleParam param); } \ No newline at end of file diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/dao/udplat/UdplatDistributorMapper.java b/api-admin/src/main/java/com/glxp/udidl/admin/dao/udplat/UdplatDistributorMapper.java index 7229fc7..cd3489f 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/dao/udplat/UdplatDistributorMapper.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/dao/udplat/UdplatDistributorMapper.java @@ -6,6 +6,7 @@ import com.glxp.udidl.admin.dto.udplat.BaseParam; import com.glxp.udidl.admin.dto.udplat.UnitsListModel; import com.glxp.udidl.admin.entity.udplat.UdplatDistributor; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -22,5 +23,5 @@ public interface UdplatDistributorMapper { int updateByPrimaryKey(UdplatDistributor record); List list(BaseParam param); UdplatDistributor selectByDistributorId(String id); - List getUnitsList(String key); + List getUnitsList(@Param("key") String key); } \ No newline at end of file diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/dto/device/ProductGoodsMatchModel.java b/api-admin/src/main/java/com/glxp/udidl/admin/dto/device/ProductGoodsMatchModel.java index 74cb55f..5b785de 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/dto/device/ProductGoodsMatchModel.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/dto/device/ProductGoodsMatchModel.java @@ -5,6 +5,6 @@ import lombok.Data; @Data public class ProductGoodsMatchModel extends ProductInfoEntity { - private String deliveryGoodId;//目录key + private String deliveryGoodsId;//目录key private String medicalCode;//医保编码 } diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/MenuTreeModel.java b/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/MenuTreeModel.java index 52d12a6..ba4689c 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/MenuTreeModel.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/MenuTreeModel.java @@ -25,6 +25,10 @@ public class MenuTreeModel { * 权限标识 */ private String perms; + /** + * 排序 + */ + private Integer sort; /** * 状态(0启用 1禁用) diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysMenuModel.java b/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysMenuModel.java index fec85cd..df7871f 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysMenuModel.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysMenuModel.java @@ -36,4 +36,8 @@ public class SysMenuModel { * 状态(0启用 1禁用) */ private String status; + /** + * 排序 + */ + private Integer sort; } diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysRoleModel.java b/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysRoleModel.java new file mode 100644 index 0000000..dd2050c --- /dev/null +++ b/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysRoleModel.java @@ -0,0 +1,30 @@ +package com.glxp.udidl.admin.dto.sys; + +import lombok.Data; + +@Data +public class SysRoleModel { + /** + * + */ + private Integer id; + + /** + * 角色名称 + */ + private String name; + + /** + * 角色代码 + */ + private String code; + + /** + * 状态0: 启用,1: 禁用 + */ + private String status; + /** + * 排序 + */ + private Integer sort; +} diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysRoleParam.java b/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysRoleParam.java new file mode 100644 index 0000000..3e45d34 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysRoleParam.java @@ -0,0 +1,10 @@ +package com.glxp.udidl.admin.dto.sys; + +import com.glxp.udidl.admin.req.ListPageRequest; +import lombok.Data; + +@Data +public class SysRoleParam extends ListPageRequest { + private String status; + private String name; +} diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysUserModel.java b/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysUserModel.java new file mode 100644 index 0000000..ae8315c --- /dev/null +++ b/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysUserModel.java @@ -0,0 +1,45 @@ +package com.glxp.udidl.admin.dto.sys; + +import lombok.Data; + +@Data +public class SysUserModel { + /** + * 用户ID + */ + private Integer id; + + /** + * 用户key, 登录用 + */ + private String userKey; + + /** + * 用户账号 + */ + private String userName; + + /** + * 用户昵称 + */ + private String nickName; + + /** + * 密码 + */ + private String password; + /** + * 状态(0启用 1禁用) + */ + private String status; + + + /** + * 角色ID + */ + private Integer roleId; + + private String Udplat_appId; + private String Udplat_secretKey; + private String Udplat_userName; +} diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysUserParam.java b/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysUserParam.java new file mode 100644 index 0000000..67c5205 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/udidl/admin/dto/sys/SysUserParam.java @@ -0,0 +1,10 @@ +package com.glxp.udidl.admin.dto.sys; + +import com.glxp.udidl.admin.req.ListPageRequest; +import lombok.Data; + +@Data +public class SysUserParam extends ListPageRequest { + private String status; + private String name; +} diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/dto/udplat/UnitsParam.java b/api-admin/src/main/java/com/glxp/udidl/admin/dto/udplat/UnitsParam.java index 85c652a..2371f35 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/dto/udplat/UnitsParam.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/dto/udplat/UnitsParam.java @@ -6,6 +6,6 @@ import lombok.Data; @Data public class UnitsParam extends ListPageRequest { - @ApiModelProperty("关键字查询") + @ApiModelProperty(value = "关键字查询") private String key; } diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/entity/sys/SysMenu.java b/api-admin/src/main/java/com/glxp/udidl/admin/entity/sys/SysMenu.java index fd5655a..b6c08ec 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/entity/sys/SysMenu.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/entity/sys/SysMenu.java @@ -1,5 +1,7 @@ package com.glxp.udidl.admin.entity.sys; +import lombok.Data; + import java.util.Date; /** @@ -8,6 +10,7 @@ import java.util.Date; * @author hong * @date 2022/01/17 */ +@Data public class SysMenu { /** * 编号 @@ -38,65 +41,14 @@ public class SysMenu { * 状态(0启用 1禁用) */ private String status; + /** + * 排序 + */ + private Integer sort; /** * 创建时间 */ private Date createTime; - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name == null ? null : name.trim(); - } - - public Integer getParentId() { - return parentId; - } - - public void setParentId(Integer parentId) { - this.parentId = parentId; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type == null ? null : type.trim(); - } - - public String getPerms() { - return perms; - } - - public void setPerms(String perms) { - this.perms = perms == null ? null : perms.trim(); - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status == null ? null : status.trim(); - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } } \ No newline at end of file diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/entity/sys/SysRole.java b/api-admin/src/main/java/com/glxp/udidl/admin/entity/sys/SysRole.java index cf6f064..492cef6 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/entity/sys/SysRole.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/entity/sys/SysRole.java @@ -1,5 +1,8 @@ package com.glxp.udidl.admin.entity.sys; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + import java.util.Date; /** @@ -8,6 +11,7 @@ import java.util.Date; * @author hong * @date 2022/01/17 */ +@Data public class SysRole { /** * @@ -28,49 +32,16 @@ public class SysRole { * 状态0: 启用,1: 禁用 */ private String status; + /** + * 排序 + */ + private Integer sort; /** * 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") private Date createTime; - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name == null ? null : name.trim(); - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code == null ? null : code.trim(); - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status == null ? null : status.trim(); - } - - public Date getCreateTime() { - return createTime; - } - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } } \ No newline at end of file diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/entity/sys/SysUser.java b/api-admin/src/main/java/com/glxp/udidl/admin/entity/sys/SysUser.java index 1098d73..5542bd4 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/entity/sys/SysUser.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/entity/sys/SysUser.java @@ -33,6 +33,10 @@ public class SysUser { * 密码 */ private String password; + /** + * 状态(0启用 1禁用) + */ + private String status; /** * 创建时间 @@ -44,59 +48,7 @@ public class SysUser { */ private Integer roleId; - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getUserKey() { - return userKey; - } - - public void setUserKey(String userKey) { - this.userKey = userKey == null ? null : userKey.trim(); - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName == null ? null : userName.trim(); - } - - public String getNickName() { - return nickName; - } - - public void setNickName(String nickName) { - this.nickName = nickName == null ? null : nickName.trim(); - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password == null ? null : password.trim(); - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public Integer getRoleId() { - return roleId; - } - - public void setRoleId(Integer roleId) { - this.roleId = roleId; - } + private String Udplat_appId; + private String Udplat_secretKey; + private String Udplat_userName; } \ No newline at end of file diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/req/ListPageRequest.java b/api-admin/src/main/java/com/glxp/udidl/admin/req/ListPageRequest.java index 7794a06..1fb047d 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/req/ListPageRequest.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/req/ListPageRequest.java @@ -1,5 +1,6 @@ package com.glxp.udidl.admin.req; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.Max; @@ -10,10 +11,11 @@ import javax.validation.constraints.Min; */ @Data public class ListPageRequest { - + @ApiModelProperty(value = "页码",required=true,example = "1") @Min(message = "分页参数错误", value = 1) private Integer page; + @ApiModelProperty(value = "行数",required = true,example = "10") @Min(value = 1, message = "分页参数不能小于1") @Max(value = 1000, message = "分页参数不能大于50") private Integer limit; diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/res/PageSimpleResponse.java b/api-admin/src/main/java/com/glxp/udidl/admin/res/PageSimpleResponse.java index 3cdaf87..67fa7d7 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/res/PageSimpleResponse.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/res/PageSimpleResponse.java @@ -1,5 +1,6 @@ package com.glxp.udidl.admin.res; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; @@ -10,7 +11,9 @@ import java.util.List; @Data public class PageSimpleResponse { // 总数 + @ApiModelProperty(value = "总数",position = 0) private Long total; // 列表 + @ApiModelProperty(value = "列表",position = 1) private List list; } diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/service/DataSync/ProductInfoDlService.java b/api-admin/src/main/java/com/glxp/udidl/admin/service/DataSync/ProductInfoDlService.java index 065ea87..5afb5cf 100644 --- a/api-admin/src/main/java/com/glxp/udidl/admin/service/DataSync/ProductInfoDlService.java +++ b/api-admin/src/main/java/com/glxp/udidl/admin/service/DataSync/ProductInfoDlService.java @@ -12,11 +12,16 @@ import com.glxp.udidl.common.util.ResultVOUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileWriter; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; @Service public class ProductInfoDlService { @@ -26,17 +31,34 @@ public class ProductInfoDlService { ProductInfoService productInfoService; @Autowired FileInfoService fileInfoService; - public BaseResponse ExportToFile(Date startDate, Date endDate,String downloadType){ - if(startDate.getTime()>endDate.getTime()) - return ResultVOUtils.error(-1,"起始日期不能大于结束日期!"); - String date0= DateUtil.formatDate(startDate); - String date1=DateUtil.formatDate(DateUtil.addDays(endDate,1));//结束日期+1天 - List list = productInfoService.selectByUpdateTime(date0,date1); - String DateStr0=DateUtil.formatDate(startDate,"yyyyMMdd"); - String dateStr1=DateUtil.formatDate(endDate,"yyyyMMdd"); - String fileName = "UDI_"+DateStr0+"_"+dateStr1+"_"+list.size()+".json"; - String path = globalConfig.getDownloadPath()+"/"+fileName; - try + + public BaseResponse ExportToFile(Date startDate, Date endDate, String downloadType) { + if (startDate.getTime() > endDate.getTime()) + return ResultVOUtils.error(-1, "起始日期不能大于结束日期!"); + String date0 = DateUtil.formatDate(startDate); + String date1 = DateUtil.formatDate(DateUtil.addDays(endDate, 1));//结束日期+1天 + List list = productInfoService.selectByUpdateTime(date0, date1); + String DateStr0 = DateUtil.formatDate(startDate, "yyyyMMdd"); + String dateStr1 = DateUtil.formatDate(endDate, "yyyyMMdd"); + //String fileName = "UDI_"+DateStr0+"_"+dateStr1+"_"+list.size()+".json"; + String fileName = "UDI_" + DateStr0 + "_" + dateStr1 + "_" + list.size() + ".zip"; + String path = globalConfig.getDownloadPath() + "/" + fileName; + BaseResponse result = SaveToZip(list, path); + if (result.success()) { + File file = new File(path); + FileInfoEntity fileInfoEntity = new FileInfoEntity(); + fileInfoEntity.setType("productInfo"); + fileInfoEntity.setFileName(fileName); + fileInfoEntity.setDownloadType(downloadType); + fileInfoEntity.setStartDate(startDate); + fileInfoEntity.setEndDate(endDate); + fileInfoEntity.setCount(list.size()); + fileInfoEntity.setFileSize(file.length()); + fileInfoEntity.setCreateTime(new Date()); + fileInfoService.insert(fileInfoEntity); + } + return result; + /* try { if(list.size()>0){ BufferedWriter bw = new BufferedWriter(new FileWriter(path,false)); @@ -61,6 +83,42 @@ public class ProductInfoDlService { }catch (Exception e){ return ResultVOUtils.error(-1,e.getMessage()); } - return ResultVOUtils.success(); + return ResultVOUtils.success();*/ + } + + private BaseResponse SaveToZip(List list, String fileName) { + int count = list.size(); + int limit = 10000; + int pageTotal = 0; + if (count % limit == 0) { + pageTotal = count / limit; + } else { + pageTotal = count / limit + 1; + } + int page = 1; + int BUFFER_SIZE = 4096; + byte[] buffer = new byte[BUFFER_SIZE]; + int readLength; + try { + File zipFile = new File(fileName); + ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(zipFile)); + while (page <= pageTotal) { + List subList = list.stream().skip((page - 1) * limit).limit(limit).collect(Collectors.toList()); + String ss = JSON.toJSONString(subList); + zip.putNextEntry(new ZipEntry(page + ".json")); + InputStream input = new ByteArrayInputStream(ss.getBytes(StandardCharsets.UTF_8)); + while ((readLength = input.read(buffer, 0, BUFFER_SIZE)) != -1) { + zip.write(buffer, 0, readLength); + } + zip.flush(); + input.close(); + page++; + } + zip.close(); + } catch (Exception e) { + e.printStackTrace(); + return ResultVOUtils.error(-1, e.getMessage()); + } + return ResultVOUtils.success(); } } diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/service/sys/SysRoleService.java b/api-admin/src/main/java/com/glxp/udidl/admin/service/sys/SysRoleService.java new file mode 100644 index 0000000..78d18f7 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/udidl/admin/service/sys/SysRoleService.java @@ -0,0 +1,13 @@ +package com.glxp.udidl.admin.service.sys; + +import com.glxp.udidl.admin.dto.sys.SysRoleModel; +import com.glxp.udidl.admin.dto.sys.SysRoleParam; +import com.glxp.udidl.common.res.BaseResponse; + +public interface SysRoleService { + BaseResponse list(SysRoleParam param); + BaseResponse insert(SysRoleModel model); + BaseResponse update(SysRoleModel model); + BaseResponse detail(Integer id); + BaseResponse delete(Integer id); +} diff --git a/api-admin/src/main/java/com/glxp/udidl/admin/service/sys/impl/SysRoleServiceImpl.java b/api-admin/src/main/java/com/glxp/udidl/admin/service/sys/impl/SysRoleServiceImpl.java new file mode 100644 index 0000000..9de6b03 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/udidl/admin/service/sys/impl/SysRoleServiceImpl.java @@ -0,0 +1,68 @@ +package com.glxp.udidl.admin.service.sys.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.glxp.udidl.admin.dao.sys.SysRoleMapper; +import com.glxp.udidl.admin.dto.sys.SysRoleModel; +import com.glxp.udidl.admin.dto.sys.SysRoleParam; +import com.glxp.udidl.admin.entity.sys.SysRole; +import com.glxp.udidl.admin.res.PageSimpleResponse; +import com.glxp.udidl.admin.service.sys.SysRoleService; +import com.glxp.udidl.common.res.BaseResponse; +import com.glxp.udidl.common.util.ResultVOUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +@Service +public class SysRoleServiceImpl implements SysRoleService { + @Autowired + SysRoleMapper mapper; + + @Override + public BaseResponse list(SysRoleParam param) { + PageHelper.startPage(param.getPage(), param.getLimit()); + List list = mapper.list(param); + PageInfo pageInfo = new PageInfo<>(list); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(list); + return ResultVOUtils.success(pageSimpleResponse); + } + + @Override + public BaseResponse insert(SysRoleModel model) { + SysRole sysRole = new SysRole(); + BeanUtils.copyProperties(model, sysRole); + sysRole.setCreateTime(new Date()); + mapper.insert(sysRole); + return ResultVOUtils.success(); + } + + @Override + public BaseResponse update(SysRoleModel model) { + SysRole sysRole = mapper.selectByPrimaryKey(model.getId()); + if (sysRole == null) + return ResultVOUtils.error(-1, "找不到记录"); + BeanUtils.copyProperties(model, sysRole); + mapper.updateByPrimaryKey(sysRole); + return ResultVOUtils.success(); + } + + @Override + public BaseResponse detail(Integer id) { + SysRole sysRole = mapper.selectByPrimaryKey(id); + if (sysRole == null) + return ResultVOUtils.error(-1, "找不到记录"); + return ResultVOUtils.success(sysRole); + } + + @Override + public BaseResponse delete(Integer id) { + mapper.deleteByPrimaryKey(id); + return ResultVOUtils.success(); + } +} diff --git a/api-admin/src/main/resources/mybatis/mapper/sys/SysMenuMapper.xml b/api-admin/src/main/resources/mybatis/mapper/sys/SysMenuMapper.xml index 7c2999d..11ef354 100644 --- a/api-admin/src/main/resources/mybatis/mapper/sys/SysMenuMapper.xml +++ b/api-admin/src/main/resources/mybatis/mapper/sys/SysMenuMapper.xml @@ -7,6 +7,7 @@ + @@ -16,10 +17,10 @@ insert into sys_menu (id, name, parent_id, - type, perms, status, create_time + type, perms, status,sort, create_time ) values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER}, - #{type,jdbcType=CHAR}, #{perms,jdbcType=VARCHAR}, #{status,jdbcType=CHAR}, #{createTime,jdbcType=TIMESTAMP} + #{type,jdbcType=CHAR}, #{perms,jdbcType=VARCHAR}, #{status,jdbcType=CHAR},#{sort,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP} ) @@ -28,16 +29,17 @@ parent_id = #{parentId,jdbcType=INTEGER}, type = #{type,jdbcType=CHAR}, perms = #{perms,jdbcType=VARCHAR}, + sort = #{sort,jdbcType=INTEGER}, status = #{status,jdbcType=CHAR} where id = #{id,jdbcType=INTEGER} - select id, name, code, status, create_time - from sys_role - where id = #{id,jdbcType=INTEGER} - - + + + + + + + + + + delete + from sys_role + where id = #{id,jdbcType=INTEGER} + + + insert into sys_role (id, name, code, + status,sort, create_time) + values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, + #{status,jdbcType=CHAR},#{sort,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}) + + + update sys_role + set name = #{name,jdbcType=VARCHAR}, + code = #{code,jdbcType=VARCHAR}, + status = #{status,jdbcType=CHAR}, + sort = #{sort,jdbcType=INTEGER}, + create_time = #{createTime,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=INTEGER} + + + + \ No newline at end of file diff --git a/api-admin/src/main/resources/mybatis/mapper/sys/SysUserMapper.xml b/api-admin/src/main/resources/mybatis/mapper/sys/SysUserMapper.xml index fb27911..8024133 100644 --- a/api-admin/src/main/resources/mybatis/mapper/sys/SysUserMapper.xml +++ b/api-admin/src/main/resources/mybatis/mapper/sys/SysUserMapper.xml @@ -6,6 +6,10 @@ + + + + @@ -15,11 +19,12 @@ where id = #{id,jdbcType=INTEGER} - insert into sys_user (id, user_key, user_name, - nick_name, password, create_time, + insert into sys_user (id, user_key, user_name, Udplat_appId,Udplat_secretKey,Udplat_userName + nick_name, password, sort, create_time, role_id) - values (#{id,jdbcType=INTEGER}, #{userKey,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, - #{nickName,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, + values (#{id,jdbcType=INTEGER}, #{userKey,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, + #{Udplat_appId,jdbcType=VARCHAR}, #{Udplat_secretKey,jdbcType=VARCHAR}, #{Udplat_userName,jdbcType=VARCHAR}, + #{nickName,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},#{sort,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{roleId,jdbcType=INTEGER}) @@ -27,18 +32,21 @@ set user_key = #{userKey,jdbcType=VARCHAR}, user_name = #{userName,jdbcType=VARCHAR}, nick_name = #{nickName,jdbcType=VARCHAR}, + Udplat_appId = #{Udplat_appId,jdbcType=VARCHAR}, + Udplat_secretKey = #{Udplat_secretKey,jdbcType=VARCHAR}, + Udplat_userName = #{Udplat_userName,jdbcType=VARCHAR}, + status = #{status,jdbcType=CHAR}, password = #{password,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=TIMESTAMP}, role_id = #{roleId,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}