Commit 6bea9dc4 authored by wangxl's avatar wangxl

77

parent c232c0bd
......@@ -3,37 +3,52 @@ package com.yiboshi.science.rest.v1;
import com.yiboshi.arch.base.ResponseDataModel;
import com.yiboshi.science.base.Pagination;
import com.yiboshi.science.config.annotation.Logs;
import com.yiboshi.science.config.security.SecurityUserHolder;
import com.yiboshi.science.entity.ComExpert;
import com.yiboshi.science.entity.SystemUser;
import com.yiboshi.science.enumeration.CommonEnum;
import com.yiboshi.science.param.dto.ComPersonDTO;
import com.yiboshi.science.param.dto.SystemUserDTO;
import com.yiboshi.science.param.query.SystemUserQueryVO;
import com.yiboshi.science.rest.BaseController;
import com.yiboshi.science.service.ComExpertService;
import com.yiboshi.science.service.ComProjectAssignService;
import com.yiboshi.science.service.SystemUserRoleService;
import com.yiboshi.science.service.SystemUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 功能:用户信息表 接口
*
* @author lkl
* @version 2021-08-26
*/
@Api(tags = "system-user",description = "用户信息表")
@Api(tags = "system-user", description = "用户信息表")
@RestController
@RequestMapping("/v1/science-admin/system-user")
public class SystemUserController extends BaseController<SystemUserService,SystemUserQueryVO, SystemUserDTO, SystemUser> {
public class SystemUserController extends BaseController<SystemUserService, SystemUserQueryVO, SystemUserDTO, SystemUser> {
@Autowired
private SystemUserService systemUserService;
@Autowired
private SystemUserRoleService systemUserRoleService;
@Autowired
private ComProjectAssignService comProjectAssignService;
@Autowired
private ComExpertService comExpertService;
/**
* 功能:分页查询
*
......@@ -89,6 +104,40 @@ public class SystemUserController extends BaseController<SystemUserService,Syste
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN')")
public ResponseDataModel<String> updateSystemUser(@Validated @RequestBody SystemUserDTO dto) {
SystemUser user = systemUserService.getById(dto.getId());
String r = StringUtils.join(dto.getRole().toArray(), ",");
List<String> roles = systemUserRoleService.getRolesListByUserId(dto.getId());
for (String e : roles) {
if (!r.contains(e)) {
systemUserRoleService.deleteRoleByUserId(dto.getId(), e);
if (e.equals(CommonEnum.systemRole.expert.getCode().toString())) {
ComExpert comExpert = new ComExpert();
comExpert.setPersonId(user.getPersonId());
comExpert = comExpertService.getEntity(comExpert);
if (null != comExpert && !comProjectAssignService.isAssignByExpertId(comExpert.getId())) {
comExpertService.deleteById(comExpert.getId());
}
}
}
}
String s = StringUtils.join(roles.toArray(), ",");
for (String e : dto.getRole()) {
if (!s.contains(e)) {
systemUserRoleService.addRoleByUserId(dto.getId(), e);
if (e.equals(CommonEnum.systemRole.expert.getCode().toString())) {
ComExpert comExpert = new ComExpert();
comExpert.setPersonId(user.getPersonId());
comExpert = comExpertService.getEntity(comExpert);
if (null == comExpert) {
comExpert = new ComExpert();
comExpert.setPersonId(user.getPersonId());
comExpert.setExpertState(1);
comExpert.setReportState(2);
comExpertService.insert(comExpert);
}
}
}
}
return ResponseDataModel.ok(systemUserService.updateSystemUser(dto));
}
}
\ No newline at end of file
......@@ -18,7 +18,6 @@ public interface ComExpertService extends BaseService<ComExpertQueryVO, ComExper
* @return
*/
ComExpertDTO getExpertById(String id);
/**
* 添加专家
*
......
......@@ -38,6 +38,12 @@ public interface ComProjectAssignService extends BaseService<ComProjectAssignQue
* @return
*/
String deleteAssignExpert(String id);
/**
* 删除分配专家
*
* @return
*/
boolean isAssignByExpertId(String id);
/**
* 专家评分
*
......
......@@ -36,8 +36,6 @@ public class ComExpertServiceImpl extends BaseServiceImpl<ComExpertDAO, ComExper
@Autowired
private ComPersonService comPersonService;
@Autowired
private ComUnitService comUnitService;
@Autowired
private SystemUserService systemUserService;
@Autowired
private SystemUserRoleService systemUserRoleService;
......@@ -180,6 +178,10 @@ public class ComExpertServiceImpl extends BaseServiceImpl<ComExpertDAO, ComExper
// comExpertSpecService.deleteById(d.getId());
// comPersonService.deleteById(d.getId());
// systemUserService.deleteById(d.getId());
if (null == d.getUserRoleId())
throw new BusinessException("系统限制,专家暂时不能删除!");
systemUserRoleService.deleteById(d.getUserRoleId());
......
......@@ -17,6 +17,7 @@ import com.yiboshi.science.param.dto.ComProjectGroupDTO;
import com.yiboshi.science.param.query.ComProjectAssignQueryVO;
import com.yiboshi.science.service.*;
import lombok.AllArgsConstructor;
import net.bytebuddy.asm.Advice;
import org.mockito.internal.matchers.Find;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -157,6 +158,16 @@ public class ComProjectAssignServiceImpl extends BaseServiceImpl<ComProjectAssig
return id;
}
public boolean isAssignByExpertId(String expertId) {
ComProjectAssign model = new ComProjectAssign();
model.setExpertId(expertId);
List<ComProjectAssign> list = this.entityList(model);
if (null != list && list.size() > 0) {
return true;
} else
return false;
}
@Transactional
public String expertEvaluation(ComProjectAssignDTO dto) {
ComProjectAssign comProjectAssign = this.getById(dto.getId());
......
......@@ -204,20 +204,6 @@ public class SystemUserServiceImpl extends BaseServiceImpl<SystemUserDAO, System
public String updateSystemUser(SystemUserDTO dto) {
SystemUser user = this.convert2Entity(dto);
String r = StringUtils.join(dto.getRole().toArray(), ",");
List<String> roles = systemUserRoleService.getRolesListByUserId(dto.getId());
for (String e : roles) {
if (!r.contains(e)) {
systemUserRoleService.deleteRoleByUserId(dto.getId(), e);
}
}
String s = StringUtils.join(roles.toArray(), ",");
for (String e : dto.getRole()) {
if (!s.contains(e)) {
systemUserRoleService.addRoleByUserId(dto.getId(), e);
}
}
return this.update(user);
}
}
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