Commit d4ab7ac5 authored by 赵啸非's avatar 赵啸非

Merge remote-tracking branch 'origin/master'

parents afdd7be5 200f3b84
......@@ -17,6 +17,7 @@ import com.mortals.xhx.module.site.model.SiteQuery;
import com.mortals.xhx.module.site.model.SiteTreeSelect;
import com.mortals.xhx.module.site.service.SiteService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
......@@ -187,8 +188,15 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
String busiDesc = "查询" + this.getModuleDesc();
int code=1;
try {
List<SiteEntity> result = this.getService().find(query, context);
model.put("data", result);
if(CollectionUtils.isNotEmpty(query.getAreaCodeList())){
List<SiteEntity> siteEntityList= query.getAreaCodeList().stream().flatMap(areaId ->
this.service.getFlatSitesByAreaCode(areaId, getContext()).stream()
).distinct().collect(Collectors.toList());
model.put("data", siteEntityList);
}else {
List<SiteEntity> result = this.getService().find(query, context);
model.put("data", result);
}
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
......
......@@ -25,10 +25,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@RestController
@Slf4j
......@@ -71,14 +68,10 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
String token = authTokenService.createToken(userEntity);
data.put("token", token);
data.put("user", userEntity);
if(StringUtils.isNotEmpty(userEntity.getSiteIds())){
if(StringUtils.isNotEmpty(userEntity.getAreaCodes())){
SitePdu sitePdu = new SitePdu();
List<Long> siteIdList = new ArrayList<>();
for(String idStr:userEntity.getSiteIds().split(",")){
siteIdList.add(DataUtil.converStr2Long(idStr,0));
}
sitePdu.setIdList(siteIdList);
sitePdu.setSize(-1);
List<String> areaCodeList = Arrays.asList(userEntity.getAreaCodes().split(","));
sitePdu.setAreaCodeList(areaCodeList);
String resp = apiModelFeign.getSitesByQuery(sitePdu);
ApiResp<JSONObject> apiResp = JSON.parseObject(resp, ApiResp.class);
if (apiResp.getCode() != YesNoEnum.YES.getValue()) {
......
......@@ -58,7 +58,6 @@ public class UserEntity extends UserVo implements IUser {
/**
* 用户类型(0.系统用户,1.普通用户,2.工作人员)
*/
@JSONField(serialize = false)
private Integer userType;
/**
* 所属站点id,多个逗号分隔
......@@ -224,6 +223,7 @@ public class UserEntity extends UserVo implements IUser {
* 获取 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @return Integer
*/
@Override
public Integer getUserType(){
return userType;
}
......
......@@ -68,4 +68,10 @@ public interface UserService extends ICRUDService<UserEntity,Long>{
void siteAuth(UserEntityExt entityExt,Context context);
/**
* 同步用户站点授权
* @throws AppException
*/
void synchSitesAuth() throws AppException;
}
\ No newline at end of file
......@@ -138,7 +138,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
update.setId(sysUser.getId());
update.setLastLoginAddress(loginIp);
update.setLastLoginTime(new Date());
this.update(update);
this.dao.update(update);
return sysUser;
}
......@@ -250,4 +250,25 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
protected void updateAfter(UserEntity entity, Context context) throws AppException {
super.updateAfter(entity, context);
}
@Override
public void synchSitesAuth() throws AppException {
UserEntity query = new UserEntity();
List<UserEntity> all = this.find(query);
all.forEach(item->{
if(StringUtils.isNotEmpty(item.getAreaCodes())){
List<String> areaCodeList = Arrays.asList(item.getAreaCodes().split(","));
String resp = areaService.getFlatSitesByAreaCodes(new AreaQuery().areaCodeList(areaCodeList), null);
JSONObject apiResp = JSON.parseObject(resp);
if (apiResp.getInteger("code") != YesNoEnum.YES.getValue()) {
throw new AppException("获取用户站点列表树数据失败:" + apiResp.getString("msg"));
}
String siteIds = apiResp.getString("data");
UserEntity userEntity = new UserEntity();
userEntity.setId(item.getId());
userEntity.setSiteIds(siteIds);
this.dao.update(userEntity);
}
});
}
}
\ No newline at end of file
......@@ -218,4 +218,22 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
return Rest.fail("获取token异常!");
}
}
/**
* 同步用户授权站点信息
*
* @return
*/
@PostMapping(value = "synchSiteAuth")
@UnAuth
public Rest<String> synchSitesAuth() {
try {
this.service.synchSitesAuth();
return Rest.ok("同步用户站点授权成功!");
} catch (Exception e) {
log.error("同步用户站点授权错误", e);
return Rest.fail("同步用户站点授权异常!");
}
}
}
\ No newline at end of file
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