All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.languagetool.server.DictMapper.xml Maven / Gradle / Ivy

There is a newer version: 6.5
Show newest version
<?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.languagetool.server.UserDictMapper">
    <select id="getUserIdByApiKey" resultType="_long">
        <!-- api_key is similar to using the password, but we don't need to care about Laravel's password hashing: -->
        SELECT id FROM users WHERE email = #{username} AND api_key = #{apiKey}
    </select>
    <select id="selectWordList" resultType="org.languagetool.server.UserDictEntry">
        SELECT id, ignore_word FROM ignore_words WHERE user_id = #{userId} ORDER BY id
    </select>
    <select id="selectWord" resultType="org.languagetool.server.UserDictEntry">
        SELECT id, ignore_word FROM ignore_words WHERE user_id = #{userId} AND ignore_word = #{word}
    </select>
    <insert id="addWord">
        INSERT INTO ignore_words (user_id, ignore_word, created_at, updated_at) VALUES (#{userId}, #{word}, #{created_at}, #{updated_at})
    </insert>
    <insert id="deleteWord">
        DELETE FROM ignore_words WHERE user_id = #{userId} AND ignore_word = #{word}
    </insert>
    
    <!-- the following items are for unit tests only: -->
    <insert id="createUserTable">
        CREATE TABLE IF NOT EXISTS users (
          id bigint GENERATED BY DEFAULT AS IDENTITY(START WITH 1, INCREMENT BY 1) PRIMARY KEY,
          email varchar(191) NOT NULL,
          password varchar(191) NOT NULL,
          api_key varchar(16) DEFAULT NULL
        )
    </insert>
    <insert id="createIgnoreWordTable">
        CREATE TABLE IF NOT EXISTS ignore_words (
          id bigint GENERATED BY DEFAULT AS IDENTITY(START WITH 1, INCREMENT BY 1) PRIMARY KEY,
          user_id int NOT NULL,
          ignore_word varchar(191) NOT NULL,
          created_at timestamp NOT NULL,
          updated_at timestamp NOT NULL
        )
    </insert>
    <insert id="createTestUser1">
        INSERT INTO users (id, email, password, api_key) VALUES (1, '[email protected]', 'pwd', 'foo');
    </insert>
    <insert id="createTestUser2">
        INSERT INTO users (id, email, password, api_key) VALUES (2, '[email protected]', 'pwd', 'foo-two');
    </insert>
    <delete id="deleteUsersTable">
        DROP TABLE IF EXISTS users
    </delete>
    <delete id="deleteIgnoreWordsTable">
        DROP TABLE IF EXISTS ignore_words
    </delete>
</mapper>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy