Commit 0ea49585 by testdl

# 用户下单功能

parent 1ac4cb82
package com.jumeirah.api.app.controller;
import com.jumeirah.common.entity.PlainType;
import com.jumeirah.common.service.PlainTypeService;
import com.jumeirah.common.vo.PlainTypeQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 飞机型号表 控制器
*
* @author wei
* @since 2020-10-09
*/
@Slf4j
@RestController
@RequestMapping("/plainType")
@Module("${cfg.module}")
@Api(value = "飞机型号表API", tags = {"飞机型号表"})
public class PlainTypeController extends BaseController {
@Autowired
private PlainTypeService plainTypeService;
/**
* 飞机型号表分页列表
*/
@GetMapping("/getAllMap")
@OperationLog(name = "分组获取飞机型号列表", type = OperationLogType.PAGE)
@ApiOperation(value = "分组获取飞机型号列表", response = PlainTypeQueryVo.class)
public ApiResult<Map<String, List<PlainType>>> getAllMap() throws Exception {
List<PlainType> plainTypeList = plainTypeService.getAllMap();
Map<String, List<PlainType>> resultList = new LinkedHashMap<>();
if (!CollectionUtils.isEmpty(plainTypeList)) {
resultList = plainTypeList.stream().collect(Collectors.groupingBy(PlainType::getSeriesName));
}
return ApiResult.ok(resultList);
}
}
...@@ -44,8 +44,8 @@ public class StrokeAddBackAndForthVo extends BaseEntity { ...@@ -44,8 +44,8 @@ public class StrokeAddBackAndForthVo extends BaseEntity {
private Integer peopleMun; private Integer peopleMun;
@NotNull(message = "飞机型号ID不能为空") @NotNull(message = "飞机型号ID不能为空")
@ApiModelProperty("飞机型号ID") @ApiModelProperty("飞机型号ID,多个中间用逗号隔开")
private Long plainTypeId; private String plainTypeIds;
@NotNull(message = "出发时间不能为空") @NotNull(message = "出发时间不能为空")
@ApiModelProperty("出发时间") @ApiModelProperty("出发时间")
......
...@@ -48,8 +48,8 @@ public class StrokeAddOneWayVo extends BaseEntity { ...@@ -48,8 +48,8 @@ public class StrokeAddOneWayVo extends BaseEntity {
private Integer peopleMun; private Integer peopleMun;
@NotNull(message = "飞机型号ID不能为空") @NotNull(message = "飞机型号ID不能为空")
@ApiModelProperty("飞机型号ID") @ApiModelProperty("飞机型号ID,多个中间用逗号隔开")
private Long plainTypeId; private String plainTypeIds;
@NotNull(message = "出发时间不能为空") @NotNull(message = "出发时间不能为空")
@ApiModelProperty("出发时间") @ApiModelProperty("出发时间")
......
package com.jumeirah.common.controller;
import com.jumeirah.common.entity.PlainType;
import com.jumeirah.common.service.PlainTypeService;
import lombok.extern.slf4j.Slf4j;
import com.jumeirah.common.param.PlainTypePageParam;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import com.jumeirah.common.vo.PlainTypeQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.common.param.IdParam;
import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* 飞机型号表 控制器
*
* @author wei
* @since 2020-10-09
*/
/*@Slf4j
@RestController
@RequestMapping("/plainType")
@Module("${cfg.module}")
@Api(value = "飞机型号表API", tags = {"飞机型号表"})*/
public class PlainTypeController extends BaseController {
@Autowired
private PlainTypeService plainTypeService;
/**
* 添加飞机型号表
*/
@PostMapping("/add")
@OperationLog(name = "添加飞机型号表", type = OperationLogType.ADD)
@ApiOperation(value = "添加飞机型号表", response = ApiResult.class)
public ApiResult<Boolean> addPlainType(@Validated(Add.class) @RequestBody PlainType plainType) throws Exception {
boolean flag = plainTypeService.savePlainType(plainType);
return ApiResult.result(flag);
}
/**
* 修改飞机型号表
*/
@PostMapping("/update")
@OperationLog(name = "修改飞机型号表", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改飞机型号表", response = ApiResult.class)
public ApiResult<Boolean> updatePlainType(@Validated(Update.class) @RequestBody PlainType plainType) throws Exception {
boolean flag = plainTypeService.updatePlainType(plainType);
return ApiResult.result(flag);
}
/**
* 删除飞机型号表
*/
@PostMapping("/delete/{id}")
@OperationLog(name = "删除飞机型号表", type = OperationLogType.DELETE)
@ApiOperation(value = "删除飞机型号表", response = ApiResult.class)
public ApiResult<Boolean> deletePlainType(@PathVariable("id") Long id) throws Exception {
boolean flag = plainTypeService.deletePlainType(id);
return ApiResult.result(flag);
}
/**
* 获取飞机型号表详情
*/
@GetMapping("/info/{id}")
@OperationLog(name = "飞机型号表详情", type = OperationLogType.INFO)
@ApiOperation(value = "飞机型号表详情", response = PlainTypeQueryVo.class)
public ApiResult<PlainTypeQueryVo> getPlainType(@PathVariable("id") Long id) throws Exception {
PlainTypeQueryVo plainTypeQueryVo = plainTypeService.getPlainTypeById(id);
return ApiResult.ok(plainTypeQueryVo);
}
/**
* 飞机型号表分页列表
*/
@PostMapping("/getPageList")
@OperationLog(name = "飞机型号表分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "飞机型号表分页列表", response = PlainTypeQueryVo.class)
public ApiResult<Paging<PlainTypeQueryVo>> getPlainTypePageList(@Validated @RequestBody PlainTypePageParam plainTypePageParam) throws Exception {
Paging<PlainTypeQueryVo> paging = plainTypeService.getPlainTypePageList(plainTypePageParam);
return ApiResult.ok(paging);
}
}
package com.jumeirah.common.entity;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
/**
* 飞机型号表
*
* @author wei
* @since 2020-10-09
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "PlainType对象")
public class PlainType extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空", groups = {Update.class})
@ApiModelProperty("主键ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@NotNull(message = "系列类型不能为空")
@ApiModelProperty("系列类型")
private Integer seriesType;
@ApiModelProperty("系列名称")
private String seriesName;
@NotBlank(message = "飞机名称不能为空")
@ApiModelProperty("飞机名称")
private String name;
@NotBlank(message = "飞机图片地址不能为空")
@ApiModelProperty("飞机图片地址")
private String imgUrl;
@NotNull(message = "状态,0-正常,1-禁用,99-删除不能为空")
@ApiModelProperty("状态,0-正常,1-禁用,99-删除")
private Integer status;
@NotNull(message = "创建时间(时间戳)不能为空")
@ApiModelProperty("创建时间(时间戳)")
private Long createTime;
@ApiModelProperty("更新时间(时间戳)")
private Long updateTime;
@ApiModelProperty("宽 单位:像素")
private Integer width;
@ApiModelProperty("高 单位:像素")
private Integer height;
}
...@@ -119,6 +119,6 @@ public class Stroke extends BaseEntity { ...@@ -119,6 +119,6 @@ public class Stroke extends BaseEntity {
@NotNull(message = "用户选择机型不能为空") @NotNull(message = "用户选择机型不能为空")
@ApiModelProperty("用户选择机型") @ApiModelProperty("用户选择机型")
private Long choosePlainType; private String choosePlainType;
} }
package com.jumeirah.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jumeirah.common.entity.PlainType;
import com.jumeirah.common.param.PlainTypePageParam;
import com.jumeirah.common.vo.PlainTypeQueryVo;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import java.io.Serializable;
/**
* 飞机型号表 Mapper 接口
*
* @author wei
* @since 2020-10-09
*/
@Repository
public interface PlainTypeMapper extends BaseMapper<PlainType> {
/**
* 根据ID获取查询对象
*
* @param id
* @return
*/
PlainTypeQueryVo getPlainTypeById(Serializable id);
/**
* 获取分页对象
*
* @param page
* @param plainTypePageParam
* @return
*/
IPage<PlainTypeQueryVo> getPlainTypePageList(@Param("page") Page page, @Param("param") PlainTypePageParam plainTypePageParam);
}
package com.jumeirah.common.param;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
/**
* <pre>
* 飞机型号表 分页参数对象
* </pre>
*
* @author wei
* @date 2020-10-09
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "飞机型号表分页参数")
public class PlainTypePageParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L;
}
package com.jumeirah.common.service;
import com.jumeirah.common.entity.PlainType;
import com.jumeirah.common.param.PlainTypePageParam;
import io.geekidea.springbootplus.framework.common.service.BaseService;
import com.jumeirah.common.vo.PlainTypeQueryVo;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import java.util.List;
/**
* 飞机型号表 服务类
*
* @author wei
* @since 2020-10-09
*/
public interface PlainTypeService extends BaseService<PlainType> {
/**
* 保存
*
* @param plainType
* @return
* @throws Exception
*/
boolean savePlainType(PlainType plainType) throws Exception;
/**
* 修改
*
* @param plainType
* @return
* @throws Exception
*/
boolean updatePlainType(PlainType plainType) throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deletePlainType(Long id) throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
PlainTypeQueryVo getPlainTypeById(Long id) throws Exception;
/**
* 获取分页对象
*
* @param plainTypePageParam
* @return
* @throws Exception
*/
Paging<PlainTypeQueryVo> getPlainTypePageList(PlainTypePageParam plainTypePageParam) throws Exception;
/**
* 获取所有飞机类型
* @return
*/
List<PlainType> getAllMap();
}
package com.jumeirah.common.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jumeirah.common.entity.PlainType;
import com.jumeirah.common.mapper.PlainTypeMapper;
import com.jumeirah.common.service.PlainTypeService;
import com.jumeirah.common.param.PlainTypePageParam;
import com.jumeirah.common.vo.PlainTypeQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* 飞机型号表 服务实现类
*
* @author wei
* @since 2020-10-09
*/
@Slf4j
@Service
public class PlainTypeServiceImpl extends BaseServiceImpl<PlainTypeMapper, PlainType> implements PlainTypeService {
@Autowired
private PlainTypeMapper plainTypeMapper;
@Transactional(rollbackFor = Exception.class)
@Override
public boolean savePlainType(PlainType plainType) throws Exception {
return super.save(plainType);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updatePlainType(PlainType plainType) throws Exception {
return super.updateById(plainType);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean deletePlainType(Long id) throws Exception {
return super.removeById(id);
}
@Override
public PlainTypeQueryVo getPlainTypeById(Long id) throws Exception {
return plainTypeMapper.getPlainTypeById(id);
}
@Override
public Paging<PlainTypeQueryVo> getPlainTypePageList(PlainTypePageParam plainTypePageParam) throws Exception {
Page<PlainTypeQueryVo> page = new PageInfo<>(plainTypePageParam, OrderItem.desc(getLambdaColumn(PlainType::getCreateTime)));
IPage<PlainTypeQueryVo> iPage = plainTypeMapper.getPlainTypePageList(page, plainTypePageParam);
return new Paging<PlainTypeQueryVo>(iPage);
}
@Override
public List<PlainType> getAllMap() {
return this.list(new QueryWrapper<PlainType>().lambda()
.orderByAsc(PlainType::getSeriesType, PlainType::getCreateTime)
);
}
}
package com.jumeirah.common.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* <pre>
* 飞机型号表 查询结果对象
* </pre>
*
* @author wei
* @date 2020-10-09
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "PlainTypeQueryVo对象")
public class PlainTypeQueryVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键ID")
private Long id;
@ApiModelProperty("系列类型")
private Integer seriesType;
@ApiModelProperty("飞机名称")
private String name;
@ApiModelProperty("飞机图片地址")
private String imgUrl;
@ApiModelProperty("状态,0-正常,1-禁用,99-删除")
private Integer status;
@ApiModelProperty("创建时间(时间戳)")
private Long createTime;
@ApiModelProperty("更新时间(时间戳)")
private Long updateTime;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jumeirah.common.mapper.PlainTypeMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, series_type, name, img_url, status, create_time, update_time
</sql>
<select id="getPlainTypeById" resultType="com.jumeirah.common.vo.PlainTypeQueryVo">
select
<include refid="Base_Column_List"/>
from plain_type where id = #{id}
</select>
<select id="getPlainTypePageList" parameterType="com.jumeirah.common.param.PlainTypePageParam"
resultType="com.jumeirah.common.vo.PlainTypeQueryVo">
select
<include refid="Base_Column_List"/>
from plain_type
</select>
</mapper>
...@@ -22,10 +22,10 @@ spring: ...@@ -22,10 +22,10 @@ spring:
redis: redis:
database: 0 database: 0
host: localhost host: localhost
password: password: 123456
port: 6379 port: 6379
# 打印SQL语句和结果集,本地开发环境可开启,线上注释掉 # 打印SQL语句和结果集,本地开发环境可开启,线上注释掉
mybatis-plus: mybatis-plus:
configuration: configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
\ No newline at end of file
...@@ -40,7 +40,7 @@ public class SpringBootPlusGenerator { ...@@ -40,7 +40,7 @@ public class SpringBootPlusGenerator {
* @param args * @param args
*/ */
public static void main(String[] args) { public static void main(String[] args) {
getCode("123"); getCode("plain_type");
} }
private static void getCode(String tableName) { private static void getCode(String tableName) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment