package com.yipin.liuwanr.mapper ;
import java.util.List ;
import com.yipin.liuwanr.entity.ProjectManagement ;
import org.apache.ibatis.annotations.Delete ;
import org.apache.ibatis.annotations.Insert ;
import org.apache.ibatis.annotations.Options ;
import org.apache.ibatis.annotations.Param ;
import org.apache.ibatis.annotations.Select ;
import org.apache.ibatis.annotations.Update ;
import com.yipin.liuwanr.entity.Judgment_Points ;
import com.yipin.liuwanr.entity.Role ;
/ * *
* 项目管理系统 项目管理表
*
* @author 86151
* /
public interface ProjectManagementMapper {
/ * *
* 查询项目名称
*
* @param projectName
* @return
* /
@Select ( "select count(*) from hr_project_management where projectName=#{projectName} and isdel = 0" )
Integer getByprojectName ( String projectName ) ;
/ * *
* 分页查询 + 条件查询
*
* @param management
* @return
* "select projectId,projectName,projectPermissions,founder,creationTime,state from hr_project_management where isdel=0" ,
* " <if test='projectPermissions!=null'> and projectPermissions=#{projectPermissions}</if>" ,
* " <if test='founder!=null and userId==null'> and founder=#{founder}</if>" , //服务端跳项目管理
* " <if test='founder==null and userId!=null'> and (userId=#{userId} or founder = 0)</if>" , //教师端,一开始进入项目管理,看见自己创建的和其他人看见的
* " <if test='founder==0 and userId!=null'> and founder=#{founder}</if>" , //教师选择创建人为系统
* " <if test='founder==1 and userId!=null'> and userId=#{userId}</if>" , //教师选则创建人为老师
* " <if test='state!=null'> and state=#{state}</if>" ,
* " <if test='systemId!=null'> and systemId=#{systemId}</if>" ,
* " <if test='projectName!=null'> and projectName like concat('%',#{projectName},'%')</if>" ,
* " ORDER BY creationTime desc" ,
* /
@Select ( { "<script>" ,
"select * from hr_project_management where isdel = 0" ,
" <if test='projectPermissions!=null'> and projectPermissions=#{projectPermissions}</if>" ,
" <if test='founder!=null'> and founder=#{founder}</if>" , //教师选择创建人为系统
" <if test='founder==null'> and founder in (1,2)</if>" , //教师选择创建人为系统
" <if test='state!=null'> and state=#{state}</if>" ,
" <if test='systemId!=null'> and systemId=#{systemId}</if>" ,
" <if test='projectName!=null'> and projectName like concat('%',#{projectName},'%')</if>" +
"<if test='founder==null or founder==3'> or ( isdel = 0 AND userId = #{userId} " +
" <if test='projectPermissions!=null'> and projectPermissions=#{projectPermissions}</if>" ,
" <if test='founder!=null'> and founder=#{founder}</if>" , //教师选择创建人为系统
" <if test='state!=null'> and state=#{state}</if>" ,
" <if test='systemId!=null'> and systemId=#{systemId}</if>" ,
" <if test='projectName!=null'> and projectName like concat('%',#{projectName},'%')</if>" ,
") </if>" +
" ORDER BY creationTime desc" ,
"</script>" } )
List < ProjectManagement > queryManagements ( ProjectManagement management ) ;
// @Select({"<script>",
//// "select projectId,projectName,projectPermissions,founder,creationTime,state,knowledgePoints,experimentIntroduction from hr_project_management where isdel=0",
// "select * from hr_project_management where isdel=0",
// " <if test='projectPermissions!=null'> and projectPermissions=#{projectPermissions}</if>",
//// " <if test='founder!=null'> and founder=#{founder}</if>",
//// " <if test='userId!=null'> and (userId=#{userId} or founder = 0)</if>",
//// " <if test='userId==null and founder!=null '> and founder=#{founder}</if>",//服务端跳项目管理
// " <if test='userId!=null'> and userId=#{userId}</if>",//教师端,一开始进入项目管理,看见自己创建的和其他人看见的
// " <if test='founder!=null'> and founder=#{founder}</if>",//教师选择创建人为系统
//// " <if test='userId!=null and founder==1'> and userId=#{userId}</if>",//教师选则创建人为老师
// " <if test='state!=null'> and state=#{state}</if>",
// " <if test='systemId!=null'> and systemId=#{systemId}</if>",
// " <if test='projectName!=null'> and projectName like concat('%',#{projectName},'%')</if>",
// " ORDER BY creationTime desc",
// "</script>"})
// List<ProjectManagement> queryManagements(ProjectManagement management);
@Select ( { "<script>" ,
"select * from hr_project_management where (roleId NOT LIKE '%3%' AND isdel = 0 AND projectPermissions != 0)" ,
" <if test='systemId!=null'> and systemId=#{systemId}</if>" ,
" ORDER BY creationTime desc" ,
"</script>" } )
List < ProjectManagement > queryManagementsExportTest ( ProjectManagement management ) ;
@Select ( { "<script>" ,
"select * from hr_project_management where isdel = 0 AND projectPermissions != 0 AND state = 1" ,
" <if test='systemId!=null'> and systemId=#{systemId}</if>" +
"<if test ='userId!=null'> or( isdel = 0 AND projectPermissions != 0 AND userId = #{userId} AND state = 1" +
"<if test='systemId!=null'> and systemId=#{systemId}</if>" +
")</if>" ,
" ORDER BY creationTime desc" ,
"</script>" } )
List < ProjectManagement > queryManagementsExport ( ProjectManagement management ) ;
/ * *
* 根据实验项目id查询信息
*
* @param projectId
* @return
* /
@Select ( "select knowledgePointsIsEnable,experimentIntroductionIsEnable,isstartexperimentSuggests,projectId,projectName,projectPermissions,experimentalGoal,caseDescription,experimentSuggests,state,isstartexperimental,isstartexperimentSuggests,userId,knowledgePoints,experimentIntroduction,systemId from hr_project_management where isdel=0 and projectId=#{projectId}" )
ProjectManagement getProjectId ( Integer projectId ) ;
/ * *
* 根据实验项目id查询项目名称
*
* @param projectId
* @return
* /
@Select ( "select projectName from hr_project_management where isdel=0 and projectId=#{projectId}" )
String getNameByProjectId ( Integer projectId ) ;
/ * *
* 批量删除
*
* @param projectId
* /
@Update ( "<script>"
+ "update hr_project_management hpm ,tms_experimental_teaching tet " +
"set hpm.isdel=1 ,tet.is_del = 1 " +
"where hpm.projectId=#{projectId} and hpm.projectId = tet.project_id"
+ "</script>" )
void deleteProjectManagement ( Integer projectId ) ;
// 202.10.29 标准版
// /**
// * 批量删除
// *
// * @param projectId
// */
// @Update("<script>"
// + "update hr_project_management set isdel=1 where projectId=#{projectId}"
// + "</script>")
// void deleteProjectManagement(Integer projectId);
/ * *
* 添加角色信息
*
* @param role
* @return
* /
@Insert ( "insert into hr_role (roleNumber,roleType,roleAttribute) VALUES (#{roleNumber},#{roleType},#{roleAttribute})" )
@Options ( useGeneratedKeys = true , keyProperty = "roleId" , keyColumn = "roleId" )
void insertRole ( Role role ) ;
/ * *
* 点击实验数据中单个角色后的编辑按钮 , 修改角色信息
*
* @param role
* /
@Update ( "update hr_role set roleNumber=#{roleNumber},roleType=#{roleType},roleAttribute=#{roleAttribute} where roleId=#{roleId}" )
void updateRole ( Role role ) ;
/ * *
* 点击编辑或者创建项目管理页面的保存按钮后 ,
* 修改角色表中的对应数据的项目id
*
* @param ids
* @param projectId
* /
// @Update("<script>" +
// "<foreach collection = 'ids' item ='id' open='' close='' separator=';'>"
// + "update hr_role set projectId=#{projectId} where roleId=#{ids}</foreach>"
// + "</script>")
@Update ( { "<script>" +
"update hr_role set projectId=#{projectId} where roleId in" +
"<foreach collection = 'ids' item ='id' open='(' close=')' separator=','>#{id}</foreach>" +
"</script>" } )
void updateRoleProjectId ( @Param ( "ids" ) List < Integer > ids , @Param ( "projectId" ) Integer projectId ) ;
@Delete ( "delete from hr_role where projectId=#{projectId}" )
void deleteRole ( Integer projectId ) ;
/ * *
* 添加角色信息后 , 在创建编辑页面的角色信息展示
*
* @param role
* @return
* /
@Select ( { "<script>" ,
"select roleId,roleNumber,roleType,roleAttribute from hr_role where roleId in" ,
"<foreach collection='role' item='ro' open='(' separator=',' close=')'>" + "#{ro} " + "</foreach> " ,
"</script>" } )
List < Role > getByRoleId ( @Param ( "role" ) List < Integer > role ) ;
/ * *
* 查询单个项目判分点信息 , 根据项目id
*
* @param projectId 项目id
* @return
* /
@Select ( { "<script>" ,
"select * from hr_judgment_points where find_in_set(#{projectId},projectId)" ,
"</script>" } )
List < Judgment_Points > getJudgmentPoints ( @Param ( "projectId" ) Integer projectId ) ;
/ * *
* 点击具体某个项目信息的编辑按钮 ,
* 跳转到编辑项目管理页面的实验数据的信息展示
*
* @param projectId
* @return
* /
@Select ( "select roleId,roleNumber,roleType,roleAttribute from hr_role where projectId=#{projectId}" )
List < Role > queryProjectId ( Integer projectId ) ;
/ * *
* 添加判分点面板的判分信息展示
*
* @return
* /
@Select ( { "<script>" ,
"select judgmentPointsId,judgmentPointsName from hr_judgment_points where isdel=0 and systemId=#{systemId} and isopen=0" ,
" <if test='judgmentPointsName!=null'> and judgmentPointsName like concat('%','${judgmentPointsName}','%')</if>" ,
"</script>" } )
List < Judgment_Points > queryAllJudgmentPoints ( Judgment_Points points ) ;
/ * *
* 从判分点添加面板 , 选择完数据后 ,
* 创建项目管理页面的实验任务信息展示
*
* @param point
* @return
* /
@Select ( { "<script>" ,
"select judgmentPointsId,judgmentPointsName,experimentalRequirements,userId from hr_judgment_points where isdel=0 and judgmentPointsId in" ,
"<foreach collection='point' item='po' open='(' separator=',' close=')'>" + "#{po} " + "</foreach> " ,
"</script>" } )
List < Judgment_Points > getByjudgmentPointsIds ( @Param ( "point" ) List < Integer > point ) ;
/ * *
* 点击具体某个项目信息的编辑按钮 ,
* 跳转到编辑项目管理页面的实验任务的信息展示
*
* @param projectId
* @return
* /
@Select ( "select judgmentPointsId,judgmentPointsName,experimentalRequirements ,userId from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0" )
List < Judgment_Points > getByProjectId ( Integer projectId ) ;
@Select ( "select judgmentPointsId,projectId from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0" )
List < Judgment_Points > queryProjectIds ( Integer projectId ) ;
/ * *
* 取出判分点中的项目管理的id
*
* @param judgmentPointsId
* @return
* /
@Select ( "select projectId,experimentalRequirements from hr_judgment_points where judgmentPointsId=#{judgmentPointsId}" )
Judgment_Points getByjudgmentPointsId ( Integer judgmentPointsId ) ;
/ * *
* 点击保存按按 , 需要修改判分点表中对应的项目id , 实验要求
*
* @param projectId
* @param judgmentPointsId
* /
@Update ( { "<script>" ,
"update hr_judgment_points set projectId=#{projectId}" ,
" <if test='experimentalRequirements!=null'>,experimentalRequirements=#{experimentalRequirements}</if>" ,
" where judgmentPointsId=#{judgmentPointsId}" ,
"</script>" } )
void updateProject ( String projectId , String experimentalRequirements , Integer judgmentPointsId ) ;
/ * *
* 添加项目管理信息
*
* @param management
* /
@Insert ( "INSERT INTO hr_project_management(roleId,projectName,projectPermissions,experimentalGoal,caseDescription,experimentSuggests,state,founder,systemId,creationTime,isstartexperimental,isstartexperimentSuggests,userId,knowledgePoints,experimentIntroduction,knowledgePointsIsEnable,experimentIntroductionIsEnable)"
+ " VALUES (#{founder},#{projectName},#{projectPermissions},#{experimentalGoal},#{caseDescription},#{experimentSuggests},#{state},#{founder},#{systemId},now(),#{isstartexperimental},#{isstartexperimentSuggests},#{userId},#{knowledgePoints},#{experimentIntroduction},#{knowledgePointsIsEnable},#{experimentIntroductionIsEnable})" )
@Options ( useGeneratedKeys = true , keyProperty = "projectId" , keyColumn = "projectId" )
void insertProjectManagement ( ProjectManagement management ) ;
/ * *
* 修改项目管理信息
*
* @param management
* /
@Update ( "update hr_project_management set projectName=#{projectName},projectPermissions=#{projectPermissions},experimentalGoal=#{experimentalGoal},caseDescription=#{caseDescription},experimentSuggests=#{experimentSuggests},state=#{state},"
+ "isstartexperimental=#{isstartexperimental},isstartexperimentSuggests=#{isstartexperimentSuggests},knowledgePoints=#{knowledgePoints},experimentIntroduction=#{experimentIntroduction},knowledgePointsIsEnable=#{knowledgePointsIsEnable},experimentIntroductionIsEnable=#{experimentIntroductionIsEnable} where projectId=#{projectId}" )
void updateProjectManagement ( ProjectManagement management ) ;
/ * *
* 根据项目id , 查询出该项目所有的判分点id
*
* @param projectId
* @return
* /
@Select ( "select judgmentPointsId from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0" )
List < Integer > getByPointProjectId ( Integer projectId ) ;
/ * *
* 根据项目id , 查询出该项目所有的角色id
*
* @param projectId
* @return
* /
@Select ( "select roleId from hr_role where projectId=#{projectId}" )
List < Integer > getByRoleProjectId ( Integer projectId ) ;
/ * *
* 查询用户角色
*
* @param userId
* @return
* /
@Select ( "SELECT ro.roleId FROM user us,role ro WHERE ro.roleId=us.accountRole AND us.userId=#{userId}" )
Integer queryRole ( Integer userId ) ;
/ * *
* 查询用户角色
*
* @param userId
* @return
* /
@Select ( "SELECT accountRole FROM user WHERE userId=#{userId}" )
Integer queryRoleId ( Integer userId ) ;
/ * *
* 查询用户角色
*
* @param userId
* @return
* /
@Select ( "SELECT roleId FROM hr_user_info WHERE userId=#{userId}" )
String queryRoleIds ( Integer userId ) ;
/ * *
* 查询项目名称
*
* @param projectPermissions
* @return
* /
@Select ( "select * from hr_project_management where projectPermissions=#{projectPermissions}" )
List < ProjectManagement > getManagements ( Integer projectPermissions ) ;
@Select ( "SELECT id FROM tms_experimental_teaching WHERE project_id =#{projectId}" )
List < Integer > queryproject ( Integer projectId ) ;
@Update ( "<script>"
+ "update hr_project_management " +
"set isdel=1 " +
"where projectId=#{projectId}"
+ "</script>" )
void daleteManegement ( Integer id ) ;
}