Commit a570531e by giaogiao

修改包机介绍

parent bebd3a9d
package com.jumeirah.api.merchant.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jumeirah.common.entity.CharterIntroduction;
import com.jumeirah.common.param.CharterIntroductionAddParam;
import com.jumeirah.common.param.CharterIntroductionUpdateParam;
import com.jumeirah.common.service.CharterIntroductionService;
import com.jumeirah.common.vo.CharterIntroductionQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
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.factory.annotation.Autowired;
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.List;
/**
* 包机介绍 控制器
*
* @author giao
* @since 2020-10-14
*/
@Slf4j
@RestController
@RequestMapping("/merchant/charterIntroduction")
@Api(value = "包机介绍API", tags = {"包机介绍"})
public class CharterIntroductionForMerController extends BaseController {
@Autowired
private CharterIntroductionService charterIntroductionService;
/**
* 添加包机介绍
*/
@PostMapping("/add")
@OperationLog(name = "添加包机介绍", type = OperationLogType.ADD)
@ApiOperation(value = "添加包机介绍")
public ApiResult<Boolean> addCharterIntroduction(@Validated(Add.class) @RequestBody CharterIntroductionAddParam charterIntroductionAddParam) throws Exception {
boolean flag = charterIntroductionService.saveCharterIntroduction(charterIntroductionAddParam);
return ApiResult.result(flag);
}
/**
* 修改包机介绍
*/
@PostMapping("/update")
@OperationLog(name = "修改包机介绍", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改包机介绍")
public ApiResult<Boolean> updateCharterIntroduction(@Validated(Update.class) @RequestBody CharterIntroductionUpdateParam charterIntroductionUpdateParam) throws Exception {
boolean flag = charterIntroductionService.updateCharterIntroduction(charterIntroductionUpdateParam);
return ApiResult.result(flag);
}
/**
* 删除包机介绍
*/
@PostMapping("/delete/{id}")
@OperationLog(name = "删除包机介绍", type = OperationLogType.DELETE)
@ApiOperation(value = "删除包机介绍")
public ApiResult<Boolean> deleteCharterIntroduction(@PathVariable("id") Long id) throws Exception {
boolean flag = charterIntroductionService.deleteCharterIntroduction(id);
return ApiResult.result(flag);
}
/**
* 获取包机介绍详情
*/
@GetMapping("/info/{id}")
@OperationLog(name = "包机介绍详情", type = OperationLogType.INFO)
@ApiOperation(value = "包机介绍详情")
public ApiResult<CharterIntroductionQueryVo> getCharterIntroduction(@PathVariable("id") Long id) throws Exception {
CharterIntroductionQueryVo charterIntroductionQueryVo = charterIntroductionService.getCharterIntroductionById(id);
return ApiResult.ok(charterIntroductionQueryVo);
}
/**
* 包机介绍分页列表
*/
@PostMapping("/getPageList")
@OperationLog(name = "包机介绍分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "包机介绍分页列表")
public ApiResult<List<CharterIntroduction>> getCharterIntroductionPageList() throws Exception {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
List<CharterIntroduction> list = charterIntroductionService.list(
new QueryWrapper<CharterIntroduction>().lambda().eq(CharterIntroduction::getMcId, jwtToken.getMcId()));
return ApiResult.ok(list);
}
}
......@@ -56,9 +56,4 @@ public class CharterIntroduction extends BaseEntity {
@ApiModelProperty("类型 1私人;2团体;3货运;4医疗")
private Integer type;
@ApiModelProperty("图片高")
private Integer imageListHeight;
@ApiModelProperty("图片宽")
private Integer imageListWidth;
}
package com.jumeirah.common.param;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 包机介绍
*
* @author giao
* @since 2020-10-14
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "CharterIntroductionAddParam")
public class CharterIntroductionAddParam extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "包机图片url, json字符串", example = "[{\"url\":\"https://picsum.photos/100/200/\",\"height\":200,\"width\":200},{\"url\":\"https://picsum.photos/100/200/\",\"height\":200,\"width\":200},{\"url\":\"https://picsum.photos/100/200/\",\"height\":200,\"width\":200}]")
private String imgUrl;
@ApiModelProperty(value = "包机文字")
private String text;
@ApiModelProperty("包机标题")
private String title;
@ApiModelProperty("类型 1私人;2团体;3货运;4医疗")
private Integer type;
}
package com.jumeirah.common.param;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 包机介绍
*
* @author giao
* @since 2020-10-14
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "CharterIntroductionUpdateParam")
public class CharterIntroductionUpdateParam extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "包机图片url, json字符串", example = "[{\"url\":\"https://picsum.photos/100/200/\",\"height\":200,\"width\":200},{\"url\":\"https://picsum.photos/100/200/\",\"height\":200,\"width\":200},{\"url\":\"https://picsum.photos/100/200/\",\"height\":200,\"width\":200}]")
private String imgUrl;
@ApiModelProperty(value = "包机文字")
private String text;
@ApiModelProperty("包机标题")
private String title;
@ApiModelProperty("类型 1私人;2团体;3货运;4医疗")
private Integer type;
}
package com.jumeirah.common.service;
import com.jumeirah.common.entity.CharterIntroduction;
import com.jumeirah.common.param.CharterIntroductionAddParam;
import com.jumeirah.common.param.CharterIntroductionPageParam;
import com.jumeirah.common.param.CharterIntroductionUpdateParam;
import com.jumeirah.common.vo.CharterIntroductionQueryForAppVo;
import com.jumeirah.common.vo.CharterIntroductionQueryVo;
import io.geekidea.springbootplus.framework.common.service.BaseService;
......@@ -18,20 +20,19 @@ public interface CharterIntroductionService extends BaseService<CharterIntroduct
/**
* 保存
*
* @param charterIntroduction
* @return
* @throws Exception
*/
boolean saveCharterIntroduction(CharterIntroduction charterIntroduction) throws Exception;
boolean saveCharterIntroduction(CharterIntroductionAddParam charterIntroductionAddParam) throws Exception;
/**
* 修改
*
* @param charterIntroduction
* @param
* @return
* @throws Exception
*/
boolean updateCharterIntroduction(CharterIntroduction charterIntroduction) throws Exception;
boolean updateCharterIntroduction(CharterIntroductionUpdateParam charterIntroductionUpdateParam) throws Exception;
/**
* 删除
......
......@@ -3,20 +3,31 @@ package com.jumeirah.common.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jumeirah.common.entity.CharterIntroduction;
import com.jumeirah.common.mapper.CharterIntroductionMapper;
import com.jumeirah.common.param.CharterIntroductionAddParam;
import com.jumeirah.common.param.CharterIntroductionPageParam;
import com.jumeirah.common.param.CharterIntroductionUpdateParam;
import com.jumeirah.common.service.CharterIntroductionService;
import com.jumeirah.common.vo.CharterIntroductionImgForAppVo;
import com.jumeirah.common.vo.CharterIntroductionQueryForAppVo;
import com.jumeirah.common.vo.CharterIntroductionQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* 包机介绍 服务实现类
*
......@@ -32,13 +43,20 @@ public class CharterIntroductionServiceImpl extends BaseServiceImpl<CharterIntro
@Transactional(rollbackFor = Exception.class)
@Override
public boolean saveCharterIntroduction(CharterIntroduction charterIntroduction) throws Exception {
public boolean saveCharterIntroduction(CharterIntroductionAddParam charterIntroductionAddParam) throws Exception {
CharterIntroduction charterIntroduction = new CharterIntroduction();
BeanUtils.copyProperties(charterIntroductionAddParam, charterIntroduction);
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
charterIntroduction.setMcId(jwtToken.getMcId());
return super.save(charterIntroduction);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateCharterIntroduction(CharterIntroduction charterIntroduction) throws Exception {
public boolean updateCharterIntroduction(CharterIntroductionUpdateParam charterIntroductionUpdateParam) throws Exception {
CharterIntroduction charterIntroduction = new CharterIntroduction();
BeanUtils.copyProperties(charterIntroductionUpdateParam, charterIntroduction);
return super.updateById(charterIntroduction);
}
......@@ -64,6 +82,24 @@ public class CharterIntroductionServiceImpl extends BaseServiceImpl<CharterIntro
public Paging<CharterIntroductionQueryForAppVo> getCharterIntroductionForAppPageList(CharterIntroductionPageParam charterIntroductionPageParam) throws Exception {
Page<CharterIntroductionQueryForAppVo> page = new PageInfo<>(charterIntroductionPageParam, OrderItem.desc("ci.create_time"));
IPage<CharterIntroductionQueryForAppVo> iPage = charterIntroductionMapper.getCharterIntroductionForAppPageList(page, charterIntroductionPageParam);
List<CharterIntroductionQueryForAppVo> records = iPage.getRecords();
List<CharterIntroductionQueryForAppVo> newRecords = new ArrayList<CharterIntroductionQueryForAppVo>();
for (CharterIntroductionQueryForAppVo charterIntroductionQueryForAppVo : records) {
ObjectMapper objectMapper = new ObjectMapper();
JavaType javaType = objectMapper.getTypeFactory().constructCollectionType(ArrayList.class, CharterIntroductionImgForAppVo.class);
List<CharterIntroductionImgForAppVo> lst = (List<CharterIntroductionImgForAppVo>) objectMapper.readValue(charterIntroductionQueryForAppVo.getImgUrl(), javaType);
charterIntroductionQueryForAppVo.setImgList(lst);
charterIntroductionQueryForAppVo.setImgUrl(null);
newRecords.add(charterIntroductionQueryForAppVo);
}
iPage.setRecords(newRecords);
return new Paging<>(iPage);
}
......
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;
/**
* <pre>
* 包机介绍 查询结果对象
* </pre>
*
* @author giao
* @date 2020-10-14
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "CharterIntroductionImgForAppVo")
public class CharterIntroductionImgForAppVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("url")
private String url;
@ApiModelProperty("高")
private Integer height;
@ApiModelProperty("宽")
private Integer width;
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* <pre>
......@@ -25,7 +26,10 @@ public class CharterIntroductionQueryForAppVo implements Serializable {
private String mcName;
@ApiModelProperty("商家头像")
private String mcHead;
@ApiModelProperty("包机图片url")
@ApiModelProperty("图片")
private List<CharterIntroductionImgForAppVo> imgList;
private String imgUrl;
@ApiModelProperty("包机文字")
......@@ -34,9 +38,4 @@ public class CharterIntroductionQueryForAppVo implements Serializable {
@ApiModelProperty("包机标题")
private String title;
@ApiModelProperty("图片高")
private Integer imageListHeight;
@ApiModelProperty("图片宽")
private Integer imageListWidth;
}
\ No newline at end of file
......@@ -28,10 +28,10 @@ public class CharterIntroductionQueryVo implements Serializable {
@ApiModelProperty("商家ID")
private Long mcId;
@ApiModelProperty("图片高")
private Integer imageListHeight;
@ApiModelProperty("图片宽")
private Integer imageListWidth;
// @ApiModelProperty("图片高")
// private Integer imageListHeight;
// @ApiModelProperty("图片宽")
// private Integer imageListWidth;
@ApiModelProperty("状态,0-正常,1-取消,99-删除")
private Integer status;
......
......@@ -4,10 +4,10 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, mc_id, status, create_time, update_time,type,text,img_url,image_list_height,image_list_width
id, mc_id, status, create_time,update_time,type,text,img_url
</sql>
<sql id="Base_Column_ListForApp">
title,text,img_url,ci.image_list_height,ci.image_list_width,m.head AS mcHead,m.name AS mcName
title,text,img_url,m.head AS mcHead,m.name AS mcName
</sql>
<select id="getCharterIntroductionById" resultType="com.jumeirah.common.vo.CharterIntroductionQueryVo">
......
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