<?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="com.microservices.wiki.mapper.projects.ProjectsMapper">
    <resultMap id="BaseResultMap" type="com.microservices.wiki.domain.projects.Projects">
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="description" property="description" jdbcType="LONGVARCHAR" />
    <result column="homepage" property="homepage" jdbcType="VARCHAR" />
    <result column="is_public" property="isPublic" jdbcType="BIT" />
    <result column="parent_id" property="parentId" jdbcType="INTEGER" />
    <result column="created_on" property="createdOn" jdbcType="TIMESTAMP" />
    <result column="updated_on" property="updatedOn" jdbcType="TIMESTAMP" />
    <result column="identifier" property="identifier" jdbcType="VARCHAR" />
    <result column="status" property="status" jdbcType="INTEGER" />
    <result column="lft" property="lft" jdbcType="INTEGER" />
    <result column="rgt" property="rgt" jdbcType="INTEGER" />
    <result column="inherit_members" property="inheritMembers" jdbcType="BIT" />
    <result column="project_type" property="projectType" jdbcType="INTEGER" />
    <result column="hidden_repo" property="hiddenRepo" jdbcType="BIT" />
    <result column="attachmenttype" property="attachmenttype" jdbcType="INTEGER" />
    <result column="user_id" property="userId" jdbcType="INTEGER" />
    <result column="dts_test" property="dtsTest" jdbcType="INTEGER" />
    <result column="enterprise_name" property="enterpriseName" jdbcType="VARCHAR" />
    <result column="organization_id" property="organizationId" jdbcType="INTEGER" />
    <result column="project_new_type" property="projectNewType" jdbcType="INTEGER" />
    <result column="gpid" property="gpid" jdbcType="INTEGER" />
    <result column="forked_from_project_id" property="forkedFromProjectId" jdbcType="INTEGER" />
    <result column="forked_count" property="forkedCount" jdbcType="INTEGER" />
    <result column="publish_resource" property="publishResource" jdbcType="INTEGER" />
    <result column="visits" property="visits" jdbcType="INTEGER" />
    <result column="hot" property="hot" jdbcType="INTEGER" />
    <result column="invite_code" property="inviteCode" jdbcType="VARCHAR" />
    <result column="qrcode" property="qrcode" jdbcType="VARCHAR" />
    <result column="qrcode_expiretime" property="qrcodeExpiretime" jdbcType="INTEGER" />
    <result column="script" property="script" jdbcType="LONGVARCHAR" />
    <result column="training_status" property="trainingStatus" jdbcType="TINYINT" />
    <result column="rep_identifier" property="repIdentifier" jdbcType="VARCHAR" />
    <result column="project_category_id" property="projectCategoryId" jdbcType="INTEGER" />
    <result column="project_language_id" property="projectLanguageId" jdbcType="INTEGER" />
    <result column="license_id" property="licenseId" jdbcType="INTEGER" />
    <result column="ignore_id" property="ignoreId" jdbcType="INTEGER" />
    <result column="praises_count" property="praisesCount" jdbcType="INTEGER" />
    <result column="watchers_count" property="watchersCount" jdbcType="INTEGER" />
    <result column="issues_count" property="issuesCount" jdbcType="INTEGER" />
    <result column="pull_requests_count" property="pullRequestsCount" jdbcType="INTEGER" />
    <result column="language" property="language" jdbcType="VARCHAR" />
    <result column="versions_count" property="versionsCount" jdbcType="INTEGER" />
    <result column="issue_tags_count" property="issueTagsCount" jdbcType="INTEGER" />
    <result column="closed_issues_count" property="closedIssuesCount" jdbcType="INTEGER" />
    <result column="open_devops" property="openDevops" jdbcType="BIT" />
    <result column="gitea_webhook_id" property="giteaWebhookId" jdbcType="INTEGER" />
    <result column="open_devops_count" property="openDevopsCount" jdbcType="INTEGER" />
    <result column="recommend" property="recommend" jdbcType="BIT" />
    <result column="platform" property="platform" jdbcType="INTEGER" />
    <result column="order_index" property="orderIndex" jdbcType="INTEGER" />
  </resultMap>

  <sql id="Base_Column_List" >
    id, name, description, homepage, is_public, parent_id, created_on, updated_on, identifier, status,
    lft, rgt, inherit_members, project_type, hidden_repo, attachmenttype, user_id, dts_test, 
    enterprise_name, organization_id, project_new_type, gpid, forked_from_project_id, 
    forked_count, publish_resource, visits, hot, invite_code, qrcode, qrcode_expiretime, 
    script, training_status, rep_identifier, project_category_id, project_language_id, license_id,
    ignore_id, praises_count, watchers_count, issues_count, pull_requests_count, language, 
    versions_count, issue_tags_count, closed_issues_count, open_devops, gitea_webhook_id, 
    open_devops_count, recommend, platform, order_index
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from projects
    where id = #{id,jdbcType=INTEGER}
  </delete>
    <update id="updateByPrimaryKey" parameterType="com.microservices.wiki.domain.projects.Projects">
    update projects
    set name = #{name,jdbcType=VARCHAR},
      homepage = #{homepage,jdbcType=VARCHAR},
      is_public = #{isPublic,jdbcType=BIT},
      parent_id = #{parentId,jdbcType=INTEGER},
      created_on = #{createdOn,jdbcType=TIMESTAMP},
      updated_on = #{updatedOn,jdbcType=TIMESTAMP},
      identifier = #{identifier,jdbcType=VARCHAR},
      status = #{status,jdbcType=INTEGER},
      lft = #{lft,jdbcType=INTEGER},
      rgt = #{rgt,jdbcType=INTEGER},
      inherit_members = #{inheritMembers,jdbcType=BIT},
      project_type = #{projectType,jdbcType=INTEGER},
      hidden_repo = #{hiddenRepo,jdbcType=BIT},
      attachmenttype = #{attachmenttype,jdbcType=INTEGER},
      user_id = #{userId,jdbcType=INTEGER},
      dts_test = #{dtsTest,jdbcType=INTEGER},
      enterprise_name = #{enterpriseName,jdbcType=VARCHAR},
      organization_id = #{organizationId,jdbcType=INTEGER},
      project_new_type = #{projectNewType,jdbcType=INTEGER},
      gpid = #{gpid,jdbcType=INTEGER},
      forked_from_project_id = #{forkedFromProjectId,jdbcType=INTEGER},
      forked_count = #{forkedCount,jdbcType=INTEGER},
      publish_resource = #{publishResource,jdbcType=INTEGER},
      visits = #{visits,jdbcType=INTEGER},
      hot = #{hot,jdbcType=INTEGER},
      invite_code = #{inviteCode,jdbcType=VARCHAR},
      qrcode = #{qrcode,jdbcType=VARCHAR},
      qrcode_expiretime = #{qrcodeExpiretime,jdbcType=INTEGER},
      training_status = #{trainingStatus,jdbcType=TINYINT},
      rep_identifier = #{repIdentifier,jdbcType=VARCHAR},
      project_category_id = #{projectCategoryId,jdbcType=INTEGER},
      project_language_id = #{projectLanguageId,jdbcType=INTEGER},
      license_id = #{licenseId,jdbcType=INTEGER},
      ignore_id = #{ignoreId,jdbcType=INTEGER},
      praises_count = #{praisesCount,jdbcType=INTEGER},
      watchers_count = #{watchersCount,jdbcType=INTEGER},
      issues_count = #{issuesCount,jdbcType=INTEGER},
      pull_requests_count = #{pullRequestsCount,jdbcType=INTEGER},
      language = #{language,jdbcType=VARCHAR},
      versions_count = #{versionsCount,jdbcType=INTEGER},
      issue_tags_count = #{issueTagsCount,jdbcType=INTEGER},
      closed_issues_count = #{closedIssuesCount,jdbcType=INTEGER},
      open_devops = #{openDevops,jdbcType=BIT},
      gitea_webhook_id = #{giteaWebhookId,jdbcType=INTEGER},
      open_devops_count = #{openDevopsCount,jdbcType=INTEGER},
      recommend = #{recommend,jdbcType=BIT},
      platform = #{platform,jdbcType=INTEGER},
      order_index = #{orderIndex,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
    <select id="getProjectByLoginAndIdentifier" resultMap="BaseResultMap"
            parameterType="com.microservices.wiki.domain.projects.Projects">
    select
    id, is_public
    from projects
    where identifier = #{identifier} or identifier = #{identifier1}
  </select>
    <select id="getProjectById" resultMap="BaseResultMap"
            parameterType="com.microservices.wiki.domain.projects.Projects">
    select
    is_public
    from projects
    where id = #{projectId}
  </select>
</mapper>