WebsiteMapper.java 1.26 KB
package com.uccc.admin.mapper;

import com.uccc.admin.domain.WebsiteConfig;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by bert on 2021-10-07 00:57
 */

public interface WebsiteMapper {
    static final String TABLE_NAME = "website_config";


    @Select({
            "<script>",
            "select * from " + TABLE_NAME + " order by id asc",
            "</script>",
    })
    List<WebsiteConfig> selectWebsiteConfigs();

    @Update({
            "<script>",
            "UPDATE " + TABLE_NAME + " SET name = #{websiteConfig.name}",
            "<when test='websiteConfig.value!=null'>",
            ",value = #{websiteConfig.value}" ,
            "</when>",
            "<when test='websiteConfig.title!=null'>",
            ",title = #{websiteConfig.title}" ,
            "</when>",
            "where id = #{websiteConfig.id}",
            "</script>",
    })
    int updateWebsite(@Param("websiteConfig") WebsiteConfig websiteConfig);

    @Select({
            "<script>",
            "select value from " + TABLE_NAME,
            "where name = #{name}",
            "</script>"
    })
    String selectConfigValueByName(@Param("name") String name);
}