forked from sfms3.0/sfms3.0
34 changed files with 914 additions and 22 deletions
@ -1,4 +0,0 @@ |
|||||
/** |
|
||||
* infra API 包,定义暴露给其它模块的 API |
|
||||
*/ |
|
||||
package com.win.module.infra.api; |
|
@ -0,0 +1,15 @@ |
|||||
|
package com.win.module.infra.api.trends; |
||||
|
|
||||
|
import com.win.module.infra.api.trends.dto.TrendsCreateReqDTO; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
|
||||
|
public interface TrendsApi { |
||||
|
|
||||
|
/** |
||||
|
* 创建动态记录 |
||||
|
* @param createDTO |
||||
|
*/ |
||||
|
void createTrends(@Valid TrendsCreateReqDTO createDTO); |
||||
|
|
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
package com.win.module.infra.api.trends.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
|
||||
|
@Data |
||||
|
public class TrendsCreateReqDTO { |
||||
|
|
||||
|
@NotNull(message = "表名不能为空") |
||||
|
private String tableName; |
||||
|
|
||||
|
@NotNull(message = "表数据id不能为空") |
||||
|
private Long tableId; |
||||
|
|
||||
|
@NotNull(message = "类型不能为空") |
||||
|
private Byte type; |
||||
|
|
||||
|
@NotNull(message = "内容不能为空") |
||||
|
private String content; |
||||
|
|
||||
|
} |
@ -1 +0,0 @@ |
|||||
package com.win.module.infra.api; |
|
@ -0,0 +1,26 @@ |
|||||
|
package com.win.module.infra.api.trends; |
||||
|
|
||||
|
import com.win.module.infra.api.trends.dto.TrendsCreateReqDTO; |
||||
|
import com.win.module.infra.service.trends.TrendsService; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
|
||||
|
/** |
||||
|
* API 访问日志的 API 实现类 |
||||
|
* |
||||
|
* @author 闻荫源码 |
||||
|
*/ |
||||
|
@Service |
||||
|
@Validated |
||||
|
public class TrendsApiImpl implements TrendsApi { |
||||
|
|
||||
|
@Resource |
||||
|
private TrendsService trendsService; |
||||
|
|
||||
|
@Override |
||||
|
public void createTrends(TrendsCreateReqDTO createDTO) { |
||||
|
trendsService.createTrends(createDTO); |
||||
|
} |
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
package com.win.module.infra.controller.remark; |
||||
|
|
||||
|
import com.win.framework.common.pojo.CommonResult; |
||||
|
import com.win.module.infra.controller.remark.vo.RemarkCreateReqVO; |
||||
|
import com.win.module.infra.controller.remark.vo.RemarkListReqVO; |
||||
|
import com.win.module.infra.controller.remark.vo.RemarkRespVO; |
||||
|
import com.win.module.infra.convert.remark.RemarkConvert; |
||||
|
import com.win.module.infra.dal.dataobject.remark.RemarkDO; |
||||
|
import com.win.module.infra.service.remark.RemarkService; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.Parameter; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import javax.validation.Valid; |
||||
|
import java.util.List; |
||||
|
|
||||
|
import static com.win.framework.common.pojo.CommonResult.success; |
||||
|
|
||||
|
@Tag(name = "管理后台 - 备注") |
||||
|
@RestController |
||||
|
@RequestMapping("/infra/remark") |
||||
|
@Validated |
||||
|
public class RemarkController { |
||||
|
|
||||
|
@Resource |
||||
|
private RemarkService remarkService; |
||||
|
|
||||
|
@PostMapping("/create") |
||||
|
@Operation(summary = "创建备注") |
||||
|
@PreAuthorize("@ss.hasPermission('infra:remark:create')") |
||||
|
public CommonResult<Long> createRemark(@Valid @RequestBody RemarkCreateReqVO createReqVO) { |
||||
|
return success(remarkService.createRemark(createReqVO)); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/get") |
||||
|
@Operation(summary = "获得备注") |
||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
||||
|
@PreAuthorize("@ss.hasPermission('infra:remark:query')") |
||||
|
public CommonResult<RemarkRespVO> getRemark(@RequestParam("id") Long id) { |
||||
|
RemarkDO remark = remarkService.getRemark(id); |
||||
|
return success(RemarkConvert.INSTANCE.convert(remark)); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/list") |
||||
|
@Operation(summary = "获得备注列表") |
||||
|
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") |
||||
|
@PreAuthorize("@ss.hasPermission('infra:remark:query')") |
||||
|
public CommonResult<List<RemarkRespVO>> getRemarkList(@Valid RemarkListReqVO listVO) { |
||||
|
List<RemarkDO> list = remarkService.getRemarkList(listVO); |
||||
|
return success(RemarkConvert.INSTANCE.convertList(list)); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
package com.win.module.infra.controller.remark.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.*; |
||||
|
import java.util.*; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.LocalDateTime; |
||||
|
import javax.validation.constraints.*; |
||||
|
|
||||
|
/** |
||||
|
* 备注 Base VO,提供给添加、修改、详细的子 VO 使用 |
||||
|
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class RemarkBaseVO { |
||||
|
|
||||
|
@Schema(description = "表名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") |
||||
|
@NotNull(message = "表名不能为空") |
||||
|
private String tableName; |
||||
|
|
||||
|
@Schema(description = "表数据id", requiredMode = Schema.RequiredMode.REQUIRED, example = "8766") |
||||
|
@NotNull(message = "表数据id不能为空") |
||||
|
private Long tableId; |
||||
|
|
||||
|
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便") |
||||
|
@NotNull(message = "备注不能为空") |
||||
|
private String remark; |
||||
|
|
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
package com.win.module.infra.controller.remark.vo; |
||||
|
|
||||
|
import lombok.*; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 备注创建 Request VO") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@ToString(callSuper = true) |
||||
|
public class RemarkCreateReqVO extends RemarkBaseVO { |
||||
|
|
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
package com.win.module.infra.controller.remark.vo; |
||||
|
|
||||
|
import lombok.*; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import com.win.framework.common.pojo.PageParam; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import static com.win.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 备注分页 Request VO") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@ToString(callSuper = true) |
||||
|
public class RemarkListReqVO extends PageParam { |
||||
|
|
||||
|
@Schema(description = "表名", example = "芋艿") |
||||
|
private String tableName; |
||||
|
|
||||
|
@Schema(description = "表数据id", example = "8766") |
||||
|
private Long tableId; |
||||
|
|
||||
|
@Schema(description = "创建时间") |
||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
||||
|
private LocalDateTime[] createTime; |
||||
|
|
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.win.module.infra.controller.remark.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.*; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 备注 Response VO") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@ToString(callSuper = true) |
||||
|
public class RemarkRespVO extends RemarkBaseVO { |
||||
|
|
||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
} |
@ -0,0 +1,81 @@ |
|||||
|
package com.win.module.infra.controller.trends; |
||||
|
|
||||
|
import com.win.framework.common.pojo.CommonResult; |
||||
|
import com.win.framework.common.pojo.PageResult; |
||||
|
import com.win.framework.excel.core.util.ExcelUtils; |
||||
|
import com.win.framework.operatelog.core.annotations.OperateLog; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsExcelVO; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsExportReqVO; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsPageReqVO; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsRespVO; |
||||
|
import com.win.module.infra.convert.trends.TrendsConvert; |
||||
|
import com.win.module.infra.dal.dataobject.trends.TrendsDO; |
||||
|
import com.win.module.infra.service.trends.TrendsService; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.Parameter; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import javax.validation.Valid; |
||||
|
import java.io.IOException; |
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
|
||||
|
import static com.win.framework.common.pojo.CommonResult.success; |
||||
|
import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
||||
|
|
||||
|
@Tag(name = "管理后台 - 动态记录") |
||||
|
@RestController |
||||
|
@RequestMapping("/infra/trends") |
||||
|
@Validated |
||||
|
public class TrendsController { |
||||
|
|
||||
|
@Resource |
||||
|
private TrendsService trendsService; |
||||
|
|
||||
|
@GetMapping("/get") |
||||
|
@Operation(summary = "获得动态记录") |
||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
||||
|
@PreAuthorize("@ss.hasPermission('infra:trends:query')") |
||||
|
public CommonResult<TrendsRespVO> getTrends(@RequestParam("id") Long id) { |
||||
|
TrendsDO trends = trendsService.getTrends(id); |
||||
|
return success(TrendsConvert.INSTANCE.convert(trends)); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/list") |
||||
|
@Operation(summary = "获得动态记录列表") |
||||
|
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") |
||||
|
@PreAuthorize("@ss.hasPermission('infra:trends:query')") |
||||
|
public CommonResult<List<TrendsRespVO>> getTrendsList(@RequestParam("ids") Collection<Long> ids) { |
||||
|
List<TrendsDO> list = trendsService.getTrendsList(ids); |
||||
|
return success(TrendsConvert.INSTANCE.convertList(list)); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/page") |
||||
|
@Operation(summary = "获得动态记录分页") |
||||
|
@PreAuthorize("@ss.hasPermission('infra:trends:query')") |
||||
|
public CommonResult<PageResult<TrendsRespVO>> getTrendsPage(@Valid TrendsPageReqVO pageVO) { |
||||
|
PageResult<TrendsDO> pageResult = trendsService.getTrendsPage(pageVO); |
||||
|
return success(TrendsConvert.INSTANCE.convertPage(pageResult)); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/export-excel") |
||||
|
@Operation(summary = "导出动态记录 Excel") |
||||
|
@PreAuthorize("@ss.hasPermission('infra:trends:export')") |
||||
|
@OperateLog(type = EXPORT) |
||||
|
public void exportTrendsExcel(@Valid TrendsExportReqVO exportReqVO, |
||||
|
HttpServletResponse response) throws IOException { |
||||
|
List<TrendsDO> list = trendsService.getTrendsList(exportReqVO); |
||||
|
// 导出 Excel
|
||||
|
List<TrendsExcelVO> datas = TrendsConvert.INSTANCE.convertList02(list); |
||||
|
ExcelUtils.write(response, "动态记录.xls", "数据", TrendsExcelVO.class, datas); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package com.win.module.infra.controller.trends.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.*; |
||||
|
import java.util.*; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.LocalDateTime; |
||||
|
import javax.validation.constraints.*; |
||||
|
|
||||
|
/** |
||||
|
* 动态记录 Base VO,提供给添加、修改、详细的子 VO 使用 |
||||
|
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class TrendsBaseVO { |
||||
|
|
||||
|
@Schema(description = "表名", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") |
||||
|
@NotNull(message = "表名不能为空") |
||||
|
private String tableName; |
||||
|
|
||||
|
@Schema(description = "表数据id", requiredMode = Schema.RequiredMode.REQUIRED, example = "9210") |
||||
|
@NotNull(message = "表数据id不能为空") |
||||
|
private Long tableId; |
||||
|
|
||||
|
@Schema(description = "类型1增加2删除3修改", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
||||
|
@NotNull(message = "类型1增加2删除3修改不能为空") |
||||
|
private Byte type; |
||||
|
|
||||
|
@Schema(description = "内容") |
||||
|
private String content; |
||||
|
|
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
package com.win.module.infra.controller.trends.vo; |
||||
|
|
||||
|
import lombok.*; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 动态记录创建 Request VO") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@ToString(callSuper = true) |
||||
|
public class TrendsCreateReqVO extends TrendsBaseVO { |
||||
|
|
||||
|
} |
@ -0,0 +1,35 @@ |
|||||
|
package com.win.module.infra.controller.trends.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.*; |
||||
|
import java.util.*; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.alibaba.excel.annotation.ExcelProperty; |
||||
|
|
||||
|
/** |
||||
|
* 动态记录 Excel VO |
||||
|
* |
||||
|
* @author 超级管理员 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class TrendsExcelVO { |
||||
|
|
||||
|
@ExcelProperty("表名") |
||||
|
private String tableName; |
||||
|
|
||||
|
@ExcelProperty("表数据id") |
||||
|
private Long tableId; |
||||
|
|
||||
|
@ExcelProperty("类型1增加2删除3修改") |
||||
|
private Byte type; |
||||
|
|
||||
|
@ExcelProperty("创建时间") |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
@ExcelProperty("内容") |
||||
|
private String content; |
||||
|
|
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package com.win.module.infra.controller.trends.vo; |
||||
|
|
||||
|
import lombok.*; |
||||
|
import java.util.*; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import com.win.framework.common.pojo.PageParam; |
||||
|
import java.time.LocalDateTime; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import static com.win.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 动态记录 Excel 导出 Request VO,参数和 TrendsPageReqVO 是一致的") |
||||
|
@Data |
||||
|
public class TrendsExportReqVO { |
||||
|
|
||||
|
@Schema(description = "表名", example = "赵六") |
||||
|
private String tableName; |
||||
|
|
||||
|
@Schema(description = "表数据id", example = "9210") |
||||
|
private Long tableId; |
||||
|
|
||||
|
@Schema(description = "类型1增加2删除3修改", example = "2") |
||||
|
private Byte type; |
||||
|
|
||||
|
@Schema(description = "创建时间") |
||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
||||
|
private LocalDateTime[] createTime; |
||||
|
|
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
package com.win.module.infra.controller.trends.vo; |
||||
|
|
||||
|
import lombok.*; |
||||
|
import java.util.*; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import com.win.framework.common.pojo.PageParam; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import static com.win.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 动态记录分页 Request VO") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@ToString(callSuper = true) |
||||
|
public class TrendsPageReqVO extends PageParam { |
||||
|
|
||||
|
@Schema(description = "表名", example = "赵六") |
||||
|
private String tableName; |
||||
|
|
||||
|
@Schema(description = "表数据id", example = "9210") |
||||
|
private Long tableId; |
||||
|
|
||||
|
@Schema(description = "类型1增加2删除3修改", example = "2") |
||||
|
private Byte type; |
||||
|
|
||||
|
@Schema(description = "创建时间") |
||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
||||
|
private LocalDateTime[] createTime; |
||||
|
|
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.win.module.infra.controller.trends.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.*; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 动态记录 Response VO") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@ToString(callSuper = true) |
||||
|
public class TrendsRespVO extends TrendsBaseVO { |
||||
|
|
||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.win.module.infra.controller.trends.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.*; |
||||
|
|
||||
|
import javax.validation.constraints.*; |
||||
|
|
||||
|
@Schema(description = "管理后台 - 动态记录更新 Request VO") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@ToString(callSuper = true) |
||||
|
public class TrendsUpdateReqVO extends TrendsBaseVO { |
||||
|
|
||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "3523") |
||||
|
@NotNull(message = "id不能为空") |
||||
|
private Long id; |
||||
|
|
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
package com.win.module.infra.convert.remark; |
||||
|
|
||||
|
import com.win.framework.common.pojo.PageResult; |
||||
|
import com.win.module.infra.controller.remark.vo.RemarkCreateReqVO; |
||||
|
import com.win.module.infra.controller.remark.vo.RemarkRespVO; |
||||
|
import com.win.module.infra.dal.dataobject.remark.RemarkDO; |
||||
|
import org.mapstruct.Mapper; |
||||
|
import org.mapstruct.factory.Mappers; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 备注 Convert |
||||
|
* |
||||
|
* @author 超级管理员 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface RemarkConvert { |
||||
|
|
||||
|
RemarkConvert INSTANCE = Mappers.getMapper(RemarkConvert.class); |
||||
|
|
||||
|
RemarkDO convert(RemarkCreateReqVO bean); |
||||
|
|
||||
|
RemarkRespVO convert(RemarkDO bean); |
||||
|
|
||||
|
List<RemarkRespVO> convertList(List<RemarkDO> list); |
||||
|
|
||||
|
PageResult<RemarkRespVO> convertPage(PageResult<RemarkDO> page); |
||||
|
|
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
package com.win.module.infra.convert.trends; |
||||
|
|
||||
|
import com.win.framework.common.pojo.PageResult; |
||||
|
import com.win.module.infra.api.trends.dto.TrendsCreateReqDTO; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsCreateReqVO; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsExcelVO; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsRespVO; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsUpdateReqVO; |
||||
|
import com.win.module.infra.dal.dataobject.trends.TrendsDO; |
||||
|
import org.mapstruct.Mapper; |
||||
|
import org.mapstruct.factory.Mappers; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 动态记录 Convert |
||||
|
* |
||||
|
* @author 超级管理员 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface TrendsConvert { |
||||
|
|
||||
|
TrendsConvert INSTANCE = Mappers.getMapper(TrendsConvert.class); |
||||
|
|
||||
|
TrendsDO convert(TrendsCreateReqVO bean); |
||||
|
|
||||
|
TrendsDO convert(TrendsUpdateReqVO bean); |
||||
|
|
||||
|
TrendsRespVO convert(TrendsDO bean); |
||||
|
|
||||
|
List<TrendsRespVO> convertList(List<TrendsDO> list); |
||||
|
|
||||
|
PageResult<TrendsRespVO> convertPage(PageResult<TrendsDO> page); |
||||
|
|
||||
|
List<TrendsExcelVO> convertList02(List<TrendsDO> list); |
||||
|
|
||||
|
TrendsDO convert(TrendsCreateReqDTO trendsDTO); |
||||
|
|
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
package com.win.module.infra.dal.dataobject.remark; |
||||
|
|
||||
|
import lombok.*; |
||||
|
import java.util.*; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.LocalDateTime; |
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import com.win.framework.mybatis.core.dataobject.BaseDO; |
||||
|
|
||||
|
/** |
||||
|
* 备注 DO |
||||
|
* |
||||
|
* @author 超级管理员 |
||||
|
*/ |
||||
|
@TableName("infra_remark") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@ToString(callSuper = true) |
||||
|
@Builder |
||||
|
@NoArgsConstructor |
||||
|
@AllArgsConstructor |
||||
|
public class RemarkDO extends BaseDO { |
||||
|
|
||||
|
/** |
||||
|
* id |
||||
|
*/ |
||||
|
@TableId |
||||
|
private Long id; |
||||
|
/** |
||||
|
* 表名 |
||||
|
*/ |
||||
|
private String tableName; |
||||
|
/** |
||||
|
* 表数据id |
||||
|
*/ |
||||
|
private Long tableId; |
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
private String remark; |
||||
|
/** |
||||
|
* 删除时间 |
||||
|
*/ |
||||
|
private LocalDateTime deletionTime; |
||||
|
/** |
||||
|
* 删除者ID |
||||
|
*/ |
||||
|
private String deleterId; |
||||
|
|
||||
|
} |
@ -0,0 +1,55 @@ |
|||||
|
package com.win.module.infra.dal.dataobject.trends; |
||||
|
|
||||
|
import lombok.*; |
||||
|
import java.util.*; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.LocalDateTime; |
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import com.win.framework.mybatis.core.dataobject.BaseDO; |
||||
|
|
||||
|
/** |
||||
|
* 动态记录 DO |
||||
|
* |
||||
|
* @author 超级管理员 |
||||
|
*/ |
||||
|
@TableName("infra_trends") |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@ToString(callSuper = true) |
||||
|
@Builder |
||||
|
@NoArgsConstructor |
||||
|
@AllArgsConstructor |
||||
|
public class TrendsDO extends BaseDO { |
||||
|
|
||||
|
/** |
||||
|
* id |
||||
|
*/ |
||||
|
@TableId |
||||
|
private Long id; |
||||
|
/** |
||||
|
* 表名 |
||||
|
*/ |
||||
|
private String tableName; |
||||
|
/** |
||||
|
* 表数据id |
||||
|
*/ |
||||
|
private Long tableId; |
||||
|
/** |
||||
|
* 类型1增加2删除3修改 |
||||
|
*/ |
||||
|
private Byte type; |
||||
|
/** |
||||
|
* 删除时间 |
||||
|
*/ |
||||
|
private LocalDateTime deletionTime; |
||||
|
/** |
||||
|
* 删除者ID |
||||
|
*/ |
||||
|
private String deleterId; |
||||
|
/** |
||||
|
* 内容 |
||||
|
*/ |
||||
|
private String content; |
||||
|
|
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
package com.win.module.infra.dal.mysql.remark; |
||||
|
|
||||
|
import com.win.framework.mybatis.core.mapper.BaseMapperX; |
||||
|
import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; |
||||
|
import com.win.module.infra.controller.remark.vo.RemarkListReqVO; |
||||
|
import com.win.module.infra.dal.dataobject.remark.RemarkDO; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 备注 Mapper |
||||
|
* |
||||
|
* @author 超级管理员 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface RemarkMapper extends BaseMapperX<RemarkDO> { |
||||
|
|
||||
|
default List<RemarkDO> selectList(RemarkListReqVO reqVO) { |
||||
|
return selectList(new LambdaQueryWrapperX<RemarkDO>() |
||||
|
.likeIfPresent(RemarkDO::getTableName, reqVO.getTableName()) |
||||
|
.eqIfPresent(RemarkDO::getTableId, reqVO.getTableId()) |
||||
|
.betweenIfPresent(RemarkDO::getCreateTime, reqVO.getCreateTime()) |
||||
|
.orderByDesc(RemarkDO::getId)); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
package com.win.module.infra.dal.mysql.trends; |
||||
|
|
||||
|
import java.util.*; |
||||
|
|
||||
|
import com.win.framework.common.pojo.PageResult; |
||||
|
import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; |
||||
|
import com.win.framework.mybatis.core.mapper.BaseMapperX; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsExportReqVO; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsPageReqVO; |
||||
|
import com.win.module.infra.dal.dataobject.trends.TrendsDO; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
/** |
||||
|
* 动态记录 Mapper |
||||
|
* |
||||
|
* @author 超级管理员 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface TrendsMapper extends BaseMapperX<TrendsDO> { |
||||
|
|
||||
|
default PageResult<TrendsDO> selectPage(TrendsPageReqVO reqVO) { |
||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<TrendsDO>() |
||||
|
.eqIfPresent(TrendsDO::getTableName, reqVO.getTableName()) |
||||
|
.eqIfPresent(TrendsDO::getTableId, reqVO.getTableId()) |
||||
|
.eqIfPresent(TrendsDO::getType, reqVO.getType()) |
||||
|
.betweenIfPresent(TrendsDO::getCreateTime, reqVO.getCreateTime()) |
||||
|
.orderByDesc(TrendsDO::getId)); |
||||
|
} |
||||
|
|
||||
|
default List<TrendsDO> selectList(TrendsExportReqVO reqVO) { |
||||
|
return selectList(new LambdaQueryWrapperX<TrendsDO>() |
||||
|
.eqIfPresent(TrendsDO::getTableName, reqVO.getTableName()) |
||||
|
.eqIfPresent(TrendsDO::getTableId, reqVO.getTableId()) |
||||
|
.eqIfPresent(TrendsDO::getType, reqVO.getType()) |
||||
|
.betweenIfPresent(TrendsDO::getCreateTime, reqVO.getCreateTime()) |
||||
|
.orderByDesc(TrendsDO::getId)); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
package com.win.module.infra.service.remark; |
||||
|
|
||||
|
import com.win.module.infra.controller.remark.vo.RemarkCreateReqVO; |
||||
|
import com.win.module.infra.controller.remark.vo.RemarkListReqVO; |
||||
|
import com.win.module.infra.dal.dataobject.remark.RemarkDO; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 备注 Service 接口 |
||||
|
* |
||||
|
* @author 超级管理员 |
||||
|
*/ |
||||
|
public interface RemarkService { |
||||
|
|
||||
|
/** |
||||
|
* 创建备注 |
||||
|
* |
||||
|
* @param createReqVO 创建信息 |
||||
|
* @return 编号 |
||||
|
*/ |
||||
|
Long createRemark(@Valid RemarkCreateReqVO createReqVO); |
||||
|
|
||||
|
/** |
||||
|
* 获得备注 |
||||
|
* |
||||
|
* @param id 编号 |
||||
|
* @return 备注 |
||||
|
*/ |
||||
|
RemarkDO getRemark(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 获得备注列表, 用于 Excel 导出 |
||||
|
* |
||||
|
* @param listReqVO 查询条件 |
||||
|
* @return 备注列表 |
||||
|
*/ |
||||
|
List<RemarkDO> getRemarkList(RemarkListReqVO listReqVO); |
||||
|
|
||||
|
} |
@ -0,0 +1,45 @@ |
|||||
|
package com.win.module.infra.service.remark; |
||||
|
|
||||
|
import com.win.module.infra.controller.remark.vo.RemarkCreateReqVO; |
||||
|
import com.win.module.infra.controller.remark.vo.RemarkListReqVO; |
||||
|
import com.win.module.infra.convert.remark.RemarkConvert; |
||||
|
import com.win.module.infra.dal.dataobject.remark.RemarkDO; |
||||
|
import com.win.module.infra.dal.mysql.remark.RemarkMapper; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 备注 Service 实现类 |
||||
|
* |
||||
|
* @author 超级管理员 |
||||
|
*/ |
||||
|
@Service |
||||
|
@Validated |
||||
|
public class RemarkServiceImpl implements RemarkService { |
||||
|
|
||||
|
@Resource |
||||
|
private RemarkMapper remarkMapper; |
||||
|
|
||||
|
@Override |
||||
|
public Long createRemark(RemarkCreateReqVO createReqVO) { |
||||
|
// 插入
|
||||
|
RemarkDO remark = RemarkConvert.INSTANCE.convert(createReqVO); |
||||
|
remarkMapper.insert(remark); |
||||
|
// 返回
|
||||
|
return remark.getId(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public RemarkDO getRemark(Long id) { |
||||
|
return remarkMapper.selectById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<RemarkDO> getRemarkList(RemarkListReqVO listReqVO) { |
||||
|
return remarkMapper.selectList(listReqVO); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,59 @@ |
|||||
|
package com.win.module.infra.service.trends; |
||||
|
|
||||
|
import com.win.framework.common.pojo.PageResult; |
||||
|
import com.win.module.infra.api.trends.dto.TrendsCreateReqDTO; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsExportReqVO; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsPageReqVO; |
||||
|
import com.win.module.infra.dal.dataobject.trends.TrendsDO; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 动态记录 Service 接口 |
||||
|
* |
||||
|
* @author 超级管理员 |
||||
|
*/ |
||||
|
public interface TrendsService { |
||||
|
|
||||
|
/** |
||||
|
* 创建动态记录 |
||||
|
* |
||||
|
* @param createReqVO 创建信息 |
||||
|
*/ |
||||
|
void createTrends(@Valid TrendsCreateReqDTO createReqVO); |
||||
|
|
||||
|
/** |
||||
|
* 获得动态记录 |
||||
|
* |
||||
|
* @param id 编号 |
||||
|
* @return 动态记录 |
||||
|
*/ |
||||
|
TrendsDO getTrends(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 获得动态记录列表 |
||||
|
* |
||||
|
* @param ids 编号 |
||||
|
* @return 动态记录列表 |
||||
|
*/ |
||||
|
List<TrendsDO> getTrendsList(Collection<Long> ids); |
||||
|
|
||||
|
/** |
||||
|
* 获得动态记录分页 |
||||
|
* |
||||
|
* @param pageReqVO 分页查询 |
||||
|
* @return 动态记录分页 |
||||
|
*/ |
||||
|
PageResult<TrendsDO> getTrendsPage(TrendsPageReqVO pageReqVO); |
||||
|
|
||||
|
/** |
||||
|
* 获得动态记录列表, 用于 Excel 导出 |
||||
|
* |
||||
|
* @param exportReqVO 查询条件 |
||||
|
* @return 动态记录列表 |
||||
|
*/ |
||||
|
List<TrendsDO> getTrendsList(TrendsExportReqVO exportReqVO); |
||||
|
|
||||
|
} |
@ -0,0 +1,55 @@ |
|||||
|
package com.win.module.infra.service.trends; |
||||
|
|
||||
|
import com.win.framework.common.pojo.PageResult; |
||||
|
import com.win.module.infra.api.trends.dto.TrendsCreateReqDTO; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsExportReqVO; |
||||
|
import com.win.module.infra.controller.trends.vo.TrendsPageReqVO; |
||||
|
import com.win.module.infra.convert.trends.TrendsConvert; |
||||
|
import com.win.module.infra.dal.dataobject.trends.TrendsDO; |
||||
|
import com.win.module.infra.dal.mysql.trends.TrendsMapper; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 动态记录 Service 实现类 |
||||
|
* |
||||
|
* @author 超级管理员 |
||||
|
*/ |
||||
|
@Service |
||||
|
@Validated |
||||
|
public class TrendsServiceImpl implements TrendsService { |
||||
|
|
||||
|
@Resource |
||||
|
private TrendsMapper trendsMapper; |
||||
|
|
||||
|
@Override |
||||
|
public void createTrends(TrendsCreateReqDTO createReqDTO) { |
||||
|
TrendsDO trends = TrendsConvert.INSTANCE.convert(createReqDTO); |
||||
|
trendsMapper.insert(trends); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public TrendsDO getTrends(Long id) { |
||||
|
return trendsMapper.selectById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<TrendsDO> getTrendsList(Collection<Long> ids) { |
||||
|
return trendsMapper.selectBatchIds(ids); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public PageResult<TrendsDO> getTrendsPage(TrendsPageReqVO pageReqVO) { |
||||
|
return trendsMapper.selectPage(pageReqVO); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<TrendsDO> getTrendsList(TrendsExportReqVO exportReqVO) { |
||||
|
return trendsMapper.selectList(exportReqVO); |
||||
|
} |
||||
|
|
||||
|
} |
@ -1,16 +0,0 @@ |
|||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|
||||
<mapper namespace="com.win.module.infra.dal.mysql.test.TestDemoMapper"> |
|
||||
|
|
||||
<!-- |
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 |
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 |
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ |
|
||||
--> |
|
||||
|
|
||||
<select id="selectList2" resultType="com.win.module.infra.dal.dataobject.test.TestDemoDO"> |
|
||||
SELECT * FROM infra_test_demo |
|
||||
</select> |
|
||||
|
|
||||
</mapper> |
|
Loading…
Reference in new issue