Commit 1ab8e481 authored by 李丛阳's avatar 李丛阳

删除用户

parent 25aa2e25
......@@ -4,6 +4,7 @@ import org.rcisoft.business.bcompany.dao.BCompanyRepository;
import org.rcisoft.business.bcompany.entity.BCompany;
import org.rcisoft.business.bcompany.service.BCompanyService;
import org.rcisoft.common.component.Global;
import org.rcisoft.common.util.TableUtil;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.entity.DataEntity;
......@@ -11,6 +12,7 @@ import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.sys.role.dao.SysRoleRepository;
import org.rcisoft.sys.user.dao.SysUserMapper;
import org.rcisoft.sys.user.entity.SysUser;
import org.rcisoft.sys.user.entity.UserRole;
......@@ -39,6 +41,10 @@ public class BCompanyServiceImpl implements BCompanyService{
@Autowired
private SysUserService userService;
@Autowired
private SysRoleRepository sysRoleRepository;
@Override
public PersistModel persist(BCompany model, SysUser user) {
int line = 0;
......@@ -85,16 +91,12 @@ public class BCompanyServiceImpl implements BCompanyService{
@Override
public PersistModel removeBCompany(String businessId) {
BCompany company = bCompanyRepository.selectOne(new BCompany(businessId,"0","1"));
sysUserMapper.deleteByCode(company.getCode());
BCompany bCompany = new BCompany();
bCompany.setDeleted();
bCompany.setBusinessId(businessId);
UserUtil.setCurrentMergeOperation(bCompany);
int line = bCompanyRepository.logicalDelete(bCompany);
/*删除关联角色*/
sysRoleRepository.deleteUserRoleByChildrenId(TableUtil.getTableByKey("1"),businessId);
/*删除sys_user*/
sysUserMapper.deleteByCompany(businessId);
/*删除b_company*/
int line = bCompanyRepository.deleteByPrimaryKey(businessId);
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
}
......
package org.rcisoft.common.util;
import java.util.HashMap;
import java.util.Map;
/**
* Created by lcy on 18/5/15.
*/
public class TableUtil {
static Map<String,String> TableMap;
static {
TableMap = new HashMap<>();
TableMap.put("1","b_company");
TableMap.put("2","b_teacher");
TableMap.put("3","b_student");
}
/**
* 获取
* @param key
* @return
*/
public static String getTableByKey(String key){
return TableMap.get(key);
}
}
......@@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Select;
import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.sys.dept.entity.DeptRole;
import org.rcisoft.sys.role.entity.SysRole;
import org.rcisoft.sys.user.entity.SysUser;
import org.springframework.stereotype.Repository;
import java.util.List;
......@@ -203,4 +202,19 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
"LEFT JOIN s_role ON s_role_menu.ROLE_ID = s_role.business_id " +
"WHERE s_menu.MODEL_ID = #{modelId} AND ROLE_ID = #{roleId}")
int queryRoleByRoleCode(@Param("modelId") String modelId, @Param("roleId") String roleId);
/**
* 根据子表id 删除 s_r_user_role
* @param tableByKey
* @param businessId
* @return
*/
@Delete("DELETE sr " +
"FROM" +
"s_r_user_role sr " +
"LEFT JOIN s_user s on s.business_id = sr.user_id " +
"LEFT JOIN ${tb} c ON c. CODE = s.login_name " +
"WHERE" +
"c.business_id = #{cid}")
int deleteUserRoleByChildrenId(@Param("tb") String tableByKey,@Param("cid") String businessId);
}
......@@ -8,14 +8,10 @@ import org.rcisoft.business.bteacher.entity.BTeacher;
import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.sys.user.entity.SysUser;
import org.rcisoft.sys.user.entity.UserRole;
import org.springframework.security.access.method.P;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List;
import static javafx.scene.input.KeyCode.V;
/**
* Created by lcy on 17/8/9.
*/
......@@ -49,9 +45,23 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
@Select("SELECT u.business_id from s_user u left join ${tab} s on u.login_name = s.code where s.business_id = #{id} and u.del_flag = 0 and u.flag = 1")
String selectUserIdByStuOrTeaId(@Param("id") String id, @Param("tab") String table);
@Update("update s_user set del_flag = 1, flag = 0 where login_name = #{code}")
@Update("update s_user set del_flag = 1 where login_name = #{code}")
int deleteByCode(String code);
/**
* 用户删除 cy 5-15
* @param code
* @return
*/
@Delete("DELETE s " +
"FROM " +
" s_user s " +
"LEFT JOIN b_company c ON c. CODE = s.login_name " +
"WHERE " +
" c.business_id = #{code}")
int deleteByCompany(String code);
@Select("<script>select * from s_user where business_id = #{userId} and password = #{password} limit 1</script>")
@ResultMap(value = "BaseResultMap")
SysUser checkPassword(@Param("userId") String userId, @Param("password") String password);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment