调整用户管理接口
This commit is contained in:
parent
ce877ff7f1
commit
d042c12a31
|
|
@ -21,6 +21,13 @@ public interface IUserService {
|
|||
*/
|
||||
PageResult<UserVo> list(PageParam pageParam, Map<String, String> params);
|
||||
|
||||
/**
|
||||
* 用户详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return UserVo
|
||||
*/
|
||||
UserVo detail(Integer id);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.mdd.admin.vo.article.ArticleListVo;
|
|||
import com.mdd.admin.vo.user.UserVo;
|
||||
import com.mdd.common.core.PageResult;
|
||||
import com.mdd.common.entity.user.User;
|
||||
import com.mdd.common.enums.ClientEnum;
|
||||
import com.mdd.common.mapper.user.UserMapper;
|
||||
import com.mdd.common.utils.StringUtil;
|
||||
import com.mdd.common.utils.TimeUtil;
|
||||
|
|
@ -31,6 +32,14 @@ public class UserServiceImpl implements IUserService {
|
|||
@Resource
|
||||
UserMapper userMapper;
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*
|
||||
* @author fzr
|
||||
* @param pageParam (分页参数)
|
||||
* @param params (搜索参数)
|
||||
* @return PageResult<UserVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<UserVo> list(PageParam pageParam, Map<String, String> params) {
|
||||
Integer pageNo = pageParam.getPageNo();
|
||||
|
|
@ -67,6 +76,8 @@ public class UserServiceImpl implements IUserService {
|
|||
UserVo vo = new UserVo();
|
||||
BeanUtils.copyProperties(user, vo);
|
||||
|
||||
vo.setSex(user.getSex());
|
||||
vo.setChannel(ClientEnum.getMsgByCode(user.getChannel()));
|
||||
vo.setAvatar(UrlUtil.toAbsoluteUrl(user.getAvatar()));
|
||||
vo.setLastLoginTime(TimeUtil.timestampToDate(user.getLastLoginTime()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(user.getCreateTime()));
|
||||
|
|
@ -109,6 +120,8 @@ public class UserServiceImpl implements IUserService {
|
|||
UserVo vo = new UserVo();
|
||||
BeanUtils.copyProperties(user, vo);
|
||||
|
||||
vo.setSex(user.getSex());
|
||||
vo.setChannel(ClientEnum.getMsgByCode(user.getChannel()));
|
||||
vo.setAvatar(UrlUtil.toAbsoluteUrl(user.getAvatar()));
|
||||
vo.setLastLoginTime(TimeUtil.timestampToDate(user.getLastLoginTime()));
|
||||
vo.setCreateTime(TimeUtil.timestampToDate(user.getCreateTime()));
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class UserVo implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private String sn;
|
||||
private Integer sn;
|
||||
private String avatar;
|
||||
private String realName;
|
||||
private String nickname;
|
||||
|
|
@ -25,4 +25,18 @@ public class UserVo implements Serializable {
|
|||
private String lastLoginTime;
|
||||
private String createTime;
|
||||
|
||||
public void setSex(Integer sex) {
|
||||
switch (sex) {
|
||||
case 0:
|
||||
this.sex = "未知";
|
||||
break;
|
||||
case 1:
|
||||
this.sex = "男";
|
||||
break;
|
||||
case 2:
|
||||
this.sex = "女";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,23 @@ public enum ClientEnum {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据编码获取Msg
|
||||
*
|
||||
* @author fzr
|
||||
* @param code 类型
|
||||
* @return String
|
||||
*/
|
||||
public static String getMsgByCode(Integer code){
|
||||
for(ClientEnum enumItem: ClientEnum.values()) {
|
||||
if (enumItem.getCode() == code) {
|
||||
return enumItem.getMsg();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public class FrontConfig {
|
|||
"/api/search",
|
||||
"/api/decorate",
|
||||
"/api/sms/send",
|
||||
"/api/upload/image",
|
||||
|
||||
"/api/login/check",
|
||||
"/api/login/register",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.mdd.common.config.GlobalConfig;
|
|||
import com.mdd.common.utils.YmlUtil;
|
||||
import com.mdd.front.LikeFrontInterceptor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
|
|
@ -41,7 +42,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|||
* 资源目录映射
|
||||
*/
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
public void addResourceHandlers(@NonNull ResourceHandlerRegistry registry) {
|
||||
String directory = YmlUtil.get("like.upload-directory");
|
||||
if (directory == null || directory.equals("")) {
|
||||
directory = GlobalConfig.uploadDirectory;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package com.mdd.front.controller;
|
||||
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.enums.AlbumEnum;
|
||||
import com.mdd.common.plugin.storage.StorageDriver;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 上传管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/upload")
|
||||
public class UploadController {
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @author fzr
|
||||
* @param request 请求对象
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/image")
|
||||
public Object image(HttpServletRequest request) {
|
||||
MultipartFile multipartFile;
|
||||
try {
|
||||
multipartFile = ((MultipartRequest) request).getFile("file");
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.failed("请正确选择上传图片");
|
||||
}
|
||||
|
||||
if (multipartFile == null) {
|
||||
return AjaxResult.failed("请选择上传图片");
|
||||
}
|
||||
|
||||
StorageDriver storageDriver = new StorageDriver();
|
||||
Map<String, Object> map = storageDriver.upload(multipartFile, "image", AlbumEnum.IMAGE.getCode());
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.mdd.front.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 上传服务接口类
|
||||
*/
|
||||
public interface IUploadService {
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> image();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.mdd.front.service.impl;
|
||||
|
||||
import com.mdd.front.service.IUploadService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 上传服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class UploadServiceImpl implements IUploadService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> image() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# 项目配置
|
||||
like:
|
||||
upload-directory: D:\www\frame\
|
||||
upload-directory: /www/like-admin/uploads/
|
||||
|
||||
# 服务配置
|
||||
server:
|
||||
|
|
|
|||
Loading…
Reference in New Issue