Mushroom blog is a very excellent blog open source blog platform, the address is: gitee.com/moxi159753/…

I’m a erupt writer, and for promotional reasons, I rewrote the back end of the Mushroom blog in just one hour!

Techniques: Spring Boot, Erupt, JPA

First initialization program, see step: www.yuque.com/yuepeng/eru…

Now start Coding ~

The blog category

To Erupt violently (name = "Erupt class ", desc = "sort")
@Table(name = "blog_category")
@Entity
public class BlogCategory extends BaseModel {

    @eruptfield (views = @view (title = "name "), edit = @edit (title =" name ", notNull = true, search = @search (vague = true))
    private String name;

    @eruptfield (views = @view (title = "limit "), edit = @edit (title =" limit ", notNull = true)
    private Integer sort;

    @eruptfield (views = @view (title = "limit "), edit = @edit (title =" Limit ", notNull = true)
    private Boolean isShow;

    @eruptfield (views = @view (title = "limit "), edit = @edit (title =" limit ", type = editType.textarea)
    private String remark;

}
Copy the code

rendering

Label management

To emerge violently from restraint (name = "Erupt ", desc = "sort")
@Table(name = "blog_tag")
@Entity
public class BlogTag extends BaseModel {


    @eruptfield (views = @view (title = "limit name "), edit = @edit (title =" limit name ", notNull = true, search = @Search(vague = true), inputType = @InputType(fullSpan = true)) )
    private String name;

    @eruptfield (views = @view (title = "sort "), edit = @edit (title =" sort ", notNull = true)
    private Integer sort;

}

Copy the code

Results show

The blog management

@erupt (name = "blogmanagement ", linkTree = @linktree (field = "blogCategory"))
@Table(name = "blog_article")
@Entity
public class Blog extends HyperModel {

    @eruptfield (views = {@view (title = "cap ", type = viewtype.image)}, edit = @edit (title =" cap ", notNull = true, type = EditType.ATTACHMENT, attachmentType = @AttachmentType(type = AttachmentType.Type.IMAGE)) )
    private String image;

    @eruptfield (views = @view (title = "title "), edit = @edit (title =" title "), notNull = true, search = @search (vague = true), inputType = @InputType(fullSpan = true)) )
    private String name;

    @eruptfield (views = @view (title = "limit ", type = viewtype.html), edit = @edit (title =" limit ", notNull = true, search = @Search(vague = true), inputType = @InputType(fullSpan = true)) )
    private String intro;

    @eruptfield (views = @view (title = "limit original "), edit = @edit (title =" limit original ", notNull = true)
    private Boolean original;

    @eruptfield (views = @view (title = "limit "), edit = @edit (title =" limit ", notNull = true)
    private Boolean publish;

    @eruptfield (views = @view (title = "erupt grade "), edit = @edit (title =" erupt grade "), notNull = true, type = editType. CHOICE, ChoiceType = @choiceType (vl = {@vl (value = "0", label = "normal "), @vl (value = "10", label = "1 "), @vl (value = "20", Label = "secondary recommendation"), @ VL (value = "30" label = "triple recommended")})))
    private Integer recommendedLevel;

    @ManyToOne
    @eruptfield (views = @view (title = "class ", column = "name"), edit = @edit (title =" class ", notNull = true, type = EditType.REFERENCE_TREE) )
    private BlogCategory blogCategory;

    @eruptfield (views = @view (title = "limit ", The template = "value && value. The replace (/ \ \ | / g," < span class = \ "text - red \" > | < / span > ') "), edit = @ edit (title = "label", notNull = true, type = EditType.TAGS, tagsType = @TagsType(fetchHandler = BlogTagHandler.class) ) )
    private String tag;

    @Lob // Article content is defined as a large text type
    @eruptfield (views = @view (title = "contents ", type = viewtype.html), edit = @edit (title =" contents ", notNull = true, type = EditType.HTML_EDITOR) )
    private String content;

    @eruptfield (views = @view (title = "notes "), edit = @edit (title =" notes ", type = editType.textarea)
    private String remark;

    @eruptfield (views = @view (title = "limit "))
    private Integer clickNum = 0; // Write to the database through the front-end interface!

}
Copy the code
@Component
public class BlogTagHandler implements TagsFetchHandler {

    @Autowired
    private EruptDao eruptDao;

    @Override
    public List<String> fetchTags(String[] params) {
        List<String> result = new ArrayList<>();
        List<Map<String, Object>> map = eruptDao.queryMapList(BlogTag.class, null.null."name");
        for (Map<String, Object> objectMap : map) {
            result.add(objectMap.get("name").toString());
        }
        returnresult; }}Copy the code

link

To Erupt violently (name = "Erupt ", orderBy = "sort")
@Table(name = "blog_link")
@Entity
public class FriendlyLink extends BaseModel {

    @eruptfield (views = @view (title = "upLIMIT "), edit = @edit (title =" uplimit ", notNull = true)
    private String name;

    @eruptfield (views = @view (title = "upLIMIT "), edit = @edit (title =" uplimit ", notNull = true)
    private String remark;

    @eruptfield (views = @view (title = "foo URL", type = viewtype.link_dialog), edit = @edit (title =" foo URL", notNull = true) )
    private String url;

    @eruptfield (views = @view (limit = "limit "), edit = @edit (limit =" limit "))
    private String email;

    @eruptfield (views = @view (title = "sort "), edit = @edit (title =" sort "))
    private Integer sort;

}
Copy the code

Once developed, paste this code and you may be able to rewrite the mushroom blog backend in five minutes!

Next, show the background functions of Mushroom blog:

The article managementClassification managementLabel managementlink

Have to admit that the color match is not as good as mushroom blog, but it has the advantage in efficiency, if you want to modify the blog field, only a simple modification of the configuration can be completed!!

Mushroom blog demo backend address: demoadmin.moguit.cn/

Rewritten post mushroom blog backend address: www.erupt.xyz/demo/#/buil…

Erupt Frame address: www.erupt.xyz