完成mp改造

This commit is contained in:
xuwenbo
2020-05-14 21:51:06 +08:00
parent f8f4273853
commit c6618d4141
8 changed files with 30 additions and 17 deletions

View File

@ -55,7 +55,7 @@ import java.util.stream.Collectors;
@Api(tags = "系统:用户管理")
@RestController
@RequestMapping("/api/users")
public class UserController {
public class SysUserController {
@Value("${rsa.private_key}")
private String privateKey;
@ -67,7 +67,7 @@ public class UserController {
private final VerificationCodeService verificationCodeService;
private final IGenerator generator;
public UserController(PasswordEncoder passwordEncoder, UserService userService, DataScope dataScope, DeptService deptService, RoleService roleService, VerificationCodeService verificationCodeService, IGenerator generator) {
public SysUserController(PasswordEncoder passwordEncoder, UserService userService, DataScope dataScope, DeptService deptService, RoleService roleService, VerificationCodeService verificationCodeService, IGenerator generator) {
this.passwordEncoder = passwordEncoder;
this.userService = userService;
this.dataScope = dataScope;

View File

@ -45,4 +45,6 @@ public interface UserAvatarService extends BaseService<UserAvatar>{
* @throws IOException /
*/
void download(List<UserAvatarDto> all, HttpServletResponse response) throws IOException;
UserAvatar saveFile(UserAvatar userAvatar);
}

View File

@ -161,9 +161,9 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, Dept> implement
*/
@Override
public Set<DeptDto> getDeleteDepts(List<Dept> deptList, Set<DeptDto> deptDtos) {
for (Dept dept : deptList) {
//todo
//deptDtos.add(generator.convert(dept,deptDtos));
deptDtos.add((DeptDto)generator.convert(deptList,DeptDto.class));
List<Dept> depts = Collections.singletonList(this.getOne(new QueryWrapper<Dept>().eq("id", dept.getId())));
if(depts!=null && depts.size()!=0){
getDeleteDepts(depts, deptDtos);

View File

@ -149,9 +149,7 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, Role> implement
*/
@Override
public void updateMenu(Role resources, RoleDto roleDto) {
//Role role =generator.convert(resources,roleDto);
//todo
Role role = new Role();
Role role =generator.convert(roleDto,Role.class);
role.setMenus(resources.getMenus());
this.save(role);
}

View File

@ -11,6 +11,7 @@ package co.yixiang.modules.system.service.impl;
import co.yixiang.modules.system.domain.User;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.modules.system.domain.UserAvatar;
import co.yixiang.modules.system.service.UserAvatarService;
import co.yixiang.utils.SecurityUtils;
import co.yixiang.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -21,8 +22,7 @@ import co.yixiang.utils.FileUtil;
import co.yixiang.modules.system.service.UserService;
import co.yixiang.modules.system.service.dto.UserDto;
import co.yixiang.modules.system.service.dto.UserQueryCriteria;
import co.yixiang.modules.system.service.mapper.UserMapper;
import lombok.AllArgsConstructor;
import co.yixiang.modules.system.service.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@ -48,16 +48,23 @@ import java.util.LinkedHashMap;
* @date 2020-05-14
*/
@Service
@AllArgsConstructor
//@AllArgsConstructor
//@CacheConfig(cacheNames = "user")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implements UserService {
public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, User> implements UserService {
@Value("${file.avatar}")
private String avatar;
private final IGenerator generator;
private final UserMapper userMapper;
private final SysUserMapper userMapper;
private final UserAvatarService userAvatarService;
public SysUserServiceImpl(IGenerator generator, SysUserMapper userMapper, UserAvatarService userAvatarService) {
this.generator = generator;
this.userMapper = userMapper;
this.userAvatarService = userAvatarService;
}
@Override
//@Cacheable
@ -139,9 +146,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
}
File file = FileUtil.upload(multipartFile, avatar);
assert file != null;
//todo
//userAvatar = userAvatarService.save(new UserAvatar(userAvatar,file.getName(), file.getPath(), FileUtil.getSize(multipartFile.getSize())));
user.setUserAvatar(userAvatar);
UserAvatar saveUserAvatar = new UserAvatar(userAvatar,file.getName(), file.getPath(), FileUtil.getSize(multipartFile.getSize()));
userAvatarService.save(saveUserAvatar);
user.setUserAvatar(saveUserAvatar);
this.save(user);
if(StringUtils.isNotBlank(oldPath)){
FileUtil.del(oldPath);

View File

@ -87,4 +87,10 @@ public class UserAvatarServiceImpl extends BaseServiceImpl<UserAvatarMapper, Use
}
FileUtil.downloadExcel(list, response);
}
@Override
public UserAvatar saveFile(UserAvatar userAvatar) {
//todo
return null;
}
}

View File

@ -23,7 +23,7 @@ import java.util.Date;
*/
@Repository
@Mapper
public interface UserMapper extends CoreMapper<User> {
public interface SysUserMapper extends CoreMapper<User> {
/**
* 修改密码

View File

@ -6,7 +6,7 @@ spring:
druid:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://localhost:3306/yxshop?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull
url: jdbc:log4jdbc:mysql://localhost:3306/yshop?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull
username: root
password: root