diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..d9d39d22 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +version: '3.7' +services: + + redis: + image: ghcr.io/mbanq/redis:latest + ports: + - "6379:6379" + expose: + - 6379 + + db: + image: mysql + container_name: mysql + ports: + - "3306:3306" + expose: + - 3306 + environment: + MYSQL_ROOT_PASSWORD: "root" + MYSQL_DATABASE: "eladmin" + #MYSQL_USER: "root" + #MYSQL_PASSWORD: "root" diff --git a/eladmin-system/me/zhengjie/portfolio/src/main/java/room/domain/MRoom.java b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/domain/MRoom.java new file mode 100644 index 00000000..f355ffc0 --- /dev/null +++ b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/domain/MRoom.java @@ -0,0 +1,90 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.domain; + +import lombok.Data; +import cn.hutool.core.bean.BeanUtil; +import io.swagger.annotations.ApiModelProperty; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.persistence.*; +import javax.validation.constraints.*; +import java.io.Serializable; + +/** +* @website https://el-admin.vip +* @description / +* @author smk +* @date 2022-05-03 +**/ +@Entity +@Data +@Table(name="m_room") +public class MRoom implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + @ApiModelProperty(value = "id") + private Long id; + + @Column(name = "type") + @ApiModelProperty(value = "type") + private String type; + + @Column(name = "size") + @ApiModelProperty(value = "size") + private String size; + + @Column(name = "air_conditional",nullable = false) + @NotNull + @ApiModelProperty(value = "airConditional") + private Integer airConditional; + + @Column(name = "fan",nullable = false) + @NotNull + @ApiModelProperty(value = "fan") + private Integer fan; + + @Column(name = "free_parking") + @ApiModelProperty(value = "freeParking") + private Integer freeParking; + + @Column(name = "description") + @ApiModelProperty(value = "description") + private String description; + + @Column(name = "bad",nullable = false) + @NotNull + @ApiModelProperty(value = "bad") + private Integer bad; + + @Column(name = "free_breakfast") + @ApiModelProperty(value = "freeBreakfast") + private Integer freeBreakfast; + + @Column(name = "image",nullable = false) + @NotBlank + @ApiModelProperty(value = "image") + private String image; + + @Column(name = "extra_information") + @ApiModelProperty(value = "extraInformation") + private String extraInformation; + + public void copy(MRoom source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} \ No newline at end of file diff --git a/eladmin-system/me/zhengjie/portfolio/src/main/java/room/repository/MRoomRepository.java b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/repository/MRoomRepository.java new file mode 100644 index 00000000..f014698b --- /dev/null +++ b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/repository/MRoomRepository.java @@ -0,0 +1,28 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.repository; + +import room.domain.MRoom; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://el-admin.vip +* @author smk +* @date 2022-05-03 +**/ +public interface MRoomRepository extends JpaRepository, JpaSpecificationExecutor { +} \ No newline at end of file diff --git a/eladmin-system/me/zhengjie/portfolio/src/main/java/room/rest/MRoomController.java b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/rest/MRoomController.java new file mode 100644 index 00000000..f5411bfc --- /dev/null +++ b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/rest/MRoomController.java @@ -0,0 +1,87 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.rest; + +import me.zhengjie.annotation.Log; +import room.domain.MRoom; +import room.service.MRoomService; +import room.service.dto.MRoomQueryCriteria; +import org.springframework.data.domain.Pageable; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://el-admin.vip +* @author smk +* @date 2022-05-03 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "room管理") +@RequestMapping("/api/mRoom") +public class MRoomController { + + private final MRoomService mRoomService; + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('mRoom:list')") + public void exportMRoom(HttpServletResponse response, MRoomQueryCriteria criteria) throws IOException { + mRoomService.download(mRoomService.queryAll(criteria), response); + } + + @GetMapping + @Log("查询room") + @ApiOperation("查询room") + @PreAuthorize("@el.check('mRoom:list')") + public ResponseEntity queryMRoom(MRoomQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(mRoomService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增room") + @ApiOperation("新增room") + @PreAuthorize("@el.check('mRoom:add')") + public ResponseEntity createMRoom(@Validated @RequestBody MRoom resources){ + return new ResponseEntity<>(mRoomService.create(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改room") + @ApiOperation("修改room") + @PreAuthorize("@el.check('mRoom:edit')") + public ResponseEntity updateMRoom(@Validated @RequestBody MRoom resources){ + mRoomService.update(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @DeleteMapping + @Log("删除room") + @ApiOperation("删除room") + @PreAuthorize("@el.check('mRoom:del')") + public ResponseEntity deleteMRoom(@RequestBody Long[] ids) { + mRoomService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/MRoomService.java b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/MRoomService.java new file mode 100644 index 00000000..ea65687b --- /dev/null +++ b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/MRoomService.java @@ -0,0 +1,83 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.service; + +import room.domain.MRoom; +import room.service.dto.MRoomDto; +import room.service.dto.MRoomQueryCriteria; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://el-admin.vip +* @description 服务接口 +* @author smk +* @date 2022-05-03 +**/ +public interface MRoomService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(MRoomQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(MRoomQueryCriteria criteria); + + /** + * 根据ID查询 + * @param id ID + * @return MRoomDto + */ + MRoomDto findById(Long id); + + /** + * 创建 + * @param resources / + * @return MRoomDto + */ + MRoomDto create(MRoom resources); + + /** + * 编辑 + * @param resources / + */ + void update(MRoom resources); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Long[] ids); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} \ No newline at end of file diff --git a/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/dto/MRoomDto.java b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/dto/MRoomDto.java new file mode 100644 index 00000000..acf8bde6 --- /dev/null +++ b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/dto/MRoomDto.java @@ -0,0 +1,51 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.service.dto; + +import lombok.Data; +import java.io.Serializable; + +/** +* @website https://el-admin.vip +* @description / +* @author smk +* @date 2022-05-03 +**/ +@Data +public class MRoomDto implements Serializable { + + private Long id; + + private String type; + + private String size; + + private Integer airConditional; + + private Integer fan; + + private Integer freeParking; + + private String description; + + private Integer bad; + + private Integer freeBreakfast; + + private String image; + + private String extraInformation; +} \ No newline at end of file diff --git a/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/dto/MRoomQueryCriteria.java b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/dto/MRoomQueryCriteria.java new file mode 100644 index 00000000..80e14d8f --- /dev/null +++ b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/dto/MRoomQueryCriteria.java @@ -0,0 +1,29 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.service.dto; + +import lombok.Data; +import java.util.List; +import me.zhengjie.annotation.Query; + +/** +* @website https://el-admin.vip +* @author smk +* @date 2022-05-03 +**/ +@Data +public class MRoomQueryCriteria{ +} \ No newline at end of file diff --git a/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/impl/MRoomServiceImpl.java b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/impl/MRoomServiceImpl.java new file mode 100644 index 00000000..c2510667 --- /dev/null +++ b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/impl/MRoomServiceImpl.java @@ -0,0 +1,113 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.service.impl; + +import room.domain.MRoom; +import me.zhengjie.utils.ValidationUtil; +import me.zhengjie.utils.FileUtil; +import lombok.RequiredArgsConstructor; +import room.repository.MRoomRepository; +import room.service.MRoomService; +import room.service.dto.MRoomDto; +import room.service.dto.MRoomQueryCriteria; +import room.service.mapstruct.MRoomMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import me.zhengjie.utils.PageUtil; +import me.zhengjie.utils.QueryHelp; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +/** +* @website https://el-admin.vip +* @description 服务实现 +* @author smk +* @date 2022-05-03 +**/ +@Service +@RequiredArgsConstructor +public class MRoomServiceImpl implements MRoomService { + + private final MRoomRepository mRoomRepository; + private final MRoomMapper mRoomMapper; + + @Override + public Map queryAll(MRoomQueryCriteria criteria, Pageable pageable){ + Page page = mRoomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + return PageUtil.toPage(page.map(mRoomMapper::toDto)); + } + + @Override + public List queryAll(MRoomQueryCriteria criteria){ + return mRoomMapper.toDto(mRoomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + } + + @Override + @Transactional + public MRoomDto findById(Long id) { + MRoom mRoom = mRoomRepository.findById(id).orElseGet(MRoom::new); + ValidationUtil.isNull(mRoom.getId(),"MRoom","id",id); + return mRoomMapper.toDto(mRoom); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public MRoomDto create(MRoom resources) { + return mRoomMapper.toDto(mRoomRepository.save(resources)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(MRoom resources) { + MRoom mRoom = mRoomRepository.findById(resources.getId()).orElseGet(MRoom::new); + ValidationUtil.isNull( mRoom.getId(),"MRoom","id",resources.getId()); + mRoom.copy(resources); + mRoomRepository.save(mRoom); + } + + @Override + public void deleteAll(Long[] ids) { + for (Long id : ids) { + mRoomRepository.deleteById(id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (MRoomDto mRoom : all) { + Map map = new LinkedHashMap<>(); + map.put(" type", mRoom.getType()); + map.put(" size", mRoom.getSize()); + map.put(" airConditional", mRoom.getAirConditional()); + map.put(" fan", mRoom.getFan()); + map.put(" freeParking", mRoom.getFreeParking()); + map.put(" description", mRoom.getDescription()); + map.put(" bad", mRoom.getBad()); + map.put(" freeBreakfast", mRoom.getFreeBreakfast()); + map.put(" image", mRoom.getImage()); + map.put(" extraInformation", mRoom.getExtraInformation()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} \ No newline at end of file diff --git a/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/mapstruct/MRoomMapper.java b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/mapstruct/MRoomMapper.java new file mode 100644 index 00000000..cf1a0e21 --- /dev/null +++ b/eladmin-system/me/zhengjie/portfolio/src/main/java/room/service/mapstruct/MRoomMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.service.mapstruct; + +import me.zhengjie.base.BaseMapper; +import room.domain.MRoom; +import room.service.dto.MRoomDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://el-admin.vip +* @author smk +* @date 2022-05-03 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface MRoomMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/domain/MRoom.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/domain/MRoom.java new file mode 100644 index 00000000..8c1121c2 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/domain/MRoom.java @@ -0,0 +1,97 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.portfolio.room.domain; + +import lombok.Data; +import cn.hutool.core.bean.BeanUtil; +import io.swagger.annotations.ApiModelProperty; +import cn.hutool.core.bean.copier.CopyOptions; +import me.zhengjie.converter.StringListConverter; +import me.zhengjie.converter.StringMapConverter; + +import javax.persistence.*; +import javax.validation.constraints.*; +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** +* @website https://el-admin.vip +* @description / +* @author smk +* @date 2022-05-03 +**/ +@Entity +@Data +@Table(name="m_room") +public class MRoom implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + @ApiModelProperty(value = "id") + private Long id; + + @Column(name = "type") + @ApiModelProperty(value = "type") + private String type; + + @Column(name = "size") + @ApiModelProperty(value = "size") + private String size; + + @Column(name = "air_conditional",nullable = false) + @NotNull + @ApiModelProperty(value = "airConditional") + private Integer airConditional; + + @Column(name = "fan",nullable = false) + @NotNull + @ApiModelProperty(value = "fan") + private Integer fan; + + @Column(name = "free_parking") + @ApiModelProperty(value = "freeParking") + private Integer freeParking; + + @Column(name = "description") + @ApiModelProperty(value = "description") + private String description; + + @Column(name = "bad",nullable = false) + @NotNull + @ApiModelProperty(value = "bad") + private Integer bad; + + @Column(name = "free_breakfast") + @ApiModelProperty(value = "freeBreakfast") + private Integer freeBreakfast; + + @Column(name = "image",nullable = false) + @ApiModelProperty(value = "image") + @Convert(converter = StringListConverter.class) + private List image; + + @Column(name = "extra_information") + @ApiModelProperty(value = "extraInformation") + @Convert(converter = StringMapConverter.class) + private HashMap extraInformation; + + public void copy(MRoom source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/domain/Room.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/domain/Room.java deleted file mode 100644 index cde3e788..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/domain/Room.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2019-2020 Zheng Jie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package me.zhengjie.portfolio.room.domain; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.bean.copier.CopyOptions; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import me.zhengjie.converter.StringListConverter; - -import javax.persistence.Column; -import javax.persistence.Convert; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import java.io.Serializable; -import java.util.List; - -/** - * @author Chanheng - * @website https://el-admin.vip - * @description / - * @date 2022-05-01 - **/ -@Entity -@Data -@Table(name = "room") -public class Room implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") - @ApiModelProperty(value = "id") - private Long id; - - @Column(name = "name", nullable = false) - @NotBlank - @ApiModelProperty(value = "name") - private String name; - - @Column(name = "description", nullable = false) - @NotBlank - @ApiModelProperty(value = "description") - private String description; - - @Column(name = "images", nullable = false) - @NotNull - @Convert(converter = StringListConverter.class) - @ApiModelProperty(value = "images") - private List images; - - @Column(name = "extra_info") - @Convert(converter = StringListConverter.class) - @ApiModelProperty(value = "extraInfo") - private List extraInfo; - - public void copy(Room source) { - BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); - } - - public List getImages() { - return images; - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/repository/RoomRepository.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/repository/MRoomRepository.java similarity index 81% rename from eladmin-system/src/main/java/me/zhengjie/portfolio/room/repository/RoomRepository.java rename to eladmin-system/src/main/java/me/zhengjie/portfolio/room/repository/MRoomRepository.java index 097d8cf2..f655f630 100644 --- a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/repository/RoomRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/repository/MRoomRepository.java @@ -15,14 +15,14 @@ */ package me.zhengjie.portfolio.room.repository; -import me.zhengjie.portfolio.room.domain.Room; +import me.zhengjie.portfolio.room.domain.MRoom; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; /** * @website https://el-admin.vip -* @author Chanheng -* @date 2022-05-01 +* @author smk +* @date 2022-05-03 **/ -public interface RoomRepository extends JpaRepository, JpaSpecificationExecutor { +public interface MRoomRepository extends JpaRepository, JpaSpecificationExecutor { } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/rest/RoomController.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/rest/MRoomController.java similarity index 57% rename from eladmin-system/src/main/java/me/zhengjie/portfolio/room/rest/RoomController.java rename to eladmin-system/src/main/java/me/zhengjie/portfolio/room/rest/MRoomController.java index 74d28fc1..1a88254a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/rest/RoomController.java +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/rest/MRoomController.java @@ -16,9 +16,9 @@ package me.zhengjie.portfolio.room.rest; import me.zhengjie.annotation.Log; -import me.zhengjie.portfolio.room.domain.Room; -import me.zhengjie.portfolio.room.service.RoomService; -import me.zhengjie.portfolio.room.service.dto.RoomQueryCriteria; +import me.zhengjie.portfolio.room.domain.MRoom; +import me.zhengjie.portfolio.room.service.MRoomService; +import me.zhengjie.portfolio.room.service.dto.MRoomQueryCriteria; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -32,56 +32,56 @@ import javax.servlet.http.HttpServletResponse; /** * @website https://el-admin.vip -* @author Chanheng -* @date 2022-05-01 +* @author smk +* @date 2022-05-03 **/ @RestController @RequiredArgsConstructor @Api(tags = "room管理") -@RequestMapping("/api/room") -public class RoomController { +@RequestMapping("/api/mRoom") +public class MRoomController { - private final RoomService roomService; + private final MRoomService mRoomService; @Log("导出数据") @ApiOperation("导出数据") @GetMapping(value = "/download") - @PreAuthorize("@el.check('room:list')") - public void exportRoom(HttpServletResponse response, RoomQueryCriteria criteria) throws IOException { - roomService.download(roomService.queryAll(criteria), response); + @PreAuthorize("@el.check('mRoom:list')") + public void exportMRoom(HttpServletResponse response, MRoomQueryCriteria criteria) throws IOException { + mRoomService.download(mRoomService.queryAll(criteria), response); } @GetMapping @Log("查询room") @ApiOperation("查询room") - @PreAuthorize("@el.check('room:list')") - public ResponseEntity queryRoom(RoomQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(roomService.queryAll(criteria,pageable),HttpStatus.OK); + @PreAuthorize("@el.check('mRoom:list')") + public ResponseEntity queryMRoom(MRoomQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(mRoomService.queryAll(criteria,pageable),HttpStatus.OK); } @PostMapping @Log("新增room") @ApiOperation("新增room") - @PreAuthorize("@el.check('room:add')") - public ResponseEntity createRoom(@Validated @RequestBody Room resources){ - return new ResponseEntity<>(roomService.create(resources),HttpStatus.CREATED); + @PreAuthorize("@el.check('mRoom:add')") + public ResponseEntity createMRoom(@Validated @RequestBody MRoom resources){ + return new ResponseEntity<>(mRoomService.create(resources),HttpStatus.CREATED); } @PutMapping @Log("修改room") @ApiOperation("修改room") - @PreAuthorize("@el.check('room:edit')") - public ResponseEntity updateRoom(@Validated @RequestBody Room resources){ - roomService.update(resources); + @PreAuthorize("@el.check('mRoom:edit')") + public ResponseEntity updateMRoom(@Validated @RequestBody MRoom resources){ + mRoomService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @DeleteMapping @Log("删除room") @ApiOperation("删除room") - @PreAuthorize("@el.check('room:del')") - public ResponseEntity deleteRoom(@RequestBody Long[] ids) { - roomService.deleteAll(ids); + @PreAuthorize("@el.check('mRoom:del')") + public ResponseEntity deleteMRoom(@RequestBody Long[] ids) { + mRoomService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); } } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/RoomService.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/MRoomService.java similarity index 69% rename from eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/RoomService.java rename to eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/MRoomService.java index fe5d8501..1fa62df2 100644 --- a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/RoomService.java +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/MRoomService.java @@ -15,9 +15,9 @@ */ package me.zhengjie.portfolio.room.service; -import me.zhengjie.portfolio.room.domain.Room; -import me.zhengjie.portfolio.room.service.dto.RoomDto; -import me.zhengjie.portfolio.room.service.dto.RoomQueryCriteria; +import me.zhengjie.portfolio.room.domain.MRoom; +import me.zhengjie.portfolio.room.service.dto.MRoomDto; +import me.zhengjie.portfolio.room.service.dto.MRoomQueryCriteria; import org.springframework.data.domain.Pageable; import java.util.Map; import java.util.List; @@ -27,10 +27,10 @@ import javax.servlet.http.HttpServletResponse; /** * @website https://el-admin.vip * @description 服务接口 -* @author Chanheng -* @date 2022-05-01 +* @author smk +* @date 2022-05-03 **/ -public interface RoomService { +public interface MRoomService { /** * 查询数据分页 @@ -38,34 +38,34 @@ public interface RoomService { * @param pageable 分页参数 * @return Map */ - Map queryAll(RoomQueryCriteria criteria, Pageable pageable); + Map queryAll(MRoomQueryCriteria criteria, Pageable pageable); /** * 查询所有数据不分页 * @param criteria 条件参数 - * @return List + * @return List */ - List queryAll(RoomQueryCriteria criteria); + List queryAll(MRoomQueryCriteria criteria); /** * 根据ID查询 * @param id ID - * @return RoomDto + * @return MRoomDto */ - RoomDto findById(Long id); + MRoomDto findById(Long id); /** * 创建 * @param resources / - * @return RoomDto + * @return MRoomDto */ - RoomDto create(Room resources); + MRoomDto create(MRoom resources); /** * 编辑 * @param resources / */ - void update(Room resources); + void update(MRoom resources); /** * 多选删除 @@ -79,5 +79,5 @@ public interface RoomService { * @param response / * @throws IOException / */ - void download(List all, HttpServletResponse response) throws IOException; + void download(List all, HttpServletResponse response) throws IOException; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/dto/MRoomDto.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/dto/MRoomDto.java new file mode 100644 index 00000000..c6d68512 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/dto/MRoomDto.java @@ -0,0 +1,53 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.portfolio.room.service.dto; + +import lombok.Data; +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; + +/** +* @website https://el-admin.vip +* @description / +* @author smk +* @date 2022-05-03 +**/ +@Data +public class MRoomDto implements Serializable { + + private Long id; + + private String type; + + private String size; + + private Integer airConditional; + + private Integer fan; + + private Integer freeParking; + + private String description; + + private Integer bad; + + private Integer freeBreakfast; + + private List image; + + private HashMap extraInformation; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/dto/RoomQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/dto/MRoomQueryCriteria.java similarity index 75% rename from eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/dto/RoomQueryCriteria.java rename to eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/dto/MRoomQueryCriteria.java index ea70dcbd..9ee66f72 100644 --- a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/dto/RoomQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/dto/MRoomQueryCriteria.java @@ -21,17 +21,9 @@ import me.zhengjie.annotation.Query; /** * @website https://el-admin.vip -* @author Chanheng -* @date 2022-05-01 +* @author smk +* @date 2022-05-03 **/ @Data -public class RoomQueryCriteria{ - - /** 模糊 */ - @Query(type = Query.Type.INNER_LIKE) - private String name; - - /** 模糊 */ - @Query(type = Query.Type.INNER_LIKE) - private String description; +public class MRoomQueryCriteria{ } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/dto/RoomDto.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/dto/RoomDto.java deleted file mode 100644 index db07bda1..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/dto/RoomDto.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2019-2020 Zheng Jie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package me.zhengjie.portfolio.room.service.dto; - -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - -/** - * @author Chanheng - * @website https://el-admin.vip - * @description / - * @date 2022-05-01 - **/ -@Data -public class RoomDto implements Serializable { - - private Long id; - - private String name; - - private String description; - - private List images; - - private List extraInfo; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/impl/MRoomServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/impl/MRoomServiceImpl.java new file mode 100644 index 00000000..fbd05626 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/impl/MRoomServiceImpl.java @@ -0,0 +1,113 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.portfolio.room.service.impl; + +import me.zhengjie.portfolio.room.domain.MRoom; +import me.zhengjie.utils.ValidationUtil; +import me.zhengjie.utils.FileUtil; +import lombok.RequiredArgsConstructor; +import me.zhengjie.portfolio.room.repository.MRoomRepository; +import me.zhengjie.portfolio.room.service.MRoomService; +import me.zhengjie.portfolio.room.service.dto.MRoomDto; +import me.zhengjie.portfolio.room.service.dto.MRoomQueryCriteria; +import me.zhengjie.portfolio.room.service.mapstruct.MRoomMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import me.zhengjie.utils.PageUtil; +import me.zhengjie.utils.QueryHelp; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +/** +* @website https://el-admin.vip +* @description 服务实现 +* @author smk +* @date 2022-05-03 +**/ +@Service +@RequiredArgsConstructor +public class MRoomServiceImpl implements MRoomService { + + private final MRoomRepository mRoomRepository; + private final MRoomMapper mRoomMapper; + + @Override + public Map queryAll(MRoomQueryCriteria criteria, Pageable pageable){ + Page page = mRoomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + return PageUtil.toPage(page.map(mRoomMapper::toDto)); + } + + @Override + public List queryAll(MRoomQueryCriteria criteria){ + return mRoomMapper.toDto(mRoomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + } + + @Override + @Transactional + public MRoomDto findById(Long id) { + MRoom mRoom = mRoomRepository.findById(id).orElseGet(MRoom::new); + ValidationUtil.isNull(mRoom.getId(),"MRoom","id",id); + return mRoomMapper.toDto(mRoom); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public MRoomDto create(MRoom resources) { + return mRoomMapper.toDto(mRoomRepository.save(resources)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(MRoom resources) { + MRoom mRoom = mRoomRepository.findById(resources.getId()).orElseGet(MRoom::new); + ValidationUtil.isNull( mRoom.getId(),"MRoom","id",resources.getId()); + mRoom.copy(resources); + mRoomRepository.save(mRoom); + } + + @Override + public void deleteAll(Long[] ids) { + for (Long id : ids) { + mRoomRepository.deleteById(id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (MRoomDto mRoom : all) { + Map map = new LinkedHashMap<>(); + map.put(" type", mRoom.getType()); + map.put(" size", mRoom.getSize()); + map.put(" airConditional", mRoom.getAirConditional()); + map.put(" fan", mRoom.getFan()); + map.put(" freeParking", mRoom.getFreeParking()); + map.put(" description", mRoom.getDescription()); + map.put(" bad", mRoom.getBad()); + map.put(" freeBreakfast", mRoom.getFreeBreakfast()); + map.put(" image", mRoom.getImage()); + map.put(" extraInformation", mRoom.getExtraInformation()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/impl/RoomServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/impl/RoomServiceImpl.java deleted file mode 100644 index 61802451..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/impl/RoomServiceImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package me.zhengjie.portfolio.room.service.impl; - -import me.zhengjie.portfolio.room.domain.Room; -import me.zhengjie.utils.ValidationUtil; -import me.zhengjie.utils.FileUtil; -import lombok.RequiredArgsConstructor; -import me.zhengjie.portfolio.room.repository.RoomRepository; -import me.zhengjie.portfolio.room.service.RoomService; -import me.zhengjie.portfolio.room.service.dto.RoomDto; -import me.zhengjie.portfolio.room.service.dto.RoomQueryCriteria; -import me.zhengjie.portfolio.room.service.mapstruct.RoomMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import me.zhengjie.utils.PageUtil; -import me.zhengjie.utils.QueryHelp; -import java.util.List; -import java.util.Map; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.LinkedHashMap; - -/** -* @website https://el-admin.vip -* @description 服务实现 -* @author Chanheng -* @date 2022-05-01 -**/ -@Service -@RequiredArgsConstructor -public class RoomServiceImpl implements RoomService { - - private final RoomRepository roomRepository; - private final RoomMapper roomMapper; - - @Override - public Map queryAll(RoomQueryCriteria criteria, Pageable pageable){ - Page page = roomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - return PageUtil.toPage(page.map(roomMapper::toDto)); - } - - @Override - public List queryAll(RoomQueryCriteria criteria){ - return roomMapper.toDto(roomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); - } - - @Override - @Transactional - public RoomDto findById(Long id) { - Room room = roomRepository.findById(id).orElseGet(Room::new); - ValidationUtil.isNull(room.getId(),"Room","id",id); - return roomMapper.toDto(room); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public RoomDto create(Room resources) { - return roomMapper.toDto(roomRepository.save(resources)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(Room resources) { - Room room = roomRepository.findById(resources.getId()).orElseGet(Room::new); - ValidationUtil.isNull( room.getId(),"Room","id",resources.getId()); - room.copy(resources); - roomRepository.save(room); - } - - @Override - public void deleteAll(Long[] ids) { - for (Long id : ids) { - roomRepository.deleteById(id); - } - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (RoomDto room : all) { - Map map = new LinkedHashMap<>(); - map.put(" name", room.getName()); - map.put(" description", room.getDescription()); - map.put(" images", room.getImages()); - map.put(" extraInfo", room.getExtraInfo()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/mapstruct/RoomMapper.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/mapstruct/MRoomMapper.java similarity index 80% rename from eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/mapstruct/RoomMapper.java rename to eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/mapstruct/MRoomMapper.java index 4ea3203c..03964743 100644 --- a/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/mapstruct/RoomMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/room/service/mapstruct/MRoomMapper.java @@ -16,17 +16,17 @@ package me.zhengjie.portfolio.room.service.mapstruct; import me.zhengjie.base.BaseMapper; -import me.zhengjie.portfolio.room.domain.Room; -import me.zhengjie.portfolio.room.service.dto.RoomDto; +import me.zhengjie.portfolio.room.domain.MRoom; +import me.zhengjie.portfolio.room.service.dto.MRoomDto; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; /** * @website https://el-admin.vip -* @author Chanheng -* @date 2022-05-01 +* @author smk +* @date 2022-05-03 **/ @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface RoomMapper extends BaseMapper { +public interface MRoomMapper extends BaseMapper { } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/domain/MTour.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/domain/MTour.java new file mode 100644 index 00000000..dbc73ea0 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/domain/MTour.java @@ -0,0 +1,103 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.portfolio.tour.domain; + +import lombok.Data; +import cn.hutool.core.bean.BeanUtil; +import io.swagger.annotations.ApiModelProperty; +import cn.hutool.core.bean.copier.CopyOptions; +import me.zhengjie.converter.StringListConverter; +import me.zhengjie.converter.StringMapConverter; + +import javax.persistence.*; +import javax.validation.constraints.*; +import java.sql.Timestamp; +import java.io.Serializable; +import java.time.LocalDate; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +/** +* @website https://el-admin.vip +* @description / +* @author smk +* @date 2022-05-03 +**/ +@Entity +@Data +@Table(name="m_tour") +public class MTour implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + @ApiModelProperty(value = "id") + private Long id; + + @Column(name = "name",nullable = false) + @NotBlank + @ApiModelProperty(value = "name") + private String name; + + @Column(name = "start_date",nullable = false) + @NotNull + @ApiModelProperty(value = "startDate") + private Date startDate = new Date(); + + @Column(name = "period",nullable = false) + @NotNull + @ApiModelProperty(value = "period") + private Integer period; + + @Column(name = "location",nullable = false) + @NotBlank + @ApiModelProperty(value = "location") + private String location; + + @Column(name = "tour_code",nullable = false) + @NotBlank + @ApiModelProperty(value = "tourCode") + private String tourCode; + + @Column(name = "tour_type",nullable = false) + @NotBlank + @ApiModelProperty(value = "tourType") + private String tourType; + + @Column(name = "description") + @ApiModelProperty(value = "description") + private String description; + + @Column(name = "extra_tour_detail",nullable = false) + @ApiModelProperty(value = "extraTourDetail") + @Convert(converter = StringMapConverter.class) + private HashMap extraTourDetail; + + @Column(name = "extra_room_detail",nullable = false) + @ApiModelProperty(value = "extraRoomDetail") + @Convert(converter = StringMapConverter.class) + private HashMap extraRoomDetail; + + @Column(name = "images",nullable = false) + @ApiModelProperty(value = "images") + @Convert(converter = StringListConverter.class) + private List images; + + public void copy(MTour source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/repository/MTourRepository.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/repository/MTourRepository.java new file mode 100644 index 00000000..c4a5c1fc --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/repository/MTourRepository.java @@ -0,0 +1,28 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.portfolio.tour.repository; + +import me.zhengjie.portfolio.tour.domain.MTour; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://el-admin.vip +* @author smk +* @date 2022-05-03 +**/ +public interface MTourRepository extends JpaRepository, JpaSpecificationExecutor { +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/rest/MTourController.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/rest/MTourController.java new file mode 100644 index 00000000..9c593d17 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/rest/MTourController.java @@ -0,0 +1,87 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.portfolio.tour.rest; + +import me.zhengjie.annotation.Log; +import me.zhengjie.portfolio.tour.domain.MTour; +import me.zhengjie.portfolio.tour.service.MTourService; +import me.zhengjie.portfolio.tour.service.dto.MTourQueryCriteria; +import org.springframework.data.domain.Pageable; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://el-admin.vip +* @author smk +* @date 2022-05-03 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "tour管理") +@RequestMapping("/api/mTour") +public class MTourController { + + private final MTourService mTourService; + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('mTour:list')") + public void exportMTour(HttpServletResponse response, MTourQueryCriteria criteria) throws IOException { + mTourService.download(mTourService.queryAll(criteria), response); + } + + @GetMapping + @Log("查询tour") + @ApiOperation("查询tour") + @PreAuthorize("@el.check('mTour:list')") + public ResponseEntity queryMTour(MTourQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(mTourService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增tour") + @ApiOperation("新增tour") + @PreAuthorize("@el.check('mTour:add')") + public ResponseEntity createMTour(@Validated @RequestBody MTour resources){ + return new ResponseEntity<>(mTourService.create(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改tour") + @ApiOperation("修改tour") + @PreAuthorize("@el.check('mTour:edit')") + public ResponseEntity updateMTour(@Validated @RequestBody MTour resources){ + mTourService.update(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @DeleteMapping + @Log("删除tour") + @ApiOperation("删除tour") + @PreAuthorize("@el.check('mTour:del')") + public ResponseEntity deleteMTour(@RequestBody Long[] ids) { + mTourService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/MTourService.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/MTourService.java new file mode 100644 index 00000000..7108f97d --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/MTourService.java @@ -0,0 +1,83 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.portfolio.tour.service; + +import me.zhengjie.portfolio.tour.service.dto.MTourDto; +import me.zhengjie.portfolio.tour.service.dto.MTourQueryCriteria; +import me.zhengjie.portfolio.tour.domain.MTour; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://el-admin.vip +* @description 服务接口 +* @author smk +* @date 2022-05-03 +**/ +public interface MTourService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(MTourQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(MTourQueryCriteria criteria); + + /** + * 根据ID查询 + * @param id ID + * @return MTourDto + */ + MTourDto findById(Long id); + + /** + * 创建 + * @param resources / + * @return MTourDto + */ + MTourDto create(MTour resources); + + /** + * 编辑 + * @param resources / + */ + void update(MTour resources); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Long[] ids); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/dto/MTourDto.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/dto/MTourDto.java new file mode 100644 index 00000000..3c3d10ae --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/dto/MTourDto.java @@ -0,0 +1,55 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.portfolio.tour.service.dto; + +import lombok.Data; +import java.sql.Timestamp; +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +/** +* @website https://el-admin.vip +* @description / +* @author smk +* @date 2022-05-03 +**/ +@Data +public class MTourDto implements Serializable { + + private Long id; + + private String name; + + private Date startDate; + + private Integer period; + + private String location; + + private String tourCode; + + private String tourType; + + private String description; + + private HashMap extraTourDetail; + + private HashMap extraRoomDetail; + + private List images; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/dto/MTourQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/dto/MTourQueryCriteria.java new file mode 100644 index 00000000..c90d2231 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/dto/MTourQueryCriteria.java @@ -0,0 +1,29 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.portfolio.tour.service.dto; + +import lombok.Data; +import java.util.List; +import me.zhengjie.annotation.Query; + +/** +* @website https://el-admin.vip +* @author smk +* @date 2022-05-03 +**/ +@Data +public class MTourQueryCriteria{ +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/impl/MTourServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/impl/MTourServiceImpl.java new file mode 100644 index 00000000..b4c2399a --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/impl/MTourServiceImpl.java @@ -0,0 +1,113 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.portfolio.tour.service.impl; + +import me.zhengjie.portfolio.tour.domain.MTour; +import me.zhengjie.portfolio.tour.repository.MTourRepository; +import me.zhengjie.portfolio.tour.service.MTourService; +import me.zhengjie.portfolio.tour.service.dto.MTourDto; +import me.zhengjie.portfolio.tour.service.dto.MTourQueryCriteria; +import me.zhengjie.utils.ValidationUtil; +import me.zhengjie.utils.FileUtil; +import lombok.RequiredArgsConstructor; +import me.zhengjie.portfolio.tour.service.mapstruct.MTourMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import me.zhengjie.utils.PageUtil; +import me.zhengjie.utils.QueryHelp; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +/** +* @website https://el-admin.vip +* @description 服务实现 +* @author smk +* @date 2022-05-03 +**/ +@Service +@RequiredArgsConstructor +public class MTourServiceImpl implements MTourService { + + private final MTourRepository mTourRepository; + private final MTourMapper mTourMapper; + + @Override + public Map queryAll(MTourQueryCriteria criteria, Pageable pageable){ + Page page = mTourRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); + return PageUtil.toPage(page.map(mTourMapper::toDto)); + } + + @Override + public List queryAll(MTourQueryCriteria criteria){ + return mTourMapper.toDto(mTourRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + } + + @Override + @Transactional + public MTourDto findById(Long id) { + MTour mTour = mTourRepository.findById(id).orElseGet(MTour::new); + ValidationUtil.isNull(mTour.getId(),"MTour","id",id); + return mTourMapper.toDto(mTour); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public MTourDto create(MTour resources) { + return mTourMapper.toDto(mTourRepository.save(resources)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(MTour resources) { + MTour mTour = mTourRepository.findById(resources.getId()).orElseGet(MTour::new); + ValidationUtil.isNull( mTour.getId(),"MTour","id",resources.getId()); + mTour.copy(resources); + mTourRepository.save(mTour); + } + + @Override + public void deleteAll(Long[] ids) { + for (Long id : ids) { + mTourRepository.deleteById(id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (MTourDto mTour : all) { + Map map = new LinkedHashMap<>(); + map.put(" name", mTour.getName()); + map.put(" startDate", mTour.getStartDate()); + map.put(" period", mTour.getPeriod()); + map.put(" location", mTour.getLocation()); + map.put(" tourCode", mTour.getTourCode()); + map.put(" tourType", mTour.getTourType()); + map.put(" description", mTour.getDescription()); + map.put(" extraTourDetail", mTour.getExtraTourDetail()); + map.put(" extraRoomDetail", mTour.getExtraRoomDetail()); + map.put(" images", mTour.getImages()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/mapstruct/MTourMapper.java b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/mapstruct/MTourMapper.java new file mode 100644 index 00000000..96c2e475 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/portfolio/tour/service/mapstruct/MTourMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.portfolio.tour.service.mapstruct; + +import me.zhengjie.base.BaseMapper; +import me.zhengjie.portfolio.tour.domain.MTour; +import me.zhengjie.portfolio.tour.service.dto.MTourDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://el-admin.vip +* @author smk +* @date 2022-05-03 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface MTourMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin/src/main/java/room/domain/MRoom.java b/eladmin/src/main/java/room/domain/MRoom.java new file mode 100644 index 00000000..f355ffc0 --- /dev/null +++ b/eladmin/src/main/java/room/domain/MRoom.java @@ -0,0 +1,90 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.domain; + +import lombok.Data; +import cn.hutool.core.bean.BeanUtil; +import io.swagger.annotations.ApiModelProperty; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.persistence.*; +import javax.validation.constraints.*; +import java.io.Serializable; + +/** +* @website https://el-admin.vip +* @description / +* @author smk +* @date 2022-05-03 +**/ +@Entity +@Data +@Table(name="m_room") +public class MRoom implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + @ApiModelProperty(value = "id") + private Long id; + + @Column(name = "type") + @ApiModelProperty(value = "type") + private String type; + + @Column(name = "size") + @ApiModelProperty(value = "size") + private String size; + + @Column(name = "air_conditional",nullable = false) + @NotNull + @ApiModelProperty(value = "airConditional") + private Integer airConditional; + + @Column(name = "fan",nullable = false) + @NotNull + @ApiModelProperty(value = "fan") + private Integer fan; + + @Column(name = "free_parking") + @ApiModelProperty(value = "freeParking") + private Integer freeParking; + + @Column(name = "description") + @ApiModelProperty(value = "description") + private String description; + + @Column(name = "bad",nullable = false) + @NotNull + @ApiModelProperty(value = "bad") + private Integer bad; + + @Column(name = "free_breakfast") + @ApiModelProperty(value = "freeBreakfast") + private Integer freeBreakfast; + + @Column(name = "image",nullable = false) + @NotBlank + @ApiModelProperty(value = "image") + private String image; + + @Column(name = "extra_information") + @ApiModelProperty(value = "extraInformation") + private String extraInformation; + + public void copy(MRoom source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} \ No newline at end of file diff --git a/eladmin/src/main/java/room/repository/MRoomRepository.java b/eladmin/src/main/java/room/repository/MRoomRepository.java new file mode 100644 index 00000000..f014698b --- /dev/null +++ b/eladmin/src/main/java/room/repository/MRoomRepository.java @@ -0,0 +1,28 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.repository; + +import room.domain.MRoom; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://el-admin.vip +* @author smk +* @date 2022-05-03 +**/ +public interface MRoomRepository extends JpaRepository, JpaSpecificationExecutor { +} \ No newline at end of file diff --git a/eladmin/src/main/java/room/rest/MRoomController.java b/eladmin/src/main/java/room/rest/MRoomController.java new file mode 100644 index 00000000..f5411bfc --- /dev/null +++ b/eladmin/src/main/java/room/rest/MRoomController.java @@ -0,0 +1,87 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.rest; + +import me.zhengjie.annotation.Log; +import room.domain.MRoom; +import room.service.MRoomService; +import room.service.dto.MRoomQueryCriteria; +import org.springframework.data.domain.Pageable; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://el-admin.vip +* @author smk +* @date 2022-05-03 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "room管理") +@RequestMapping("/api/mRoom") +public class MRoomController { + + private final MRoomService mRoomService; + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('mRoom:list')") + public void exportMRoom(HttpServletResponse response, MRoomQueryCriteria criteria) throws IOException { + mRoomService.download(mRoomService.queryAll(criteria), response); + } + + @GetMapping + @Log("查询room") + @ApiOperation("查询room") + @PreAuthorize("@el.check('mRoom:list')") + public ResponseEntity queryMRoom(MRoomQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(mRoomService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增room") + @ApiOperation("新增room") + @PreAuthorize("@el.check('mRoom:add')") + public ResponseEntity createMRoom(@Validated @RequestBody MRoom resources){ + return new ResponseEntity<>(mRoomService.create(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改room") + @ApiOperation("修改room") + @PreAuthorize("@el.check('mRoom:edit')") + public ResponseEntity updateMRoom(@Validated @RequestBody MRoom resources){ + mRoomService.update(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @DeleteMapping + @Log("删除room") + @ApiOperation("删除room") + @PreAuthorize("@el.check('mRoom:del')") + public ResponseEntity deleteMRoom(@RequestBody Long[] ids) { + mRoomService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/eladmin/src/main/java/room/service/MRoomService.java b/eladmin/src/main/java/room/service/MRoomService.java new file mode 100644 index 00000000..ea65687b --- /dev/null +++ b/eladmin/src/main/java/room/service/MRoomService.java @@ -0,0 +1,83 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.service; + +import room.domain.MRoom; +import room.service.dto.MRoomDto; +import room.service.dto.MRoomQueryCriteria; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://el-admin.vip +* @description 服务接口 +* @author smk +* @date 2022-05-03 +**/ +public interface MRoomService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(MRoomQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(MRoomQueryCriteria criteria); + + /** + * 根据ID查询 + * @param id ID + * @return MRoomDto + */ + MRoomDto findById(Long id); + + /** + * 创建 + * @param resources / + * @return MRoomDto + */ + MRoomDto create(MRoom resources); + + /** + * 编辑 + * @param resources / + */ + void update(MRoom resources); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Long[] ids); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} \ No newline at end of file diff --git a/eladmin/src/main/java/room/service/dto/MRoomDto.java b/eladmin/src/main/java/room/service/dto/MRoomDto.java new file mode 100644 index 00000000..acf8bde6 --- /dev/null +++ b/eladmin/src/main/java/room/service/dto/MRoomDto.java @@ -0,0 +1,51 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.service.dto; + +import lombok.Data; +import java.io.Serializable; + +/** +* @website https://el-admin.vip +* @description / +* @author smk +* @date 2022-05-03 +**/ +@Data +public class MRoomDto implements Serializable { + + private Long id; + + private String type; + + private String size; + + private Integer airConditional; + + private Integer fan; + + private Integer freeParking; + + private String description; + + private Integer bad; + + private Integer freeBreakfast; + + private String image; + + private String extraInformation; +} \ No newline at end of file diff --git a/eladmin/src/main/java/room/service/dto/MRoomQueryCriteria.java b/eladmin/src/main/java/room/service/dto/MRoomQueryCriteria.java new file mode 100644 index 00000000..80e14d8f --- /dev/null +++ b/eladmin/src/main/java/room/service/dto/MRoomQueryCriteria.java @@ -0,0 +1,29 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.service.dto; + +import lombok.Data; +import java.util.List; +import me.zhengjie.annotation.Query; + +/** +* @website https://el-admin.vip +* @author smk +* @date 2022-05-03 +**/ +@Data +public class MRoomQueryCriteria{ +} \ No newline at end of file diff --git a/eladmin/src/main/java/room/service/impl/MRoomServiceImpl.java b/eladmin/src/main/java/room/service/impl/MRoomServiceImpl.java new file mode 100644 index 00000000..c2510667 --- /dev/null +++ b/eladmin/src/main/java/room/service/impl/MRoomServiceImpl.java @@ -0,0 +1,113 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.service.impl; + +import room.domain.MRoom; +import me.zhengjie.utils.ValidationUtil; +import me.zhengjie.utils.FileUtil; +import lombok.RequiredArgsConstructor; +import room.repository.MRoomRepository; +import room.service.MRoomService; +import room.service.dto.MRoomDto; +import room.service.dto.MRoomQueryCriteria; +import room.service.mapstruct.MRoomMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import me.zhengjie.utils.PageUtil; +import me.zhengjie.utils.QueryHelp; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +/** +* @website https://el-admin.vip +* @description 服务实现 +* @author smk +* @date 2022-05-03 +**/ +@Service +@RequiredArgsConstructor +public class MRoomServiceImpl implements MRoomService { + + private final MRoomRepository mRoomRepository; + private final MRoomMapper mRoomMapper; + + @Override + public Map queryAll(MRoomQueryCriteria criteria, Pageable pageable){ + Page page = mRoomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + return PageUtil.toPage(page.map(mRoomMapper::toDto)); + } + + @Override + public List queryAll(MRoomQueryCriteria criteria){ + return mRoomMapper.toDto(mRoomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + } + + @Override + @Transactional + public MRoomDto findById(Long id) { + MRoom mRoom = mRoomRepository.findById(id).orElseGet(MRoom::new); + ValidationUtil.isNull(mRoom.getId(),"MRoom","id",id); + return mRoomMapper.toDto(mRoom); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public MRoomDto create(MRoom resources) { + return mRoomMapper.toDto(mRoomRepository.save(resources)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(MRoom resources) { + MRoom mRoom = mRoomRepository.findById(resources.getId()).orElseGet(MRoom::new); + ValidationUtil.isNull( mRoom.getId(),"MRoom","id",resources.getId()); + mRoom.copy(resources); + mRoomRepository.save(mRoom); + } + + @Override + public void deleteAll(Long[] ids) { + for (Long id : ids) { + mRoomRepository.deleteById(id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (MRoomDto mRoom : all) { + Map map = new LinkedHashMap<>(); + map.put(" type", mRoom.getType()); + map.put(" size", mRoom.getSize()); + map.put(" airConditional", mRoom.getAirConditional()); + map.put(" fan", mRoom.getFan()); + map.put(" freeParking", mRoom.getFreeParking()); + map.put(" description", mRoom.getDescription()); + map.put(" bad", mRoom.getBad()); + map.put(" freeBreakfast", mRoom.getFreeBreakfast()); + map.put(" image", mRoom.getImage()); + map.put(" extraInformation", mRoom.getExtraInformation()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} \ No newline at end of file diff --git a/eladmin/src/main/java/room/service/mapstruct/MRoomMapper.java b/eladmin/src/main/java/room/service/mapstruct/MRoomMapper.java new file mode 100644 index 00000000..cf1a0e21 --- /dev/null +++ b/eladmin/src/main/java/room/service/mapstruct/MRoomMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package room.service.mapstruct; + +import me.zhengjie.base.BaseMapper; +import room.domain.MRoom; +import room.service.dto.MRoomDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://el-admin.vip +* @author smk +* @date 2022-05-03 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface MRoomMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/sql/eladmin.sql b/sql/eladmin.sql index 00234d29..1e24b057 100644 --- a/sql/eladmin.sql +++ b/sql/eladmin.sql @@ -816,6 +816,28 @@ CREATE TABLE `tool_qiniu_content` ( UNIQUE KEY `uniq_name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='七牛云文件存储'; +-- ---------------------------- +-- eladmin.m_room definition +-- ---------------------------- + + +-- eladmin.m_room definition + +CREATE TABLE `m_room` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `type` varchar(20) DEFAULT NULL, + `size` varchar(20) DEFAULT NULL, + `air_conditional` tinyint(1) NOT NULL DEFAULT '0', + `fan` tinyint(1) NOT NULL DEFAULT '0', + `free_parking` tinyint(1) DEFAULT '0', + `description` varchar(255) DEFAULT NULL, + `bad` int NOT NULL, + `free_breakfast` tinyint(1) DEFAULT '0', + `image` text NOT NULL, + `extra_information` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + -- ---------------------------- -- Records of tool_qiniu_content -- ---------------------------- diff --git a/sql/tool_picture.sql b/sql/tool_picture.sql index 6b36d0db..7ab6501a 100644 --- a/sql/tool_picture.sql +++ b/sql/tool_picture.sql @@ -1,2 +1,3 @@ -- 删除免费图床表 -DROP TABLE tool_picture; \ No newline at end of file +DROP TABLE tool_picture; + diff --git a/tour/index.vue b/tour/index.vue new file mode 100644 index 00000000..a5c0be7b --- /dev/null +++ b/tour/index.vue @@ -0,0 +1,142 @@ + + + + + diff --git a/tour/mTour.js b/tour/mTour.js new file mode 100644 index 00000000..350a5371 --- /dev/null +++ b/tour/mTour.js @@ -0,0 +1,27 @@ +import request from '@/utils/request' + +export function add(data) { + return request({ + url: 'api/mTour', + method: 'post', + data + }) +} + +export function del(ids) { + return request({ + url: 'api/mTour/', + method: 'delete', + data: ids + }) +} + +export function edit(data) { + return request({ + url: 'api/mTour', + method: 'put', + data + }) +} + +export default { add, edit, del }