30个文件已修改
1个文件已删除
14个文件已添加
| | |
| | | <poi.version>4.1.2</poi.version> |
| | | <velocity.version>2.3</velocity.version> |
| | | <jwt.version>0.9.1</jwt.version> |
| | | <hutool.version>5.7.17</hutool.version> |
| | | </properties> |
| | | |
| | | <!-- 依赖声明 --> |
| | |
| | | <!-- </exclusion>--> |
| | | <!-- </exclusions>--> |
| | | </dependency> |
| | | |
| | | <!-- io常用工具类 --> |
| | | <dependency> |
| | | <groupId>commons-io</groupId> |
| | |
| | | <version>${ruoyi.version}</version> |
| | | </dependency> |
| | | |
| | | <!--hutool工具包--> |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | <version>${hutool.version}</version> |
| | | </dependency> |
| | | </dependencies> |
| | | </dependencyManagement> |
| | | |
| | |
| | | max-active: 8 |
| | | # #连接池最大阻塞等待时间(使用负值表示没有限制) |
| | | max-wait: -1ms |
| | | |
| | | jackson: |
| | | default-property-inclusion: non_null |
| | | # token配置 |
| | | token: |
| | | # 令牌自定义标识 |
| | |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | <version>4.6.10</version> |
| | | </dependency> |
| | | |
| | | <!-- zxing生成二维码 --> |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.ruoyi.common.basic.PageVO; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.exception.GlobalException; |
| | | import com.ruoyi.common.utils.ExcelUtil; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | |
| | | * @author mitao |
| | | * @since 2024-03-13 |
| | | */ |
| | | @Api(tags = "部门管理相关接口") |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/dept") |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "部门管理相关接口") |
| | | public class TbDeptController { |
| | | |
| | | private final HttpServletResponse response; |
| | |
| | | /** |
| | | * 导入 |
| | | * @param file 文件 |
| | | * @return AjaxResult |
| | | * @return R |
| | | */ |
| | | @PostMapping("/import") |
| | | @ApiOperation("导入") |
| | | public AjaxResult importExcel(@RequestPart("file")MultipartFile file) { |
| | | public R<Object> importExcel(@RequestPart("file")MultipartFile file) { |
| | | try { |
| | | tbDeptService.importExcel(file); |
| | | } catch (Exception e) { |
| | | log.error("导入失败", e); |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 分页条件查询 |
| | | * @param query 查询条件 |
| | | * @return AjaxResult<PageVO<DeptVO>> |
| | | * @return R<PageVO<DeptVO>> |
| | | */ |
| | | @PostMapping("/page") |
| | | @ApiOperation("分页条件查询") |
| | | public AjaxResult<PageVO<DeptVO>> page(@RequestBody DeptQuery query) { |
| | | return AjaxResult.success(tbDeptService.queryPage(query)); |
| | | public R<PageDTO<DeptVO>> page(@RequestBody DeptQuery query) { |
| | | return R.ok(tbDeptService.queryPage(query)); |
| | | } |
| | | |
| | | @GetMapping("/{id}") |
| | | /** |
| | | * 根据id查询部门详情 |
| | | * @param id 部门id |
| | | * @return DeptVO |
| | | */ |
| | | @GetMapping("/getById") |
| | | @ApiOperation("根据id查询部门详情") |
| | | public AjaxResult<DeptVO> getById(@PathVariable Integer id) { |
| | | public R<DeptVO> getById(@RequestParam Integer id) { |
| | | TbDept dept = tbDeptService.getById(id); |
| | | DeptVO deptVO = new DeptVO(); |
| | | BeanUtils.copyBeanProp(deptVO, dept); |
| | | return AjaxResult.success(deptVO); |
| | | return R.ok(deptVO); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param dto |
| | | * @return |
| | | * @param dto 部门更新实体 |
| | | * @return 响应成功 |
| | | */ |
| | | @PostMapping("/edit") |
| | | @ApiOperation("编辑") |
| | | public AjaxResult edit(@RequestBody DeptUpdateDTO dto){ |
| | | public R<Object> edit(@RequestBody DeptUpdateDTO dto){ |
| | | TbDept tbDept = new TbDept(); |
| | | BeanUtils.copyBeanProp(tbDept,dto); |
| | | tbDeptService.updateById(tbDept); |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 重点关注 |
| | | * @param dto |
| | | * @return |
| | | * @param dto 部门更新实体 |
| | | * @return 响应成功 |
| | | */ |
| | | @PostMapping("/focus") |
| | | @ApiOperation("重点关注") |
| | | public AjaxResult focus(@RequestBody DeptFocusDTO dto){ |
| | | public R<Object> focus(@RequestBody DeptFocusDTO dto){ |
| | | TbDept tbDept = new TbDept(); |
| | | BeanUtils.copyBeanProp(tbDept,dto); |
| | | tbDeptService.lambdaUpdate() |
| | | .eq(TbDept::getId, dto.getId()) |
| | | .set(TbDept::getFocussed, dto.getFocussed()) |
| | | .update(); |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.ruoyi.common.basic.PageVO; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.BeanUtils; |
| | | import com.ruoyi.system.domain.TbFieldCategory; |
| | | import com.ruoyi.system.dto.FieldCategoryDTO; |
| | | import com.ruoyi.system.dto.ShowHideDTO; |
| | |
| | | import com.ruoyi.system.query.FieldCategoryQuery; |
| | | import com.ruoyi.system.service.TbFieldCategoryService; |
| | | import com.ruoyi.system.vo.FieldCategoryDetailVO; |
| | | import com.ruoyi.system.vo.FieldCategoryVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | 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.validation.constraints.NotNull; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author mitao |
| | | * @since 2024-03-13 |
| | | */ |
| | | @Api(tags = "字段分类管理") |
| | | @Validated |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/field-category") |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "字段分类管理相关接口") |
| | | public class TbFieldCategoryController { |
| | | |
| | | private final TbFieldCategoryService tbFieldCategoryService; |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param dto 字段分类数据传输对象 |
| | | * @return AjaxResult |
| | | * @return R |
| | | */ |
| | | @PostMapping("/add") |
| | | @ApiOperation("添加") |
| | | public AjaxResult add(@RequestBody FieldCategoryDTO dto) { |
| | | public R<Object> add(@RequestBody @Validated FieldCategoryDTO dto) { |
| | | try { |
| | | tbFieldCategoryService.add(dto); |
| | | } catch (Exception e) { |
| | | log.error("添加分类异常", e); |
| | | throw new RuntimeException("操作失败"); |
| | | } |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 根据id获取字段分类详情 |
| | | * @param id 字段分类id |
| | | * @return AjaxResult |
| | | * @return R |
| | | */ |
| | | @GetMapping("/getById") |
| | | @ApiOperation("根据id获取字段分类详情") |
| | | @ApiImplicitParam(name = "id", value = "字段分类id", required = true) |
| | | public AjaxResult<FieldCategoryDetailVO> getById(@RequestParam(value = "id") @NotNull(message = "id不能为空") Integer id) { |
| | | public R<FieldCategoryDetailVO> getById(@RequestParam(value = "id") Integer id) { |
| | | TbFieldCategory oneCategory = tbFieldCategoryService.getById(id); |
| | | FieldCategoryDetailVO vo = new FieldCategoryDetailVO(); |
| | | BeanUtils.copyBeanProp(vo, oneCategory); |
| | | if (Objects.isNull(oneCategory)) { |
| | | return R.ok(new FieldCategoryDetailVO()); |
| | | } |
| | | FieldCategoryDetailVO vo = BeanUtils.copyBean(oneCategory, FieldCategoryDetailVO.class); |
| | | //根据一级分类id,查询二级分类 |
| | | List<TbFieldCategory> twoCategoryList = tbFieldCategoryService.lambdaQuery().eq(TbFieldCategory::getParentId, oneCategory.getId()).list(); |
| | | twoCategoryList.forEach(item->{ |
| | | FieldCategoryDetailVO twoCategoryVO = new FieldCategoryDetailVO(); |
| | | BeanUtils.copyBeanProp(twoCategoryVO, item); |
| | | FieldCategoryDetailVO twoCategoryVO = BeanUtils.copyBean(item, FieldCategoryDetailVO.class); |
| | | vo.getChildren().add(twoCategoryVO); |
| | | //根据二级分类id,查询三级分类 |
| | | List<TbFieldCategory> threeCategoryList = tbFieldCategoryService.lambdaQuery().eq(TbFieldCategory::getParentId, item.getId()).list(); |
| | | threeCategoryList.forEach(threeCategory->{ |
| | | FieldCategoryDetailVO threeCategoryVO = new FieldCategoryDetailVO(); |
| | | BeanUtils.copyBeanProp(threeCategoryVO, threeCategory); |
| | | FieldCategoryDetailVO threeCategoryVO = BeanUtils.copyBean(threeCategory, FieldCategoryDetailVO.class); |
| | | twoCategoryVO.getChildren().add(threeCategoryVO); |
| | | }); |
| | | vo.getChildren().add(twoCategoryVO); |
| | | }); |
| | | return AjaxResult.success(vo); |
| | | return R.ok(vo); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PostMapping("/page") |
| | | @ApiOperation("分页条件查询") |
| | | public AjaxResult<PageVO<FieldCategoryDetailVO>> page(@RequestBody FieldCategoryQuery query) { |
| | | return AjaxResult.success(tbFieldCategoryService.queryPage(query)); |
| | | public R<PageDTO<FieldCategoryVO>> page(@RequestBody FieldCategoryQuery query) { |
| | | return R.ok(tbFieldCategoryService.queryPage(query)); |
| | | } |
| | | |
| | | /** |
| | | * 隐藏显示操作 |
| | | * @param dto 显示隐藏操作数据传输对象 |
| | | * @return AjaxResult |
| | | * @return R |
| | | */ |
| | | @PostMapping("/show-hide") |
| | | @PutMapping("/show-hide") |
| | | @ApiOperation("隐藏显示操作") |
| | | public AjaxResult showHide(@RequestBody ShowHideDTO dto) { |
| | | try { |
| | | public R<Object> showHide(@RequestBody ShowHideDTO dto) { |
| | | tbFieldCategoryService.showHide(dto); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("操作失败"); |
| | | } |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @GetMapping("/delete-children") |
| | | /** |
| | | * 删除分类子节点 |
| | | * @param id id |
| | | * @return R |
| | | */ |
| | | @DeleteMapping("/delete-children") |
| | | @ApiOperation("编辑页面删除子字段分类") |
| | | @ApiImplicitParam(name = "id", value = "字段分类id", required = true) |
| | | public AjaxResult deleteChildren(@RequestParam(value = "id") @NotNull(message = "id不能为空") Integer id){ |
| | | public R<Object> deleteChildren(@RequestParam(value = "id") Integer id){ |
| | | try { |
| | | tbFieldCategoryService.deleteChildren(id); |
| | | } catch (Exception e) { |
| | | log.error("编辑页面删除子字段分类失败",e); |
| | | throw new RuntimeException("操作失败"); |
| | | } |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @GetMapping("/delete") |
| | | /** |
| | | * 删除分类 |
| | | * @param id id |
| | | * @return R |
| | | */ |
| | | @DeleteMapping("/delete") |
| | | @ApiOperation("列表页面删除分类") |
| | | @ApiImplicitParam(name = "id", value = "字段分类id", required = true) |
| | | public AjaxResult delete(@RequestParam(value = "id") @NotNull(message = "id不能为空") Integer id){ |
| | | try { |
| | | public R<Void> delete(@RequestParam(value = "id") Integer id){ |
| | | tbFieldCategoryService.delete(id); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("操作失败"); |
| | | } |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/edit") |
| | | /** |
| | | * 编辑分类 |
| | | * @param dto 字段分类更新数据传输对象 |
| | | * @return R |
| | | */ |
| | | @PutMapping("/edit") |
| | | @ApiOperation("编辑") |
| | | public AjaxResult edit(@RequestBody FieldCategoryUpdateDTO dto) { |
| | | try { |
| | | public R<Object> edit(@RequestBody FieldCategoryUpdateDTO dto) { |
| | | tbFieldCategoryService.edit(dto); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("操作失败"); |
| | | } |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.BeanUtils; |
| | | import com.ruoyi.system.domain.TbField; |
| | | import com.ruoyi.system.dto.FieldDTO; |
| | | import com.ruoyi.system.dto.ShowHideDTO; |
| | | import com.ruoyi.system.dto.update.FieldUpdateDTO; |
| | | import com.ruoyi.system.query.FieldQuery; |
| | | import com.ruoyi.system.service.TbFieldCategoryService; |
| | | import com.ruoyi.system.service.TbFieldService; |
| | | import com.ruoyi.system.vo.FieldCategoryVO; |
| | | import com.ruoyi.system.vo.FieldVO; |
| | | 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 java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author mitao |
| | | * @since 2024-03-13 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/tb-field") |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/field") |
| | | @Api(tags = "字段管理相关接口") |
| | | public class TbFieldController { |
| | | |
| | | private final TbFieldService tbFieldService; |
| | | private final TbFieldCategoryService tbFieldCategoryService; |
| | | |
| | | /** |
| | | * 获取分类列表 |
| | | * @param id 分类id |
| | | * @return 分类列表 |
| | | */ |
| | | @GetMapping("/categories") |
| | | @ApiOperation(value = "获取分类列表",notes = "一级分类id传0,二级分类传一级分类id,三级分类同理") |
| | | public R<List<FieldCategoryVO>> queryFieldCategories(@RequestParam Integer id) { |
| | | return R.ok(tbFieldCategoryService.queryFieldCategories(id)); |
| | | } |
| | | |
| | | /** |
| | | * 添加字段 |
| | | * @param dto 字段数据传输对象 |
| | | * @return 响应状态 |
| | | */ |
| | | @PostMapping("/add") |
| | | @ApiOperation("添加字段") |
| | | public R<Void> add(@RequestBody @Validated FieldDTO dto){ |
| | | tbFieldService.add(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @GetMapping("/influenced-data") |
| | | @ApiOperation("隐藏字段,获取同步隐藏的基础数据") |
| | | public R<List<String>> influencedData(@RequestParam Integer id) { |
| | | return R.ok(tbFieldService.influencedData(id)); |
| | | } |
| | | /** |
| | | * 隐藏显示操作 |
| | | * @param dto 显示隐藏操作数据传输对象 |
| | | * @return R |
| | | */ |
| | | @PostMapping("/show-hide") |
| | | @ApiOperation("隐藏显示操作") |
| | | public R<Void> showHide(@RequestBody ShowHideDTO dto) { |
| | | tbFieldService.showHide(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 编辑字段 |
| | | * @param dto 字段数据传输对象 |
| | | * @return 响应状态 |
| | | */ |
| | | @PostMapping("/edit") |
| | | @ApiOperation("编辑字段") |
| | | public R<Void> add(@RequestBody @Validated FieldUpdateDTO dto){ |
| | | TbField field = tbFieldService.getById(dto.getId()); |
| | | if (Objects.isNull(field)) { |
| | | throw new RuntimeException("参数异常"); |
| | | } |
| | | TbField tbField = BeanUtils.copyBean(dto, TbField.class); |
| | | tbFieldService.updateById(tbField); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 分页条件查询 |
| | | * @param query 部门条件查询对象 |
| | | * @return PageVO<FieldCategoryDetailVO> |
| | | */ |
| | | @PostMapping("/page") |
| | | @ApiOperation("分页条件查询") |
| | | public R<PageDTO<FieldVO>> page(@RequestBody FieldQuery query) { |
| | | return R.ok(tbFieldService.queryPage(query)); |
| | | } |
| | | |
| | | /** |
| | | * 获取详情 |
| | | * @param id id |
| | | * @return FieldVO |
| | | */ |
| | | @GetMapping("/getById") |
| | | @ApiOperation("获取详情") |
| | | public R<FieldVO> getById(@RequestParam Integer id){ |
| | | TbField field = tbFieldService.getById(id); |
| | | return R.ok(BeanUtils.copyBean(field, FieldVO.class)); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | * @param id id |
| | | * @return 响应状态 |
| | | */ |
| | | @DeleteMapping("/delete") |
| | | @ApiOperation("删除") |
| | | public R<Void> delete(@RequestParam Integer id){ |
| | | tbFieldService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |
| | |
| | | devtools: |
| | | restart: |
| | | # 热部署开关 |
| | | enabled: false |
| | | enabled: true |
| | | # redis 配置 |
| | | redis: |
| | | # 地址 |
| | |
| | | max-active: 8 |
| | | # #连接池最大阻塞等待时间(使用负值表示没有限制) |
| | | max-wait: -1ms |
| | | jackson: |
| | | default-property-inclusion: non_null |
| | | |
| | | # token配置 |
| | | token: |
| | |
| | | <artifactId>springfox-swagger-ui</artifactId> |
| | | <version>3.0.0</version> |
| | | </dependency> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>com.github.xiaoymin</groupId>--> |
| | | <!-- <artifactId>knife4j-spring-boot-starter</artifactId>--> |
| | | <!-- <version>3.0.3</version>--> |
| | | <!-- </dependency>--> |
| | | <dependency> |
| | | <groupId>com.github.xiaoymin</groupId> |
| | | <artifactId>knife4j-openapi2-spring-boot-starter</artifactId> |
| | | <version>4.4.0</version> |
| | | <artifactId>knife4j-spring-boot-starter</artifactId> |
| | | <version>3.0.3</version> |
| | | </dependency> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>io.swagger</groupId>--> |
| | |
| | | <artifactId>easypoi-spring-boot-starter</artifactId> |
| | | <version>4.4.0</version> |
| | | </dependency> |
| | | |
| | | <!--hutool工具包--> |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
New file |
| | |
| | | package com.ruoyi.common.basic; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import com.ruoyi.common.utils.BeanUtils; |
| | | import com.ruoyi.common.utils.CollUtils; |
| | | import com.ruoyi.common.utils.Convert; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.util.List; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @ApiModel(description = "分页结果") |
| | | public class PageDTO<T> { |
| | | @ApiModelProperty("总条数") |
| | | protected Long total; |
| | | @ApiModelProperty("总页码数") |
| | | protected Long pages; |
| | | @ApiModelProperty("当前页数据") |
| | | protected List<T> list; |
| | | |
| | | public static <T> PageDTO<T> empty(Long total, Long pages) { |
| | | return new PageDTO<>(total, pages, CollUtils.emptyList()); |
| | | } |
| | | public static <T> PageDTO<T> empty(Page<?> page) { |
| | | return new PageDTO<>(page.getTotal(), page.getPages(), CollUtils.emptyList()); |
| | | } |
| | | |
| | | public static <T> PageDTO<T> of(Page<T> page) { |
| | | if(page == null){ |
| | | return new PageDTO<>(); |
| | | } |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | return empty(page); |
| | | } |
| | | return new PageDTO<>(page.getTotal(), page.getPages(), page.getRecords()); |
| | | } |
| | | public static <T,R> PageDTO<T> of(Page<R> page, Function<R, T> mapper) { |
| | | if(page == null){ |
| | | return new PageDTO<>(); |
| | | } |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | return empty(page); |
| | | } |
| | | return new PageDTO<>(page.getTotal(), page.getPages(), |
| | | page.getRecords().stream().map(mapper).collect(Collectors.toList())); |
| | | } |
| | | public static <T> PageDTO<T> of(Page<?> page, List<T> list) { |
| | | return new PageDTO<>(page.getTotal(), page.getPages(), list); |
| | | } |
| | | |
| | | public static <T, R> PageDTO<T> of(Page<R> page, Class<T> clazz) { |
| | | return new PageDTO<>(page.getTotal(), page.getPages(), BeanUtils.copyList(page.getRecords(), clazz)); |
| | | } |
| | | |
| | | public static <T, R> PageDTO<T> of(Page<R> page, Class<T> clazz, Convert<R, T> convert) { |
| | | return new PageDTO<>(page.getTotal(), page.getPages(), BeanUtils.copyList(page.getRecords(), clazz, convert)); |
| | | } |
| | | |
| | | @ApiModelProperty(hidden = true) |
| | | @JsonIgnore |
| | | public boolean isEmpty(){ |
| | | return list == null || list.size() == 0; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import java.io.Serializable; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 响应信息主体 |
| | |
| | | |
| | | /** 失败 */ |
| | | public static final int FAIL = HttpStatus.ERROR; |
| | | |
| | | @ApiModelProperty(value = "业务状态码,200-成功,其它-失败") |
| | | private int code; |
| | | |
| | | @ApiModelProperty(value = "响应消息", example = "操作成功") |
| | | private String msg; |
| | | |
| | | @ApiModelProperty(value = "响应数据") |
| | | private T data; |
| | | |
| | | public static <T> R<T> ok() |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import lombok.Getter; |
| | | import lombok.AllArgsConstructor; |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum FieldInputTypeEnum { |
| | | MANUAL_INPUT(1, "手动输入"), |
| | | FIXED_CONTENT(2, "固定内容"); |
| | | |
| | | private final Integer code; |
| | | private final String desc; |
| | | |
| | | public static FieldInputTypeEnum getEnumByCode(Integer code) { |
| | | for (FieldInputTypeEnum e : FieldInputTypeEnum.values()) { |
| | | if (e.code.equals(code)) { |
| | | return e; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import lombok.Getter; |
| | | import lombok.AllArgsConstructor; |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum FieldTypeEnum { |
| | | NUMBER(1, "数字"), |
| | | TEXT(2, "文本"), |
| | | PERCENTAGE(3, "百分比"); |
| | | |
| | | private final Integer code; |
| | | private final String desc; |
| | | |
| | | public static FieldTypeEnum getEnumByCode(Integer code) { |
| | | for (FieldTypeEnum e : FieldTypeEnum.values()) { |
| | | if (e.code.equals(code)) { |
| | | return e; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum ShowStatus { |
| | | HIDE(0, "隐藏"), |
| | | SHOW(1, "展示"); |
| | | SHOW(0, "展示"), |
| | | HIDE(1, "隐藏"); |
| | | |
| | | private final Integer code; |
| | | private final String desc; |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 数组工具类 |
| | | * @ClassName ArrayUtils |
| | | * @author wusongsong |
| | | * @since 2022/7/10 12:02 |
| | | * @version 1.0.0 |
| | | **/ |
| | | public class ArrayUtils extends ArrayUtil { |
| | | |
| | | |
| | | |
| | | /** |
| | | * 将源数组转换成指定类型的列表 |
| | | * |
| | | * @param originList 原始列表 |
| | | * @param targetClazz 转换后列表元素的类型 |
| | | * @param <R> 原始列表元素的类型 |
| | | * @param <T> 目标列表元素的类型 |
| | | * @return 目标类型的集合 |
| | | */ |
| | | public static <R, T> List<T> convert(R[] originList, Class<T> targetClazz) { |
| | | return convert(originList, targetClazz, null); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 将源数组转换成指定类型的列表 |
| | | * |
| | | * @param originList 原始列表 |
| | | * @param targetClazz 转换后列表元素的类型 |
| | | * @param convert 转换特殊字段接口 |
| | | * @param <R> 原始列表元素的类型 |
| | | * @param <T> 目标列表元素的类型 |
| | | * @return 目标类型的集合 |
| | | */ |
| | | public static <R, T> List<T> convert(R[] originList, Class<T> targetClazz, Convert<R, T> convert) { |
| | | if (isEmpty(originList)) { |
| | | return null; |
| | | } |
| | | |
| | | return Arrays.stream(originList) |
| | | .map(origin -> BeanUtils.copyBean(origin, targetClazz, convert)) |
| | | .collect(Collectors.toList()); |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 继承自 hutool 的BeanUtil,增加了bean转换时自定义转换器的功能 |
| | | */ |
| | | public class BeanUtils extends BeanUtil { |
| | | |
| | | /** |
| | | * 将原对象转换成目标对象,对于字段不匹配的字段可以使用转换器处理 |
| | | * |
| | | * @param source 原对象 |
| | | * @param clazz 目标对象的class |
| | | * @param convert 转换器 |
| | | * @param <R> 原对象类型 |
| | | * @param <T> 目标对象类型 |
| | | * @return 目标对象 |
| | | */ |
| | | public static <R, T> T copyBean(R source, Class<T> clazz, Convert<R, T> convert) { |
| | | T target = copyBean(source, clazz); |
| | | if (convert != null) { |
| | | convert.convert(source, target); |
| | | } |
| | | return target; |
| | | } |
| | | /** |
| | | * 将原对象转换成目标对象,对于字段不匹配的字段可以使用转换器处理 |
| | | * |
| | | * @param source 原对象 |
| | | * @param clazz 目标对象的class |
| | | * @param <R> 原对象类型 |
| | | * @param <T> 目标对象类型 |
| | | * @return 目标对象 |
| | | */ |
| | | public static <R, T> T copyBean(R source, Class<T> clazz){ |
| | | if (source == null) { |
| | | return null; |
| | | } |
| | | return toBean(source, clazz); |
| | | } |
| | | |
| | | public static <R, T> List<T> copyList(List<R> list, Class<T> clazz) { |
| | | if (list == null || list.size() == 0) { |
| | | return CollUtils.emptyList(); |
| | | } |
| | | return copyToList(list, clazz); |
| | | } |
| | | |
| | | public static <R, T> List<T> copyList(List<R> list, Class<T> clazz, Convert<R, T> convert) { |
| | | if (list == null || list.size() == 0) { |
| | | return CollUtils.emptyList(); |
| | | } |
| | | return list.stream().map(r -> copyBean(r, clazz, convert)).collect(Collectors.toList()); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | /** |
| | | * 实现后在接口访问时如果接口实现了这个接口 |
| | | * 会被自动自行接口check进行校验 |
| | | **/ |
| | | public interface Checker<T> { |
| | | |
| | | /** |
| | | * 用于实现validation不能校验的数据逻辑 |
| | | */ |
| | | default void check(){ |
| | | |
| | | } |
| | | |
| | | default void check(T data){ |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.collection.IterUtil; |
| | | |
| | | |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 继承自 hutool 的集合工具类 |
| | | */ |
| | | public class CollUtils extends CollectionUtil { |
| | | |
| | | public static <T> List<T> emptyList() { |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | public static <T> Set<T> emptySet() { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | public static <K,V> Map<K, V> emptyMap() { |
| | | return Collections.emptyMap(); |
| | | } |
| | | |
| | | public static <T> Set<T> singletonSet(T t) { |
| | | return Collections.singleton(t); |
| | | } |
| | | |
| | | public static <T> List<T> singletonList(T t) { |
| | | return Collections.singletonList(t); |
| | | } |
| | | |
| | | public static List<Integer> convertToInteger(List<String> originList){ |
| | | return CollUtils.isNotEmpty(originList) ? originList.stream().map(NumberUtils::parseInt).collect(Collectors.toList()) : null; |
| | | } |
| | | |
| | | public static List<Long> convertToLong(List<String> originLIst){ |
| | | return CollUtils.isNotEmpty(originLIst) ? originLIst.stream().map(NumberUtils::parseLong).collect(Collectors.toList()) : null; |
| | | } |
| | | |
| | | /** |
| | | * 以 conjunction 为分隔符将集合转换为字符串 如果集合元素为数组、Iterable或Iterator,则递归组合其为字符串 |
| | | * @param collection 集合 |
| | | * @param conjunction 分隔符 |
| | | * @param <T> 集合元素类型 |
| | | * @return 连接后的字符串 |
| | | * See Also: IterUtil.join(Iterator, CharSequence) |
| | | */ |
| | | public static <T> String join(Collection<T> collection, CharSequence conjunction) { |
| | | if (null == collection || collection.isEmpty()) { |
| | | return null; |
| | | } |
| | | return IterUtil.join(collection.iterator(), conjunction); |
| | | } |
| | | |
| | | public static <T> String joinIgnoreNull(Collection<T> collection, CharSequence conjunction) { |
| | | if (null == collection || collection.isEmpty()) { |
| | | return null; |
| | | } |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (T t : collection) { |
| | | if(t == null) continue; |
| | | sb.append(t).append(","); |
| | | } |
| | | if(sb.length() <= 0){ |
| | | return null; |
| | | } |
| | | return sb.deleteCharAt(sb.length() - 1).toString(); |
| | | } |
| | | |
| | | /** |
| | | * 集合校验逻辑 |
| | | * |
| | | * @param data 要校验的集合 |
| | | * @param checker 校验器 |
| | | * @param <T> 集合元素类型 |
| | | */ |
| | | public static <T> void check(List<T> data, Checker<T> checker){ |
| | | if(data == null){ |
| | | return; |
| | | } |
| | | for (T t : data){ |
| | | checker.check(t); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 集合校验逻辑 |
| | | * |
| | | * @param data 要校验的集合 |
| | | * @param <T> 集合元素类型 |
| | | */ |
| | | public static <T extends Checker<T>> void check(List<T> data){ |
| | | if(data == null){ |
| | | return; |
| | | } |
| | | for (T t : data){ |
| | | t.check(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 将元素加入到集合中,为null的过滤掉 |
| | | * |
| | | * @param list 集合 |
| | | * @param data 要添加的数据 |
| | | * @param <T> 元素类型 |
| | | */ |
| | | public static <T> void add(Collection<T> list, T... data) { |
| | | if (list == null || ArrayUtils.isEmpty(data)) { |
| | | return; |
| | | } |
| | | for (T t : data) { |
| | | if (ObjectUtils.isNotEmpty(t)) { |
| | | list.add(t); |
| | | } |
| | | } |
| | | } |
| | | //将两个集合出现次数相加 |
| | | public static Map<Long, Integer> union(Map<Long, Integer> map1, Map<Long, Integer> map2) { |
| | | if (CollUtils.isEmpty(map1)) { |
| | | return map2; |
| | | } else if (CollUtils.isEmpty(map2)) { |
| | | return map1; |
| | | } |
| | | for (Map.Entry<Long, Integer> entry : map1.entrySet()) { |
| | | Integer num = map2.get(entry.getKey()); |
| | | map2.put(entry.getKey(), NumberUtils.null2Zero(num) + entry.getValue()); |
| | | } |
| | | return map2; |
| | | } |
| | | |
| | | public static <T,R> R getFiledOfFirst(List<T> list, Function<T, R> function) { |
| | | if (CollUtils.isEmpty(list)) { |
| | | return null; |
| | | } |
| | | return function.apply(list.get(0)); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | /** |
| | | * 对原对象进行计算,设置到目标对象中 |
| | | **/ |
| | | public interface Convert<R,T>{ |
| | | void convert(R origin, T target); |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.util.NumberUtil; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | public class NumberUtils extends NumberUtil { |
| | | |
| | | |
| | | /** |
| | | * 如果number为空,将number转换为0,否则原数字返回 |
| | | * |
| | | * @param number 原数值 |
| | | * @return 整型数字,0或原数字 |
| | | */ |
| | | public static Integer null2Zero(Integer number){ |
| | | return number == null ? 0 : number; |
| | | } |
| | | |
| | | /** |
| | | * 如果number为空,将number转换为0,否则原数字返回 |
| | | * |
| | | * @param number 原数值 |
| | | * @return 整型数字,0或原数字 |
| | | */ |
| | | public static Double null2Zero(Double number){ |
| | | return number == null ? 0 : number; |
| | | } |
| | | |
| | | /** |
| | | * 如果number为空,将number转换为0L,否则原数字返回 |
| | | * |
| | | * @param number 原数值 |
| | | * @return 长整型数字,0L或原数字 |
| | | */ |
| | | public static Long null2Zero(Long number){ |
| | | return number == null ? 0L : number; |
| | | } |
| | | |
| | | |
| | | public static Double setScale(Double number) { |
| | | return new BigDecimal(number) |
| | | .setScale(2, BigDecimal.ROUND_HALF_UP) |
| | | .doubleValue(); |
| | | } |
| | | /** |
| | | * 比较两个数字是否相同, |
| | | * @param number1 数值1 |
| | | * @param number2 数值2 |
| | | * @return 是否一致 |
| | | */ |
| | | public static boolean equals(Integer number1, Integer number2) { |
| | | if(number1 == null || number2 == null){ |
| | | return false; |
| | | } |
| | | return number1.equals(number2); |
| | | } |
| | | |
| | | /** |
| | | * 数字除法保留指定小数位 |
| | | * @param num1 被除数 |
| | | * @param num2 除数 |
| | | * @param scale 小数点位数 |
| | | * @return 结果 |
| | | */ |
| | | public static Double divToDouble(Integer num1, Integer num2, int scale){ |
| | | if(num2 == null || num2 ==0 || num1 == null || num1 == 0) { |
| | | return 0d; |
| | | } |
| | | return div(num1, num2, scale).doubleValue(); |
| | | } |
| | | |
| | | public static Double max(List<Double> data){ |
| | | if(CollUtils.isEmpty(data)){ |
| | | return null; |
| | | } |
| | | return data.stream() |
| | | .max(Comparator.comparingDouble(num -> num)) |
| | | .orElse(0d); |
| | | } |
| | | public static Double min(List<Double> data){ |
| | | if(CollUtils.isEmpty(data)){ |
| | | return null; |
| | | } |
| | | return data.stream() |
| | | .min(Comparator.comparingDouble(num -> num)) |
| | | .orElse(0d); |
| | | } |
| | | |
| | | public static Double average(List<Double> data){ |
| | | if(CollUtils.isEmpty(data)){ |
| | | return 0d; |
| | | } |
| | | return data.stream() |
| | | .collect(Collectors.averagingDouble(Double::doubleValue)); |
| | | |
| | | } |
| | | |
| | | public static Integer toInt(Object obj) { |
| | | return obj == null ? null |
| | | : obj instanceof Integer |
| | | ? (int) obj : null; |
| | | } |
| | | |
| | | /** |
| | | * 取绝对值,如果为null,返回0 |
| | | * @param number 数值 |
| | | * @return 绝对值 |
| | | */ |
| | | public static int abs(Integer number) { |
| | | return number == null |
| | | ? 0 |
| | | : Math.abs(number); |
| | | } |
| | | |
| | | /** |
| | | * 数字格式化字符串,不足位数补0 |
| | | * |
| | | * @param originNumber 原始数字 |
| | | * @param digit 数字位数 |
| | | * @return 字符串 |
| | | */ |
| | | public static String repair0(Integer originNumber, Integer digit){ |
| | | StringBuilder number = new StringBuilder(originNumber + ""); |
| | | while (number.length() < digit) { |
| | | number.insert(0, "0"); |
| | | } |
| | | return number.toString(); |
| | | } |
| | | |
| | | |
| | | public static String scaleToStr(Integer num, int offset) { |
| | | // 1.计算位数 |
| | | int m = (int) Math.pow(10, offset); |
| | | // 2.计算商 |
| | | int s = num / m; |
| | | // 3.计算余数 |
| | | int y = num % m; |
| | | if (y == 0) { |
| | | return Integer.toString(s); |
| | | } |
| | | // 2.计算余数 |
| | | return s + "." + y; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * Object操作工具 |
| | | **/ |
| | | public class ObjectUtils extends ObjectUtil { |
| | | |
| | | /** |
| | | * 为object设置默认值,对target中的基本类型进行默认值初始化, |
| | | * 为null的对象不操作 |
| | | * |
| | | * @param target 需要初始化的对象 |
| | | */ |
| | | public static void setDefault(Object target) { |
| | | if (target == null) { |
| | | return; |
| | | } |
| | | Class<?> clazz = target.getClass(); |
| | | Field[] declaredFields = clazz.getDeclaredFields(); |
| | | for (Field field : declaredFields) { |
| | | setDefault(field, target); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 给某个字段设置为默认值 |
| | | * |
| | | * @param field |
| | | * @param target |
| | | */ |
| | | private static void setDefault(Field field, Object target) { |
| | | field.setAccessible(true); |
| | | try { |
| | | Object value = field.get(target); |
| | | if (value != null) { |
| | | return; |
| | | } |
| | | String type = field.getGenericType().toString(); |
| | | Object defaultValue; |
| | | switch (type) { |
| | | case "class java.lang.String": |
| | | case "class java.lang.Character": |
| | | defaultValue = ""; |
| | | break; |
| | | case "class java.lang.Double": |
| | | defaultValue = 0.0d; |
| | | break; |
| | | case "class java.lang.Long": |
| | | defaultValue = 0L; |
| | | break; |
| | | case "class java.lang.Short": |
| | | defaultValue = (short) 0; |
| | | break; |
| | | case "class java.lang.Integer": |
| | | defaultValue = 0; |
| | | break; |
| | | case "class java.lang.Float": |
| | | defaultValue = 0f; |
| | | break; |
| | | case "class java.lang.Byte": |
| | | defaultValue = (byte) 0; |
| | | break; |
| | | case "class java.math.BigDecimal": |
| | | defaultValue = BigDecimal.ZERO; |
| | | break; |
| | | case "class java.lang.Boolean": |
| | | defaultValue = Boolean.FALSE; |
| | | break; |
| | | default: |
| | | defaultValue = null; |
| | | |
| | | } |
| | | field.set(target, defaultValue); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | |
| | | <artifactId>tomcat-embed-core</artifactId> |
| | | </dependency> |
| | | |
| | | <!--hutool工具包--> |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | |
| | | @ApiModelProperty(value = "填报状态(1=未填报 2=数据缺失 3=已填报)") |
| | | @TableField("status") |
| | | private Boolean status; |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "删除标志(0代表存在 1代表删除)") |
| | | @TableField("del_flag") |
| | |
| | | private String fieldDescription; |
| | | |
| | | @ApiModelProperty(value = "计算类型(1=数字计算 2=文本统计 3=百分比统计)") |
| | | @TableField("caculate_type") |
| | | private Boolean caculateType; |
| | | @TableField("calculate_type") |
| | | private Integer calculateType; |
| | | |
| | | @ApiModelProperty(value = "字段id") |
| | | @TableField("field_id") |
| | | private Integer fieldId; |
| | | |
| | | @ApiModelProperty(value = "计算公式") |
| | | @TableField("caculate_formula") |
| | | private String caculateFormula; |
| | | @TableField("calculate_formula") |
| | | private String calculateFormula; |
| | | |
| | | @ApiModelProperty(value = "隐藏状态(0=展示中 1=已隐藏)") |
| | | @TableField("status") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "删除标志(0代表存在 1代表删除)") |
| | | @TableField("del_flag") |
| | |
| | | |
| | | @ApiModelProperty(value = "配置类型子类型(1=数据指标一/形式指标一 2=数据指标二/形式指标二 3=数据指标三/形式指标三 4=数据指标四/形式指标四)") |
| | | @TableField("sub_type") |
| | | private Boolean subType; |
| | | private Integer subType; |
| | | |
| | | @ApiModelProperty(value = "删除标志(0代表存在 1代表删除)") |
| | | @TableField("del_flag") |
| | |
| | | @ApiModelProperty(value = "县级标志(不包含直辖市的区 0:否 1:是)") |
| | | @TableField("county_flag") |
| | | @Excel(name = "县级标志 是/否",replace = {"是_1","否_2"}) |
| | | private Boolean countyFlag; |
| | | private Integer countyFlag; |
| | | |
| | | @ApiModelProperty(value = "负责人") |
| | | @TableField("person_in_charge") |
| | |
| | | |
| | | @ApiModelProperty(value = "是否重点关注(0:否 1:是)") |
| | | @TableField("focussed") |
| | | private Boolean focussed; |
| | | private Integer focussed; |
| | | |
| | | @ApiModelProperty(value = "创建者") |
| | | @TableField("create_by") |
| | |
| | | |
| | | @ApiModelProperty(value = "字段类型(1=数字 2=文本 3=百分比)") |
| | | @TableField("field_type") |
| | | private Boolean fieldType; |
| | | private Integer fieldType; |
| | | |
| | | @ApiModelProperty(value = "一级分类id") |
| | | @TableField("level_one_category_id") |
| | | private Integer levelOneCategoryId; |
| | | |
| | | @ApiModelProperty(value = "二级分类id") |
| | | @TableField("level_two_category_id") |
| | | private Integer levelTwoCategoryId; |
| | | |
| | | @ApiModelProperty(value = "三级分类id") |
| | | @TableField("level_three_category_id") |
| | | private Integer levelThreeCategoryId; |
| | | |
| | | @ApiModelProperty(value = "一级分类") |
| | | @TableField("level_one_category") |
| | |
| | | @TableField("level_three_category") |
| | | private String levelThreeCategory; |
| | | |
| | | @ApiModelProperty(value = "隐藏状态法(0=展示中 1=已隐藏)") |
| | | @TableField("hidden") |
| | | private Integer hidden; |
| | | @ApiModelProperty(value = "隐藏状态(0=展示中 1=已隐藏)") |
| | | @TableField("status") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "数字最小值") |
| | | @TableField("num_min") |
| | |
| | | @TableField("sort_order") |
| | | private Integer sortOrder; |
| | | |
| | | @ApiModelProperty(value = "状态(0=隐藏 1=显示)") |
| | | @ApiModelProperty(value = "状态(0=展示 1=隐藏)") |
| | | @TableField("status") |
| | | private Integer status; |
| | | |
| | |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | private String fieldCategoryName; |
| | | |
| | | @ApiModelProperty(value = "序号") |
| | | @NotBlank(message = "序号不能为空") |
| | | @NotNull(message = "序号不能为空") |
| | | private Integer sortOrder; |
| | | |
| | | @ApiModelProperty(value = "子分类") |
New file |
| | |
| | | package com.ruoyi.system.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/3/15 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "字段数据传输对象") |
| | | public class FieldDTO { |
| | | |
| | | @ApiModelProperty(value = "字段名") |
| | | @NotBlank(message="字段名不能为空") |
| | | private String fieldName; |
| | | |
| | | @ApiModelProperty(value = "字段类型(1=数字 2=文本 3=百分比)") |
| | | @NotNull(message="字段类型不能为空") |
| | | private Integer fieldType; |
| | | |
| | | @ApiModelProperty(value = "一级分类id") |
| | | @NotNull(message="分类id不能为空") |
| | | private Integer levelOneCategoryId; |
| | | |
| | | @ApiModelProperty(value = "二级分类id") |
| | | private Integer levelTwoCategoryId; |
| | | |
| | | @ApiModelProperty(value = "三级分类id") |
| | | private Integer levelThreeCategoryId; |
| | | |
| | | @ApiModelProperty(value = "数字最小值") |
| | | private Integer numMin; |
| | | |
| | | @ApiModelProperty(value = "数字最大值") |
| | | private Integer numMax; |
| | | |
| | | @ApiModelProperty(value = "文本输入类型(1=手动输入 2=固定内容)") |
| | | private Integer textInputType; |
| | | |
| | | @ApiModelProperty(value = "文本最少字数") |
| | | private Integer textMinNum; |
| | | |
| | | @ApiModelProperty(value = "文本最多字数") |
| | | private Integer textMaxNum; |
| | | |
| | | @ApiModelProperty(value = "文本内容设置(不同内容以','隔开)") |
| | | private String textContent; |
| | | } |
| | |
| | | @NotNull(message = "id不能为空") |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(value = "状态(0=隐藏 1=显示)") |
| | | @ApiModelProperty(value = "状态(0=展示 1=隐藏)") |
| | | @NotNull(message = "status不能为空") |
| | | private Integer status; |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.dto.update; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/3/15 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "字段数据传输对象") |
| | | public class FieldUpdateDTO { |
| | | |
| | | @ApiModelProperty(value = "id") |
| | | @NotBlank(message = "id不能为空") |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(value = "字段名") |
| | | @NotBlank(message="字段名不能为空") |
| | | private String fieldName; |
| | | |
| | | @ApiModelProperty(value = "字段类型(1=数字 2=文本 3=百分比)") |
| | | @NotNull(message="字段类型不能为空") |
| | | private Integer fieldType; |
| | | |
| | | @ApiModelProperty(value = "一级分类id") |
| | | @NotNull(message="分类id不能为空") |
| | | private Integer levelOneCategoryId; |
| | | |
| | | @ApiModelProperty(value = "二级分类id") |
| | | private Integer levelTwoCategoryId; |
| | | |
| | | @ApiModelProperty(value = "三级分类id") |
| | | private Integer levelThreeCategoryId; |
| | | |
| | | @ApiModelProperty(value = "数字最小值") |
| | | private Integer numMin; |
| | | |
| | | @ApiModelProperty(value = "数字最大值") |
| | | private Integer numMax; |
| | | |
| | | @ApiModelProperty(value = "文本输入类型(1=手动输入 2=固定内容)") |
| | | private Integer textInputType; |
| | | |
| | | @ApiModelProperty(value = "文本最少字数") |
| | | private Integer textMinNum; |
| | | |
| | | @ApiModelProperty(value = "文本最多字数") |
| | | private Integer textMaxNum; |
| | | |
| | | @ApiModelProperty(value = "文本内容设置(不同内容以','隔开)") |
| | | private String textContent; |
| | | } |
| | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/3/13 |
| | | */ |
| | | @ApiModel("部门条件查询对象") |
| | | @Data |
| | | @ApiModel("部门条件查询对象") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class DeptQuery extends BasePage { |
| | | |
| | | private static final long serialVersionUID = 2925694647205543161L; |
| | | |
| | | @ApiModelProperty("部门名称") |
| | | private String areaName; |
| | | |
| | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/3/14 |
| | | */ |
| | | @ApiModel("部门条件查询对象") |
| | | @Data |
| | | @ApiModel("部门条件查询对象") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class FieldCategoryQuery extends BasePage { |
| | | |
| | | private static final long serialVersionUID = -1051848065579715873L; |
New file |
| | |
| | | package com.ruoyi.system.query; |
| | | |
| | | import com.ruoyi.common.core.domain.BasePage; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/3/15 |
| | | */ |
| | | @Data |
| | | @ApiModel("字段条件查询对象") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class FieldQuery extends BasePage { |
| | | |
| | | private static final long serialVersionUID = 4027555973828289972L; |
| | | |
| | | @ApiModelProperty(value = "字段名") |
| | | private String fieldName; |
| | | |
| | | @ApiModelProperty(value = "字段类型(1=数字 2=文本 3=百分比)") |
| | | private Integer fieldType; |
| | | |
| | | @ApiModelProperty(value = "所属分类") |
| | | private String levelOneCategory; |
| | | |
| | | @ApiModelProperty(value = "二级分类") |
| | | private String levelTwoCategory; |
| | | |
| | | @ApiModelProperty(value = "三级分类") |
| | | private String levelThreeCategory; |
| | | |
| | | @ApiModelProperty(value = "状态 0=展示 1=隐藏") |
| | | private Integer status; |
| | | } |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.basic.PageVO; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.system.domain.TbDept; |
| | | import com.ruoyi.system.query.DeptQuery; |
| | | import com.ruoyi.system.vo.DeptVO; |
| | |
| | | */ |
| | | public interface TbDeptService extends IService<TbDept> { |
| | | |
| | | PageVO<DeptVO> queryPage(DeptQuery query); |
| | | PageDTO<DeptVO> queryPage(DeptQuery query); |
| | | |
| | | void importExcel(MultipartFile file) throws Exception; |
| | | } |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.basic.PageVO; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.system.domain.TbFieldCategory; |
| | | import com.ruoyi.system.dto.FieldCategoryDTO; |
| | | import com.ruoyi.system.dto.ShowHideDTO; |
| | | import com.ruoyi.system.dto.update.FieldCategoryUpdateDTO; |
| | | import com.ruoyi.system.query.FieldCategoryQuery; |
| | | import com.ruoyi.system.vo.FieldCategoryVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | void add(FieldCategoryDTO dto); |
| | | |
| | | PageVO<FieldCategoryVO> queryPage(FieldCategoryQuery query); |
| | | PageDTO<FieldCategoryVO> queryPage(FieldCategoryQuery query); |
| | | |
| | | void showHide(ShowHideDTO dto); |
| | | |
| | |
| | | void deleteChildren(Integer id); |
| | | |
| | | void delete(Integer id); |
| | | |
| | | List<FieldCategoryVO> queryFieldCategories(Integer id); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.system.domain.TbField; |
| | | import com.ruoyi.system.dto.FieldDTO; |
| | | import com.ruoyi.system.dto.ShowHideDTO; |
| | | import com.ruoyi.system.query.FieldQuery; |
| | | import com.ruoyi.system.vo.FieldVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface TbFieldService extends IService<TbField> { |
| | | |
| | | void add(FieldDTO dto); |
| | | |
| | | void showHide(ShowHideDTO dto); |
| | | |
| | | PageDTO<FieldVO> queryPage(FieldQuery query); |
| | | |
| | | List<String> influencedData(Integer id); |
| | | } |
| | |
| | | import cn.afterturn.easypoi.excel.ExcelImportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ImportParams; |
| | | import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.basic.PageVO; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.utils.CollUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.system.domain.TbDept; |
| | | import com.ruoyi.system.handler.DeptVerifyHandler; |
| | | import com.ruoyi.system.mapper.TbDeptMapper; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.InputStream; |
| | | import java.util.*; |
| | | |
| | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class TbDeptServiceImpl extends ServiceImpl<TbDeptMapper, TbDept> implements TbDeptService { |
| | | |
| | | private final DeptVerifyHandler deptVerifyHandler; |
| | | private final HttpServletResponse response; |
| | | |
| | | @Override |
| | | public PageVO<DeptVO> queryPage(DeptQuery query) { |
| | | public PageDTO<DeptVO> queryPage(DeptQuery query) { |
| | | Page<TbDept> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | LambdaQueryWrapper<TbDept> queryWrapper = new LambdaQueryWrapper<TbDept>() |
| | | .like(StringUtils.isNotEmpty(query.getAreaName()), TbDept::getAreaName, query.getAreaName()) |
| | | Page<TbDept> tbDeptPage = this.lambdaQuery().like(StringUtils.isNotEmpty(query.getAreaName()), TbDept::getAreaName, query.getAreaName()) |
| | | .like(StringUtils.isNotEmpty(query.getAccount()), TbDept::getAccount, query.getAccount()) |
| | | .like(StringUtils.isNotEmpty(query.getPhone()), TbDept::getPhone, query.getPhone()) |
| | | .orderByDesc(TbDept::getCreateTime); |
| | | Page<TbDept> deptPage = this.baseMapper.selectPage(page, queryWrapper); |
| | | PageVO<DeptVO> pageVO = new PageVO<>(); |
| | | pageVO.setPageNo(deptPage.getPages()); |
| | | pageVO.setPageSize(deptPage.getSize()); |
| | | pageVO.setTotalPages(deptPage.getTotal()); |
| | | pageVO.setTotalCount(deptPage.getTotal()); |
| | | IPage<DeptVO> convert = deptPage.convert(result -> { |
| | | DeptVO deptVO = new DeptVO(); |
| | | BeanUtils.copyBeanProp(deptVO, result); |
| | | return deptVO; |
| | | }); |
| | | pageVO.setRecords(convert.getRecords()); |
| | | return pageVO; |
| | | .orderByDesc(TbDept::getCreateTime) |
| | | .page(page); |
| | | if (CollUtils.isEmpty(tbDeptPage.getRecords())) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | return PageDTO.of(tbDeptPage, DeptVO.class); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 校验区划代码是否重复 |
| | | * @param deptList |
| | | * @return |
| | | * @param deptList 部门列表 |
| | | * @return 重复的区划代码 |
| | | */ |
| | | public List<String> hasDuplicateAreaCode(List<TbDept> deptList) { |
| | | Set<String> areaCodes = new HashSet<>(); |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.basic.PageVO; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.enums.ShowStatus; |
| | | import com.ruoyi.common.utils.BeanUtils; |
| | | import com.ruoyi.common.utils.CollUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.system.domain.TbFieldCategory; |
| | | import com.ruoyi.system.dto.FieldCategoryDTO; |
| | | import com.ruoyi.system.dto.ShowHideDTO; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PageVO<FieldCategoryVO> queryPage(FieldCategoryQuery query) { |
| | | public PageDTO<FieldCategoryVO> queryPage(FieldCategoryQuery query) { |
| | | Page<TbFieldCategory> page = this.lambdaQuery() |
| | | .like(StringUtils.isNotBlank(query.getFieldCategoryName()), TbFieldCategory::getFieldCategoryName, query.getFieldCategoryName()) |
| | | .eq(ObjectUtils.isNotEmpty(query.getStatus()), TbFieldCategory::getStatus, query.getStatus()) |
| | | .eq(TbFieldCategory::getParentId, 0) |
| | | .orderByDesc(TbFieldCategory::getCreateTime) |
| | | .page(new Page<>(query.getPageNum(), query.getPageSize())); |
| | | PageVO<FieldCategoryVO> pageVO = new PageVO<>(); |
| | | pageVO.setPageNo(page.getPages()); |
| | | pageVO.setPageSize(page.getSize()); |
| | | pageVO.setTotalPages(page.getTotal()); |
| | | pageVO.setTotalCount(page.getTotal()); |
| | | pageVO.setRecords(page.getRecords().stream().map(item -> { |
| | | FieldCategoryVO fieldCategoryVO = new FieldCategoryVO(); |
| | | BeanUtils.copyBeanProp(fieldCategoryVO, item); |
| | | return fieldCategoryVO; |
| | | }).collect(Collectors.toList())); |
| | | return pageVO; |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | return PageDTO.of(page, FieldCategoryVO.class); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void showHide(ShowHideDTO dto) { |
| | | TbFieldCategory category = this.getById(dto.getId()); |
| | | updateCategoryAndChildren(dto.getId(), dto.getStatus()); |
| | | } |
| | | |
| | | private void updateCategoryAndChildren(Integer id, Integer status) { |
| | | TbFieldCategory category = this.getById(id); |
| | | if (Objects.isNull(category)) { |
| | | throw new RuntimeException("非法id"); |
| | | } |
| | | this.lambdaUpdate().eq(TbFieldCategory::getId, dto.getId()).set(TbFieldCategory::getStatus, dto.getStatus()); |
| | | this.lambdaUpdate() |
| | | .eq(TbFieldCategory::getId, id) |
| | | .set(TbFieldCategory::getStatus, status) |
| | | .update(); |
| | | List<TbFieldCategory> children = this.lambdaQuery().eq(TbFieldCategory::getParentId, category.getId()).list(); |
| | | if (CollUtils.isNotEmpty(children)) { |
| | | List<Integer> childIds = children.stream().map(TbFieldCategory::getId).collect(Collectors.toList()); |
| | | childIds.forEach(childId -> updateCategoryAndChildren(childId, status)); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | public void delete(Integer id) { |
| | | //一级分类 |
| | | TbFieldCategory category = this.getById(id); |
| | | if (Objects.isNull(category)) { |
| | | throw new RuntimeException("非法参数"); |
| | | } |
| | | //查询是否有二级分类 |
| | | List<TbFieldCategory> threeCategoryList = this.lambdaQuery().eq(TbFieldCategory::getParentId, id).list(); |
| | | if (CollectionUtils.isNotEmpty(threeCategoryList)) { |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | private void updateCategory(FieldCategoryUpdateDTO dto) { |
| | | if (dto == null) return; |
| | | this.lambdaUpdate() |
| | |
| | | .eq(TbFieldCategory::getId, dto.getId()) |
| | | .update(); |
| | | } |
| | | |
| | | @Override |
| | | public List<FieldCategoryVO> queryFieldCategories(Integer id) { |
| | | List<TbFieldCategory> list = this.lambdaQuery() |
| | | .select(TbFieldCategory::getId,TbFieldCategory::getFieldCategoryName) |
| | | .eq(TbFieldCategory::getParentId, id) |
| | | .eq(TbFieldCategory::getStatus, ShowStatus.SHOW) |
| | | .list(); |
| | | return BeanUtils.copyList(list, FieldCategoryVO.class); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.json.JSONArray; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.enums.FieldInputTypeEnum; |
| | | import com.ruoyi.common.enums.FieldTypeEnum; |
| | | import com.ruoyi.common.utils.BeanUtils; |
| | | import com.ruoyi.common.utils.CollUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.TbBasicDataConfig; |
| | | import com.ruoyi.system.domain.TbField; |
| | | import com.ruoyi.system.domain.TbFieldCategory; |
| | | import com.ruoyi.system.dto.FieldDTO; |
| | | import com.ruoyi.system.dto.ShowHideDTO; |
| | | import com.ruoyi.system.mapper.TbFieldMapper; |
| | | import com.ruoyi.system.query.FieldQuery; |
| | | import com.ruoyi.system.service.TbBasicDataConfigService; |
| | | import com.ruoyi.system.service.TbFieldCategoryService; |
| | | import com.ruoyi.system.service.TbFieldService; |
| | | import com.ruoyi.system.vo.FieldVO; |
| | | import lombok.Data; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author mitao |
| | | * @since 2024-03-13 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class TbFieldServiceImpl extends ServiceImpl<TbFieldMapper, TbField> implements TbFieldService { |
| | | private final TbFieldCategoryService tbFieldCategoryService; |
| | | private final TbBasicDataConfigService tbBasicDataConfigService; |
| | | |
| | | @Override |
| | | public void add(FieldDTO dto) { |
| | | //参数校验 |
| | | Integer fieldType = dto.getFieldType(); |
| | | //1:数字 2:文本 3:百分比 |
| | | if (FieldTypeEnum.TEXT.getCode().equals(fieldType)) { |
| | | if (StringUtils.isNull(dto.getTextInputType())) { |
| | | throw new RuntimeException("输入类型不能为空"); |
| | | } else if (FieldInputTypeEnum.FIXED_CONTENT.getCode().equals(dto.getTextInputType()) && StringUtils.isBlank(dto.getTextContent())) { |
| | | throw new RuntimeException("内容设置不能为空"); |
| | | } |
| | | } |
| | | TbField tbField = BeanUtils.copyBean(dto, TbField.class); |
| | | TbFieldCategory category1 = tbFieldCategoryService.getById(dto.getLevelOneCategoryId()); |
| | | tbField.setLevelOneCategory(category1.getFieldCategoryName()); |
| | | if (StringUtils.isNotNull(dto.getLevelTwoCategoryId())) { |
| | | TbFieldCategory category2 = tbFieldCategoryService.getById(dto.getLevelTwoCategoryId()); |
| | | tbField.setLevelTwoCategory(category2.getFieldCategoryName()); |
| | | } |
| | | if (StringUtils.isNotNull(dto.getLevelThreeCategoryId())) { |
| | | TbFieldCategory category3 = tbFieldCategoryService.getById(dto.getLevelThreeCategoryId()); |
| | | tbField.setLevelThreeCategory(category3.getFieldCategoryName()); |
| | | } |
| | | this.save(tbField); |
| | | } |
| | | |
| | | @Override |
| | | public void showHide(ShowHideDTO dto) { |
| | | TbField field = this.getById(dto.getId()); |
| | | if (StringUtils.isNull(field)) { |
| | | throw new RuntimeException("非法参数"); |
| | | } |
| | | //隐藏字段 |
| | | this.lambdaUpdate().set(TbField::getStatus, dto.getStatus()).eq(TbField::getId, dto.getId()).update(); |
| | | //隐藏基础数据 TODO |
| | | tbBasicDataConfigService.lambdaUpdate().eq(TbBasicDataConfig::getFieldId, dto.getId()).set(TbBasicDataConfig::getStatus, dto.getStatus()).update(); |
| | | } |
| | | |
| | | @Override |
| | | public PageDTO<FieldVO> queryPage(FieldQuery query) { |
| | | Page<TbField> page = this.lambdaQuery() |
| | | .like(StringUtils.isNotEmpty(query.getFieldName()), TbField::getFieldName, query.getFieldName()) |
| | | .like(StringUtils.isNotEmpty(query.getLevelOneCategory()), TbField::getLevelOneCategory, query.getLevelOneCategory()) |
| | | .like(StringUtils.isNotEmpty(query.getLevelTwoCategory()), TbField::getLevelTwoCategory, query.getLevelTwoCategory()) |
| | | .like(StringUtils.isNotEmpty(query.getLevelThreeCategory()), TbField::getLevelThreeCategory, query.getLevelThreeCategory()) |
| | | .eq(StringUtils.isNotNull(query.getStatus()), TbField::getStatus, query.getStatus()) |
| | | .eq(StringUtils.isNotNull(query.getFieldType()), TbField::getFieldType, query.getFieldType()) |
| | | .orderByDesc(TbField::getCreateTime) |
| | | .page(new Page<>(query.getPageNum(), query.getPageSize())); |
| | | if (CollUtils.isEmpty(page.getRecords())) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | return PageDTO.of(page, FieldVO.class); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> influencedData(Integer id) { |
| | | List<TbBasicDataConfig> list = tbBasicDataConfigService.lambdaQuery().eq(TbBasicDataConfig::getFieldId, id).list(); |
| | | if (CollUtils.isEmpty(list)) { |
| | | return CollUtils.emptyList(); |
| | | } |
| | | return list.stream().map(TbBasicDataConfig::getTypeName).collect(Collectors.toList()); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String string = "蓝色_10,红色_20,绿色_30"; |
| | | String[] split = string.split(","); |
| | | for (String s : split) { |
| | | String[] split1 = s.split("_"); |
| | | System.out.println(split1[1]); |
| | | } |
| | | //百分比1_百分比2:得分 |
| | | String string1 = "10_20:50,20_30:50,30_40:60"; |
| | | CalculateDTO calculateDTO = new CalculateDTO(); |
| | | calculateDTO.setKey("10_20"); |
| | | calculateDTO.setValue("20"); |
| | | CalculateDTO calculateDTO1 = new CalculateDTO(); |
| | | calculateDTO1.setKey("20_30"); |
| | | calculateDTO1.setValue("30"); |
| | | List<CalculateDTO> list = new ArrayList<>(); |
| | | list.add(calculateDTO); |
| | | list.add(calculateDTO1); |
| | | JSONArray objects = new JSONArray(list); |
| | | String jsonString = objects.toJSONString(2); |
| | | System.err.println(jsonString); |
| | | } |
| | | } |
| | | @Data |
| | | class CalculateDTO{ |
| | | private String key; |
| | | private String value; |
| | | } |
| | |
| | | @ApiModelProperty(value = "分类id") |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(value = "状态(0=隐藏 1=显示)") |
| | | @ApiModelProperty(value = "状态(0=展示 1=隐藏)") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "分类名称") |
New file |
| | |
| | | package com.ruoyi.system.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/3/15 |
| | | */ |
| | | @Data |
| | | @ApiModel(value="字段视图对象") |
| | | public class FieldVO { |
| | | |
| | | @ApiModelProperty(value = "字段id") |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(value = "字段名") |
| | | private String fieldName; |
| | | |
| | | @ApiModelProperty(value = "字段类型(1=数字 2=文本 3=百分比)") |
| | | private Integer fieldType; |
| | | |
| | | @ApiModelProperty(value = "一级分类id") |
| | | private Integer levelOneCategoryId; |
| | | |
| | | @ApiModelProperty(value = "二级分类id") |
| | | private Integer levelTwoCategoryId; |
| | | |
| | | @ApiModelProperty(value = "三级分类id") |
| | | private Integer levelThreeCategoryId; |
| | | |
| | | @ApiModelProperty(value = "一级分类") |
| | | private String levelOneCategory; |
| | | |
| | | @ApiModelProperty(value = "二级分类") |
| | | private String levelTwoCategory; |
| | | |
| | | @ApiModelProperty(value = "三级分类") |
| | | private String levelThreeCategory; |
| | | |
| | | @ApiModelProperty(value = "隐藏状态(0=展示中 1=已隐藏)") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "数字最小值") |
| | | private Integer numMin; |
| | | |
| | | @ApiModelProperty(value = "数字最大值") |
| | | private Integer numMax; |
| | | |
| | | @ApiModelProperty(value = "文本输入类型(1=手动输入 2=固定内容)") |
| | | private Integer textInputType; |
| | | |
| | | @ApiModelProperty(value = "文本最少字数") |
| | | private Integer textMinNum; |
| | | |
| | | @ApiModelProperty(value = "文本最多字数") |
| | | private Integer textMaxNum; |
| | | |
| | | @ApiModelProperty(value = "文本内容设置(不同内容以','隔开)") |
| | | private String textContent; |
| | | } |
| | |
| | | <result column="basic_data_category_id" property="basicDataCategoryId" /> |
| | | <result column="type_name" property="typeName" /> |
| | | <result column="field_description" property="fieldDescription" /> |
| | | <result column="caculate_type" property="caculateType" /> |
| | | <result column="caculate_formula" property="caculateFormula" /> |
| | | <result column="calculate_type" property="calculateType" /> |
| | | <result column="calculate_formula" property="calculateFormula" /> |
| | | <result column="status" property="status" /> |
| | | <result column="field_id" property="fieldId" /> |
| | | <result column="del_flag" property="delFlag" /> |
| | | <result column="create_by" property="createBy" /> |
| | | <result column="create_time" property="createTime" /> |
| | |
| | | <result column="level_one_category" property="levelOneCategory" /> |
| | | <result column="level_two_category" property="levelTwoCategory" /> |
| | | <result column="level_three_category" property="levelThreeCategory" /> |
| | | <result column="hidden" property="hidden" /> |
| | | <result column="status" property="status" /> |
| | | <result column="num_min" property="numMin" /> |
| | | <result column="num_max" property="numMax" /> |
| | | <result column="text_input_type" property="textInputType" /> |