Commit 93f14a3020e6230232208a8210c30f6c86440586
1 parent
12008f99
修复头像上传功能
Showing
5 changed files
with
6 additions
and
5 deletions
src/main/java/com/huaheng/common/utils/file/FileUploadUtils.java
src/main/java/com/huaheng/pc/system/user/controller/ProfileController.java
... | ... | @@ -138,6 +138,7 @@ public class ProfileController extends BaseController |
138 | 138 | if (!file.isEmpty()) |
139 | 139 | { |
140 | 140 | String avatar = FileUploadUtils.upload(file); |
141 | + user.setId(getUser().getId()); | |
141 | 142 | user.setAvatar(avatar); |
142 | 143 | if (userService.updateUserInfo(user) > 0) |
143 | 144 | { |
... | ... |
src/main/resources/application.yml
src/main/resources/templates/system/user/profile/avatar.html
... | ... | @@ -24,12 +24,12 @@ |
24 | 24 | </div> |
25 | 25 | <div th:include="include::footer"></div> |
26 | 26 | <script th:src="@{/ajax/libs/cropbox/cropbox.js}"></script> |
27 | -<script type="text/javascript"> | |
27 | + <script th:inline="javascript"> | |
28 | 28 | $(window).load(function() { |
29 | 29 | var options = { |
30 | 30 | thumbBox: '.thumbBox', |
31 | 31 | spinner: '.spinner', |
32 | - imgSrc: '/wms/img/profile.jpg' | |
32 | + imgSrc: '/wms/profile/' + [[${user.avatar}]] | |
33 | 33 | } |
34 | 34 | var cropper = $('.imageBox').cropbox(options); |
35 | 35 | $('#avatar').on('change', |
... | ... |
src/main/resources/templates/system/user/profile/profile.html
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 | <div class="contact-box"> |
36 | 36 | <div class="col-sm-4"> |
37 | 37 | <div class="text-center"> |
38 | - <img alt="image" class="img-circle m-t-xs img-responsive" th:src="(${user.avatar} == '') ? '../../img/profiles.jpg' : '/profile/' + ${user.avatar}"> | |
38 | + <img alt="image" class="img-circle m-t-xs img-responsive" th:src="(${user.avatar} == '') ? '../../img/profiles.jpg' : '../../profile/' + ${user.avatar}"> | |
39 | 39 | <div class="m-t-xs font-bold">[[${user.loginIp}]]</div> |
40 | 40 | </div> |
41 | 41 | </div> |
... | ... |