Skip to content

Commit

Permalink
基础景点
Browse files Browse the repository at this point in the history
  • Loading branch information
niziming committed Jul 12, 2022
1 parent ce450ab commit 7ce65c0
Show file tree
Hide file tree
Showing 11 changed files with 294 additions and 332 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package cn.zm.trip.restful;

import cn.zm.common.base.ResResult;
import cn.zm.mybatis.base.BaseController;
import cn.zm.trip.entity.dto.BaseScenicSpotDTO;
import cn.zm.trip.entity.vo.BaseScenicSpotVO;
import cn.zm.trip.service.IBaseScenicSpotService;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Objects;
import java.util.List;

/**
* 基础景点
* @author 十渊
* @since 2022-07-12
*/
@RequestMapping("baseScenicSpot")
@RestController
@Api(tags = "基础景点")
public class BaseScenicSpotController extends BaseController {

@Resource
private IBaseScenicSpotService baseScenicSpotService;

@GetMapping
@ApiOperation("基础景点page查询")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页数", defaultValue = "1"),
@ApiImplicitParam(name = "size", value = "每页个数", defaultValue = "10"),
@ApiImplicitParam(name = "orderByColumn", value = "排序字段"),
@ApiImplicitParam(name = "isDesc", value = "是否降序")
})
public ResResult<IPage<BaseScenicSpotVO>> getByPage(@Validated BaseScenicSpotDTO baseScenicSpot) {
// TODO 分页查询
IPage<BaseScenicSpotVO> page = baseScenicSpotService.selectByPage(getPage(), baseScenicSpot);
return ResResult.succ(page);
}

// @PostMapping("list")
// @ApiOperation("基础景点list查询")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "orderByColumn", value = "排序字段"),
// @ApiImplicitParam(name = "isDesc", value = "是否降序")
// })
// public ResResult<List<BaseScenicSpotVO>> list(@Validated @RequestBody BaseScenicSpotDTO baseScenicSpot) {
// // TODO 分页查询
// IPage<BaseScenicSpotVO> page = baseScenicSpotService.list(getPage(), baseScenicSpot);
// return ResResult.succ(page);
// }

@GetMapping("{id}")
@ApiOperation("基础景点查询(id)")
public ResResult<BaseScenicSpotVO> get(@PathVariable String id) {
// TODO 查询
boolean aNull = Objects.isNull(baseScenicSpotService.getById(id));
return ResResult.succ(aNull ? null : baseScenicSpotService.getById(id).convert());
}

@PostMapping
@ApiOperation("基础景点新增")
public ResResult add(@RequestBody @Validated BaseScenicSpotDTO baseScenicSpot) {
// TODO 新增
baseScenicSpotService.save(baseScenicSpot.convert());
return ResResult.succ("新增成功");
}

@DeleteMapping("{id}")
@ApiOperation("基础景点删除")
public ResResult del(@PathVariable String id) {
// TODO 删除
baseScenicSpotService.removeById(id);
return ResResult.succ("删除成功");
}

@PutMapping
@ApiOperation("基础景点修改")
public ResResult update(@RequestBody @Validated BaseScenicSpotDTO baseScenicSpot) {
// TODO 修改
baseScenicSpotService.updateById(baseScenicSpot.convert());
return ResResult.succ("修改成功");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package cn.zm.trip.entity;

import cn.zm.trip.entity.vo.BaseScenicSpotVO;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import cn.zm.mybatis.utils.ObjectConvert;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
@TableName("base_scenic_spot")
@ApiModel(value="BaseScenicSpot对象", description="基础景点")
public class BaseScenicSpot extends ObjectConvert<BaseScenicSpotVO>{
@ApiModelProperty(value = "ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "景点信息标题")
private String title;
@ApiModelProperty(value = "景点发布作者ID")
private Long author;
@ApiModelProperty(value = "景点发布作者姓名")
private String authorName;
@ApiModelProperty(value = "景点类型")
private String type;
@ApiModelProperty(value = "景点缩略图")
private String avatar;
@ApiModelProperty(value = "景点联系电话")
private String phone;
@ApiModelProperty(value = "景点级别")
private String level;
@ApiModelProperty(value = "景点门票")
private Double price;
@ApiModelProperty(value = "景点位置")
private String location;
@ApiModelProperty(value = "景点邮政编码")
private String zip;
@ApiModelProperty(value = "景点开放时间")
private String opentime;
@ApiModelProperty(value = "景点信息发布时间")
@TableField("creatTime")
private LocalDateTime creatTime;
@ApiModelProperty(value = "景点描述内容")
private String content;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package cn.zm.trip.entity.dto;

import cn.zm.trip.entity.BaseScenicSpot;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import cn.zm.mybatis.utils.ObjectConvert;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
@TableName("base_scenic_spot")
@ApiModel(value="BaseScenicSpotDTO对象", description="基础景点")
public class BaseScenicSpotDTO extends ObjectConvert<BaseScenicSpot>{
@ApiModelProperty(value = "ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "景点信息标题")
private String title;
@ApiModelProperty(value = "景点发布作者ID")
private Long author;
@ApiModelProperty(value = "景点发布作者姓名")
private String authorName;
@ApiModelProperty(value = "景点类型")
private String type;
@ApiModelProperty(value = "景点缩略图")
private String avatar;
@ApiModelProperty(value = "景点联系电话")
private String phone;
@ApiModelProperty(value = "景点级别")
private String level;
@ApiModelProperty(value = "景点门票")
private Double price;
@ApiModelProperty(value = "景点位置")
private String location;
@ApiModelProperty(value = "景点邮政编码")
private String zip;
@ApiModelProperty(value = "景点开放时间")
private String opentime;
@ApiModelProperty(value = "景点信息发布时间")
@TableField("creatTime")
private LocalDateTime creatTime;
@ApiModelProperty(value = "景点描述内容")
private String content;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package cn.zm.trip.entity.vo;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import cn.zm.mybatis.utils.ObjectConvert;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
@TableName("base_scenic_spot")
@ApiModel(value="BaseScenicSpotVO对象", description="基础景点")
public class BaseScenicSpotVO {
@ApiModelProperty(value = "ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "景点信息标题")
private String title;
@ApiModelProperty(value = "景点发布作者ID")
private Long author;
@ApiModelProperty(value = "景点发布作者姓名")
private String authorName;
@ApiModelProperty(value = "景点类型")
private String type;
@ApiModelProperty(value = "景点缩略图")
private String avatar;
@ApiModelProperty(value = "景点联系电话")
private String phone;
@ApiModelProperty(value = "景点级别")
private String level;
@ApiModelProperty(value = "景点门票")
private Double price;
@ApiModelProperty(value = "景点位置")
private String location;
@ApiModelProperty(value = "景点邮政编码")
private String zip;
@ApiModelProperty(value = "景点开放时间")
private String opentime;
@ApiModelProperty(value = "景点信息发布时间")
@TableField("creatTime")
private LocalDateTime creatTime;
@ApiModelProperty(value = "景点描述内容")
private String content;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package cn.zm.trip.mapper;

import cn.zm.trip.entity.BaseScenicSpot;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface BaseScenicSpotMapper extends BaseMapper<BaseScenicSpot> {

}

This file was deleted.

Loading

0 comments on commit 7ce65c0

Please sign in to comment.