mirror of https://github.com/elunez/eladmin
add-tour-room
parent
75e08c6cd0
commit
b7cb9e65d7
|
@ -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"
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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<MRoom, Long>, JpaSpecificationExecutor<MRoom> {
|
||||
}
|
|
@ -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<Object> 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<Object> 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<Object> 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<Object> deleteMRoom(@RequestBody Long[] ids) {
|
||||
mRoomService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
|
@ -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<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(MRoomQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<MRoomDto>
|
||||
*/
|
||||
List<MRoomDto> 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<MRoomDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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{
|
||||
}
|
|
@ -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<String,Object> queryAll(MRoomQueryCriteria criteria, Pageable pageable){
|
||||
Page<MRoom> page = mRoomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(mRoomMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MRoomDto> 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<MRoomDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (MRoomDto mRoom : all) {
|
||||
Map<String,Object> 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);
|
||||
}
|
||||
}
|
|
@ -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<MRoomDto, MRoom> {
|
||||
|
||||
}
|
|
@ -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<String> image;
|
||||
|
||||
@Column(name = "extra_information")
|
||||
@ApiModelProperty(value = "extraInformation")
|
||||
@Convert(converter = StringMapConverter.class)
|
||||
private HashMap<String, String> extraInformation;
|
||||
|
||||
public void copy(MRoom source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
|
@ -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<String> images;
|
||||
|
||||
@Column(name = "extra_info")
|
||||
@Convert(converter = StringListConverter.class)
|
||||
@ApiModelProperty(value = "extraInfo")
|
||||
private List<String> extraInfo;
|
||||
|
||||
public void copy(Room source) {
|
||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
public List<String> getImages() {
|
||||
return images;
|
||||
}
|
||||
}
|
|
@ -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<Room, Long>, JpaSpecificationExecutor<Room> {
|
||||
public interface MRoomRepository extends JpaRepository<MRoom, Long>, JpaSpecificationExecutor<MRoom> {
|
||||
}
|
|
@ -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<Object> queryRoom(RoomQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(roomService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
@PreAuthorize("@el.check('mRoom:list')")
|
||||
public ResponseEntity<Object> 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<Object> createRoom(@Validated @RequestBody Room resources){
|
||||
return new ResponseEntity<>(roomService.create(resources),HttpStatus.CREATED);
|
||||
@PreAuthorize("@el.check('mRoom:add')")
|
||||
public ResponseEntity<Object> 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<Object> updateRoom(@Validated @RequestBody Room resources){
|
||||
roomService.update(resources);
|
||||
@PreAuthorize("@el.check('mRoom:edit')")
|
||||
public ResponseEntity<Object> 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<Object> deleteRoom(@RequestBody Long[] ids) {
|
||||
roomService.deleteAll(ids);
|
||||
@PreAuthorize("@el.check('mRoom:del')")
|
||||
public ResponseEntity<Object> deleteMRoom(@RequestBody Long[] ids) {
|
||||
mRoomService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
|
@ -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<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(RoomQueryCriteria criteria, Pageable pageable);
|
||||
Map<String,Object> queryAll(MRoomQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<RoomDto>
|
||||
* @return List<MRoomDto>
|
||||
*/
|
||||
List<RoomDto> queryAll(RoomQueryCriteria criteria);
|
||||
List<MRoomDto> 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<RoomDto> all, HttpServletResponse response) throws IOException;
|
||||
void download(List<MRoomDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
|
@ -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<String> image;
|
||||
|
||||
private HashMap<String, String> extraInformation;
|
||||
}
|
|
@ -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{
|
||||
}
|
|
@ -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<String> images;
|
||||
|
||||
private List<String> extraInfo;
|
||||
}
|
|
@ -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<String,Object> queryAll(MRoomQueryCriteria criteria, Pageable pageable){
|
||||
Page<MRoom> page = mRoomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(mRoomMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MRoomDto> 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<MRoomDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (MRoomDto mRoom : all) {
|
||||
Map<String,Object> 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);
|
||||
}
|
||||
}
|
|
@ -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<String,Object> queryAll(RoomQueryCriteria criteria, Pageable pageable){
|
||||
Page<Room> page = roomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(roomMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoomDto> 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<RoomDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (RoomDto room : all) {
|
||||
Map<String,Object> 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);
|
||||
}
|
||||
}
|
|
@ -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<RoomDto, Room> {
|
||||
public interface MRoomMapper extends BaseMapper<MRoomDto, MRoom> {
|
||||
|
||||
}
|
|
@ -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<String, String> extraTourDetail;
|
||||
|
||||
@Column(name = "extra_room_detail",nullable = false)
|
||||
@ApiModelProperty(value = "extraRoomDetail")
|
||||
@Convert(converter = StringMapConverter.class)
|
||||
private HashMap<String, String> extraRoomDetail;
|
||||
|
||||
@Column(name = "images",nullable = false)
|
||||
@ApiModelProperty(value = "images")
|
||||
@Convert(converter = StringListConverter.class)
|
||||
private List<String> images;
|
||||
|
||||
public void copy(MTour source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
|
@ -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<MTour, Long>, JpaSpecificationExecutor<MTour> {
|
||||
}
|
|
@ -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<Object> 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<Object> 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<Object> 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<Object> deleteMTour(@RequestBody Long[] ids) {
|
||||
mTourService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
|
@ -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<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(MTourQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<MTourDto>
|
||||
*/
|
||||
List<MTourDto> 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<MTourDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
|
@ -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<String, String> extraTourDetail;
|
||||
|
||||
private HashMap<String, String> extraRoomDetail;
|
||||
|
||||
private List<String> images;
|
||||
}
|
|
@ -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{
|
||||
}
|
|
@ -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<String,Object> queryAll(MTourQueryCriteria criteria, Pageable pageable){
|
||||
Page<MTour> page = mTourRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
return PageUtil.toPage(page.map(mTourMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MTourDto> 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<MTourDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (MTourDto mTour : all) {
|
||||
Map<String,Object> 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);
|
||||
}
|
||||
}
|
|
@ -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<MTourDto, MTour> {
|
||||
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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<MRoom, Long>, JpaSpecificationExecutor<MRoom> {
|
||||
}
|
|
@ -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<Object> 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<Object> 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<Object> 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<Object> deleteMRoom(@RequestBody Long[] ids) {
|
||||
mRoomService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
|
@ -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<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(MRoomQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<MRoomDto>
|
||||
*/
|
||||
List<MRoomDto> 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<MRoomDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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{
|
||||
}
|
|
@ -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<String,Object> queryAll(MRoomQueryCriteria criteria, Pageable pageable){
|
||||
Page<MRoom> page = mRoomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(mRoomMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MRoomDto> 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<MRoomDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (MRoomDto mRoom : all) {
|
||||
Map<String,Object> 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);
|
||||
}
|
||||
}
|
|
@ -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<MRoomDto, MRoom> {
|
||||
|
||||
}
|
|
@ -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
|
||||
-- ----------------------------
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
-- 删除免费图床表
|
||||
DROP TABLE tool_picture;
|
||||
DROP TABLE tool_picture;
|
||||
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission" />
|
||||
<!--表单组件-->
|
||||
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
|
||||
<el-form-item label="id">
|
||||
<el-input v-model="form.id" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="name" prop="name">
|
||||
<el-input v-model="form.name" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="startDate" prop="startDate">
|
||||
<el-input v-model="form.startDate" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="period" prop="period">
|
||||
<el-input v-model="form.period" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="location" prop="location">
|
||||
<el-input v-model="form.location" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="tourCode" prop="tourCode">
|
||||
<el-input v-model="form.tourCode" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="tourType" prop="tourType">
|
||||
<el-input v-model="form.tourType" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="description">
|
||||
<el-input v-model="form.description" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="extraTourDetail" prop="extraTourDetail">
|
||||
<el-input v-model="form.extraTourDetail" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="extraRoomDetail" prop="extraRoomDetail">
|
||||
<el-input v-model="form.extraRoomDetail" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="images" prop="images">
|
||||
<el-input v-model="form.images" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
||||
<el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--表格渲染-->
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="id" label="id" />
|
||||
<el-table-column prop="name" label="name" />
|
||||
<el-table-column prop="startDate" label="startDate" />
|
||||
<el-table-column prop="period" label="period" />
|
||||
<el-table-column prop="location" label="location" />
|
||||
<el-table-column prop="tourCode" label="tourCode" />
|
||||
<el-table-column prop="tourType" label="tourType" />
|
||||
<el-table-column prop="description" label="description" />
|
||||
<el-table-column prop="extraTourDetail" label="extraTourDetail" />
|
||||
<el-table-column prop="extraRoomDetail" label="extraRoomDetail" />
|
||||
<el-table-column prop="images" label="images" />
|
||||
<el-table-column v-if="checkPer(['admin','mTour:edit','mTour:del'])" label="操作" width="150px" align="center">
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudMTour from '@/api/mTour'
|
||||
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
|
||||
const defaultForm = { id: null, name: null, startDate: null, period: null, location: null, tourCode: null, tourType: null, description: null, extraTourDetail: null, extraRoomDetail: null, images: null }
|
||||
export default {
|
||||
name: 'MTour',
|
||||
components: { pagination, crudOperation, rrOperation, udOperation },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({ title: 'tour', url: 'api/mTour', idField: 'id', sort: 'id,desc', crudMethod: { ...crudMTour }})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
permission: {
|
||||
add: ['admin', 'mTour:add'],
|
||||
edit: ['admin', 'mTour:edit'],
|
||||
del: ['admin', 'mTour:del']
|
||||
},
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
startDate: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
period: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
location: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
tourCode: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
tourType: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
extraTourDetail: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
extraRoomDetail: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
images: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
]
|
||||
} }
|
||||
},
|
||||
methods: {
|
||||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -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 }
|
Loading…
Reference in New Issue