添加删除公司代码

master
bynt 3 years ago
parent a408749066
commit dbbf2cd754

@ -37,4 +37,12 @@ public interface CompanyRepository extends JpaRepository<Company, Long>, JpaSpec
@Modifying
@Query("UPDATE Company set status = ?2 where id = ?1")
void updateCompanyStatus(Long id, Integer status);
/**
* id
* @param companyId
*/
@Modifying
@Query(value = "delete from Company where id = ?1")
void deleteCompanyId(Long companyId);
}

@ -215,4 +215,13 @@ public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificat
@Modifying
@Query(value = "update User set enabled = ?1 where id = ?2")
void updateStatusById(Boolean aFalse, Long currentUserId);
/**
* id
* @param companyId
* @return
*/
@Modifying
@Query(value = "delete from User where companyId = ?1")
int deleteByCompanyId(Long companyId);
}

@ -2,12 +2,10 @@ package com.baiye.modules.system.rest;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.model.dto.TaskQueryCriteria;
import com.baiye.modules.system.domain.Task;
import com.baiye.modules.system.service.TaskService;
import com.baiye.socket.WebSocketServer;
import com.baiye.util.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
@ -16,7 +14,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@ -256,7 +256,6 @@ public class UserController {
*
* @return
*/
@GetMapping("/info/findByName")
@ApiOperation("名称查询")
public UserDto info(@RequestParam("username") String username) {
@ -282,4 +281,19 @@ public class UserController {
public ResponseEntity<Object> getLeaderList() {
return new ResponseEntity<>(userService.queryRoleUser(RoleNumberConstants.MINUS_NINE_NUMBER), HttpStatus.OK);
}
/**
*
*
* @return
*/
@PostMapping("/deleteCompany")
@ApiOperation("id删除公司")
public ResponseEntity<Object> deleteCompany(Long companyId) {
userService.deleteCompany(companyId);
return new ResponseEntity<>(HttpStatus.OK);
}
}

@ -58,4 +58,6 @@ public interface CompanyService {
void updateCompany(CompanyDto companyDto);
void deleteCompanyByCompanyId(Long companyId);
}

@ -19,6 +19,7 @@ import com.baiye.modules.system.domain.User;
import com.baiye.model.dto.UserDto;
import com.baiye.modules.system.service.dto.UserQueryCriteria;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
@ -178,4 +179,11 @@ public interface UserService {
* @param id
*/
void updateUserStatusByCompanyId(Long id);
/**
*
* @param companyId
* @return
*/
void deleteCompany(Long companyId);
}

@ -122,4 +122,9 @@ public class CompanyServiceImpl implements CompanyService {
companyRepository.save(byUserId);
}
}
@Override
public void deleteCompanyByCompanyId(Long companyId) {
companyRepository.deleteCompanyId(companyId);
}
}

@ -45,6 +45,8 @@ import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -135,6 +137,13 @@ public class UserServiceImpl implements UserService {
userRepository.updateStatusByCompanyId(Boolean.TRUE, id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteCompany(Long companyId) {
userRepository.deleteByCompanyId(companyId);
companyService.deleteCompanyByCompanyId(companyId);
}
@Override
public Object queryAll(UserQueryCriteria criteria, Pageable pageable) {
@ -315,6 +324,7 @@ public class UserServiceImpl implements UserService {
convert.setIsOperator(Boolean.TRUE);
}
}
return convert;
}
return null;

@ -9,13 +9,17 @@ spring:
freemarker:
check-template-location: false
profiles:
active: prod
active: dev
jackson:
time-zone: GMT+8
data:
redis:
repositories:
enabled: false
servlet:
multipart:
max-request-size: 200MB
max-file-size: 200MB
#配置 Jpa
jpa:
hibernate:

Loading…
Cancel
Save