From 77e4741346fb02d5a1f845b89f681a56d06dad0e Mon Sep 17 00:00:00 2001 From: 安瑾然 <107107765@qq.com> Date: 星期二, 12 七月 2022 14:59:29 +0800 Subject: [PATCH] minio接口修正,宣传、常见问题接口开发 --- src/main/java/com/example/jz/modle/entity/Publicity.java | 94 ++---- src/main/java/com/example/jz/service/impl/MinIOServiceImpl.java | 68 ++- src/main/java/com/example/jz/modle/R.java | 4 src/main/java/com/example/jz/service/impl/PublicityServiceImpl.java | 36 ++ src/main/java/com/example/jz/service/MinIOService.java | 6 src/main/java/com/example/jz/service/CommonQuestionService.java | 5 src/main/java/com/example/jz/modle/dto/CommonQuestionDto.java | 61 ++++ src/main/java/com/example/jz/modle/dto/PublicityDto.java | 61 ++++ src/main/java/com/example/jz/config/SwaggerConfig.java | 4 pom.xml | 20 + src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java | 5 src/main/java/com/example/jz/controller/CommonQuestionController.java | 34 + src/main/java/com/example/jz/modle/entity/Message.java | 57 --- src/main/resources/application.properties | 10 src/test/java/com/example/jz/MinIOTest.java | 18 + src/main/java/com/example/jz/modle/entity/CommonQuestion.java | 97 +---- src/main/java/com/example/jz/dao/CommonQuestionDao.java | 6 src/main/resources/mapper/PublicityDao.xml | 34 ++ src/main/java/com/example/jz/controller/MinIOController.java | 28 + src/main/java/com/example/jz/controller/PublicityController.java | 75 +++- src/main/java/com/example/jz/controller/AnnouncementController.java | 2 src/main/java/com/example/jz/dao/PublicityDao.java | 6 src/main/java/com/example/jz/config/MybatisPlusConfig.java | 1 src/main/java/com/example/jz/modle/PageParam.java | 106 +++++++ src/main/java/com/example/jz/service/PublicityService.java | 11 src/main/resources/mapper/CommonQuestionDao.xml | 38 ++ src/main/java/com/example/jz/service/impl/CommonQuestionServiceImpl.java | 12 27 files changed, 639 insertions(+), 260 deletions(-) diff --git a/pom.xml b/pom.xml index 5bb23bd..217e9f4 100644 --- a/pom.xml +++ b/pom.xml @@ -49,6 +49,26 @@ <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>3.0.0</version> + <exclusions> + <exclusion> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + </exclusion> + <exclusion> + <groupId>io.swagger</groupId> + <artifactId>swagger-models</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>1.5.21</version> + </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-models</artifactId> + <version>1.5.21</version> </dependency> <dependency> <groupId>com.github.xiaoymin</groupId> diff --git a/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java b/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java index f61d378..ce97b0b 100644 --- a/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java +++ b/src/main/java/com/example/jz/config/DefaultExceptionHandlerConfig.java @@ -1,10 +1,7 @@ package com.example.jz.config; -import com.example.jz.enums.BusinessHttpStatus; import com.example.jz.exception.BusinessException; -import com.example.jz.modle.entity.R; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; +import com.example.jz.modle.R; import org.springframework.stereotype.Controller; import org.springframework.validation.BindException; import org.springframework.web.bind.MethodArgumentNotValidException; diff --git a/src/main/java/com/example/jz/config/MybatisPlusConfig.java b/src/main/java/com/example/jz/config/MybatisPlusConfig.java index 24e21b7..aa3fe75 100644 --- a/src/main/java/com/example/jz/config/MybatisPlusConfig.java +++ b/src/main/java/com/example/jz/config/MybatisPlusConfig.java @@ -13,6 +13,7 @@ public class MybatisPlusConfig { /** * 鍒嗛〉鎻掍欢 + * * @return PaginationInterceptor */ @Bean diff --git a/src/main/java/com/example/jz/config/SwaggerConfig.java b/src/main/java/com/example/jz/config/SwaggerConfig.java index 1e6898e..4269a27 100644 --- a/src/main/java/com/example/jz/config/SwaggerConfig.java +++ b/src/main/java/com/example/jz/config/SwaggerConfig.java @@ -20,7 +20,7 @@ return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() - .apis(RequestHandlerSelectors.basePackage("com.school")) + .apis(RequestHandlerSelectors.basePackage("com.example.jz")) .paths(PathSelectors.any()) .build(); } @@ -31,7 +31,7 @@ .title("闈掔緤缁忎睛鎺ュ彛鏂囨。") .description("闈掔緤缁忎睛鎺ュ彛鏂囨。Swagger鐗�") .termsOfServiceUrl("https://www.baidu.com/") - .contact(new Contact("瀹夌懢鐒�","https://www.baidu.com/", "1070107765@qq.com")) + .contact(new Contact("浼樺垱绔�", "https://www.baidu.com/", "1070107765@qq.com")) .version("1.0") .build(); } diff --git a/src/main/java/com/example/jz/controller/AnnouncementController.java b/src/main/java/com/example/jz/controller/AnnouncementController.java index 4c09abe..3dadd1e 100644 --- a/src/main/java/com/example/jz/controller/AnnouncementController.java +++ b/src/main/java/com/example/jz/controller/AnnouncementController.java @@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.api.ApiController; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.example.jz.modle.entity.Announcement; -import com.example.jz.modle.entity.R; +import com.example.jz.modle.R; import com.example.jz.service.AnnouncementService; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/com/example/jz/controller/CommonQuestionController.java b/src/main/java/com/example/jz/controller/CommonQuestionController.java index c99d745..eca49b5 100644 --- a/src/main/java/com/example/jz/controller/CommonQuestionController.java +++ b/src/main/java/com/example/jz/controller/CommonQuestionController.java @@ -1,13 +1,15 @@ package com.example.jz.controller; - import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.api.ApiController; import com.baomidou.mybatisplus.extension.api.R; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.example.jz.modle.PageParam; import com.example.jz.modle.entity.CommonQuestion; import com.example.jz.service.CommonQuestionService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -22,6 +24,7 @@ */ @RestController @RequestMapping("commonQuestion") +@Api(tags = "甯歌闂琛�(CommonQuestion)琛ㄦ帴鍙�") public class CommonQuestionController extends ApiController { /** * 鏈嶅姟瀵硅薄 @@ -32,13 +35,14 @@ /** * 鍒嗛〉鏌ヨ鎵�鏈夋暟鎹� * - * @param page 鍒嗛〉瀵硅薄 + * @param page 鍒嗛〉瀵硅薄 * @param commonQuestion 鏌ヨ瀹炰綋 * @return 鎵�鏈夋暟鎹� */ @GetMapping - public R selectAll(Page<CommonQuestion> page, CommonQuestion commonQuestion) { - return success(this.commonQuestionService.page(page, new QueryWrapper<>(commonQuestion))); + @ApiOperation("鍒嗛〉鏌ヨ鎵�鏈夋暟鎹�") + public R<IPage<CommonQuestion>> selectAll(PageParam<CommonQuestion> page, CommonQuestion commonQuestion) { + return R.ok(commonQuestionService.page(page, new QueryWrapper<>(commonQuestion))); } /** @@ -48,8 +52,9 @@ * @return 鍗曟潯鏁版嵁 */ @GetMapping("{id}") - public R selectOne(@PathVariable Serializable id) { - return success(this.commonQuestionService.getById(id)); + @ApiOperation(value = "閫氳繃涓婚敭鏌ヨ鍗曟潯鏁版嵁", notes = "閫氳繃涓婚敭鏌ヨ鍗曟潯鏁版嵁") + public R<CommonQuestion> selectOne(@PathVariable Serializable id) { + return R.ok(commonQuestionService.getById(id)); } /** @@ -59,8 +64,9 @@ * @return 鏂板缁撴灉 */ @PostMapping - public R insert(@RequestBody CommonQuestion commonQuestion) { - return success(this.commonQuestionService.save(commonQuestion)); + @ApiOperation(value = "鏂板鏁版嵁", notes = "鏂板鏁版嵁") + public R<Boolean> insert(@RequestBody CommonQuestion commonQuestion) { + return R.ok(commonQuestionService.save(commonQuestion)); } /** @@ -70,8 +76,9 @@ * @return 淇敼缁撴灉 */ @PutMapping - public R update(@RequestBody CommonQuestion commonQuestion) { - return success(this.commonQuestionService.updateById(commonQuestion)); + @ApiOperation(value = "淇敼鏁版嵁", notes = "淇敼鏁版嵁") + public R<Boolean> update(@RequestBody CommonQuestion commonQuestion) { + return R.ok(commonQuestionService.updateById(commonQuestion)); } /** @@ -81,8 +88,9 @@ * @return 鍒犻櫎缁撴灉 */ @DeleteMapping - public R delete(@RequestParam("idList") List<Long> idList) { - return success(this.commonQuestionService.removeByIds(idList)); + @ApiOperation(value = "鍒犻櫎鏁版嵁", notes = "鍒犻櫎鏁版嵁") + public R<Boolean> delete(@RequestParam("idList") List<Long> idList) { + return R.ok(commonQuestionService.removeByIds(idList)); } } diff --git a/src/main/java/com/example/jz/controller/MinIOController.java b/src/main/java/com/example/jz/controller/MinIOController.java index e640f40..5924f20 100644 --- a/src/main/java/com/example/jz/controller/MinIOController.java +++ b/src/main/java/com/example/jz/controller/MinIOController.java @@ -1,21 +1,35 @@ package com.example.jz.controller; +import com.example.jz.modle.R; import com.example.jz.service.MinIOService; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import java.io.IOException; @RestController @RequestMapping("/minio") +@Api(tags = "MinIO鎺ュ彛") public class MinIOController { @Resource private MinIOService minIOService; - @RequestMapping(method = RequestMethod.GET,value = "/{fileName}") - public String getUrl(@PathVariable String fileName){ - return ""; + @RequestMapping(method = RequestMethod.GET, value = "/getUrl") + @ApiOperation("鑾峰彇鏂囦欢棰勮鍦板潃") + public R<String> getUrl(@RequestParam String fileName) { + return R.ok(minIOService.getPreviewFileUrl(fileName)); + } + + @PostMapping("/upload") + @ApiOperation("涓婁紶鏂囦欢") + public R<String> uploadFile(@RequestParam("file") MultipartFile file) throws IOException { + if (file.isEmpty()) { + return R.failed("鏂囦欢涓虹┖"); + } + String fileName = minIOService.upload(file); + return R.ok(fileName); } } diff --git a/src/main/java/com/example/jz/controller/PublicityController.java b/src/main/java/com/example/jz/controller/PublicityController.java index 288c017..6521d7d 100644 --- a/src/main/java/com/example/jz/controller/PublicityController.java +++ b/src/main/java/com/example/jz/controller/PublicityController.java @@ -1,18 +1,20 @@ package com.example.jz.controller; - import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.api.ApiController; -import com.baomidou.mybatisplus.extension.api.R; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.example.jz.modle.PageParam; import com.example.jz.modle.entity.Publicity; +import com.example.jz.modle.R; import com.example.jz.service.PublicityService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.io.Serializable; -import java.util.List; +import java.util.Date; /** * 鍏叡瀹d紶琛�(Publicity)琛ㄦ帶鍒跺眰 @@ -22,7 +24,8 @@ */ @RestController @RequestMapping("publicity") -public class PublicityController extends ApiController { +@Api(tags = "鍏叡瀹d紶琛�(Publicity)琛ㄦ帴鍙�") +public class PublicityController { /** * 鏈嶅姟瀵硅薄 */ @@ -32,13 +35,14 @@ /** * 鍒嗛〉鏌ヨ鎵�鏈夋暟鎹� * - * @param page 鍒嗛〉瀵硅薄 + * @param page 鍒嗛〉瀵硅薄 * @param publicity 鏌ヨ瀹炰綋 * @return 鎵�鏈夋暟鎹� */ @GetMapping - public R selectAll(Page<Publicity> page, Publicity publicity) { - return success(this.publicityService.page(page, new QueryWrapper<>(publicity))); + @ApiOperation("鍒嗛〉鏌ヨ鎵�鏈夋暟鎹�") + public R<IPage<Publicity>> selectAll(PageParam<Publicity> page, Publicity publicity) { + return R.ok(publicityService.page(page, new QueryWrapper<>(publicity))); } /** @@ -48,8 +52,9 @@ * @return 鍗曟潯鏁版嵁 */ @GetMapping("{id}") - public R selectOne(@PathVariable Serializable id) { - return success(this.publicityService.getById(id)); + @ApiOperation("閫氳繃涓婚敭鏌ヨ鍗曟潯鏁版嵁") + public R<Publicity> selectOne(@PathVariable Serializable id) { + return R.ok(publicityService.getById(id)); } /** @@ -59,8 +64,10 @@ * @return 鏂板缁撴灉 */ @PostMapping - public R insert(@RequestBody Publicity publicity) { - return success(this.publicityService.save(publicity)); + @ApiOperation("娣诲姞鍏叡瀹d紶") + public R<Boolean> insert(@RequestBody Publicity publicity) { + publicity.setCtime(new Date()); + return R.ok(publicityService.save(publicity)); } /** @@ -70,19 +77,45 @@ * @return 淇敼缁撴灉 */ @PutMapping - public R update(@RequestBody Publicity publicity) { - return success(this.publicityService.updateById(publicity)); + @ApiOperation("淇敼鍏叡瀹d紶鍐呭") + public R<Boolean> update(@RequestBody Publicity publicity) { + return R.ok(publicityService.updateById(publicity)); } /** - * 鍒犻櫎鏁版嵁 + * 涓嬫灦鍏叡瀹d紶 * - * @param idList 涓婚敭缁撳悎 - * @return 鍒犻櫎缁撴灉 + * @param id 涓婚敭缁撳悎 + * @return 鎵ц缁撴灉 */ - @DeleteMapping - public R delete(@RequestParam("idList") List<Long> idList) { - return success(this.publicityService.removeByIds(idList)); + @GetMapping("status/down/{id}") + @ApiOperation("涓嬫灦鍏叡瀹d紶") + public R<Boolean> undercarriage(@PathVariable Serializable id) { + return R.ok(publicityService.undercarriage(id)); + } + + /** + * 涓婃灦鍏叡瀹d紶 + * + * @param id 涓婚敭缁撳悎 + * @return 鎵ц缁撴灉 + */ + @GetMapping("status/up/{id}") + @ApiOperation("涓婃灦鍏叡瀹d紶") + public R<Boolean> grounding(@PathVariable Serializable id) { + return R.ok(publicityService.grounding(id)); + } + + /** + * 鍒犻櫎鍏叡瀹d紶 + * + * @param id 涓婚敭缁撳悎 + * @return 鎵ц缁撴灉 + */ + @DeleteMapping("{id}") + @ApiOperation("鍒犻櫎鍏叡瀹d紶") + public R<Boolean> delete(@PathVariable Serializable id) { + return R.ok(publicityService.removeById(id)); } } diff --git a/src/main/java/com/example/jz/dao/CommonQuestionDao.java b/src/main/java/com/example/jz/dao/CommonQuestionDao.java index b1e7821..0db6c35 100644 --- a/src/main/java/com/example/jz/dao/CommonQuestionDao.java +++ b/src/main/java/com/example/jz/dao/CommonQuestionDao.java @@ -1,7 +1,12 @@ package com.example.jz.dao; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.example.jz.modle.dto.CommonQuestionDto; import com.example.jz.modle.entity.CommonQuestion; +import org.apache.ibatis.annotations.Param; /** * 甯歌闂琛�(CommonQuestion)琛ㄦ暟鎹簱璁块棶灞� @@ -11,5 +16,6 @@ */ public interface CommonQuestionDao extends BaseMapper<CommonQuestion> { + IPage<CommonQuestionDto> findByPage(Page<CommonQuestionDto> page,@Param("qw") QueryWrapper<Object> objectQueryWrapper); } diff --git a/src/main/java/com/example/jz/dao/PublicityDao.java b/src/main/java/com/example/jz/dao/PublicityDao.java index 1016f4b..8235881 100644 --- a/src/main/java/com/example/jz/dao/PublicityDao.java +++ b/src/main/java/com/example/jz/dao/PublicityDao.java @@ -1,7 +1,12 @@ package com.example.jz.dao; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.example.jz.modle.PageParam; +import com.example.jz.modle.dto.PublicityDto; import com.example.jz.modle.entity.Publicity; +import org.apache.ibatis.annotations.Param; /** * 鍏叡瀹d紶琛�(Publicity)琛ㄦ暟鎹簱璁块棶灞� @@ -11,5 +16,6 @@ */ public interface PublicityDao extends BaseMapper<Publicity> { + IPage<PublicityDto> findByPage(PageParam<PublicityDto> page,@Param("qw") QueryWrapper<PublicityDto> publicityDtoQueryWrapper); } diff --git a/src/main/java/com/example/jz/modle/PageParam.java b/src/main/java/com/example/jz/modle/PageParam.java new file mode 100644 index 0000000..c68f6a0 --- /dev/null +++ b/src/main/java/com/example/jz/modle/PageParam.java @@ -0,0 +1,106 @@ +package com.example.jz.modle; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.ApiParam; + +import java.util.List; + +public class PageParam<T> extends Page<T> { + + /** + * 鏌ヨ鏁版嵁鍒楄〃 + */ + @ApiParam(hidden = true) + private List<T> records; + /** + * 鎬绘暟 + */ + @ApiParam(hidden = true) + private long total = 0; + + /** + * 姣忛〉鏄剧ず鏉℃暟锛岄粯璁� 10 + */ + @ApiParam(value = "姣忛〉澶у皬锛岄粯璁�10", required = false, defaultValue = "10") + private long size = 10; + + /** + * 褰撳墠椤� + */ + @ApiParam(value = "褰撳墠椤碉紝榛樿1",required = false,defaultValue = "1") + private long current = 1; + + /** + * 鏄惁杩涜 count 鏌ヨ + */ + @ApiParam(hidden = true) + private boolean isSearchCount = true; + + @Override + @ApiParam(hidden = true) + public List<T> getRecords() { + return this.records; + } + + @Override + public Page<T> setRecords(List<T> records) { + this.records = records; + return this; + } + + @Override + public long getTotal() { + return this.total; + } + + @Override + public Page<T> setTotal(long total) { + this.total = total; + return this; + } + + @ApiParam(hidden = true) + public boolean getSearchCount() { + if (total < 0) { + return false; + } + return isSearchCount; + } + + @Override + @ApiParam(hidden = true) + public boolean isSearchCount() { + if (total < 0) { + return false; + } + return isSearchCount; + } + + @Override + public Page<T> setSearchCount(boolean isSearchCount) { + this.isSearchCount = isSearchCount; + return this; + } + + @Override + public long getSize() { + return this.size; + } + + @Override + public Page<T> setSize(long size) { + this.size = size; + return this; + } + + @Override + public long getCurrent() { + return this.current; + } + + @Override + public Page<T> setCurrent(long current) { + this.current = current; + return this; + } +} diff --git a/src/main/java/com/example/jz/modle/entity/R.java b/src/main/java/com/example/jz/modle/R.java similarity index 92% rename from src/main/java/com/example/jz/modle/entity/R.java rename to src/main/java/com/example/jz/modle/R.java index df5dfac..8498f22 100644 --- a/src/main/java/com/example/jz/modle/entity/R.java +++ b/src/main/java/com/example/jz/modle/R.java @@ -1,4 +1,4 @@ -package com.example.jz.modle.entity; +package com.example.jz.modle; import com.example.jz.enums.BusinessHttpStatus; import lombok.*; @@ -37,7 +37,7 @@ } public static <T> R<T> ok(T data) { - return restResult(data, BusinessHttpStatus.SUCCESS.value(), null); + return restResult(data, BusinessHttpStatus.SUCCESS.value(), "鎵ц鎴愬姛"); } public static <T> R<T> ok(T data, String msg) { diff --git a/src/main/java/com/example/jz/modle/dto/CommonQuestionDto.java b/src/main/java/com/example/jz/modle/dto/CommonQuestionDto.java new file mode 100644 index 0000000..b2391c4 --- /dev/null +++ b/src/main/java/com/example/jz/modle/dto/CommonQuestionDto.java @@ -0,0 +1,61 @@ +package com.example.jz.modle.dto; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * 甯歌闂琛�(CommonQuestion)琛ㄥ疄浣撶被 + * + * @author makejava + * @since 2022-07-11 16:35:57 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +@TableName("common_question") +public class CommonQuestionDto extends Model<CommonQuestionDto> { + //甯歌闂id + @ApiModelProperty(value = "甯歌闂id") + private Integer id; + //甯歌闂鍏抽敭瀛� + @ApiModelProperty(value = "甯歌闂鍏抽敭瀛�") + private String questionTitle; + //鐘舵�侊紝0涓烘湭鍙戝竷锛�1涓哄彂甯冿紝2涓轰笅鏋� + @ApiModelProperty(value = "鐘舵�侊紝0涓烘湭鍙戝竷锛�1涓哄彂甯冿紝2涓轰笅鏋�") + private Integer status; + //鍖归厤闂 + @ApiModelProperty(value = "鍖归厤闂") + private String matchQuestion; + //闂瑙g瓟 + @ApiModelProperty(value = "闂瑙g瓟") + private String answer; + //鍒涘缓浜� + @ApiModelProperty(value = "鍒涘缓浜�") + private String creator; + //鍒涘缓鏃堕棿 + private Date ctime; + //鍙戝竷鏃堕棿 + private Date releaseTime; + + /** + * 鑾峰彇涓婚敭鍊� + * + * @return 涓婚敭鍊� + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} + diff --git a/src/main/java/com/example/jz/modle/dto/PublicityDto.java b/src/main/java/com/example/jz/modle/dto/PublicityDto.java new file mode 100644 index 0000000..bf0904a --- /dev/null +++ b/src/main/java/com/example/jz/modle/dto/PublicityDto.java @@ -0,0 +1,61 @@ +package com.example.jz.modle.dto; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * 鍏叡瀹d紶琛�(Publicity)琛ㄥ疄浣撶被 + * + * @author makejava + * @since 2022-07-11 16:35:57 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +public class PublicityDto extends Model<PublicityDto> { + //鍏叡瀹d紶id + @TableId + @ApiModelProperty(value = "鍏叡瀹d紶id") + private Integer id; + //鍏叡瀹d紶鏍囬 + @ApiModelProperty(value = "鍏叡瀹d紶鏍囬") + private String publicityTitle; + //鐘舵�侊紝0涓烘湭鍙戝竷锛�1涓哄彂甯冿紝2涓轰笅鏋� + @ApiModelProperty(value = "鐘舵�侊紝0涓烘湭鍙戝竷锛�1涓哄彂甯冿紝2涓轰笅鏋�") + private Integer status; + //鍐呭 + @ApiModelProperty(value = "鍐呭") + private String text; + //鍒涘缓浜哄鍚� + @ApiModelProperty(value = "鍒涘缓浜哄鍚�") + private String creator; + //鍒涘缓鏃堕棿 + @ApiModelProperty(value = "鍒涘缓鏃堕棿") + private Date ctime; + //鍙戝竷鏃堕棿 + @ApiModelProperty(value = "鍙戝竷鏃堕棿") + private Date releaseTime; + + /** + * 鑾峰彇涓婚敭鍊� + * + * @return 涓婚敭鍊� + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} + diff --git a/src/main/java/com/example/jz/modle/entity/CommonQuestion.java b/src/main/java/com/example/jz/modle/entity/CommonQuestion.java index a695e0d..31e83b9 100644 --- a/src/main/java/com/example/jz/modle/entity/CommonQuestion.java +++ b/src/main/java/com/example/jz/modle/entity/CommonQuestion.java @@ -1,7 +1,16 @@ package com.example.jz.modle.entity; import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + import java.io.Serializable; /** @@ -10,89 +19,35 @@ * @author makejava * @since 2022-07-11 16:35:57 */ -@SuppressWarnings("serial") +@Data +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +@TableName("common_question") public class CommonQuestion extends Model<CommonQuestion> { //甯歌闂id - private Integer questionId; + @ApiModelProperty(value = "甯歌闂id") + private Integer id; //甯歌闂鍏抽敭瀛� + @ApiModelProperty(value = "甯歌闂鍏抽敭瀛�") private String questionTitle; //鐘舵�侊紝0涓烘湭鍙戝竷锛�1涓哄彂甯冿紝2涓轰笅鏋� + @ApiModelProperty(value = "鐘舵�侊紝0涓烘湭鍙戝竷锛�1涓哄彂甯冿紝2涓轰笅鏋�") private Integer status; //鍖归厤闂 + @ApiModelProperty(value = "鍖归厤闂") private String matchQuestion; //闂瑙g瓟 + @ApiModelProperty(value = "闂瑙g瓟") private String answer; //鍒涘缓浜� - private String creator; + @ApiModelProperty(value = "鍒涘缓浜�") + private Integer creator; //鍒涘缓鏃堕棿 - private Date createTime; + private Date ctime; //鍙戝竷鏃堕棿 private Date releaseTime; - - - public Integer getQuestionId() { - return questionId; - } - - public void setQuestionId(Integer questionId) { - this.questionId = questionId; - } - - public String getQuestionTitle() { - return questionTitle; - } - - public void setQuestionTitle(String questionTitle) { - this.questionTitle = questionTitle; - } - - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public String getMatchQuestion() { - return matchQuestion; - } - - public void setMatchQuestion(String matchQuestion) { - this.matchQuestion = matchQuestion; - } - - public String getAnswer() { - return answer; - } - - public void setAnswer(String answer) { - this.answer = answer; - } - - public String getCreator() { - return creator; - } - - public void setCreator(String creator) { - this.creator = creator; - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public Date getReleaseTime() { - return releaseTime; - } - - public void setReleaseTime(Date releaseTime) { - this.releaseTime = releaseTime; - } /** * 鑾峰彇涓婚敭鍊� @@ -101,7 +56,7 @@ */ @Override protected Serializable pkVal() { - return this.questionId; + return this.id; } - } +} diff --git a/src/main/java/com/example/jz/modle/entity/Message.java b/src/main/java/com/example/jz/modle/entity/Message.java index cfee1b5..24051af 100644 --- a/src/main/java/com/example/jz/modle/entity/Message.java +++ b/src/main/java/com/example/jz/modle/entity/Message.java @@ -1,7 +1,11 @@ package com.example.jz.modle.entity; import java.util.Date; + import com.baomidou.mybatisplus.extension.activerecord.Model; +import lombok.Data; +import lombok.NoArgsConstructor; + import java.io.Serializable; /** @@ -11,58 +15,19 @@ * @since 2022-07-11 16:35:57 */ @SuppressWarnings("serial") +@Data +@NoArgsConstructor public class Message extends Model<Message> { //娑堟伅id - private Integer messageId; + private Integer id; //娑堟伅鍐呭 private String text; //鐢ㄦ埛id private Integer userId; //缇d private Integer groupId; - - private Date createTime; - - - public Integer getMessageId() { - return messageId; - } - - public void setMessageId(Integer messageId) { - this.messageId = messageId; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public Integer getUserId() { - return userId; - } - - public void setUserId(Integer userId) { - this.userId = userId; - } - - public Integer getGroupId() { - return groupId; - } - - public void setGroupId(Integer groupId) { - this.groupId = groupId; - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } + //鍒涘缓鏃堕棿 + private Date cTime; /** * 鑾峰彇涓婚敭鍊� @@ -71,7 +36,7 @@ */ @Override protected Serializable pkVal() { - return this.messageId; + return this.id; } - } +} diff --git a/src/main/java/com/example/jz/modle/entity/Publicity.java b/src/main/java/com/example/jz/modle/entity/Publicity.java index 9f4093c..8b2d8ae 100644 --- a/src/main/java/com/example/jz/modle/entity/Publicity.java +++ b/src/main/java/com/example/jz/modle/entity/Publicity.java @@ -1,7 +1,17 @@ package com.example.jz.modle.entity; import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + import java.io.Serializable; /** @@ -10,79 +20,35 @@ * @author makejava * @since 2022-07-11 16:35:57 */ -@SuppressWarnings("serial") +@Data +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = true) +@TableName("publicity") public class Publicity extends Model<Publicity> { //鍏叡瀹d紶id - private Integer publicityId; + @TableId + @ApiModelProperty(value = "鍏叡瀹d紶id") + private Integer id; //鍏叡瀹d紶鏍囬 + @ApiModelProperty(value = "鍏叡瀹d紶鏍囬") private String publicityTitle; //鐘舵�侊紝0涓烘湭鍙戝竷锛�1涓哄彂甯冿紝2涓轰笅鏋� + @ApiModelProperty(value = "鐘舵�侊紝0涓烘湭鍙戝竷锛�1涓哄彂甯冿紝2涓轰笅鏋�") private Integer status; //鍐呭 + @ApiModelProperty(value = "鍐呭") private String text; - //鍒涘缓浜� - private String creator; + //鍒涘缓浜篿d + @ApiModelProperty(value = "鍒涘缓浜篿d") + private Integer creator; //鍒涘缓鏃堕棿 - private Date createTime; + @ApiModelProperty(value = "鍒涘缓鏃堕棿") + private Date ctime; //鍙戝竷鏃堕棿 + @ApiModelProperty(value = "鍙戝竷鏃堕棿") private Date releaseTime; - - - public Integer getPublicityId() { - return publicityId; - } - - public void setPublicityId(Integer publicityId) { - this.publicityId = publicityId; - } - - public String getPublicityTitle() { - return publicityTitle; - } - - public void setPublicityTitle(String publicityTitle) { - this.publicityTitle = publicityTitle; - } - - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public String getCreator() { - return creator; - } - - public void setCreator(String creator) { - this.creator = creator; - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public Date getReleaseTime() { - return releaseTime; - } - - public void setReleaseTime(Date releaseTime) { - this.releaseTime = releaseTime; - } /** * 鑾峰彇涓婚敭鍊� @@ -91,7 +57,7 @@ */ @Override protected Serializable pkVal() { - return this.publicityId; + return this.id; } - } +} diff --git a/src/main/java/com/example/jz/service/CommonQuestionService.java b/src/main/java/com/example/jz/service/CommonQuestionService.java index 2227cb0..ed001a5 100644 --- a/src/main/java/com/example/jz/service/CommonQuestionService.java +++ b/src/main/java/com/example/jz/service/CommonQuestionService.java @@ -1,6 +1,10 @@ package com.example.jz.service; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import com.example.jz.modle.dto.CommonQuestionDto; import com.example.jz.modle.entity.CommonQuestion; /** @@ -11,5 +15,6 @@ */ public interface CommonQuestionService extends IService<CommonQuestion> { + IPage<CommonQuestionDto> findByPage(Page<CommonQuestionDto> page, QueryWrapper<Object> objectQueryWrapper); } diff --git a/src/main/java/com/example/jz/service/MinIOService.java b/src/main/java/com/example/jz/service/MinIOService.java index 2182b05..1b9559e 100644 --- a/src/main/java/com/example/jz/service/MinIOService.java +++ b/src/main/java/com/example/jz/service/MinIOService.java @@ -1,5 +1,11 @@ package com.example.jz.service; +import org.springframework.web.multipart.MultipartFile; + public interface MinIOService { public String getPreviewFileUrl(String fileName); + + String upload(MultipartFile file); + + Boolean delete(String fileName); } diff --git a/src/main/java/com/example/jz/service/PublicityService.java b/src/main/java/com/example/jz/service/PublicityService.java index 1350601..34c52b3 100644 --- a/src/main/java/com/example/jz/service/PublicityService.java +++ b/src/main/java/com/example/jz/service/PublicityService.java @@ -1,7 +1,13 @@ package com.example.jz.service; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import com.example.jz.modle.PageParam; +import com.example.jz.modle.dto.PublicityDto; import com.example.jz.modle.entity.Publicity; + +import java.io.Serializable; /** * 鍏叡瀹d紶琛�(Publicity)琛ㄦ湇鍔℃帴鍙� @@ -11,5 +17,10 @@ */ public interface PublicityService extends IService<Publicity> { + Boolean undercarriage(Serializable id); + + Boolean grounding(Serializable id); + + IPage<PublicityDto> findByPage(PageParam<PublicityDto> page, QueryWrapper<PublicityDto> publicityDtoQueryWrapper); } diff --git a/src/main/java/com/example/jz/service/impl/CommonQuestionServiceImpl.java b/src/main/java/com/example/jz/service/impl/CommonQuestionServiceImpl.java index a6f0a3c..085bc84 100644 --- a/src/main/java/com/example/jz/service/impl/CommonQuestionServiceImpl.java +++ b/src/main/java/com/example/jz/service/impl/CommonQuestionServiceImpl.java @@ -1,10 +1,16 @@ package com.example.jz.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.example.jz.dao.CommonQuestionDao; +import com.example.jz.modle.dto.CommonQuestionDto; import com.example.jz.modle.entity.CommonQuestion; import com.example.jz.service.CommonQuestionService; import org.springframework.stereotype.Service; + +import javax.annotation.Resource; /** * 甯歌闂琛�(CommonQuestion)琛ㄦ湇鍔″疄鐜扮被 @@ -14,6 +20,12 @@ */ @Service("commonQuestionService") public class CommonQuestionServiceImpl extends ServiceImpl<CommonQuestionDao, CommonQuestion> implements CommonQuestionService { + @Resource + private CommonQuestionDao commonQuestionDao; + @Override + public IPage<CommonQuestionDto> findByPage(Page<CommonQuestionDto> page, QueryWrapper<Object> objectQueryWrapper) { + return commonQuestionDao.findByPage(page, objectQueryWrapper); + } } diff --git a/src/main/java/com/example/jz/service/impl/MinIOServiceImpl.java b/src/main/java/com/example/jz/service/impl/MinIOServiceImpl.java index 0d2ea6a..4c3966d 100644 --- a/src/main/java/com/example/jz/service/impl/MinIOServiceImpl.java +++ b/src/main/java/com/example/jz/service/impl/MinIOServiceImpl.java @@ -1,17 +1,24 @@ package com.example.jz.service.impl; +import cn.hutool.core.util.IdUtil; import com.example.jz.config.MinIOConfig; +import com.example.jz.exception.BusinessException; import com.example.jz.service.MinIOService; import io.minio.GetPresignedObjectUrlArgs; import io.minio.MinioClient; +import io.minio.PutObjectOptions; +import io.minio.UploadObjectArgs; import io.minio.errors.*; import io.minio.http.Method; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.concurrent.TimeUnit; @Service @@ -20,34 +27,45 @@ MinioClient minioClient; @Autowired MinIOConfig minIOConfig; + @Override - public String getPreviewFileUrl(String fileName){ + public String getPreviewFileUrl(String fileName) { String res = null; try { - res = minioClient.presignedGetObject(minIOConfig.getBucketName(), fileName); - } catch (ErrorResponseException e) { - throw new RuntimeException(e); - } catch (InsufficientDataException e) { - throw new RuntimeException(e); - } catch (InternalException e) { - throw new RuntimeException(e); - } catch (InvalidBucketNameException e) { - throw new RuntimeException(e); - } catch (InvalidExpiresRangeException e) { - throw new RuntimeException(e); - } catch (InvalidKeyException e) { - throw new RuntimeException(e); - } catch (InvalidResponseException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException(e); - } catch (ServerException e) { - throw new RuntimeException(e); - } catch (XmlParserException e) { - throw new RuntimeException(e); + res = minioClient.getPresignedObjectUrl( + GetPresignedObjectUrlArgs.builder() + .method(Method.GET) + .bucket(minIOConfig.getBucketName()) + .object(fileName) + .build()); + } catch (Exception e) { + throw new BusinessException("鑾峰彇鏂囦欢棰勮鍦板潃澶辫触"); } - return res; + return res; + } + + @Override + public String upload(MultipartFile file) { + String objectName = null; + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); + objectName = sdf.format(new Date()) + "/" + IdUtil.simpleUUID() + "." + file.getContentType().split("/")[1]; + PutObjectOptions putObjectOptions = new PutObjectOptions(file.getInputStream().available(), -1); + putObjectOptions.setContentType(file.getContentType()); + minioClient.putObject(minIOConfig.getBucketName(), objectName, file.getInputStream(), putObjectOptions); + } catch (Exception e) { + throw new BusinessException("涓婁紶鏂囦欢澶辫触"); + } + return objectName; + } + + @Override + public Boolean delete(String fileName) { + try { + minioClient.removeObject(minIOConfig.getBucketName(), fileName); + } catch (Exception e) { + throw new BusinessException("鍒犻櫎鏂囦欢澶辫触"); + } + return true; } } diff --git a/src/main/java/com/example/jz/service/impl/PublicityServiceImpl.java b/src/main/java/com/example/jz/service/impl/PublicityServiceImpl.java index ace765f..64c5953 100644 --- a/src/main/java/com/example/jz/service/impl/PublicityServiceImpl.java +++ b/src/main/java/com/example/jz/service/impl/PublicityServiceImpl.java @@ -1,10 +1,18 @@ package com.example.jz.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.example.jz.dao.PublicityDao; +import com.example.jz.modle.PageParam; +import com.example.jz.modle.dto.PublicityDto; import com.example.jz.modle.entity.Publicity; import com.example.jz.service.PublicityService; import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.io.Serializable; +import java.util.Date; /** * 鍏叡瀹d紶琛�(Publicity)琛ㄦ湇鍔″疄鐜扮被 @@ -15,5 +23,33 @@ @Service("publicityService") public class PublicityServiceImpl extends ServiceImpl<PublicityDao, Publicity> implements PublicityService { + @Resource + private PublicityDao publicityDao; + + @Override + public Boolean undercarriage(Serializable id) { + Publicity publicity = publicityDao.selectById(id); + publicity.setStatus(2); + if (publicityDao.updateById(publicity) == 1) { + return true; + } + return false; + } + + @Override + public Boolean grounding(Serializable id) { + Publicity publicity = publicityDao.selectById(id); + publicity.setStatus(1); + publicity.setReleaseTime(new Date()); + if (publicityDao.updateById(publicity) == 1) { + return true; + } + return false; + } + + @Override + public IPage<PublicityDto> findByPage(PageParam<PublicityDto> page, QueryWrapper<PublicityDto> publicityDtoQueryWrapper) { + return publicityDao.findByPage(page, publicityDtoQueryWrapper); + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 45ec867..5ab70b3 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,13 +1,11 @@ ### web server.port=8080 - ### datasource #test spring.datasource.url=jdbc:mysql://42.193.1.25:3306/qyjz?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai spring.datasource.username=root spring.datasource.password=321$YcYl@1970! spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver - ### datasource-pool spring.datasource.type=com.zaxxer.hikari.HikariDataSource spring.datasource.hikari.minimum-idle=10 @@ -19,11 +17,15 @@ spring.datasource.hikari.connection-timeout=10000 spring.datasource.hikari.connection-test-query=SELECT 1 spring.datasource.hikari.validation-timeout=1000 - -# ??????????? +# ???????? spring.servlet.multipart.max-file-size=50MB # minio?? minio.address=http://119.28.5.249:9000 minio.accessKey=minioadmin minio.secretKey=minioadmin minio.bucketName=img +# mybatis?? +mybatis-plus.global-config.banner=false +mybatis-plus.global-config.db-config.id-type=auto +mybatis-plus.global-config.db-config.field-strategy=NOT_NULL +mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl diff --git a/src/main/resources/mapper/CommonQuestionDao.xml b/src/main/resources/mapper/CommonQuestionDao.xml new file mode 100644 index 0000000..6b3e018 --- /dev/null +++ b/src/main/resources/mapper/CommonQuestionDao.xml @@ -0,0 +1,38 @@ +<?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.example.jz.dao.CommonQuestionDao"> + + <resultMap type="com.example.jz.modle.entity.CommonQuestion" id="CommonQuestionMap"> + <result property="questionTitle" column="question_title" jdbcType="VARCHAR"/> + <result property="status" column="status" jdbcType="INTEGER"/> + <result property="matchQuestion" column="match_question" jdbcType="VARCHAR"/> + <result property="answer" column="answer" jdbcType="VARCHAR"/> + <result property="creator" column="creator" jdbcType="INTEGER"/> + <result property="releaseTime" column="release_time" jdbcType="TIMESTAMP"/> + <result property="id" column="id" jdbcType="INTEGER"/> + <result property="ctime" column="ctime" jdbcType="TIMESTAMP"/> + </resultMap> + + <resultMap type="com.example.jz.modle.dto.CommonQuestionDto" id="CommonQuestionDtoMap"> + <result property="questionTitle" column="question_title" jdbcType="VARCHAR"/> + <result property="status" column="status" jdbcType="INTEGER"/> + <result property="matchQuestion" column="match_question" jdbcType="VARCHAR"/> + <result property="answer" column="answer" jdbcType="VARCHAR"/> + <result property="creator" column="creator" jdbcType="INTEGER"/> + <result property="releaseTime" column="release_time" jdbcType="TIMESTAMP"/> + <result property="id" column="id" jdbcType="INTEGER"/> + <result property="ctime" column="ctime" jdbcType="TIMESTAMP"/> + </resultMap> + + + <select id="findByPage" resultType="com.example.jz.modle.dto.CommonQuestionDto"> + select c.question_title,c.status,c.match_question,c.answer,u.real_name creator,c.release_time,c.id,c.ctime + from common_question c + join user u on c.creator = u.id + ${qw.customSqlSegment} + </select> + + + +</mapper> + diff --git a/src/main/resources/mapper/PublicityDao.xml b/src/main/resources/mapper/PublicityDao.xml new file mode 100644 index 0000000..bfdf1d5 --- /dev/null +++ b/src/main/resources/mapper/PublicityDao.xml @@ -0,0 +1,34 @@ +<?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.example.jz.dao.PublicityDao"> + + <resultMap type="com.example.jz.modle.entity.Publicity" id="PublicityMap"> + <result property="publicityTitle" column="publicity_title" jdbcType="VARCHAR"/> + <result property="status" column="status" jdbcType="INTEGER"/> + <result property="text" column="text" jdbcType="VARCHAR"/> + <result property="creator" column="creator" jdbcType="VARCHAR"/> + <result property="releaseTime" column="release_time" jdbcType="TIMESTAMP"/> + <result property="id" column="id" jdbcType="INTEGER"/> + <result property="ctime" column="ctime" jdbcType="TIMESTAMP"/> + </resultMap> + + <resultMap type="com.example.jz.modle.dto.PublicityDto" id="PublicityDtoMap"> + <result property="publicityTitle" column="publicity_title" jdbcType="VARCHAR"/> + <result property="status" column="status" jdbcType="INTEGER"/> + <result property="text" column="text" jdbcType="VARCHAR"/> + <result property="creator" column="creator" jdbcType="VARCHAR"/> + <result property="releaseTime" column="release_time" jdbcType="TIMESTAMP"/> + <result property="id" column="id" jdbcType="INTEGER"/> + <result property="ctime" column="ctime" jdbcType="TIMESTAMP"/> + </resultMap> + + <select id="findByPage" resultType="com.example.jz.modle.dto.PublicityDto"> + select p.publicity_title,p.status,p.text,u.real_name creator,p.release_time,p.id,p.ctime + from publicity p + join user u on p.creator = u.id + ${qw.customSqlSegment} + </select> + + +</mapper> + diff --git a/src/test/java/com/example/jz/MinIOTest.java b/src/test/java/com/example/jz/MinIOTest.java new file mode 100644 index 0000000..baf8412 --- /dev/null +++ b/src/test/java/com/example/jz/MinIOTest.java @@ -0,0 +1,18 @@ +package com.example.jz; + +import com.example.jz.service.MinIOService; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class MinIOTest { + @Autowired + MinIOService minIOService; + + @Test + void testFileDelete() { + + } + +} -- Gitblit v1.8.0