Преглед изворни кода

修改查询接口 及删除

wangfeng пре 6 година
родитељ
комит
883b2b5a9b

+ 1 - 0
user-service/src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -35,6 +35,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/userInfo/getUserInfoPag").permitAll()
                 .antMatchers("/user/getPermission").permitAll()
                 .antMatchers("/userInfo/updateUserInfoAll").permitAll()
+                .antMatchers("/userInfo/updateDeleted").permitAll()
                 .antMatchers("/**").authenticated();
 //        .antMatchers("/**").permitAll();
     }

+ 1 - 0
user-service/src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -49,6 +49,7 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/userInfo/getUserInfoPag", request)
                 || matchers("/user/getPermission", request)
                 || matchers("/userInfo/updateUserInfoAll", request)
+                || matchers("/userInfo/updateDeleted", request)
                 
                 || matchers("/", request)){
                     return;

+ 5 - 3
user-service/src/main/java/com/diagbot/entity/UserInfo.java

@@ -1,4 +1,4 @@
-package com.diagbot.entity;
+package com.diagbot.dto;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -7,14 +7,16 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 
+import lombok.Getter;
+import lombok.Setter;
+
 /**
  * 
  * @author wangfeng
  * @Description: 用户信息类表
  * @date 2018年9月17日 下午4:35:35
  */
-@TableName("sys_user and sys_user_organization")
-public class UserInfo implements Serializable{
+public class UserInfoDTO implements Serializable{
 	
 	 private static final long serialVersionUID = 1L;
 

+ 0 - 115
user-service/src/main/java/com/diagbot/entity/UserInfoOrganizations.java

@@ -1,115 +0,0 @@
-package com.diagbot.entity;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * 
- * @author wangfeng
- * @Description: 用于修改用户信息及机构信息
- * @date 2018年9月18日 下午3:06:58
- */
-public class UserInfoOrganizations implements Serializable {
-	
-	  private String isDeleted;//删除
-	  private Date gmtModified;//修改时间
-	  private String modifier;//修改人id
-	  private String email;//邮箱
-	  private String principal;//负责人
-	  private String address;//单位地址
-	  private Integer type;//机构属性
-	  private String position;//岗位部门
-	  private String isReject;//是否通过认证 N:未通过,Y:已通过
-	  private Integer rejectType;//未通过类型
-	  private String rejectComment;//认证被拒理由
-	  private String status;//认证状态(0:未认证,1:已认证,2:认证中)
-	  private Long userId;//用户id
-	public String getIsDeleted() {
-		return isDeleted;
-	}
-	public void setIsDeleted(String isDeleted) {
-		this.isDeleted = isDeleted;
-	}
-	public Date getGmtModified() {
-		return gmtModified;
-	}
-	public void setGmtModified(Date gmtModified) {
-		this.gmtModified = gmtModified;
-	}
-	public String getModifier() {
-		return modifier;
-	}
-	public void setModifier(String modifier) {
-		this.modifier = modifier;
-	}
-	public String getEmail() {
-		return email;
-	}
-	public void setEmail(String email) {
-		this.email = email;
-	}
-	public String getPrincipal() {
-		return principal;
-	}
-	public void setPrincipal(String principal) {
-		this.principal = principal;
-	}
-	public String getAddress() {
-		return address;
-	}
-	public void setAddress(String address) {
-		this.address = address;
-	}
-	public Integer getType() {
-		return type;
-	}
-	public void setType(Integer type) {
-		this.type = type;
-	}
-	public String getPosition() {
-		return position;
-	}
-	public void setPosition(String position) {
-		this.position = position;
-	}
-	public String getIsReject() {
-		return isReject;
-	}
-	public void setIsReject(String isReject) {
-		this.isReject = isReject;
-	}
-	public Integer getRejectType() {
-		return rejectType;
-	}
-	public void setRejectType(Integer rejectType) {
-		this.rejectType = rejectType;
-	}
-	public String getRejectComment() {
-		return rejectComment;
-	}
-	public void setRejectComment(String rejectComment) {
-		this.rejectComment = rejectComment;
-	}
-	public String getStatus() {
-		return status;
-	}
-	public void setStatus(String status) {
-		this.status = status;
-	}
-	public Long getUserId() {
-		return userId;
-	}
-	public void setUserId(Long userId) {
-		this.userId = userId;
-	}
-	@Override
-	public String toString() {
-		return "UserInfoOrganizations [isDeleted=" + isDeleted + ", gmtModified=" + gmtModified + ", modifier="
-				+ modifier + ", email=" + email + ", principal=" + principal + ", address=" + address + ", type=" + type
-				+ ", position=" + position + ", isReject=" + isReject + ", rejectType=" + rejectType
-				+ ", rejectComment=" + rejectComment + ", status=" + status + ", userId=" + userId + "]";
-	}
-	  
-	  
-
-}

+ 6 - 4
user-service/src/main/java/com/diagbot/mapper/UserMapper.java

@@ -3,9 +3,9 @@ package com.diagbot.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.diagbot.dto.UserInfoDTO;
 import com.diagbot.entity.User;
-import com.diagbot.entity.UserInfo;
-import com.diagbot.entity.UserInfoOrganizations;
+import com.diagbot.vo.UserInfoOrganizationsVO;
 
 import org.apache.ibatis.annotations.Param;
 
@@ -26,7 +26,9 @@ public interface UserMapper extends BaseMapper<User> {
 
     IPage<User> selectUserListPage(Page page, @Param("user") User user);
     
-    IPage<UserInfo> selectUserInfoListPage(Page page,@Param("userInfo") UserInfo userInfo);
+    IPage<UserInfoDTO> selectUserInfoListPage(Page page,@Param("userInfo") UserInfoDTO userInfo);
     
-    public Integer updateUserInfoAll(UserInfoOrganizations userInfo);
+    public Integer updateUserInfoAll(UserInfoOrganizationsVO userInfo);
+    
+    public Integer updateDeleted(@Param("map") Map<String ,String> map);
 }

+ 34 - 32
user-service/src/main/java/com/diagbot/service/UserService.java

@@ -1,32 +1,34 @@
-package com.diagbot.service;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.diagbot.entity.User;
-import com.diagbot.entity.UserInfo;
-import com.diagbot.entity.UserInfoOrganizations;
-
-import javafx.scene.control.Pagination;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * <p>
- *  服务类
- * </p>
- *
- * @author gaodm
- * @since 2018-08-02
- */
-public interface UserService extends IService<User> {
-
-    User findByName(String username);
-
-    IPage<User> selectUserListPage(Page<User> page, User user);
-    
-    public IPage<UserInfo>  selectUserInfoListPage(Page<UserInfo> page,UserInfo userInfo);
-    
-    public Integer updateUserInfoAll(UserInfoOrganizations userInfo);
-}
+package com.diagbot.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.dto.UserInfoDTO;
+import com.diagbot.entity.User;
+import com.diagbot.vo.UserInfoOrganizationsVO;
+
+import javafx.scene.control.Pagination;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author gaodm
+ * @since 2018-08-02
+ */
+public interface UserService extends IService<User> {
+
+    User findByName(String username);
+
+    IPage<User> selectUserListPage(Page<User> page, User user);
+    
+    public IPage<UserInfoDTO>  selectUserInfoListPage(Page<UserInfoDTO> page,UserInfoDTO userInfo);
+    
+    public Integer updateUserInfoAll(UserInfoOrganizationsVO userInfo);
+
+	Integer updateDeleted(Map<String, String> map);
+}

+ 10 - 4
user-service/src/main/java/com/diagbot/service/impl/UserServiceImpl.java

@@ -3,11 +3,12 @@ package com.diagbot.service.impl;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.dto.UserInfoDTO;
 import com.diagbot.entity.User;
-import com.diagbot.entity.UserInfo;
-import com.diagbot.entity.UserInfoOrganizations;
 import com.diagbot.mapper.UserMapper;
 import com.diagbot.service.UserService;
+import com.diagbot.vo.UserInfoOrganizationsVO;
+
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -33,14 +34,19 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         return baseMapper.selectUserListPage(page, user);
     }
     @Override
-    public IPage<UserInfo>  selectUserInfoListPage(Page<UserInfo> page,UserInfo userInfo){
+    public IPage<UserInfoDTO>  selectUserInfoListPage(Page<UserInfoDTO> page,UserInfoDTO userInfo){
     	return baseMapper.selectUserInfoListPage(page, userInfo);
     	
     }
 
 	@Override
-	public Integer  updateUserInfoAll(UserInfoOrganizations userInfo) {
+	public Integer  updateUserInfoAll(UserInfoOrganizationsVO userInfo) {
 		return baseMapper.updateUserInfoAll(userInfo);
 		
 	}
+	@Override
+	public Integer updateDeleted(Map<String,String> map){
+		return baseMapper.updateDeleted(map);
+		
+	}
 }

+ 42 - 0
user-service/src/main/java/com/diagbot/vo/UserInfoOrganizationsVO.java

@@ -0,0 +1,42 @@
+package com.diagbot.vo;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 
+ * @author wangfeng
+ * @Description: 用于修改用户信息及机构信息
+ * @date 2018年9月18日 下午3:06:58
+ */
+@Getter
+@Setter
+public class UserInfoOrganizationsVO implements Serializable {
+	
+	  private Date gmtModified;//修改时间
+	  private String modifier;//修改人id
+	  private String email;//邮箱
+	  private String principal;//负责人
+	  private String address;//单位地址
+	  private Integer type;//机构属性
+	  private String position;//岗位部门
+	  private String isReject;//是否通过认证 N:未通过,Y:已通过
+	  private Integer rejectType;//未通过类型
+	  private String rejectComment;//认证被拒理由
+	  private String status;//认证状态(0:未认证,1:已认证,2:认证中)
+	  private Long userId;//用户id
+	
+	@Override
+	public String toString() {
+		return "UserInfoOrganizations [gmtModified=" + gmtModified + ", modifier="
+				+ modifier + ", email=" + email + ", principal=" + principal + ", address=" + address + ", type=" + type
+				+ ", position=" + position + ", isReject=" + isReject + ", rejectType=" + rejectType
+				+ ", rejectComment=" + rejectComment + ", status=" + status + ", userId=" + userId + "]";
+	}
+	  
+	  
+
+}

+ 27 - 10
user-service/src/main/java/com/diagbot/web/UserInfoController.java

@@ -1,24 +1,27 @@
 package com.diagbot.web;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.RespDTO;
-import com.diagbot.entity.User;
-import com.diagbot.entity.UserInfo;
-import com.diagbot.entity.UserInfoOrganizations;
+import com.diagbot.dto.UserInfoDTO;
 import com.diagbot.facade.UserFacade;
+import com.diagbot.util.UserUtils;
+import com.diagbot.vo.UserInfoOrganizationsVO;
 
+import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import springfox.documentation.annotations.ApiIgnore;
 
 /**
  * @Description: 外部用户信息
@@ -26,6 +29,7 @@ import springfox.documentation.annotations.ApiIgnore;
  * @time: 2018年9月17日 下午1:53:53
  */
 @RestController
+@Api(value="用户信息和机构信息API", tags={"用户信息和机构信息API"})
 @RequestMapping("/userInfo")
 public class UserInfoController {
 	
@@ -36,21 +40,34 @@ public class UserInfoController {
 	    @PostMapping("/getUserInfoPag")
 	    @SysLogger("getUserInfoPag")
 //	    @ApiIgnore
-	    public RespDTO getUserInfoPag(Page page,String orgName,String autStatus ){
-	    	UserInfo userInfo =new UserInfo();
+	    public RespDTO<UserInfoDTO> getUserInfoPag(Page page, String orgName, String autStatus ){
+	    	UserInfoDTO userInfo =new UserInfoDTO();
 	    	userInfo.setOrgName(orgName);
 	    	userInfo.setAutStatus(autStatus);
-	        IPage<UserInfo> user=  userFacade.selectUserInfoListPage(page,userInfo);
+	        IPage<UserInfoDTO> user=  userFacade.selectUserInfoListPage(page,userInfo);
 	        return RespDTO.onSuc(user);
 	    }
 	    
-	    @ApiOperation(value = "修改用户信息和机构信息以及删除用户信息和机构信息", notes = "用户信息和机构信息")
+	    @ApiOperation(value = "修改用户信息和机构信息以", notes = "用户信息和机构信息")
 	    @PostMapping("/updateUserInfoAll")
 	    @SysLogger("updateUserInfoAll")
-	    public RespDTO updateUserInfoAll(UserInfoOrganizations userInfo){
+	    public RespDTO<UserInfoOrganizationsVO> updateUserInfoAll( UserInfoOrganizationsVO userInfo){
 	         int res= userFacade.updateUserInfoAll(userInfo);
 	         
-	        return RespDTO.onSuc("成功"+res);
+	        return RespDTO.onSuc("修改成功"+res);
+	    }
+	    
+	    @ApiOperation(value = "删除用户信息和机构信息", notes = "用户信息和机构信息")
+	    @PostMapping("/updateDeleted")
+	    @SysLogger("updateDeleted")
+	    public RespDTO updateDeleted(@RequestParam String  userId){
+	    	Map<String,String> map = new HashMap<String, String>();
+	    	map.put("userId", userId);
+	    	map.put("modifier",UserUtils.getCurrentPrincipleID());
+	    	SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+	    	map.put("gmtModified",df.format(new Date()));
+	    	 int res= userFacade.updateDeleted(map);
+	    	 return RespDTO.onSuc("刪除成功"+res);
 	    }
 	
 }

+ 0 - 77
user-service/src/main/resources/mapper/UserInfoMapper.xml

@@ -1,77 +0,0 @@
-<?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.diagbot.mapper.UserInfoMapper">
-    <select id="selectUserInfoPage"  parameterType="com.diagbot.entity.UserInfo" resultType="com.diagbot.entity.UserInfo">
-		SELECT
-		u.id AS userId,
-		u.gmt_create as userGmtCreate,
-		u.username as userName,
-		u.linkman as linKman,
-		u.email as email,
-		org.id AS orgId,
-		org.gmt_create as orgGmtCreate,
-		org.name as orgName
-		FROM sys_user u
-		LEFT JOIN sys_user_organization uorg ON u.id = uorg.user_id
-		LEFT JOIN sys_organization org ON uorg.organization_id = org.id
-		WHERE u.is_deleted = 'N' AND u.TYPE = "0" ORDER BY u.gmt_create DESC
-	</select>
-	<select id="selectUserInfoListPage"  resultType="com.diagbot.entity.UserInfo">
-	 SELECT
-		u.id AS userId,
-		u.gmt_create AS userGmtCreate,
-		u.username AS userName,
-		u.linkman AS linKman,
-		u.email AS email,
-		org.id AS orgId,
-		org.gmt_create AS orgGmtCreate,
-		org.name AS orgName,
-		org.type as orgType,
-		org.principal AS orgPrincipal,
-		org.address as orgAddress,
-		org.parent_id as orgParent_id,
-		org.sub_num as orgSub_num,
-		aut.position as autPosition,
-		aut.is_reject as autIsReject,
-		aut.status as autStatus
-		FROM sys_user u
-		LEFT JOIN sys_user_organization uorg ON u.id = uorg.user_id
-		LEFT JOIN sys_organization org ON uorg.organization_id = org.id
-	        LEFT JOIN sys_user_authentication aut ON u.id = aut.user_id
-		WHERE u.is_deleted = 'N' AND u.TYPE = "0" 
-		<if test="userInfo.orgName != null">
-		 AND org.name LIKE CONCAT('%', #{userInfo.orgName}, '%') 
-		 </if>
-		 <if test="userInfo.autStatus != null">
-	     AND aut.status = #{userInfo.autStatus}  
-	     </if>
-	     ORDER BY  u.gmt_create DESC
-	</select>
-	
-	<update id="updateUserInfoAll" parameterType="java.util.Map" >
-	UPDATE sys_user u ,sys_user_organization a ,
-	sys_organization b ,sys_user_authentication c
-	SET
-	<if test="isDeleted !=null">
-	 u.is_deleted = #{isDeleted},a.is_deleted=  #{isDeleted},b.is_deleted=  #{isDeleted},c.is_deleted= #{isDeleted},
-	</if>
-	<if test="email != null">
-	u.gmt_modified=#{gmtModified},u.modifier=#{modifier},
-	u.email=#{email},
-	</if>
-	<if test="principal != null || address != null || type != null">
-	b.gmt_modified=#{gmtModified},b.modifier=#{modifier},
-	b.principal=#{principal},b.address=#{address},b.type=#{type}
-	</if>
-	<if test="position != null ||">
-	c.gmt_modified=#{gmtModified},c.modifier=#{modifier},
-	c.position=#{position},c.is_reject=#{isReject},c.reject_type=#{rejectType},
-	c.reject_comment=#{rejectComment},c.status = #{status}
-	</if>
-	WHERE u.id = #{userId} 
-	AND c.user_id= #{userId} 
-	AND a.user_id = #{userId} 
-	AND a.organization_id =b.id
-</update>
-
-</mapper>

+ 173 - 158
user-service/src/main/resources/mapper/UserMapper.xml

@@ -1,158 +1,173 @@
-<?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.diagbot.mapper.UserMapper">
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.diagbot.entity.User">
-        <id column="id" property="id" />
-        <result column="is_deleted" property="isDeleted" />
-        <result column="gmt_create" property="gmtCreate" />
-        <result column="gmt_modified" property="gmtModified" />
-        <result column="creator" property="creator" />
-        <result column="modifier" property="modifier" />
-        <result column="password" property="password" />
-        <result column="username" property="username" />
-        <result column="linkman" property="linkman" />
-        <result column="email" property="email" />
-        <result column="type" property="type" />
-    </resultMap>
-
-    <select id="findByName" resultMap="BaseResultMap" parameterType="java.lang.String">
-        select * from sys_user
-        where username = #{username} and is_deleted = 'N'
-    </select>
-
-    <select id="selectUserListPage" resultMap="BaseResultMap">
-		select u.*
-		from sys_user u
-        LEFT JOIN sys_user_role ur on u.id= ur.user_id
-        LEFT JOIN sys_role r on ur.role_id=r.id
-        where u.is_deleted = 'N'
-        <if test="user.id != null">
-            and u.id = #{user.id}
-        </if>
-    </select>
-
-<!-- 	<select id="selectUserInfoListPage" resultMap="BaseResultMap">
-		select u.*
-		LEFT JOIN sys_user_role ur on u.id= ur.user_id
-		LEFT JOIN
-		sys_role r on ur.role_id=r.id
-		where u.is_deleted = 'N' and type = "0"
-		ORDER BY gmt_create DESC
-	</select> -->
-	
-    <select id="selectUserInfoPage"  parameterType="com.diagbot.entity.UserInfo" resultType="com.diagbot.entity.UserInfo">
-		SELECT
-		u.id AS userId,
-		u.gmt_create as userGmtCreate,
-		u.username as userName,
-		u.linkman as linKman,
-		u.email as email,
-		org.id AS orgId,
-		org.gmt_create as orgGmtCreate,
-		org.name as orgName
-		FROM sys_user u
-		LEFT JOIN sys_user_organization uorg ON u.id = uorg.user_id
-		LEFT JOIN sys_organization org ON uorg.organization_id = org.id
-		WHERE u.is_deleted = 'N' AND u.TYPE = 0 ORDER BY u.gmt_create DESC
-	</select>
-	<select id="selectUserInfoListPage"  resultType="com.diagbot.entity.UserInfo">
-	 SELECT
-		u.id AS userId,
-		u.gmt_create AS userGmtCreate,
-		u.username AS userName,
-		u.linkman AS linKman,
-		u.email AS email,
-		org.id AS orgId,
-		org.gmt_create AS orgGmtCreate,
-		org.name AS orgName,
-		org.type as orgType,
-		org.principal AS orgPrincipal,
-		org.address as orgAddress,
-		org.parent_id as orgParent_id,
-		org.sub_num as orgSub_num,
-		aut.position as autPosition,
-		aut.is_reject as autIsReject,
-		aut.status as autStatus
-		FROM sys_user u
-		LEFT JOIN sys_user_organization uorg ON u.id = uorg.user_id
-		LEFT JOIN sys_organization org ON uorg.organization_id = org.id
-	        LEFT JOIN sys_user_authentication aut ON u.id = aut.user_id
-		WHERE u.is_deleted = 'N' AND u.TYPE = 0
-		<if test="userInfo.orgName != null">
-		 AND org.name LIKE CONCAT('%', #{userInfo.orgName}, '%') 
-		 </if>
-		 <if test="userInfo.autStatus != null">
-	     AND aut.status = #{userInfo.autStatus}  
-	     </if>
-	     ORDER BY  u.gmt_create DESC
-	</select>
-	
-	<update id="updateUserInfoAll" parameterType="com.diagbot.entity.UserInfoOrganizations" >
-	UPDATE sys_user u ,sys_user_organization a ,
-	sys_organization b ,sys_user_authentication c
-	SET  u.remark = "0" 
-	<if test="isDeleted !=null">
-	 ,u.is_deleted = #{isDeleted}
-	 ,a.is_deleted=  #{isDeleted}
-	 ,b.is_deleted=  #{isDeleted}
-	 ,c.is_deleted= #{isDeleted}
-	</if>
-	<if test="email != null">
-	    <if test="gmtModified !=null"> 
-	      ,u.gmt_modified=#{gmtModified}
-	   </if>
-	   <if test="modifier != modifier">
-	      ,u.modifier=#{modifier}
-	   </if>
-	  ,u.email=#{email}
-	</if>
-	<if test="principal != null || address != null || type != null">
-	     <if test="gmtModified !=null"> 
-	       ,b.gmt_modified=#{gmtModified}
-	     </if>
-	     <if test="modifier != null">
-	      ,b.modifier=#{modifier}
-	     </if>
-		<if test="principal != null">
-		  ,b.principal=#{principal}
-		</if>
-		<if test="address != null">
-		  ,b.address=#{address}
-		</if>
-		<if test="type != null">
-		  ,b.type=#{type}
-		</if>
-	</if>
-	
-	<if test="position != null || isReject != null || rejectType !=null || rejectComment !=null || status != null">
-	    <if test="gmtModified !=null">
-		  ,c.gmt_modified=#{gmtModified}
-		</if>
-		<if test="modifier != null">
-		  ,c.modifier=#{modifier}
-		</if>
-		<if test="position != null">
-		  ,c.position=#{position}
-		</if>
-		<if test="isReject != null">
-		 ,c.is_reject=#{isReject}
-		</if>
-		<if test="rejectType !=null">
-		  ,c.reject_type=#{rejectType}
-		</if>
-		<if test="rejectComment !=null">
-		  ,c.reject_comment=#{rejectComment}
-		</if>
-		<if test="status != null">
-		  ,c.status = #{status}
-		</if>
-	</if>
-	WHERE u.id = #{userId} 
-	AND c.user_id= #{userId} 
-	AND a.user_id = #{userId} 
-	AND a.organization_id =b.id
-</update>
-
-</mapper>
+<?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.diagbot.mapper.UserMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.User">
+        <id column="id" property="id" />
+        <result column="is_deleted" property="isDeleted" />
+        <result column="gmt_create" property="gmtCreate" />
+        <result column="gmt_modified" property="gmtModified" />
+        <result column="creator" property="creator" />
+        <result column="modifier" property="modifier" />
+        <result column="password" property="password" />
+        <result column="username" property="username" />
+        <result column="linkman" property="linkman" />
+        <result column="email" property="email" />
+        <result column="type" property="type" />
+    </resultMap>
+
+    <select id="findByName" resultMap="BaseResultMap" parameterType="java.lang.String">
+        select * from sys_user
+        where username = #{username} and is_deleted = 'N'
+    </select>
+
+    <select id="selectUserListPage" resultMap="BaseResultMap">
+		select u.*
+		from sys_user u
+        LEFT JOIN sys_user_role ur on u.id= ur.user_id
+        LEFT JOIN sys_role r on ur.role_id=r.id
+        where u.is_deleted = 'N'
+        <if test="user.id != null">
+            and u.id = #{user.id}
+        </if>
+    </select>
+
+<!-- 	<select id="selectUserInfoListPage" resultMap="BaseResultMap">
+		select u.*
+		LEFT JOIN sys_user_role ur on u.id= ur.user_id
+		LEFT JOIN
+		sys_role r on ur.role_id=r.id
+		where u.is_deleted = 'N' and type = "0"
+		ORDER BY gmt_create DESC
+	</select> -->
+	
+   <!--  <select id="selectUserInfoPage"  parameterType="com.diagbot.dto.UserInfoDTO" resultType="com.diagbot.dto.UserInfoDTO">
+		SELECT
+		u.id AS userId,
+		u.gmt_create as userGmtCreate,
+		u.username as userName,
+		u.linkman as linKman,
+		u.email as email,
+		org.id AS orgId,
+		org.gmt_create as orgGmtCreate,
+		org.name as orgName
+		FROM sys_user u
+		LEFT JOIN sys_user_organization uorg ON u.id = uorg.user_id
+		LEFT JOIN sys_organization org ON uorg.organization_id = org.id
+		WHERE u.is_deleted = 'N' AND u.TYPE = 0 ORDER BY u.gmt_create DESC
+	</select> -->
+	<select id="selectUserInfoListPage"  resultType="com.diagbot.dto.UserInfoDTO">
+	 SELECT
+		u.id AS userId,
+		u.gmt_create AS userGmtCreate,
+		u.username AS userName,
+		u.linkman AS linKman,
+		u.email AS email,
+		org.id AS orgId,
+		org.gmt_create AS orgGmtCreate,
+		org.name AS orgName,
+		org.type as orgType,
+		org.principal AS orgPrincipal,
+		org.address as orgAddress,
+		org.parent_id as orgParent_id,
+		org.sub_num as orgSub_num,
+		aut.position as autPosition,
+		aut.is_reject as autIsReject,
+		aut.status as autStatus
+		FROM sys_user u
+		LEFT JOIN sys_user_organization uorg ON u.id = uorg.user_id
+		LEFT JOIN sys_organization org ON uorg.organization_id = org.id
+	        LEFT JOIN sys_user_authentication aut ON u.id = aut.user_id
+		WHERE u.is_deleted = 'N' AND u.TYPE = 0
+		<if test="userInfo.orgName != null">
+		 AND org.name LIKE CONCAT('%', #{userInfo.orgName}, '%') 
+		 </if>
+		 <if test="userInfo.autStatus != null">
+	     AND aut.status = #{userInfo.autStatus}  
+	     </if>
+	     ORDER BY  u.gmt_create DESC
+	</select>
+	
+	<update id="updateUserInfoAll" parameterType="com.diagbot.vo.UserInfoOrganizationsVO" >
+	UPDATE sys_user u ,sys_user_organization a ,
+	sys_organization b ,sys_user_authentication c
+	SET  u.remark = "0" 
+	<if test="email != null">
+	    <if test="gmtModified !=null"> 
+	      ,u.gmt_modified=#{gmtModified}
+	   </if>
+	   <if test="modifier != modifier">
+	      ,u.modifier=#{modifier}
+	   </if>
+	  ,u.email=#{email}
+	</if>
+	<if test="principal != null || address != null || type != null">
+	     <if test="gmtModified !=null"> 
+	       ,b.gmt_modified=#{gmtModified}
+	     </if>
+	     <if test="modifier != null">
+	      ,b.modifier=#{modifier}
+	     </if>
+		<if test="principal != null">
+		  ,b.principal=#{principal}
+		</if>
+		<if test="address != null">
+		  ,b.address=#{address}
+		</if>
+		<if test="type != null">
+		  ,b.type=#{type}
+		</if>
+	</if>
+	
+	<if test="position != null || isReject != null || rejectType !=null || rejectComment !=null || status != null">
+	    <if test="gmtModified !=null">
+		  ,c.gmt_modified=#{gmtModified}
+		</if>
+		<if test="modifier != null">
+		  ,c.modifier=#{modifier}
+		</if>
+		<if test="position != null">
+		  ,c.position=#{position}
+		</if>
+		<if test="isReject != null">
+		 ,c.is_reject=#{isReject}
+		</if>
+		<if test="rejectType !=null">
+		  ,c.reject_type=#{rejectType}
+		</if>
+		<if test="rejectComment !=null">
+		  ,c.reject_comment=#{rejectComment}
+		</if>
+		<if test="status != null">
+		  ,c.status = #{status}
+		</if>
+	</if>
+	WHERE u.id = #{userId} 
+	AND c.user_id= #{userId} 
+	AND a.user_id = #{userId} 
+	AND a.organization_id =b.id
+</update>
+
+ <update id="updateDeleted" parameterType="java.util.Map">
+	UPDATE sys_user u ,sys_user_organization a ,
+	 sys_organization b,sys_user_authentication c
+	SET u.is_deleted = "Y",a.is_deleted= "Y",b.is_deleted= "Y",c.is_deleted="Y"
+	<if test="map.gmtModified !=null">
+	,u.gmt_modified=#{map.gmtModified}
+	,b.gmt_modified=#{map.gmtModified}
+	,c.gmt_modified=#{map.gmtModified}
+	</if>
+	<if test="map.modifier != null">
+	,u.modifier=#{map.modifier}
+	,b.modifier=#{map.modifier}
+	,c.modifier=#{map.modifier}
+	</if>
+	WHERE u.id = #{map.userId} 
+	AND c.user_id= #{map.userId} 
+	AND a.user_id = #{map.userId} 
+	AND a.organization_id =b.id
+</update>
+
+
+</mapper>