Merge remote-tracking branch 'origin/preview' into preview
commit
925705caaa
|
@ -1,13 +1,22 @@
|
||||||
package com.mcwl.web.controller.communityCenter;
|
package com.mcwl.web.controller.communityCenter;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
|
import com.mcwl.common.core.page.PageDomain;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.communityCenter.domain.Community;
|
import com.mcwl.communityCenter.domain.Community;
|
||||||
|
import com.mcwl.communityCenter.domain.dto.CommunityDto;
|
||||||
|
import com.mcwl.communityCenter.domain.vo.CommunityVo;
|
||||||
import com.mcwl.communityCenter.service.CommunityService;
|
import com.mcwl.communityCenter.service.CommunityService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,46 +33,44 @@ public class CommunityController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社区列表
|
* 社区列表
|
||||||
|
*
|
||||||
* @return 社区列表
|
* @return 社区列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "社区列表")
|
@ApiOperation(value = "社区列表")
|
||||||
@GetMapping("list")
|
@PostMapping("list")
|
||||||
public List<Community> getCommunityList(){
|
public TableDataInfo getCommunityList(@RequestBody PageDomain pageDomain) {
|
||||||
return communityService.list();
|
return communityService.listByPage(pageDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加社区
|
* 添加社区
|
||||||
* @param community 社区
|
*
|
||||||
|
* @param communityDto 社区参数
|
||||||
* @return 添加结果
|
* @return 添加结果
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "添加社区")
|
@ApiOperation(value = "添加社区")
|
||||||
@PostMapping("add")
|
@PostMapping("add")
|
||||||
public boolean addCommunity(@RequestBody Community community){
|
public AjaxResult addCommunity(@RequestBody CommunityDto communityDto) {
|
||||||
return communityService.save(community);
|
Community community = new Community();
|
||||||
|
BeanUtil.copyProperties(communityDto, community);
|
||||||
|
communityService.save(community);
|
||||||
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除社区
|
* 删除社区
|
||||||
|
*
|
||||||
* @param id 社区id
|
* @param id 社区id
|
||||||
* @return 删除结果
|
* @return 删除结果
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "删除社区")
|
@ApiOperation(value = "删除社区")
|
||||||
@PostMapping("delete")
|
@PostMapping("delete")
|
||||||
public boolean deleteCommunity(Long id){
|
public AjaxResult deleteCommunity(@NotNull(message = "id不能为空")
|
||||||
return communityService.removeById(id);
|
@ApiParam(value = "id", required = true)
|
||||||
}
|
Long id) {
|
||||||
|
communityService.removeById(id);
|
||||||
/**
|
return AjaxResult.success();
|
||||||
* 修改社区
|
|
||||||
* @param community 社区
|
|
||||||
* @return 修改结果
|
|
||||||
*/
|
|
||||||
@ApiOperation(value = "修改社区")
|
|
||||||
@PostMapping("update")
|
|
||||||
public boolean updateCommunity(@RequestBody Community community){
|
|
||||||
return communityService.updateById(community);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.mcwl.common.core.page;
|
package com.mcwl.common.core.page;
|
||||||
|
|
||||||
import com.mcwl.common.utils.StringUtils;
|
import com.mcwl.common.utils.StringUtils;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ -9,23 +11,29 @@ import javax.validation.constraints.NotNull;
|
||||||
*
|
*
|
||||||
* @author mcwl
|
* @author mcwl
|
||||||
*/
|
*/
|
||||||
|
@ApiModel("分页数据")
|
||||||
public class PageDomain
|
public class PageDomain
|
||||||
{
|
{
|
||||||
/** 当前记录起始索引 */
|
/** 当前记录起始索引 */
|
||||||
@NotNull(message = "当前记录起始索引不能为空")
|
@NotNull(message = "当前记录起始索引不能为空")
|
||||||
|
@ApiModelProperty(value = "当前记录起始索引",required = true)
|
||||||
private Integer pageNum;
|
private Integer pageNum;
|
||||||
|
|
||||||
/** 每页显示记录数 */
|
/** 每页显示记录数 */
|
||||||
@NotNull(message = "每页显示记录数不能为空")
|
@NotNull(message = "每页显示记录数不能为空")
|
||||||
|
@ApiModelProperty(value = "每页显示记录数",required = true)
|
||||||
private Integer pageSize;
|
private Integer pageSize;
|
||||||
|
|
||||||
/** 排序列 */
|
/** 排序列 */
|
||||||
|
@ApiModelProperty(value = "排序列")
|
||||||
private String orderByColumn;
|
private String orderByColumn;
|
||||||
|
|
||||||
/** 排序的方向desc或者asc */
|
/** 排序的方向desc或者asc */
|
||||||
|
@ApiModelProperty(value = "排序的方向desc或者asc", example = "asc")
|
||||||
private String isAsc = "asc";
|
private String isAsc = "asc";
|
||||||
|
|
||||||
/** 分页参数合理化 */
|
/** 分页参数合理化 */
|
||||||
|
@ApiModelProperty(hidden = true)
|
||||||
private Boolean reasonable = true;
|
private Boolean reasonable = true;
|
||||||
|
|
||||||
public String getOrderBy()
|
public String getOrderBy()
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package com.mcwl.common.core.page;
|
package com.mcwl.common.core.page;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -8,20 +11,25 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author mcwl
|
* @author mcwl
|
||||||
*/
|
*/
|
||||||
|
@ApiModel("表格分页数据对象")
|
||||||
public class TableDataInfo implements Serializable
|
public class TableDataInfo implements Serializable
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 总记录数 */
|
/** 总记录数 */
|
||||||
|
@ApiModelProperty(value = "总记录数")
|
||||||
private long total;
|
private long total;
|
||||||
|
|
||||||
/** 列表数据 */
|
/** 列表数据 */
|
||||||
|
@ApiModelProperty(value = "列表数据")
|
||||||
private List<?> rows;
|
private List<?> rows;
|
||||||
|
|
||||||
/** 消息状态码 */
|
/** 消息状态码 */
|
||||||
|
@ApiModelProperty(value = "消息状态码")
|
||||||
private int code;
|
private int code;
|
||||||
|
|
||||||
/** 消息内容 */
|
/** 消息内容 */
|
||||||
|
@ApiModelProperty(value = "消息内容")
|
||||||
private String msg;
|
private String msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.mcwl.communityCenter.domain.dto;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社区请求参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("cc_community")
|
||||||
|
@ApiModel(value = "社区请求参数")
|
||||||
|
public class CommunityDto {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社区名称
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "社区名称", required = true)
|
||||||
|
@NotBlank(message = "社区名称不能为空")
|
||||||
|
private String communityName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社区类型
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "社区类型", required = true)
|
||||||
|
@NotNull(message = "社区类型不能为空")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 价格
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "价格", required = true)
|
||||||
|
@NotNull(message = "价格不能为空")
|
||||||
|
private Double price;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 有效期类型
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "有效期类型", required = true)
|
||||||
|
@NotNull(message = "有效期类型不能为空")
|
||||||
|
private Integer validityType;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.mcwl.communityCenter.domain.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社区请求参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("cc_community")
|
||||||
|
@ApiModel(value = "社区返回数据")
|
||||||
|
public class CommunityVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社区id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "社区id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社区名称
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "社区名称")
|
||||||
|
private String communityName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,10 @@
|
||||||
package com.mcwl.communityCenter.service;
|
package com.mcwl.communityCenter.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.common.core.page.PageDomain;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.communityCenter.domain.Community;
|
import com.mcwl.communityCenter.domain.Community;
|
||||||
|
|
||||||
public interface CommunityService extends IService<Community> {
|
public interface CommunityService extends IService<Community> {
|
||||||
|
TableDataInfo listByPage(PageDomain pageDomain);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,60 @@
|
||||||
package com.mcwl.communityCenter.service.impl;
|
package com.mcwl.communityCenter.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.constant.HttpStatus;
|
||||||
|
import com.mcwl.common.core.page.PageDomain;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
|
import com.mcwl.common.utils.HttpUtil;
|
||||||
|
import com.mcwl.common.utils.StringUtils;
|
||||||
import com.mcwl.communityCenter.domain.Community;
|
import com.mcwl.communityCenter.domain.Community;
|
||||||
|
import com.mcwl.communityCenter.domain.vo.CommunityVo;
|
||||||
import com.mcwl.communityCenter.mapper.CommunityMapper;
|
import com.mcwl.communityCenter.mapper.CommunityMapper;
|
||||||
import com.mcwl.communityCenter.service.CommunityService;
|
import com.mcwl.communityCenter.service.CommunityService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community> implements CommunityService {
|
public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community> implements CommunityService {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableDataInfo listByPage(PageDomain pageDomain) {
|
||||||
|
|
||||||
|
Page<Community> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
|
||||||
|
|
||||||
|
|
||||||
|
boolean isAsc = Objects.equals(pageDomain.getIsAsc(), "asc");
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(pageDomain.getOrderByColumn())) {
|
||||||
|
pageDomain.setOrderByColumn("create_time");
|
||||||
|
}
|
||||||
|
OrderItem orderItem = new OrderItem(pageDomain.getOrderByColumn(), isAsc);
|
||||||
|
page.addOrder(orderItem);
|
||||||
|
|
||||||
|
baseMapper.selectPage(page, null);
|
||||||
|
|
||||||
|
List<Community> communityList = page.getRecords();
|
||||||
|
List<CommunityVo> communityVoList = new ArrayList<>();
|
||||||
|
for (Community community : communityList) {
|
||||||
|
CommunityVo communityVo = new CommunityVo();
|
||||||
|
BeanUtil.copyProperties(community, communityVo);
|
||||||
|
communityVoList.add(communityVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||||
|
tableDataInfo.setRows(communityVoList);
|
||||||
|
tableDataInfo.setTotal(page.getTotal());
|
||||||
|
tableDataInfo.setCode(HttpStatus.SUCCESS);
|
||||||
|
tableDataInfo.setMsg("查询成功");
|
||||||
|
|
||||||
|
return tableDataInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue