mirror of
https://github.com/chillzhuang/SpringBlade.git
synced 2024-11-14 22:49:31 +08:00
🎉 2.0.0.RELEASE
This commit is contained in:
parent
13bd7e1fe0
commit
25d7988c24
@ -1,123 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.demo.controller;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.AllArgsConstructor;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.modules.system.service.IDictService;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.demo.entity.Blog;
|
||||
import org.springblade.demo.vo.BlogVO;
|
||||
import org.springblade.demo.wrapper.BlogWrapper;
|
||||
import org.springblade.demo.service.IBlogService;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2019-02-13
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/blog")
|
||||
@Api(value = "", tags = "接口")
|
||||
public class BlogController extends BladeController {
|
||||
|
||||
private IBlogService blogService;
|
||||
|
||||
private IDictService dictService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperation(value = "详情", notes = "传入blog", position = 1)
|
||||
public R<BlogVO> detail(Blog blog) {
|
||||
Blog detail = blogService.getOne(Condition.getQueryWrapper(blog));
|
||||
BlogWrapper blogWrapper = new BlogWrapper(dictService);
|
||||
return R.data(blogWrapper.entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "分页", notes = "传入blog", position = 2)
|
||||
public R<IPage<BlogVO>> list(Blog blog, Query query) {
|
||||
IPage<Blog> pages = blogService.page(Condition.getPage(query), Condition.getQueryWrapper(blog));
|
||||
BlogWrapper blogWrapper = new BlogWrapper(dictService);
|
||||
return R.data(blogWrapper.pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperation(value = "分页", notes = "传入blog", position = 3)
|
||||
public R<IPage<BlogVO>> page(BlogVO blog, Query query) {
|
||||
IPage<BlogVO> pages = blogService.selectBlogPage(Condition.getPage(query), blog);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperation(value = "新增", notes = "传入blog", position = 4)
|
||||
public R save(@Valid @RequestBody Blog blog) {
|
||||
return R.status(blogService.save(blog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "修改", notes = "传入blog", position = 5)
|
||||
public R update(@Valid @RequestBody Blog blog) {
|
||||
return R.status(blogService.updateById(blog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperation(value = "新增或修改", notes = "传入blog", position = 6)
|
||||
public R submit(@Valid @RequestBody Blog blog) {
|
||||
return R.status(blogService.saveOrUpdate(blog));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperation(value = "物理删除", notes = "传入ids", position = 7)
|
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(blogService.removeByIds(Func.toIntList(ids)));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.demo.dto;
|
||||
|
||||
import org.springblade.demo.entity.Blog;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 数据传输对象实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2019-02-13
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BlogDTO extends Blog {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.demo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2019-02-13
|
||||
*/
|
||||
@Data
|
||||
@TableName("blade_blog")
|
||||
@ApiModel(value = "Blog对象", description = "Blog对象")
|
||||
public class Blog implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private String blogTitle;
|
||||
|
||||
private String blogContent;
|
||||
|
||||
private LocalDateTime blogDate;
|
||||
|
||||
private Integer isDeleted;
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.demo.mapper;
|
||||
|
||||
import org.springblade.demo.entity.Blog;
|
||||
import org.springblade.demo.vo.BlogVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2019-02-13
|
||||
*/
|
||||
public interface BlogMapper extends BaseMapper<Blog> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page
|
||||
* @param blog
|
||||
* @return
|
||||
*/
|
||||
List<BlogVO> selectBlogPage(IPage page, BlogVO blog);
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?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="org.springblade.demo.mapper.BlogMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="blogResultMap" type="org.springblade.demo.entity.Blog">
|
||||
<id column="id" property="id"/>
|
||||
<result column="blog_title" property="blogTitle"/>
|
||||
<result column="blog_content" property="blogContent"/>
|
||||
<result column="blog_date" property="blogDate"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="baseColumnList">
|
||||
select
|
||||
id, blog_title, blog_content, blog_date, is_deleted
|
||||
</sql>
|
||||
|
||||
<select id="selectBlogPage" resultMap="blogResultMap">
|
||||
select * from blade_blog where is_deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -1,40 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.demo.service;
|
||||
|
||||
import org.springblade.demo.entity.Blog;
|
||||
import org.springblade.demo.vo.BlogVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
/**
|
||||
* 服务类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2019-02-13
|
||||
*/
|
||||
public interface IBlogService extends IService<Blog> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page
|
||||
* @param blog
|
||||
* @return
|
||||
*/
|
||||
IPage<BlogVO> selectBlogPage(IPage<BlogVO> page, BlogVO blog);
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.demo.service.impl;
|
||||
|
||||
import org.springblade.demo.entity.Blog;
|
||||
import org.springblade.demo.vo.BlogVO;
|
||||
import org.springblade.demo.mapper.BlogMapper;
|
||||
import org.springblade.demo.service.IBlogService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
/**
|
||||
* 服务实现类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2019-02-13
|
||||
*/
|
||||
@Service
|
||||
public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements IBlogService {
|
||||
|
||||
@Override
|
||||
public IPage<BlogVO> selectBlogPage(IPage<BlogVO> page, BlogVO blog) {
|
||||
return page.setRecords(baseMapper.selectBlogPage(page, blog));
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.demo.vo;
|
||||
|
||||
import org.springblade.demo.entity.Blog;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
* 视图实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2019-02-13
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "BlogVO对象", description = "BlogVO对象")
|
||||
public class BlogVO extends Blog {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.demo.wrapper;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.mp.support.BaseEntityWrapper;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.modules.system.service.IDictService;
|
||||
import org.springblade.demo.entity.Blog;
|
||||
import org.springblade.demo.vo.BlogVO;
|
||||
|
||||
/**
|
||||
* 包装类,返回视图层所需的字段
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2019-02-13
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public class BlogWrapper extends BaseEntityWrapper<Blog, BlogVO> {
|
||||
|
||||
private IDictService dictService;
|
||||
|
||||
@Override
|
||||
public BlogVO entityVO(Blog blog) {
|
||||
BlogVO blogVO = BeanUtil.copy(blog, BlogVO.class);
|
||||
|
||||
/*R<String> dict = dictService.getValue("blog" , blogVO.getCategory());
|
||||
if (dict.isSuccess()) {
|
||||
String categoryName = dict.getData();
|
||||
blogVO.setCategoryName(categoryName);
|
||||
}*/
|
||||
|
||||
return blogVO;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user