|
@@ -1,16 +1,16 @@
|
|
|
package com.ruoyi.web.controller.system;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
+
|
|
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
|
+import com.ruoyi.common.core.domain.model.LoginUser;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.common.utils.ServletUtils;
|
|
|
+import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
@@ -19,6 +19,7 @@ import com.ruoyi.system.domain.TPersonalPage;
|
|
|
import com.ruoyi.system.service.ITPersonalPageService;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
/**
|
|
|
* 个人页Controller
|
|
@@ -100,4 +101,42 @@ public class TPersonalPageController extends BaseController
|
|
|
{
|
|
|
return toAjax(tPersonalPageService.deleteTPersonalPageByIds(ids));
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 状态修改
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:personalPage:edit')")
|
|
|
+ @PutMapping("/changeEnable")
|
|
|
+ public AjaxResult changeStatus(@RequestBody TPersonalPage tPersonalPage)
|
|
|
+ {
|
|
|
+ if (tPersonalPage == null){
|
|
|
+ return AjaxResult.error("数据不能为空");
|
|
|
+ }
|
|
|
+ if (tPersonalPage.getId() <= 0){
|
|
|
+ return AjaxResult.error("ID不能为空");
|
|
|
+ }
|
|
|
+ if (!tPersonalPage.getEnable().equals("0") && !tPersonalPage.getEnable().equals("1")){
|
|
|
+ return AjaxResult.error("修改失败");
|
|
|
+ }
|
|
|
+ tPersonalPage.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+ return toAjax(tPersonalPageService.updateEnable(tPersonalPage));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 头像上传
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:personalPage:edit')")
|
|
|
+ @PostMapping("/avatar")
|
|
|
+ public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file, Long id) throws IOException {
|
|
|
+ if (!file.isEmpty()) {
|
|
|
+ String avatar = FileUploadUtils.upload(RuoYiConfig.getUploadPath(), file);
|
|
|
+
|
|
|
+ if (tPersonalPageService.updateAvatar(id, avatar)) {
|
|
|
+ AjaxResult ajax = AjaxResult.success();
|
|
|
+ ajax.put("imgUrl", avatar);
|
|
|
+ return ajax;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return AjaxResult.error("上传图片异常,请联系管理员");
|
|
|
+ }
|
|
|
}
|