Commit a117d846 by lpx

# 商家管理公务机出售/托管相关接口

parent f835ddbc
package com.jumeirah.api.merchant.controller.plain;
import com.jumeirah.api.merchant.entity.param.McBusinessPlainAddParam;
import com.jumeirah.common.entity.BusinessPlain;
import com.jumeirah.common.param.BusinessPlainPageParam;
import com.jumeirah.common.service.BusinessPlainService;
import com.jumeirah.common.vo.BusinessPlainQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;
/**
* 公务机出售托管表 控制器
*
* @author giao
* @since 2020-10-14
*/
@Slf4j
@RestController
@RequestMapping("/merchant/businessPlain")
@Api(value = "公务机出售托管表API", tags = {"公务机出售托管表"})
public class McBusinessPlainController extends BaseController {
@Autowired
private BusinessPlainService businessPlainService;
/**
* 添加公务机出售托管表
*/
@PostMapping("/add")
@OperationLog(name = "添加公务机出售托管表", type = OperationLogType.ADD)
@ApiOperation(value = "添加公务机出售托管表")
public ApiResult<Boolean> addBusinessPlain(@Validated(Add.class) @RequestBody McBusinessPlainAddParam mcBusinessPlainAddParam) throws Exception {
BusinessPlain businessPlain = new BusinessPlain();
BeanUtils.copyProperties(mcBusinessPlainAddParam, businessPlain);
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
businessPlain.setMcId(jwtToken.getMcId());
boolean flag = businessPlainService.saveBusinessPlain(businessPlain);
return ApiResult.result(flag);
}
/**
* 修改公务机出售托管表
*/
@PostMapping("/update")
@OperationLog(name = "修改公务机出售托管表", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改公务机出售托管表")
public ApiResult<Boolean> updateBusinessPlain(@Validated(Update.class) @RequestBody McBusinessPlainAddParam mcBusinessPlainAddParam) throws Exception {
BusinessPlain businessPlain = new BusinessPlain();
BeanUtils.copyProperties(mcBusinessPlainAddParam, businessPlain);
boolean flag = businessPlainService.updateBusinessPlain(businessPlain);
return ApiResult.result(flag);
}
/**
* 删除公务机出售托管表
*/
@PostMapping("/delete/{id}")
@OperationLog(name = "删除公务机出售托管表", type = OperationLogType.DELETE)
@ApiOperation(value = "删除公务机出售托管表")
public ApiResult<Boolean> deleteBusinessPlain(@PathVariable("id") Long id) throws Exception {
boolean flag = businessPlainService.deleteBusinessPlain(id);
return ApiResult.result(flag);
}
/**
* 公务机出售托管表分页列表
*/
@PostMapping("/getPageList")
@OperationLog(name = "公务机出售托管表分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "公务机出售托管表分页列表")
public ApiResult<Paging<BusinessPlainQueryVo>> getBusinessPlainPageList(@Validated @RequestBody BusinessPlainPageParam businessPlainPageParam) throws Exception {
Paging<BusinessPlainQueryVo> paging = businessPlainService.getBusinessPlainPageList(businessPlainPageParam);
return ApiResult.ok(paging);
}
// /**
// * 获取公务机出售托管表详情
// */
// @GetMapping("/info/{id}")
// @OperationLog(name = "公务机出售托管表详情", type = OperationLogType.INFO)
// @ApiOperation(value = "公务机出售托管表详情")
// public ApiResult<BusinessPlainQueryVo> getBusinessPlain(@PathVariable("id") Long id) throws Exception {
// BusinessPlainQueryVo businessPlainQueryVo = businessPlainService.getBusinessPlainById(id);
// return ApiResult.ok(businessPlainQueryVo);
// }
}
package com.jumeirah.api.merchant.entity.param;
import com.jumeirah.common.entity.base.ImgJson;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 公务机出售/托管表
*
* @author giao
* @since 2020-10-14
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "BusinessPlain对象")
public class McBusinessPlainAddParam extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空", groups = {Update.class})
@ApiModelProperty("主键ID")
private Long id;
@NotNull(message = "业务类型,0-出售,1-托管不能为空")
@ApiModelProperty("业务类型,0-出售,1-托管")
private Integer businessType;
@ApiModelProperty("机型介绍")
private String introduction;
@ApiModelProperty("销售员姓名")
private String name;
@ApiModelProperty("销售联系电话")
private String phone;
@ApiModelProperty("微信号")
private String wechat;
@ApiModelProperty("图片相关数据json")
private List<ImgJson> imgUrl;
}
package com.jumeirah.common.campusstore;
import com.alibaba.fastjson.JSONArray;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
*
* @description 用以mysql中json格式的字段,进行转换的自定义转换器,转换为实体类的JSONArray属性
* MappedTypes注解中的类代表此转换器可以自动转换为的java对象
* MappedJdbcTypes注解中设置的是对应的jdbctype
*/
@MappedTypes(JSONArray.class)
@MappedJdbcTypes(JdbcType.VARCHAR)
public class ArrayJsonHandler extends BaseTypeHandler<JSONArray> {
//设置非空参数
@Override
public void setNonNullParameter(PreparedStatement ps, int i, JSONArray parameter, JdbcType jdbcType) throws SQLException {
ps.setString(i, String.valueOf(parameter.toJSONString()));
}
//根据列名,获取可以为空的结果
@Override
public JSONArray getNullableResult(ResultSet rs, String columnName) throws SQLException {
String sqlJson = rs.getString(columnName);
if (null != sqlJson){
return JSONArray.parseArray(sqlJson);
}
return null;
}
//根据列索引,获取可以为空的结果
@Override
public JSONArray getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
String sqlJson = rs.getString(columnIndex);
if (null != sqlJson){
return JSONArray.parseArray(sqlJson);
}
return null;
}
@Override
public JSONArray getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
String sqlJson = cs.getString(columnIndex);
if (null != sqlJson){
return JSONArray.parseArray(sqlJson);
}
return null;
}
}
package com.jumeirah.common.campusstore;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
*
* @description 用以mysql中json格式的字段,进行转换的自定义转换器,转换为实体类的JSONObject属性
* MappedTypes注解中的类代表此转换器可以自动转换为的java对象
* MappedJdbcTypes注解中设置的是对应的jdbctype
*/
@MappedTypes(JSONObject.class)
@MappedJdbcTypes(JdbcType.VARCHAR)
public class ObjectJsonHandler extends BaseTypeHandler<JSONObject>{
//设置非空参数
@Override
public void setNonNullParameter(PreparedStatement ps, int i, JSONObject parameter, JdbcType jdbcType) throws SQLException {
ps.setString(i, String.valueOf(parameter.toJSONString()));
}
//根据列名,获取可以为空的结果
@Override
public JSONObject getNullableResult(ResultSet rs, String columnName) throws SQLException {
String sqlJson = rs.getString(columnName);
if (null != sqlJson){
return JSONObject.parseObject(sqlJson);
}
return null;
}
//根据列索引,获取可以为空的结果
@Override
public JSONObject getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
String sqlJson = rs.getString(columnIndex);
if (null != sqlJson){
return JSONObject.parseObject(sqlJson);
}
return null;
}
@Override
public JSONObject getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
String sqlJson = cs.getString(columnIndex);
if (null != sqlJson){
return JSONObject.parseObject(sqlJson);
}
return null;
}
}
package com.jumeirah.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.jumeirah.common.entity.base.ImgJson;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -10,7 +14,8 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.sql.Timestamp;
import java.util.List;
/**
* 公务机出售/托管表
......@@ -22,6 +27,7 @@ import java.util.Date;
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "BusinessPlain对象")
@TableName(autoResultMap = true)
public class BusinessPlain extends BaseEntity {
private static final long serialVersionUID = 1L;
......@@ -38,9 +44,6 @@ public class BusinessPlain extends BaseEntity {
@ApiModelProperty("业务类型,0-出售,1-托管")
private Integer businessType;
@ApiModelProperty("图片url")
private String imgUrl;
@ApiModelProperty("机型介绍")
private String introduction;
......@@ -58,14 +61,13 @@ public class BusinessPlain extends BaseEntity {
private Integer status;
@ApiModelProperty("创建时间(时间戳)")
private Date createTime;
private Timestamp createTime;
@ApiModelProperty("更新时间(时间戳)")
private Date updateTime;
private Timestamp updateTime;
@ApiModelProperty("图片高")
private Integer imageListHeight;
@ApiModelProperty("图片宽")
private Integer imageListWidth;
@TableField(typeHandler = FastjsonTypeHandler.class)
@ApiModelProperty("图片相关数据json (包括:路径,宽和高)")
private List<ImgJson> imgUrl;
}
package com.jumeirah.common.entity.base;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @ClassName ImgJson
* @Descripteion 请写点注释吧!
* @Date 2020/10/22 11:21
* @Version 1.0
**/
@Data
@ApiModel(value = "图片json对象")
public class ImgJson implements Serializable {
@ApiModelProperty("地址url")
private String url;
@ApiModelProperty("高")
private Long height;
@ApiModelProperty("宽")
private Long width;
}
package com.jumeirah.common.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.jumeirah.common.entity.base.ImgJson;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* <pre>
......@@ -18,15 +23,13 @@ import java.io.Serializable;
@Data
@Accessors(chain = true)
@ApiModel(value = "BusinessPlainQueryForAppVo对象")
@TableName(autoResultMap = true)
public class BusinessPlainQueryForAppVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("商家name")
private String mcName;
@ApiModelProperty("图片url")
private String imgUrl;
@ApiModelProperty("机型介绍")
private String introduction;
......@@ -41,8 +44,8 @@ public class BusinessPlainQueryForAppVo implements Serializable {
@ApiModelProperty("商家头像")
private String mcHead;
@ApiModelProperty("图片高")
private Integer imageListHeight;
@ApiModelProperty("图片宽")
private Integer imageListWidth;
}
\ No newline at end of file
@TableField(typeHandler = FastjsonTypeHandler.class)
@ApiModelProperty("图片相关数据json (包括:路径,宽和高)")
private List<ImgJson> imgList;
}
package com.jumeirah.common.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.jumeirah.common.entity.base.ImgJson;
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;
import java.sql.Timestamp;
import java.util.List;
/**
* <pre>
......@@ -19,7 +24,8 @@ import java.util.Date;
@Data
@Accessors(chain = true)
@ApiModel(value = "BusinessPlainQueryVo对象")
public class BusinessPlainQueryVo implements Serializable {
@TableName(autoResultMap = true)
public class BusinessPlainQueryVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键ID")
......@@ -31,9 +37,6 @@ public class BusinessPlainQueryVo implements Serializable {
@ApiModelProperty("业务类型,0-出售,1-托管")
private Integer businessType;
@ApiModelProperty("图片url")
private String imgUrl;
@ApiModelProperty("机型介绍")
private String introduction;
......@@ -50,8 +53,12 @@ public class BusinessPlainQueryVo implements Serializable {
private Integer status;
@ApiModelProperty("创建时间(时间戳)")
private Date createTime;
private Timestamp createTime;
@ApiModelProperty("更新时间(时间戳)")
private Date updateTime;
}
\ No newline at end of file
private Timestamp updateTime;
@TableField(typeHandler = FastjsonTypeHandler.class)
@ApiModelProperty("图片相关数据json (包括:路径,宽和高)")
private List<ImgJson> imgList;
}
......@@ -4,11 +4,27 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, mc_id, business_type, img_url, introduction, name, phone, wechat, status, create_time, update_time,image_list_height,image_list_width
id,
mc_id,
business_type,
img_url,
introduction,
name,
phone,
wechat,
status,
create_time,
update_time
</sql>
<sql id="Base_Column_ListForApp">
bp.business_type, bp.img_url, bp.introduction, bp.name, bp.phone, bp.wechat,m.`name` AS mcName
bp.business_type,
bp.img_url,
bp.introduction,
bp.name,
bp.phone,
bp.wechat,
m.`name` AS mcName
</sql>
<select id="getBusinessPlainById" resultType="com.jumeirah.common.vo.BusinessPlainQueryVo">
......@@ -18,20 +34,31 @@
</select>
<select id="getBusinessPlainPageList" parameterType="com.jumeirah.common.param.BusinessPlainPageParam"
resultType="com.jumeirah.common.vo.BusinessPlainQueryVo">
resultMap="pageListMap">
select
<include refid="Base_Column_List"/>
from business_plain as bp
<include refid="Base_Column_List"/>
from business_plain
</select>
<resultMap id="pageListMap" type="com.jumeirah.common.vo.BusinessPlainQueryVo">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="img_url" property="imgList" typeHandler="com.jumeirah.common.campusstore.ArrayJsonHandler"></result>
</resultMap>
<select id="getBusinessPlainPageListForApp" parameterType="com.jumeirah.common.param.BusinessPlainPageParam"
resultType="com.jumeirah.common.vo.BusinessPlainQueryForAppVo">
resultMap="pageListMapForApp">
select
<include refid="Base_Column_ListForApp"/>,bp.image_list_height,bp.image_list_width,m.`head` AS mcHead
<include refid="Base_Column_ListForApp"/>,
m.`head` AS mcHead
from business_plain bp
INNER JOIN merchant m ON bp.mc_id=m.id
where bp.business_type=#{param.type}
AND m.state=1 and m.audit_register_status=1
where bp.business_type = #{param.type}
AND m.state = 1
and m.audit_register_status = 1
</select>
<resultMap id="pageListMapForApp" type="com.jumeirah.common.vo.BusinessPlainQueryForAppVo">
<result column="img_url" property="imgList" typeHandler="com.jumeirah.common.campusstore.ArrayJsonHandler"></result>
</resultMap>
</mapper>
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