package com.ruoyi.web.controller.api;
|
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.framework.web.service.TokenService;
|
import com.ruoyi.system.domain.*;
|
import com.ruoyi.system.dto.AllertTitleDto;
|
import com.ruoyi.system.dto.RegionDto;
|
import com.ruoyi.system.service.*;
|
import com.ruoyi.web.controller.query.CityQueryDto;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.annotation.Resource;
|
import java.nio.file.LinkOption;
|
import java.util.Arrays;
|
import java.util.List;
|
import java.util.Objects;
|
|
@RestController
|
@RequestMapping("/web")
|
public class WebController {
|
|
|
@Resource
|
private TIndexMenuService indexMenuService;
|
@Resource
|
private TRegionService regionService;
|
|
@Autowired
|
private TokenService tokenService;
|
@Resource
|
private TUserChangeService changeService;
|
@Resource
|
private TUserChangeDetailService changeDetailService;
|
@Resource
|
private TAppUserService appUserService;
|
|
@ApiOperation(value = "获取地区树状图",tags = "web端偏好设置")
|
@PostMapping(value = "/region/tree")
|
public R<List<RegionDto>> regionTree() {
|
|
List<RegionDto> regionDtos = regionService.regionTree();
|
|
|
return R.ok(regionDtos);
|
}
|
|
|
|
@ApiOperation(value = "通过cityCodes查职称分类",tags = "web端偏好设置")
|
@PostMapping(value = "/title/tree")
|
public R<List<AllertTitleDto>> list(@Validated @RequestBody CityQueryDto cityQueryDto) {
|
String[] split = cityQueryDto.getStrings().split(",");
|
cityQueryDto.getCityCode().addAll(Arrays.asList(split));
|
List<AllertTitleDto> allertTitleDtos = indexMenuService.allert(cityQueryDto.getCityCode());
|
return R.ok(allertTitleDtos);
|
}
|
|
@ApiOperation(value = "设置偏好设置",tags = "web端偏好设置")
|
@PostMapping(value = "/title/set")
|
public R<List<AllertTitleDto>> set(@RequestBody List<TUserChangeDetail> userChangeDetails) {
|
Long userId = tokenService.getLoginUser().getUserId();
|
TAppUser byId = appUserService.getById(userId);
|
if(Objects.nonNull(byId)){
|
byId.setIsSetPreference(1);
|
appUserService.updateById(byId);
|
}
|
|
//保存一次变更记录
|
|
TUserChange tUserChange = new TUserChange();
|
tUserChange.setUserId(userId);
|
changeService.save(tUserChange);
|
|
|
//保存变更细节
|
for (TUserChangeDetail userChangeDetail : userChangeDetails) {
|
userChangeDetail.setChangeId(tUserChange.getId());
|
}
|
changeDetailService.saveBatch(userChangeDetails);
|
|
|
return R.ok();
|
}
|
|
}
|