Here are the examples of the java api @org.springframework.stereotype.Service(userService) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
73 Examples
19
View Source File : UserRepositoryImpl.java
License : Apache License 2.0
Project Creator : yin5980280
License : Apache License 2.0
Project Creator : yin5980280
@Service("userService")
public clreplaced UserRepositoryImpl extends AbstractBaseLogicRepositoryImpl<User> implements UserRepository {
}
19
View Source File : UserServiceImpl.java
License : MIT License
Project Creator : xk11961677
License : MIT License
Project Creator : xk11961677
/**
* 用户表
*
* @author code generator
* @date 2019-09-11 13:34:28
*/
@Service("userService")
public clreplaced UserServiceImpl extends BaseService<User> implements UserService {
@Override
public User getByUsername(String username) {
return new User();
}
}
19
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : wanhao838088
License : Apache License 2.0
Project Creator : wanhao838088
@Service("userService")
public clreplaced UserServiceImpl extends ServiceImpl<UserDao, UserEnreplacedy> implements UserService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
Page<UserEnreplacedy> page = this.selectPage(new Query<UserEnreplacedy>(params).getPage(), new EnreplacedyWrapper<UserEnreplacedy>());
return new PageUtils(page);
}
}
19
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : sunshinelyz
License : Apache License 2.0
Project Creator : sunshinelyz
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Override
@RequiresLogin
public String getUserInfo() {
try {
return "[{'id': 1, 'username':'liuyazhuang', 'sex':'mail', 'age':'18', 'address':'chengdu'}]";
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
}
}
19
View Source File : UserServiceImpl.java
License : GNU Affero General Public License v3.0
Project Creator : ramostear
License : GNU Affero General Public License v3.0
Project Creator : ramostear
/**
* @author : ramostear/树下魅狐
* @version : Una-Boot-1.3.0
* <p>This java file was created by ramostear in 2020/5/28 0028 18:09.
* The following is the description information about this file:</p>
* <p>description:</p>
*/
@Service("userService")
public clreplaced UserServiceImpl extends BaseServiceImpl<User, Integer> implements UserService {
private final UserRepository userRepository;
@Autowired
public UserServiceImpl(UserRepository userRepository) {
super(userRepository);
this.userRepository = userRepository;
}
@Override
@Transactional
public User create(User user) {
replacedert.notNull(user, "User data must not be null");
replacedert.hasLength(user.getUsername(), "username can not be empty.");
replacedert.hasLength(user.getPreplacedword(), "preplacedword must not be null.");
replacedert.hasLength(user.getEmail(), "email must not be null.");
replacedert.isTrue(replacedertUtils.isEmail(user.getEmail()), "email address is incorrect.");
user.setPreplacedword(UnaBootUtils.simpleHash(user.getPreplacedword(), user.getUsername()));
return userRepository.save(user);
}
@Override
@Transactional
public User update(User user) {
replacedert.notNull(user, "user data must not be null.");
replacedert.hasLength(user.getUsername(), "User`s username must not be null.");
replacedert.hasLength(user.getEmail(), "User`s email must not be null.");
replacedert.isTrue(replacedertUtils.isEmail(user.getEmail()), "email address is incorrect.");
user.setUpdateTime(DateTimeUtils.now());
return userRepository.save(user);
}
@Override
public boolean usernameNotExists(String username) {
replacedert.hasLength(username, "username must not be null.");
User user = userRepository.findByUsername(username);
return user == null;
}
@Override
public boolean emailNotExists(String email) {
replacedert.hasLength(email, "email must not be null.");
replacedert.isTrue(replacedertUtils.isEmail(email), "email address is incorrect.");
User user = userRepository.findByEmail(email);
return user == null;
}
@Override
public Optional<User> findByPrincipal(String principal) {
if (StringUtils.isBlank(principal)) {
return Optional.empty();
}
User user;
if (replacedertUtils.isEmail(principal)) {
user = userRepository.findByEmail(principal);
} else {
user = userRepository.findByUsername(principal);
}
return (user == null) ? Optional.empty() : Optional.of(user);
}
@Override
public Long countByRole(String role) {
return userRepository.countByRole(role);
}
@Override
public Page<User> findAllByRole(String role, Pageable pageable) {
return userRepository.findAllByRole(role, pageable);
}
}
19
View Source File : UserServiceImpl.java
License : MIT License
Project Creator : PacktPublishing
License : MIT License
Project Creator : PacktPublishing
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Override
public String getUserCredentials(String username) {
Map<String, String> credentials = new HashMap<>();
AppPreplacedwordEncoder encoder = new AppPreplacedwordEncoder();
// Without salt
/*
credentials.put("sjctrags",encoder.md5Encoder("sjctrags", null));
credentials.put("admin", encoder.md5Encoder("admin", null));
credentials.put("hradmin", encoder.md5Encoder("hradmin", null));
*/
// With Salt (username as salt)
credentials.put("sjctrags", encoder.md5Encoder("sjctrags", "sjctrags"));
credentials.put("admin", encoder.md5Encoder("admin", "admin"));
credentials.put("hradmin", encoder.md5Encoder("hradmin", "hradmin"));
return credentials.get(username);
}
@Override
public Set<String> getuserRoles(String username) {
Map<String, Set<String>> roles = new HashMap<>();
Set<String> userA = new HashSet<>();
Set<String> userB = new HashSet<>();
Set<String> userC = new HashSet<>();
userA.add("ROLE_USER");
userB.add("ROLE_ADMIN");
userB.add("ROLE_USER");
userC.add("ROLE_HR");
userC.add("ROLE_ADMIN");
userC.add("ROLE_USER");
roles.put("sjctrags", userA);
roles.put("admin", userB);
roles.put("hradmin", userC);
return roles.get(username);
}
}
19
View Source File : UserServiceImpl.java
License : MIT License
Project Creator : PacktPublishing
License : MIT License
Project Creator : PacktPublishing
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Override
public String getUserCredentials(String username) {
Map<String, String> credentials = new HashMap<>();
AppPreplacedwordEncoder encoder = new AppPreplacedwordEncoder();
credentials.put("sjctrags", "sjctrags");
credentials.put("admin", "admin");
credentials.put("hradmin", "hradmin");
// Without salt
// credentials.put("sjctrags",encoder.md5Encoder("sjctrags", null));
// credentials.put("admin", encoder.md5Encoder("admin", null));
// credentials.put("hradmin", encoder.md5Encoder("hradmin", null));
// With Salt (username as salt)
// credentials.put("sjctrags",encoder.md5Encoder("sjctrags", "sjctrags"));
// credentials.put("admin", encoder.md5Encoder("admin", "admin"));
// credentials.put("hradmin", encoder.md5Encoder("hradmin", "hradmin"));
return credentials.get(username);
}
@Override
public Set<String> getuserRoles(String username) {
Map<String, Set<String>> roles = new HashMap<>();
Set<String> userA = new HashSet<>();
Set<String> userB = new HashSet<>();
Set<String> userC = new HashSet<>();
userA.add("ROLE_USER");
userB.add("ROLE_ADMIN");
userB.add("ROLE_USER");
userC.add("ROLE_HR");
userC.add("ROLE_ADMIN");
userC.add("ROLE_USER");
roles.put("sjctrags", userA);
roles.put("admin", userB);
roles.put("hradmin", userC);
return roles.get(username);
}
}
19
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : Jerusalem01
License : Apache License 2.0
Project Creator : Jerusalem01
@Service("userService")
public clreplaced UserServiceImpl extends ServiceImpl<UserDao, UserEnreplacedy> implements UserService {
@Override
public UserEnreplacedy queryByMobile(String mobile) {
return baseMapper.selectOne(new QueryWrapper<UserEnreplacedy>().eq("mobile", mobile));
}
@Override
public long login(LoginForm form) {
UserEnreplacedy user = queryByMobile(form.getMobile());
replacedert.isNull(user, "手机号或密码错误");
// 密码错误
if (!user.getPreplacedword().equals(DigestUtils.sha256Hex(form.getPreplacedword()))) {
throw new RRException("手机号或密码错误");
}
return user.getUserId();
}
}
19
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : chubaostream
License : Apache License 2.0
Project Creator : chubaostream
/**
* Created by yangyang115 on 18-7-27.
*/
@Service("userService")
public clreplaced UserServiceImpl extends PageServiceSupport<User, QUser, UserRepository> implements UserService {
@Override
public User findByCode(final String code) {
if (code == null || code.isEmpty()) {
return null;
}
return repository.findByCode(code);
}
@Override
public List<User> findByCodes(List<String> codes) {
if (codes == null || codes.isEmpty()) {
return new ArrayList<>();
}
return repository.findByCodes(codes);
}
@Override
public List<User> findByIds(List<String> ids) {
if (ids == null || ids.isEmpty()) {
return new ArrayList<>();
}
return repository.findByIds(ids);
}
@Override
public List<User> findByAppId(final long appId) {
return repository.findByAppId(appId);
}
@Override
public int addAppUser(final ApplicationUser appUser) {
if (appUser == null) {
return 0;
}
return repository.addAppUser(appUser);
}
@Override
public List<User> findByAppCode(final String appCode) {
return repository.findByAppCode(appCode);
}
@Override
public int deleteAppUser(final long userId, final long appId) {
return repository.deleteAppUser(userId, appId);
}
@Override
public int deleteAppUserById(final long appUserId) {
return repository.deleteAppUserById(appUserId);
}
@Override
public ApplicationUser findAppUserById(long appUserId) {
return repository.findAppUserById(appUserId);
}
@Override
public ApplicationUser findAppUserByAppIdAndUserId(long appId, long userId) {
return repository.findAppUserByAppIdAndUserId(appId, userId);
}
@Override
public boolean belong(final long userId, final long appId) {
return repository.belong(userId, appId);
}
@Override
public List<User> findByWhereSql(String sql, Object obj) {
return repository.findByWhereSql(ObjectUtil.replaceSql(obj, sql));
}
@Override
public boolean validateWhereSql(String sql, Object obj) {
List<User> users = findByWhereSql(sql, obj);
if (NullUtil.isEmpty(users)) {
return false;
}
return true;
}
@Override
public List<User> findByRole(int role) {
return repository.findByRole(role);
}
}
18
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : zhupanlinch
License : Apache License 2.0
Project Creator : zhupanlinch
/**
* <p>
* 服务实现类
* </p>
*
* @author wangl
* @since 2017-10-31
*/
@Service("userService")
@Transactional(readOnly = true, rollbackFor = Exception.clreplaced)
public clreplaced UserServiceImpl extends ServiceImpl<UserDao, User> implements UserService {
/* 这里caching不能添加put 因为添加了总会执行该方法
* @see com.mysiteforme.service.UserService#findUserByLoginName(java.lang.String)
*/
@Cacheable(value = "user", key = "'user_name_'+#name", unless = "#result == null")
@Override
public User findUserByLoginName(String name) {
// TODO Auto-generated method stub
Map<String, Object> map = Maps.newHashMap();
map.put("loginName", name);
User u = baseMapper.selectUserByMap(map);
return u;
}
@Cacheable(value = "user", key = "'user_id_'+T(String).valueOf(#id)", unless = "#result == null")
@Override
public User findUserById(Long id) {
// TODO Auto-generated method stub
Map<String, Object> map = Maps.newHashMap();
map.put("id", id);
return baseMapper.selectUserByMap(map);
}
@Override
@Caching(put = { @CachePut(value = "user", key = "'user_id_'+T(String).valueOf(#result.id)", condition = "#result.id != null and #result.id != 0"), @CachePut(value = "user", key = "'user_name_'+#user.loginName", condition = "#user.loginName !=null and #user.loginName != ''"), @CachePut(value = "user", key = "'user_email_'+#user.email", condition = "#user.email != null and #user.email != ''"), @CachePut(value = "user", key = "'user_tel_'+#user.tel", condition = "#user.tel != null and #user.tel != ''") })
@Transactional(readOnly = false, rollbackFor = Exception.clreplaced)
public User saveUser(User user) {
ToolUtil.entryptPreplacedword(user);
user.setLocked(false);
baseMapper.insert(user);
// 保存用户角色关系
this.saveUserRoles(user.getId(), user.getRoleLists());
return findUserById(user.getId());
}
@Override
@Caching(evict = { @CacheEvict(value = "user", key = "'user_id_'+T(String).valueOf(#user.id)", condition = "#user.id != null and #user.id != 0"), @CacheEvict(value = "user", key = "'user_name_'+#user.loginName", condition = "#user.loginName !=null and #user.loginName != ''"), @CacheEvict(value = "user", key = "'user_email_'+#user.email", condition = "#user.email != null and #user.email != ''"), @CacheEvict(value = "user", key = "'user_tel_'+#user.tel", condition = "#user.tel != null and #user.tel != ''") })
@Transactional(readOnly = false, rollbackFor = Exception.clreplaced)
public User updateUser(User user) {
baseMapper.updateById(user);
// 先解除用户跟角色的关系
this.dropUserRolesByUserId(user.getId());
this.saveUserRoles(user.getId(), user.getRoleLists());
return user;
}
@Transactional(readOnly = false, rollbackFor = Exception.clreplaced)
@Override
public void saveUserRoles(Long id, Set<Role> roleSet) {
baseMapper.saveUserRoles(id, roleSet);
}
@Transactional(readOnly = false, rollbackFor = Exception.clreplaced)
@Override
public void dropUserRolesByUserId(Long id) {
baseMapper.dropUserRolesByUserId(id);
}
@Override
public int userCount(String param) {
EnreplacedyWrapper<User> wrapper = new EnreplacedyWrapper<>();
wrapper.eq("login_name", param).or().eq("email", param).or().eq("tel", param);
int count = baseMapper.selectCount(wrapper);
return count;
}
@Transactional(readOnly = false, rollbackFor = Exception.clreplaced)
@Override
@Caching(evict = { @CacheEvict(value = "user", key = "'user_id_'+T(String).valueOf(#user.id)", condition = "#user.id != null and #user.id != 0"), @CacheEvict(value = "user", key = "'user_name_'+#user.loginName", condition = "#user.loginName !=null and #user.loginName != ''"), @CacheEvict(value = "user", key = "'user_email_'+#user.email", condition = "#user.email != null and #user.email != ''"), @CacheEvict(value = "user", key = "'user_tel_'+#user.tel", condition = "#user.tel != null and #user.tel != ''") })
public void deleteUser(User user) {
user.setDelFlag(true);
user.updateById();
}
/**
* 查询用户拥有的每个菜单具体数量
* @return
*/
@Override
public Map selectUserMenuCount() {
return baseMapper.selectUserMenuCount();
}
@Override
public List<User> selectUserByRoleId(Long roleId) {
return baseMapper.selectUserByRoleId(roleId);
}
}
18
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : zhihuili
License : Apache License 2.0
Project Creator : zhihuili
@Service("userService")
public clreplaced UserServiceImpl {
@Autowired
private UserDao userDao;
public User searchUser(int id) {
return userDao.findUser(id);
}
}
18
View Source File : UserService.java
License : GNU General Public License v3.0
Project Creator : wlhbdp
License : GNU General Public License v3.0
Project Creator : wlhbdp
@Service("userService")
public clreplaced UserService extends BaseService<User> implements IUserService {
@Autowired
UserMapper userMapper;
@Override
public User getOneUser(Integer id) {
return userMapper.selectByPrimaryKey(id);
}
@Override
public IBaseMapper<User> getBaseMapper() {
return userMapper;
}
}
18
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : wangl1989
License : Apache License 2.0
Project Creator : wangl1989
/**
* <p>
* 服务实现类
* </p>
*
* @author wangl
* @since 2017-10-31
*/
@Service("userService")
@Transactional(readOnly = true, rollbackFor = Exception.clreplaced)
public clreplaced UserServiceImpl extends ServiceImpl<UserDao, User> implements UserService {
/* 这里caching不能添加put 因为添加了总会执行该方法
* @see com.mysiteforme.service.UserService#findUserByLoginName(java.lang.String)
*/
@Cacheable(value = "user", key = "'user_name_'+#name", unless = "#result == null")
@Override
public User findUserByLoginName(String name) {
// TODO Auto-generated method stub
Map<String, Object> map = Maps.newHashMap();
map.put("loginName", name);
User u = baseMapper.selectUserByMap(map);
return u;
}
@Cacheable(value = "user", key = "'user_id_'+T(String).valueOf(#id)", unless = "#result == null")
@Override
public User findUserById(Long id) {
// TODO Auto-generated method stub
Map<String, Object> map = Maps.newHashMap();
map.put("id", id);
return baseMapper.selectUserByMap(map);
}
@Override
@Caching(put = { @CachePut(value = "user", key = "'user_id_'+T(String).valueOf(#result.id)", condition = "#result.id != null and #result.id != 0"), @CachePut(value = "user", key = "'user_name_'+#user.loginName", condition = "#user.loginName !=null and #user.loginName != ''"), @CachePut(value = "user", key = "'user_email_'+#user.email", condition = "#user.email != null and #user.email != ''"), @CachePut(value = "user", key = "'user_tel_'+#user.tel", condition = "#user.tel != null and #user.tel != ''") })
@Transactional(readOnly = false, rollbackFor = Exception.clreplaced)
public User saveUser(User user) {
ToolUtil.entryptPreplacedword(user);
user.setLocked(false);
baseMapper.insert(user);
// 保存用户角色关系
this.saveUserRoles(user.getId(), user.getRoleLists());
return findUserById(user.getId());
}
@Override
@Caching(evict = { @CacheEvict(value = "user", key = "'user_id_'+T(String).valueOf(#user.id)", condition = "#user.id != null and #user.id != 0"), @CacheEvict(value = "user", key = "'user_name_'+#user.loginName", condition = "#user.loginName !=null and #user.loginName != ''"), @CacheEvict(value = "user", key = "'user_email_'+#user.email", condition = "#user.email != null and #user.email != ''"), @CacheEvict(value = "user", key = "'user_tel_'+#user.tel", condition = "#user.tel != null and #user.tel != ''") })
@Transactional(readOnly = false, rollbackFor = Exception.clreplaced)
public User updateUser(User user) {
baseMapper.updateById(user);
// 先解除用户跟角色的关系
this.dropUserRolesByUserId(user.getId());
this.saveUserRoles(user.getId(), user.getRoleLists());
return user;
}
@Transactional(readOnly = false, rollbackFor = Exception.clreplaced)
@Override
public void saveUserRoles(Long id, Set<Role> roleSet) {
baseMapper.saveUserRoles(id, roleSet);
}
@Transactional(readOnly = false, rollbackFor = Exception.clreplaced)
@Override
public void dropUserRolesByUserId(Long id) {
baseMapper.dropUserRolesByUserId(id);
}
@Override
public int userCount(String param) {
EnreplacedyWrapper<User> wrapper = new EnreplacedyWrapper<>();
wrapper.eq("login_name", param).or().eq("email", param).or().eq("tel", param);
int count = baseMapper.selectCount(wrapper);
return count;
}
@Transactional(readOnly = false, rollbackFor = Exception.clreplaced)
@Override
@Caching(evict = { @CacheEvict(value = "user", key = "'user_id_'+T(String).valueOf(#user.id)", condition = "#user.id != null and #user.id != 0"), @CacheEvict(value = "user", key = "'user_name_'+#user.loginName", condition = "#user.loginName !=null and #user.loginName != ''"), @CacheEvict(value = "user", key = "'user_email_'+#user.email", condition = "#user.email != null and #user.email != ''"), @CacheEvict(value = "user", key = "'user_tel_'+#user.tel", condition = "#user.tel != null and #user.tel != ''") })
public void deleteUser(User user) {
user.setDelFlag(true);
user.updateById();
}
/**
* 查询用户拥有的每个菜单具体数量
* @return
*/
@Override
public Map selectUserMenuCount() {
return baseMapper.selectUserMenuCount();
}
}
18
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : TFdream
License : Apache License 2.0
Project Creator : TFdream
/**
* ${DESCRIPTION}
*
* @author Ricky Fung
*/
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
private final AtomicLong counter = new AtomicLong(1);
@Override
public Long insert(User user) {
System.out.println("insert user" + user);
return 15L;
}
@Override
public List<User> getUsers(int age) {
List<User> users = new ArrayList<>();
for (int i = 0; i < 5; i++) {
User user = new User();
user.setId(counter.getAndIncrement());
user.setName("ricky_" + user.getId());
user.setPreplacedword("root");
user.setAge(age + i);
users.add(user);
}
return users;
}
@Override
public int update(User user) {
System.out.println("update user:" + user);
return 1;
}
}
18
View Source File : UserService.java
License : Apache License 2.0
Project Creator : soumyadip007
License : Apache License 2.0
Project Creator : soumyadip007
/**
* @author Soumyadip Chowdhury
* @github soumyadip007
*/
@Service("userService")
public clreplaced UserService {
private UserRepository userRepository;
@Autowired
public UserService(UserRepository userRepository) {
this.userRepository = userRepository;
}
public User findByEmail(String email) {
return userRepository.findByEmail(email);
}
public User findByConfirmationToken(String confirmationToken) {
return userRepository.findByConfirmationToken(confirmationToken);
}
public void saveUser(User user) {
userRepository.save(user);
}
public List<User> findAll() {
return userRepository.findAll();
}
}
18
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : smallFive55
License : Apache License 2.0
Project Creator : smallFive55
@Service("userService")
public clreplaced UserServiceImpl implements com.alibaba.dubbo.examples.rest.api.UserService {
private final AtomicLong idGen = new AtomicLong();
@Override
public User getUser(Long id) {
return new User(id, "username" + id);
}
@Override
public Long registerUser(User user) {
// System.out.println("Username is " + user.getName());
return idGen.incrementAndGet();
}
}
18
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : penggle
License : Apache License 2.0
Project Creator : penggle
@Validated
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Override
public void createUser(User user) {
System.out.println(">>> createUser : " + user);
}
@Override
public void updateUser(User user) {
System.out.println(">>> updateUser : " + user);
}
@Override
public void deleteUserById(Long userId) {
System.out.println(">>> deleteUserById : " + userId);
}
@Override
public void modifyPreplacedword(User user) {
System.out.println(">>> modifyPreplacedword : " + user);
}
@Override
public String resetPreplacedword(Long userId, String preplacedword) {
System.out.println(">>> modifyPreplacedword : " + userId + " , " + preplacedword);
return null;
}
}
18
View Source File : UserServiceImpl.java
License : MIT License
Project Creator : PacktPublishing
License : MIT License
Project Creator : PacktPublishing
/**
* @author Sourabh Sharma
*/
@Service("userService")
public clreplaced UserServiceImpl extends BaseService<User, String> implements UserService {
private UserRepository<User, String> userRepository;
/**
* @param userRepository
*/
@Autowired
public UserServiceImpl(UserRepository<User, String> userRepository) {
super(userRepository);
this.userRepository = userRepository;
}
@Override
public void add(User user) throws Exception {
if (userRepository.containsName(user.getName())) {
throw new Exception(String.format("There is already a product with the name - %s", user.getName()));
}
if (user.getName() == null || "".equals(user.getName())) {
throw new Exception("Booking name cannot be null or empty string.");
}
super.add(user);
}
/**
* @param name
* @return
* @throws Exception
*/
@Override
public Collection<User> findByName(String name) throws Exception {
return userRepository.findByName(name);
}
/**
* @param user
* @throws Exception
*/
@Override
public void update(User user) throws Exception {
userRepository.update(user);
}
/**
* @param id
* @throws Exception
*/
@Override
public void delete(String id) throws Exception {
userRepository.remove(id);
}
/**
* @param restaurantId
* @return
* @throws Exception
*/
@Override
public Enreplacedy findById(String restaurantId) throws Exception {
return userRepository.get(restaurantId);
}
/**
* @param name
* @return
* @throws Exception
*/
@Override
public Collection<User> findByCriteria(Map<String, ArrayList<String>> name) throws Exception {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
}
18
View Source File : UserServiceImpl.java
License : MIT License
Project Creator : PacktPublishing
License : MIT License
Project Creator : PacktPublishing
/**
* @author Sourabh Sharma
*/
@Service("userService")
public clreplaced UserServiceImpl extends BaseService<User, String> implements UserService {
private UserRepository<User, String> userRepository;
/**
* @param userRepository
*/
@Autowired
public UserServiceImpl(UserRepository<User, String> userRepository) {
super(userRepository);
this.userRepository = userRepository;
}
@Override
public void add(User user) throws Exception {
if (userRepository.containsName(user.getName())) {
throw new Exception(String.format("There is already a product with the name - %s", user.getName()));
}
if (user.getName() == null || "".equals(user.getName())) {
throw new Exception("Booking name cannot be null or empty string.");
}
super.add(user);
}
/**
* @param name
* @return
* @throws Exception
*/
@Override
public Collection<User> findByName(String name) throws Exception {
return userRepository.findByName(name);
}
/**
* @param user
* @throws Exception
*/
@Override
public void update(User user) throws Exception {
userRepository.update(user);
}
/**
* @param id
* @throws Exception
*/
@Override
public void delete(String id) throws Exception {
userRepository.remove(id);
}
/**
* @param id
* @return
* @throws Exception
*/
@Override
public Enreplacedy findById(String id) throws Exception {
return userRepository.get(id);
}
/**
* @param name
* @return
* @throws Exception
*/
@Override
public Collection<User> findByCriteria(Map<String, ArrayList<String>> name) throws Exception {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
}
18
View Source File : UserServiceImpl.java
License : MIT License
Project Creator : PacktPublishing
License : MIT License
Project Creator : PacktPublishing
/**
* @author Sourabh Sharma
*/
@Service("userService")
public clreplaced UserServiceImpl extends BaseService<User, String> implements UserService {
private UserRepository<User, String> userRepository;
/**
* @param userRepository
*/
@Autowired
public UserServiceImpl(UserRepository<User, String> userRepository) {
super(userRepository);
this.userRepository = userRepository;
}
@Override
public void add(User user) throws Exception {
if (userRepository.containsName(user.getName())) {
Object[] args = { user.getName() };
throw new DuplicateUserException("duplicateUser", args);
}
if (user.getName() == null || "".equals(user.getName())) {
Object[] args = { "User with null or empty name" };
throw new InvalidUserException("invalidUser", args);
}
super.add(user);
}
/**
* @param name
*/
@Override
public Collection<User> findByName(String name) throws Exception {
return userRepository.findByName(name);
}
/**
* @param user
*/
@Override
public void update(String id, User user) throws Exception {
userRepository.update(id, user);
}
/**
* @param id
*/
@Override
public void delete(String id) throws Exception {
userRepository.remove(id);
}
/**
* @param id
*/
@Override
public User findById(String id) throws Exception {
return userRepository.get(id);
}
/**
* @param name
*/
@Override
public Collection<User> findByCriteria(Map<String, ArrayList<String>> name) throws Exception {
throw new UnsupportedOperationException(// To change body of generated methods, choose Tools | Templates.
"Not supported yet.");
}
}
18
View Source File : UserServiceImpl.java
License : MIT License
Project Creator : PacktPublishing
License : MIT License
Project Creator : PacktPublishing
/**
* @author Sourabh Sharma
*/
@Service("userService")
public clreplaced UserServiceImpl extends BaseService<User, String> implements UserService {
private UserRepository<User, String> userRepository;
/**
* @param userRepository
*/
@Autowired
public UserServiceImpl(UserRepository<User, String> userRepository) {
super(userRepository);
this.userRepository = userRepository;
}
@Override
public void add(User user) throws Exception {
if (userRepository.containsName(user.getName())) {
Object[] args = { user.getName() };
throw new DuplicateUserException("duplicateUser", args);
}
if (user.getName() == null || "".equals(user.getName())) {
Object[] args = { "User with null or empty name" };
throw new InvalidUserException("invalidUser", args);
}
super.add(user);
}
/**
* @param name
*/
@Override
public Collection<User> findByName(String name) throws Exception {
return userRepository.findByName(name);
}
/**
* @param user
*/
@Override
public void update(User user) throws Exception {
userRepository.update(user);
}
/**
* @param id
*/
@Override
public void delete(String id) throws Exception {
userRepository.remove(id);
}
/**
* @param id
*/
@Override
public Enreplacedy findById(String id) throws Exception {
return userRepository.get(id);
}
/**
* @param name
*/
@Override
public Collection<User> findByCriteria(Map<String, ArrayList<String>> name) throws Exception {
throw new UnsupportedOperationException(// To change body of generated methods, choose Tools | Templates.
"Not supported yet.");
}
}
18
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : monkeyk
License : Apache License 2.0
Project Creator : monkeyk
/**
* 2016/6/3
*
* @author Shengzhao Li
*/
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Autowired
private UsersAuthzRepository usersAuthzRepository;
@Override
public UsersOverviewDto loadUsersOverviewDto(String username) {
List<Users> usersList = usersAuthzRepository.findUsersByUsername(username);
return new UsersOverviewDto(usersList, username);
}
@Override
public UsersFormDto loadUsersFormDto() {
UsersFormDtoLoader dtoLoader = new UsersFormDtoLoader();
return dtoLoader.load();
}
@Override
public boolean isExistedUsername(String username) {
final Users user = usersAuthzRepository.findByUsername(username);
return user != null;
}
@Override
public String saveUsers(UsersFormDto formDto) {
UsersFormSaver saver = new UsersFormSaver(formDto);
return saver.save();
}
}
18
View Source File : UserService.java
License : MIT License
Project Creator : Linliquan
License : MIT License
Project Creator : Linliquan
@Service("userService")
public clreplaced UserService extends AbstractService<User, User> implements IUserService {
public UserService() {
this.setTableName("user");
}
@Resource
private IUserMapper userMapper;
@Override
protected IOperations<User, User> getMapper() {
return userMapper;
}
@Override
public void setTableName(String tableName) {
this.tableName = tableName;
;
}
// public User getUserByName(String user_name) {
// User user = userMapper.getUserByName(user_name);
// return user;
// }
public String login(String user_name, String user_preplacedword) {
return userMapper.login(user_name, user_preplacedword);
}
public String getUserById(String user_name, String user_preplacedword) {
return userMapper.getUserById(user_name, user_preplacedword);
}
public String registJudge(String user_name) {
return userMapper.registJudge(user_name);
}
// 更改密码
public Integer resetPreplacedword(String user_name, String newUser_preplacedword) {
return userMapper.resetPreplacedword(user_name, newUser_preplacedword);
}
// 判断用户名是否重复
@Override
public String rearchUserName(String user_name) {
return userMapper.rearchUserName(user_name);
}
}
18
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
private final AtomicLong idGen = new AtomicLong();
@Override
public User getUser(Long id) {
return new User(id, "username" + id);
}
@Override
public Long registerUser(User user) {
// System.out.println("Username is " + user.getName());
return idGen.incrementAndGet();
}
}
18
View Source File : UserServiceImpl.java
License : MIT License
Project Creator : a466350665
License : MIT License
Project Creator : a466350665
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
private static List<User> userList;
static {
userList = new ArrayList<>();
userList.add(new User(1, "管理员", "admin", "123456"));
}
@Override
public Result<SsoUser> login(String username, String preplacedword) {
for (User user : userList) {
if (user.getUsername().equals(username)) {
if (user.getPreplacedword().equals(preplacedword)) {
return Result.createSuccess(new SsoUser(user.getId(), user.getUsername()));
} else {
return Result.createError("密码有误");
}
}
}
return Result.createError("用户不存在");
}
}
17
View Source File : UserServiceImpl.java
License : GNU General Public License v3.0
Project Creator : zhonghuasheng
License : GNU General Public License v3.0
Project Creator : zhonghuasheng
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Autowired
private UserDAO userDao;
@Override
public void add(User user) {
userDao.add(user);
}
@Override
public User getById(int id) {
return userDao.getById(id);
}
}
17
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : ZHENFENG13
License : Apache License 2.0
Project Creator : ZHENFENG13
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Autowired
private UserDao userDao;
@Override
public User login(User user) {
return userDao.login(user);
}
@Override
public List<User> queryList(Map<String, Object> map) {
return userDao.findUsers(map);
}
@Override
public int queryTotal(Map<String, Object> map) {
return userDao.getTotalUser(map);
}
@Override
public void save(User user) {
// 防止有人胡乱修改导致其他人无法正常登陆
if (!"admin".equals(user.getUserName().trim())) {
user.setPreplacedword(MD5Util.MD5Encode(user.getPreplacedword(), "UTF-8"));
user.setUserName(AntiXssUtil.replaceHtmlCode(user.getUserName()));
userDao.addUser(user);
}
}
@Override
public void updatePreplacedword(User user) {
// 防止有人胡乱修改导致其他人无法正常登陆
if (!"admin".equals(user.getUserName().trim())) {
user.setPreplacedword(MD5Util.MD5Encode(user.getPreplacedword(), "UTF-8"));
user.setUserName(AntiXssUtil.replaceHtmlCode(user.getUserName()));
userDao.updateUser(user);
}
}
@Override
public void delete(Integer id) {
userDao.deleteUser(id);
}
@Override
public void deleteBatch(Integer[] ids) {
userDao.deleteBatch(ids);
}
@Override
public User queryObject(Integer id) {
User user = userDao.getUserById(id);
if (user != null) {
user.setPreplacedword(null);
}
return user;
}
}
17
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : ZHENFENG13
License : Apache License 2.0
Project Creator : ZHENFENG13
/**
* @author [email protected]
* @project_name perfect-ssm
* @date 2017-3-1
*/
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Resource
private UserDao userDao;
@Override
public User login(User user) {
return userDao.login(user);
}
@Override
public List<User> findUser(Map<String, Object> map) {
return userDao.findUsers(map);
}
@Override
public int updateUser(User user) {
// 防止有人胡乱修改导致其他人无法正常登陆
if ("admin".equals(user.getUserName())) {
return 0;
}
user.setUserName(AntiXssUtil.replaceHtmlCode(user.getUserName()));
return userDao.updateUser(user);
}
@Override
public Long getTotalUser(Map<String, Object> map) {
return userDao.getTotalUser(map);
}
@Override
public int addUser(User user) {
if (user.getUserName() == null || user.getPreplacedword() == null || getTotalUser(null) > 90) {
return 0;
}
user.setUserName(AntiXssUtil.replaceHtmlCode(user.getUserName()));
return userDao.addUser(user);
}
@Override
public int deleteUser(Integer id) {
// 防止有人胡乱修改导致其他人无法正常登陆
if (2 == id) {
return 0;
}
return userDao.deleteUser(id);
}
}
17
View Source File : UserServiceImpl.java
License : GNU General Public License v3.0
Project Creator : zhaoqicheng
License : GNU General Public License v3.0
Project Creator : zhaoqicheng
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Autowired
private UserDao userDao;
@Override
public UserEnreplacedy queryObject(Long userId) {
return userDao.queryObject(userId);
}
@Override
public List<UserEnreplacedy> queryList(Map<String, Object> map) {
return userDao.queryList(map);
}
@Override
public int queryTotal(Map<String, Object> map) {
return userDao.queryTotal(map);
}
@Override
public void save(String mobile, String preplacedword) {
UserEnreplacedy user = new UserEnreplacedy();
user.setMobile(mobile);
user.setUsername(mobile);
user.setPreplacedword(DigestUtils.sha256Hex(preplacedword));
user.setCreateTime(new Date());
userDao.save(user);
}
@Override
public void update(UserEnreplacedy user) {
userDao.update(user);
}
@Override
public void delete(Long userId) {
userDao.delete(userId);
}
@Override
public void deleteBatch(Long[] userIds) {
userDao.deleteBatch(userIds);
}
@Override
public UserEnreplacedy queryByMobile(String mobile) {
return userDao.queryByMobile(mobile);
}
@Override
public long login(String mobile, String preplacedword) {
UserEnreplacedy user = queryByMobile(mobile);
replacedert.isNull(user, "手机号或密码错误");
// 密码错误
if (!user.getPreplacedword().equals(DigestUtils.sha256Hex(preplacedword))) {
throw new RRException("手机号或密码错误");
}
return user.getUserId();
}
}
17
View Source File : UserServiceImpl.java
License : MIT License
Project Creator : zhangjikai
License : MIT License
Project Creator : zhangjikai
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Resource(name = "userDao")
public UserDao userDao;
@Override
public void addUser(User user) {
userDao.addUser(user);
}
@Override
public void deleteUser() {
}
@Override
public boolean deleteUserById(int userId, int group) {
return userDao.deleteUserById(userId, group);
}
@Override
public void updateUser(User user) {
userDao.updateUser(user);
}
@Override
public User getUserByEmail(String email) {
return userDao.getUserByEmail(email);
}
@Override
public User getUserByName(String username) {
return userDao.getUserByName(username);
}
@Override
public User login(String username, String preplacedword) {
return userDao.getUserByName$Pw(username, preplacedword);
}
@Override
public Pager<User> listUsers(int pageNo, int pageSize) {
return userDao.listUserByPage(pageNo, pageSize);
}
}
17
View Source File : UserService.java
License : Apache License 2.0
Project Creator : yangengzhe
License : Apache License 2.0
Project Creator : yangengzhe
/**
* @date 2017年1月22日 下午7:27:24
* @author yangengzhe
*/
@Service("userService")
public clreplaced UserService implements IUserService {
@Resource
private UserMapper userDao;
@Override
public User getUserById(int userId) {
return this.userDao.selectByPrimaryKey(userId);
}
@Override
public User getUserByUID(int userUID) {
return this.userDao.selectByUID(userUID);
}
@Override
public String insertUser(Integer uid, String name, String photo, String sign) {
User u = getUserByUID(uid);
if (u != null && u.getUid().equals(uid))
return null;
User user = new User();
user.setAddtime(new Date());
user.setHeadphoto(photo);
user.setName(name);
user.setOnline(0);
user.setSign(sign);
user.setUid(uid);
user.setPreplacedword(Security.getPreplacedword(uid));
this.userDao.insert(user);
return null;
}
@Override
public List<User> searchUsersByKeyword(String keyword) {
if (keyword == null || keyword.equals(""))
return new ArrayList<User>();
return userDao.searchUserByKeyword(keyword);
}
}
17
View Source File : UserService.java
License : MIT License
Project Creator : wuyouzhuguli
License : MIT License
Project Creator : wuyouzhuguli
/**
* @author MrBird
*/
@Service("userService")
public clreplaced UserService {
private Logger log = LoggerFactory.getLogger(this.getClreplaced());
@Autowired
private RestTemplate restTemplate;
@HystrixCollapser(batchMethod = "findUserBatch", collapserProperties = { @HystrixProperty(name = "timerDelayInMilliseconds", value = "100") })
public Future<User> findUser(Long id) {
log.info("获取单个用户信息");
// return new AsyncResult<User>() {
// @Override
// public User invoke() {
// return restTemplate.getForObject("http://Server-Provider/user/{id}", User.clreplaced, id);
// }
// };
return null;
}
@HystrixCommand
public List<User> findUserBatch(List<Long> ids) {
log.info("批量获取用户信息,ids: " + ids);
User[] users = restTemplate.getForObject("http://Server-Provider/user/users?ids={1}", User[].clreplaced, StringUtils.join(ids, ","));
return Arrays.asList(users);
}
public String getCacheKey(Long id) {
return String.valueOf(id);
}
@CacheResult(cacheKeyMethod = "getCacheKey")
@HystrixCommand(fallbackMethod = "getUserDefault", commandKey = "getUserById", groupKey = "userGroup", threadPoolKey = "getUserThread")
public User getUser(Long id) {
log.info("获取用户信息");
return restTemplate.getForObject("http://Server-Provider/user/{id}", User.clreplaced, id);
}
@HystrixCommand(fallbackMethod = "getUserDefault2")
public User getUserDefault(Long id) {
String a = null;
// 测试服务降级
a.toString();
User user = new User();
user.setId(-1L);
user.setUsername("defaultUser");
user.setPreplacedword("123456");
return user;
}
public User getUserDefault2(Long id, Throwable e) {
System.out.println(e.getMessage());
User user = new User();
user.setId(-2L);
user.setUsername("defaultUser2");
user.setPreplacedword("123456");
return user;
}
public List<User> getUsers() {
return this.restTemplate.getForObject("http://Server-Provider/user", List.clreplaced);
}
public String addUser() {
User user = new User(1L, "mrbird", "123456");
HttpStatus status = this.restTemplate.postForEnreplacedy("http://Server-Provider/user", user, null).getStatusCode();
if (status.is2xxSuccessful()) {
return "新增用户成功";
} else {
return "新增用户失败";
}
}
@CacheRemove(commandKey = "getUserById")
@HystrixCommand
public void updateUser(@CacheKey("id") User user) {
this.restTemplate.put("http://Server-Provider/user", user);
}
public void deleteUser(@PathVariable Long id) {
this.restTemplate.delete("http://Server-Provider/user/{1}", id);
}
}
17
View Source File : UserService.java
License : GNU General Public License v3.0
Project Creator : wlhbdp
License : GNU General Public License v3.0
Project Creator : wlhbdp
@Service("userService")
public clreplaced UserService extends BaseService<User> implements IUserService {
@Autowired
UserMapper userMapper;
@Override
public User getOneUser(Integer id) {
return userMapper.selectByPrimaryKey(id);
}
@Override
public IBaseMapper<User> getBaseMapper() {
return userMapper;
}
public void runAdClickRealTimeTask() {
// userMapper.save()
}
}
17
View Source File : UserServiceImpl.java
License : MIT License
Project Creator : wangruns
License : MIT License
Project Creator : wangruns
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Autowired
private UserDao userDao;
public boolean findLogin(User u) {
boolean isUserExisted = false;
User result = userDao.selectByUser(u);
if (result != null) {
isUserExisted = true;
}
return isUserExisted;
}
public boolean isEmailExisted(String email) {
boolean isEmailExisted = false;
User result = userDao.selectByEmail(email);
if (result != null) {
isEmailExisted = true;
}
return isEmailExisted;
}
public boolean insert(User u) {
boolean isInsertSuccessful = false;
int affectedRows = userDao.insert(u);
if (affectedRows > 0) {
isInsertSuccessful = true;
}
return isInsertSuccessful;
}
public List<User> getAllRecords() {
return userDao.selectAll();
}
public List<Integer> getAllUserIdRecords() {
return userDao.selectAllUserId();
}
public boolean isHasPrivilege(HttpServletRequest request) {
boolean isHasPrivilege = false;
User user = userDao.selectByUser(Request.getUserFromHttpServletRequest(request));
if (user == null) {
return isHasPrivilege;
}
Role role = userDao.selectRoleByUserId(user.getUserId());
if (role != null) {
isHasPrivilege = true;
}
return isHasPrivilege;
}
public void batchDeleteById(int[] userIds) {
if (userIds == null) {
return;
}
userDao.deleteByIds(userIds);
}
public boolean tooQuickly(HttpServletRequest request, int minutes) {
// 第一次操作
if (request.getSession().getAttribute("lastTime") == null) {
request.getSession().setAttribute("lastTime", new SimpleDateFormat("mm").format(new Date()));
return false;
}
// 第二次及其以上的操作
String lastMinute = (String) request.getSession().getAttribute("lastTime");
String curMinute = new SimpleDateFormat("mm").format(new Date());
if (Math.abs(Integer.valueOf(curMinute) - Integer.valueOf(lastMinute)) <= minutes) {
return true;
}
request.getSession().setAttribute("lastTime", curMinute);
return false;
}
}
17
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : StevenWash
License : Apache License 2.0
Project Creator : StevenWash
/**
* UserService 接口ude实现类
* @author 没有蜡笔的小新 2015/12/21
*/
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
// @Resource("userDao")
@Autowired
private UserDao userDao = null;
// // getter和setter
// public UserDao getUserDao() {
// return userDao;
// }
//
// public void setUserDao(UserDao userDao) {
// this.userDao = userDao;
// }
@Override
public void addLogin(User user) {
user.setLoginId(XXShopUtil.getId());
user.setLoginTime(XXShopUtil.getNow());
userDao.addLogin(user.getLoginId(), user.getIp(), user.getName(), user.getLoginTime());
}
@Override
public void updateEmail(String id, String email) {
userDao.updateEmail(id, email);
}
@Override
public void updatePreplacedword(String id, String preplacedword) {
userDao.updatePreplacedword(id, preplacedword);
}
@Override
public void updatePhoneNum(String id, String phoneNum) {
System.out.println("ServiceLmpl :" + phoneNum);
userDao.updatePhoneNum(id, phoneNum);
}
@Override
public void register(User user) {
user.setId(XXShopUtil.getId());
user.setRegTime(XXShopUtil.getNow());
user.setRole("u");
user.setMoney(0);
userDao.addUser(user);
}
// @Override
// public User login(String name, String preplacedword) {
// return userDao.getUserByNameAndPwd(name, preplacedword);
// }
// 通过账号和密码查询用户
@Override
public User findUser(String name, String preplacedword) {
User user = this.userDao.getUserByNameAndPwd(name, preplacedword);
return user;
}
@Override
public boolean isexist(String name) {
int num = userDao.getNumByName(name);
return num != 0;
}
@Override
public void updateAvatar(String id, String avar) {
userDao.updateAvatar(id, avar);
}
@Override
public void updateMoney(String id, float money) {
userDao.updateMoney(id, money);
}
@Override
public List<User> getAllUser() {
return userDao.getAllUser();
}
@Override
public void deleteUser(String id) {
userDao.deleteUser(id);
}
@Override
public User getUser(String id) {
return userDao.getUser(id);
}
@Override
public void updateStatus(String id, int status) {
userDao.updateStatus(id, status);
}
@Override
public void updateMember(String memberId, Integer status, String memberId1, String preplacedword, String role) {
userDao.updateStatus(memberId, status);
userDao.updatePreplacedword(memberId, preplacedword);
userDao.updateRole(memberId, role);
}
}
17
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : leifchen
License : Apache License 2.0
Project Creator : leifchen
/**
* 用户Service的实现类
* <p>
* @Author LeifChen
* @Date 2019-02-26
*/
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Autowired
private UserMapper userMapper;
@Override
public JsonResult<User> login(String username, String preplacedword) {
int resultCount = userMapper.checkUsername(username);
if (resultCount == 0) {
return JsonResult.error("用户名不存在");
}
User user = userMapper.selectLogin(username, Md5Utils.encode(preplacedword));
if (user == null) {
return JsonResult.error("密码错误");
}
user.setPreplacedword(StringUtils.EMPTY);
return JsonResult.success("登录成功", user);
}
@Override
public JsonResult<String> register(User user) {
JsonResult<String> validResponse = checkValid(user.getUsername(), Const.USERNAME);
if (!validResponse.isSuccess()) {
return validResponse;
}
validResponse = checkValid(user.getEmail(), Const.EMAIL);
if (!validResponse.isSuccess()) {
return validResponse;
}
user.setRole(Const.Role.ROLE_CUSTOMER);
user.setPreplacedword(Md5Utils.encode(user.getPreplacedword()));
int resultCount = userMapper.insert(user);
if (resultCount == 0) {
return JsonResult.error("注册失败");
}
return JsonResult.success("注册成功");
}
@Override
public JsonResult<String> checkValid(String str, String type) {
if (StringUtils.isNotEmpty(type)) {
// 校验
if (Const.USERNAME.equals(type)) {
int resultCount = userMapper.checkUsername(str);
if (resultCount > 0) {
return JsonResult.error("用户名已存在");
}
} else if (Const.EMAIL.equals(type)) {
int resultCount = userMapper.checkEmail(str);
if (resultCount > 0) {
return JsonResult.error("email已存在");
}
} else {
return JsonResult.error("参数不合法");
}
} else {
return JsonResult.error(ResponseCodeEnum.ILLEGAL_ARGUMENT.getDesc());
}
return JsonResult.success("校验成功");
}
@Override
public JsonResult<String> selectQuestion(String username) {
JsonResult validResponse = checkValid(username, Const.USERNAME);
if (validResponse.isSuccess()) {
return JsonResult.error("用户不存在");
}
String question = userMapper.selectQuestionByUsername(username);
if (StringUtils.isNotBlank(question)) {
return JsonResult.success(question);
}
return JsonResult.error("找回密码的问题是空的");
}
@Override
public JsonResult<String> checkAnswer(String username, String question, String answer) {
int resultCount = userMapper.checkAnswer(username, question, answer);
if (resultCount > 0) {
String forgetToken = UUID.randomUUID().toString();
RedisShardedPoolUtils.setEx(Const.TOKEN_PREFIX + username, forgetToken, 60 * 60 * 12);
return JsonResult.success(forgetToken);
}
return JsonResult.error("问题的答案错误");
}
@Override
public JsonResult<String> forgetResetPreplacedword(String username, String preplacedwordNew, String forgetToken) {
if (StringUtils.isBlank(forgetToken)) {
return JsonResult.error("参数错误,token需要传递");
}
JsonResult validResponse = checkValid(username, Const.USERNAME);
if (validResponse.isSuccess()) {
return JsonResult.error("用户不存在");
}
String token = RedisShardedPoolUtils.get(Const.TOKEN_PREFIX + username);
if (StringUtils.isBlank(token)) {
return JsonResult.error("token无效或者过期");
}
if (StringUtils.equals(forgetToken, token)) {
String md5Preplacedword = Md5Utils.encode(preplacedwordNew);
int rowCount = userMapper.updatePreplacedwordByUsername(username, md5Preplacedword);
if (rowCount > 0) {
return JsonResult.success("修改密码成功");
}
} else {
return JsonResult.error("token错误,请重新获取重置密码的token");
}
return JsonResult.error("修改密码失败");
}
@Override
public JsonResult<String> resetPreplacedword(String preplacedwordOld, String preplacedwordNew, User user) {
int resultCount = userMapper.checkPreplacedword(Md5Utils.encode(preplacedwordOld), user.getId());
if (resultCount == 0) {
return JsonResult.error("旧密码错误");
}
user.setPreplacedword(Md5Utils.encode(preplacedwordNew));
int updateCount = userMapper.updateByPrimaryKeySelective(user);
if (updateCount > 0) {
return JsonResult.success("密码更新成功");
}
return JsonResult.error("密码更新失败");
}
@Override
public JsonResult<User> updateInformation(User user) {
int resultCount = userMapper.checkEmailByUserId(user.getEmail(), user.getId());
if (resultCount > 0) {
return JsonResult.error("email已存在,请更换email再尝试更新");
}
User updateUser = new User();
updateUser.setId(user.getId());
updateUser.setEmail(user.getEmail());
updateUser.setPhone(user.getPhone());
updateUser.setQuestion(user.getQuestion());
updateUser.setAnswer(user.getAnswer());
updateUser.setUpdateTime(new Date());
int updateCount = userMapper.updateByPrimaryKeySelective(updateUser);
if (updateCount > 0) {
return JsonResult.success("更新个人信息成功", updateUser);
}
return JsonResult.error("更新个人信息失败");
}
// backend
@Override
public JsonResult checkAdminRole(User user) {
if (user != null && user.getRole() == Const.Role.ROLE_ADMIN) {
return JsonResult.success();
}
return JsonResult.error();
}
}
17
View Source File : UserServiceImpl.java
License : MIT License
Project Creator : hzihui
License : MIT License
Project Creator : hzihui
/**
* @author HZI.HUI
* @date 2019/8/7 22:07
*/
@Service("userService")
@RequiredArgsConstructor
public clreplaced UserServiceImpl implements UserService {
private final ProductService productService;
@Override
public UserVO getUserAndProductsByUserId(String userId) {
User user = User.builder().id("2000").name("Feign").gender("男").age(18).build();
UserVO userVO = new UserVO();
BeanUtils.copyProperties(user, userVO);
userVO.setBakcName(productService.getProductByUserId(user.getName()));
return userVO;
}
}
17
View Source File : IUserServiceImpl.java
License : Apache License 2.0
Project Creator : huifer
License : Apache License 2.0
Project Creator : huifer
@Slf4j
@Service("userService")
public clreplaced IUserServiceImpl implements IUserService {
final TUserMapper userMapper;
public IUserServiceImpl(TUserMapper userMapper) {
this.userMapper = userMapper;
}
@Override
public Result<Boolean> settingRole(UserBindRoleReq req) {
return null;
}
@Override
public Result<Boolean> delete(IdsReq req) {
if (req != null) {
List<Long> ids = req.getIds();
if (!ids.isEmpty()) {
int del = this.userMapper.deleteBatchIds(ids);
return (del > 0) ? OkResult.DELETE.to(Boolean.TRUE) : ErrorResult.DELETE.to(Boolean.FALSE);
}
}
throw new IllegalArgumentException("参数不存在");
}
@Override
public Result<Boolean> editor(UserEditorReq req) {
if (req != null) {
TUser tUser = userMapper.selectById(req.getId());
if (tUser != null) {
if (StringUtils.isNotBlank(req.getUsername())) {
tUser.setUserName(req.getUsername());
}
if (StringUtils.isNotBlank(req.getPreplacedword())) {
tUser.setPreplacedword(Md5Util.MD5(req.getPreplacedword()));
}
int update = this.userMapper.updateById(tUser);
return (update > 0) ? OkResult.UPDATE.to(Boolean.TRUE) : ErrorResult.UPDATE.to(Boolean.FALSE);
}
}
throw new IllegalArgumentException("当前id用户名不存在");
}
@Override
public Result<Page<UserQueryRes>> query(UserQueryReq req, PageReq pageReq) {
Page page = new Page<>(pageReq.getNum(), pageReq.getSize());
QueryWrapper<TUser> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotBlank(req.getUsername())) {
queryWrapper.like(TUser.COL_USER_NAME, req.getUsername());
}
queryWrapper.orderByDesc(TUser.COL_CREATE_TIME);
Page tUserPage = this.userMapper.selectPage(page, queryWrapper);
List<UserQueryRes> res = new ArrayList<>();
List<TUser> records = tUserPage.getRecords();
for (TUser record : records) {
UserQueryRes userQueryRes = new UserQueryRes();
BeanUtils.copyProperties(record, userQueryRes);
res.add(userQueryRes);
}
tUserPage.setRecords(res);
return OkResult.QUERY.to(tUserPage);
}
@Override
public Result<Boolean> add(UserAddReq req) {
TUser convert = req.convert();
convert.setCreateTime(LocalDateTime.now());
convert.setUpdateTime(LocalDateTime.now());
// todo: 2020/5/27 设置create_user
int insert = userMapper.insert(convert);
return (insert > 0) ? OkResult.INSERT.to(Boolean.TRUE) : ErrorResult.INSERT.to(Boolean.FALSE);
}
}
17
View Source File : UserServiceimpl.java
License : MIT License
Project Creator : hsxhsx
License : MIT License
Project Creator : hsxhsx
@Service("userService")
// 本类内方法指定使用缓存时,默认的名称就是userCach
@CacheConfig(cacheNames = "User")
@Transactional
public clreplaced UserServiceimpl implements UserService {
@Autowired
private com.hsx.myshop.dao.userMapper userMapper;
@Override
@Cacheable(key = "getMethodName()")
public List<User> findAll() {
try {
List<User> list = userMapper.selectAll();
return list;
} catch (Exception e) {
System.out.println(e);
}
return null;
}
@CachePut(value = "#user", key = "#userDto.username")
public Response addUser(UserDto userDto) {
Response response = new Response();
try {
User user = new User();
user.setUsername(userDto.getUsername());
user.setPreplacedword(userDto.getPreplacedword());
long id = SnowFlake.nextId();
user.setId(id);
userMapper.insert(user);
response.setCode(ResponseCode.SUCCESS.toString());
response.setMsg(ResponseMsg.SUCCESS.toString());
} catch (Exception e) {
response.setCode(ResponseCode.FAILURE.toString());
response.setMsg(ResponseMsg.FAILURE.toString());
response.setData(e.toString());
}
return response;
}
}
17
View Source File : UserService.java
License : MIT License
Project Creator : gauravrmazra
License : MIT License
Project Creator : gauravrmazra
/**
* @author Mazra, Gaurav Rai
*/
@Service("userService")
public clreplaced UserService {
private static final AtomicLong counter = new AtomicLong(0);
private List<User> users = new ArrayList<>();
public UserService() {
}
public List<User> findAllUsers() {
return users;
}
public Optional<User> findById(final long id) {
return users.stream().filter(user -> user.getId() == id).findFirst();
}
public Optional<User> findByName(final String name) {
return users.stream().filter(user -> user.getUsername().equalsIgnoreCase(name)).findFirst();
}
public void saveUser(final User user) {
user.setId(counter.incrementAndGet());
users.add(user);
}
public void updateUser(final User user) {
int index = users.indexOf(user);
users.set(index, user);
}
public void deleteUserById(final long id) {
for (Iterator<User> iterator = users.iterator(); iterator.hasNext(); ) {
User user = iterator.next();
if (user.getId() == id) {
iterator.remove();
}
}
}
public boolean userExists(final User user) {
return findByName(user.getUsername()).isPresent();
}
}
17
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : devops-dojo
License : Apache License 2.0
Project Creator : devops-dojo
/**
* @author zutherb
*/
@Service("userService")
public clreplaced UserServiceImpl extends AbstractServiceImpl<UserInfo, User> implements UserService {
private UserRepository userRepository;
private ShaPreplacedwordEncoder preplacedwordEncoder;
@Value("${authentication.salt}")
private String authenticationSalt;
@Autowired
public UserServiceImpl(@Qualifier("userRepository") UserRepository repository, @Qualifier("dozerMapper") Mapper dozerMapper, @Qualifier("userPreplacedwordEncoder") ShaPreplacedwordEncoder preplacedwordEncoder) {
super(repository, dozerMapper, UserInfo.clreplaced, User.clreplaced);
this.userRepository = repository;
this.preplacedwordEncoder = preplacedwordEncoder;
}
@Override
public UserInfo findById(ObjectId userId) {
User user = userRepository.findById(userId);
return (user != null) ? getDozerMapper().map(user, UserInfo.clreplaced) : null;
}
@Override
public UserInfo findByUsername(String username) {
User user = userRepository.findByUsername(username);
return (user != null) ? getDozerMapper().map(user, UserInfo.clreplaced) : null;
}
@Override
public boolean existsUserWithEmail(String email) {
return userRepository.existsUserWithEmail(email);
}
@Override
public List<UserInfo> findAll() {
return super.findAll();
}
@Override
public void save(UserInfo userInfo) {
if (!userInfo.isPersisted()) {
String preplacedword = preplacedwordEncoder.encodePreplacedword(userInfo.getPreplacedword(), authenticationSalt);
userInfo = new UserInfo(userInfo.getFirstname(), userInfo.getLastname(), userInfo.getUsername(), userInfo.getEmail(), preplacedword, userInfo.getRoles(), userInfo.getAddress());
}
super.save(userInfo);
}
}
17
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : ccfish86
License : Apache License 2.0
Project Creator : ccfish86
/**
* Created by wx on 2017/10/27.
*/
@Service("userService")
public clreplaced UserServiceImpl implements IUserService {
@Resource
private IMUserMapper userMapper;
@Override
public IMUser getUserById(Integer userId) {
return userMapper.selectUserById(userId);
}
@Override
public IMUser getUserByName(String userName) {
return userMapper.selectUserByName(userName);
}
@Override
public List<IMUser> getAllUser() {
return userMapper.selectAllUser();
}
@Override
public Boolean addUser(IMUser user) {
return userMapper.insertSelective(user) > 0;
}
@Override
public Boolean deleteUser(Integer id) {
return userMapper.deleteByPrimaryKey(id) > 0;
}
@Override
public Boolean updateUser(IMUser user) {
return userMapper.updateByPrimaryKeySelective(user) > 0;
}
@Override
public Boolean updatePreplacedword(IMUser user) {
return userMapper.updatePreplacedwordSelective(user) > 0;
}
}
17
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : aberic
License : Apache License 2.0
Project Creator : aberic
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Resource
private UserMapper userMapper;
@Resource
private RoleMapper roleMapper;
@Override
public int init(User user) {
if (StringUtils.isEmpty(user.getUsername()) || StringUtils.isEmpty(user.getPreplacedword())) {
return 0;
}
if (null != userMapper.get(user.getUsername())) {
return update(user);
}
return add(user);
}
@Override
public int add(User user) {
if (StringUtils.isEmpty(user.getUsername()) || StringUtils.isEmpty(user.getPreplacedword())) {
return 0;
}
user.setDate(DateUtil.getCurrent("yyyyMMddHHmmss"));
return userMapper.add(user);
}
@Override
public int create(User user) {
if (StringUtils.isEmpty(user.getUsername()) || StringUtils.isEmpty(user.getPreplacedword())) {
return 0;
}
if (null != userMapper.get(user.getUsername())) {
return 0;
}
user.setPreplacedword(MD5Util.md5(user.getPreplacedword()));
user.setDate(DateUtil.getCurrent("yyyyMMddHHmmss"));
return add(user);
}
@Override
public int delete(int id) {
return userMapper.delete(id);
}
@Override
public int update(User user) {
return userMapper.update(user);
}
@Override
public int upgrade(User user) {
if (StringUtils.isEmpty(user.getUsername()) || StringUtils.isEmpty(user.getPreplacedword())) {
return 0;
}
user.setPreplacedword(MD5Util.md5(user.getPreplacedword()));
return userMapper.upgrade(user);
}
@Override
public int updatePreplacedword(User user) {
if (StringUtils.isEmpty(user.getUsername()) || StringUtils.isEmpty(user.getPreplacedword())) {
return 0;
}
user.setPreplacedword(MD5Util.md5(user.getPreplacedword()));
return userMapper.updatePreplacedword(user);
}
@Override
public int updateRole(User user) {
return userMapper.updateRole(user);
}
@Override
public int setRole(User user) {
return userMapper.setRole(user);
}
@Override
public List<User> listAll() {
List<User> users = userMapper.listAll();
for (User user : users) {
try {
user.setDate(DateUtil.strDateFormat(user.getDate(), "yyyyMMddHHmmss", "yyyy/MM/dd HH:mm:ss"));
user.setRoleName(roleMapper.getRoleById(user.getRoleId()).getName());
} catch (Exception e) {
e.printStackTrace();
}
}
return users;
}
@Override
public List<Role> listRole() {
return roleMapper.listRole();
}
@Override
public User get(String username) {
return userMapper.get(username);
}
@Override
public User get(int id) {
return userMapper.getById(id);
}
@Override
public String login(User user) {
User userCache = userMapper.get(user.getUsername());
try {
if (MD5Util.verify(user.getPreplacedword(), userCache.getPreplacedword())) {
String token = UUID.randomUUID().toString();
// CacheUtil.putString(user.getUsername(), token);
CacheUtil.putUser(token, userCache);
return token;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public int addRole(Role role) {
return roleMapper.add(role);
}
@Override
public int addRoleList(List<Role> roles) {
if (roles.size() > 0) {
return roleMapper.addList(roles);
}
return 0;
}
@Override
public Role getRoleById(int id) {
return roleMapper.getRoleById(id);
}
}
17
View Source File : UserServiceImpl.java
License : MIT License
Project Creator : 632team
License : MIT License
Project Creator : 632team
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Autowired
private UserDao userDao;
@Override
public User login(User u) {
return userDao.selectUserByUserNameAndPreplacedword(u);
}
@Override
public void insertUser(User u) {
userDao.insertUser(u);
}
@Override
public void updateUser(User u) {
userDao.updateUser(u);
}
@Override
public User selectUserByName(User u) {
return userDao.selectUserByUserName(u);
}
@Override
public List<User> selectAllUser() {
return userDao.selectAllUser();
}
@Override
public void delete(User u) {
userDao.deleteUser(u);
}
}
16
View Source File : UserServiceImpl.java
License : MIT License
Project Creator : yuuki80code
License : MIT License
Project Creator : yuuki80code
/**
* (User)表服务实现类
*
* @author makejava
* @since 2019-08-28 21:04:38
*/
@Service("userService")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public clreplaced UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
final UserMapper userMapper;
final UserRoleService userRoleService;
@Override
public UserVo findByUsername(String username) {
return this.userMapper.findByUsername(username);
}
@Override
public Page selectUserWithRoleAndDept(PageInfo params, User user) {
return userMapper.selectUserWithRoleAndDept(new QueryRequest(params), user);
}
@Override
@Transactional(rollbackFor = Exception.clreplaced)
public Response addUser(UserVo user) {
UserVo byUsername = findByUsername(user.getUsername());
if (byUsername != null) {
return Response.faild("用户名已存在");
}
User user1 = new User();
BeanUtils.copyProperties(user, user1);
user1.setPreplacedword(new BCryptPreplacedwordEncoder().encode(user.getPreplacedword()));
this.save(user1);
user.setId(user1.getId());
setUserRole(user);
return Response.success("新增成功");
}
@Override
@Transactional(rollbackFor = Exception.clreplaced)
public Response editUser(UserVo user) {
User user1 = new User();
BeanUtils.copyProperties(user, user1);
user1.setPreplacedword(null);
this.updateById(user1);
userRoleService.remove(new LambdaQueryWrapper<UserRole>().ge(UserRole::getUserId, user1.getId()));
setUserRole(user);
return Response.success("修改成功");
}
@Override
public Response deleteUsers(String ids) {
List<String> strings = Arrays.asList(Strings.split(ids, ","));
this.removeByIds(strings);
userRoleService.remove(new LambdaQueryWrapper<UserRole>().in(UserRole::getUserId, strings));
return Response.success("删除成功");
}
@Override
public Response updateAvatar(String avatar) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String username = (String) authentication.getPrincipal();
this.update(new LambdaUpdateWrapper<User>().eq(User::getUsername, username).set(Strings.isNotEmpty(username), User::getAvatar, avatar));
return Response.success("更新成功");
}
private void setUserRole(UserVo user) {
List<UserRole> userRoles = user.getRoleIds().stream().map(roleId -> {
UserRole userRole = new UserRole();
userRole.setRoleId(roleId);
userRole.setUserId(user.getId());
return userRole;
}).collect(Collectors.toList());
userRoleService.saveBatch(userRoles);
}
@Override
public UserVo findByPhone(String phone) {
return this.userMapper.findByPhone(phone);
}
}
16
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : yjjdick
License : Apache License 2.0
Project Creator : yjjdick
@Service("userService")
public clreplaced UserServiceImpl extends BaseServiceImpl<UserDao, User> implements UserService {
@Autowired
AreaService areaService;
@Autowired
private SnService snService;
@Override
public User queryByMobile(String mobile) {
User user = new User();
user.setMobile(mobile);
return this.findFirstByModel(user);
}
@Override
public String login(LoginForm form) {
User user = queryByMobile(form.getMobile());
replacedert.isNull(user, "手机号或密码错误");
// 密码错误
if (!user.getPreplacedword().equals(DigestUtils.sha256Hex(form.getPreplacedword()))) {
throw new RRException("手机号或密码错误");
}
return user.getUserId();
}
@Override
public User addMaUser(WxMaUserInfo wxMaUserInfo) {
User user = new User();
String userId = snService.generate(SnEnum.USER);
user.setUserId(userId);
user.setAvatar(wxMaUserInfo.getAvatarUrl());
user.setMaOpenId(wxMaUserInfo.getOpenId());
user.setNickname(wxMaUserInfo.getNickName());
user.setGender(Integer.parseInt(wxMaUserInfo.getGender()));
user.setUnionId(wxMaUserInfo.getUnionId());
Language language = Language.getByEnumName(wxMaUserInfo.getLanguage());
user.setLanguage((int) language.getValue());
user.save();
return user;
}
@Override
public Integer getYestodayNewUsers() {
List<Filter> filterList = new ArrayList<>();
Filter start = new Filter();
start.setOperator(Filter.Operator.ge);
start.setProperty("create_date");
Date todayBegin = DateUtil.beginOfDay(new Date());
todayBegin = DateUtil.offsetDay(todayBegin, -1);
start.setValue(todayBegin);
filterList.add(start);
Filter end = new Filter();
end.setOperator(Filter.Operator.le);
end.setProperty("create_date");
Date todayEnd = DateUtil.endOfDay(new Date());
todayEnd = DateUtil.offsetDay(todayEnd, -1);
end.setValue(todayEnd);
filterList.add(end);
List<User> userList = this.findByFilters(filterList);
return userList.size();
}
@Override
public Integer getTotalUsers() {
List<User> users = this.findAll();
return users.size();
}
}
16
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : wjggwm
License : Apache License 2.0
Project Creator : wjggwm
@Service("userService")
public clreplaced UserServiceImpl extends AbstractService<UserEnreplacedy, Long> implements UserService {
@Autowired
private UserMapper userMapper;
@Autowired
private EmailUtil emailUtil;
// 这句必须要加上。不然会报空指针异常,因为在实际调用的时候不是BaseMapper调用,而是具体的mapper,这里为userMapper
@Autowired
public void setBaseMapper() {
super.setBaseMapper(userMapper);
}
/**
* 重写用户插入,逻辑:
* 1、插入用户
* 2、插入用户和角色的对应关系
* 3、插入用户的个人资料信息
*/
public int insert(UserEnreplacedy userEnreplacedy, String preplacedword) {
try {
if (userMapper.insert(userEnreplacedy) == 1) {
if (userMapper.insertUserRole(userEnreplacedy) == 1) {
userEnreplacedy.getUserInfo().setId(userEnreplacedy.getId());
int cnt = userMapper.insertUserInfo(userEnreplacedy);
// 发送邮件
emailUtil.send126Mail(userEnreplacedy.getAccountName(), "系统消息通知", "您好,您的账户已创建,账户名:" + userEnreplacedy.getAccountName() + " ,密码:" + preplacedword);
return cnt;
} else {
throw new ServiceException("更新用户: " + userEnreplacedy.getId() + " 的权限信息失败");
}
} else {
throw new ServiceException("新增用户: " + userEnreplacedy.getId() + " 失败");
}
} catch (Exception e) {
throw new ServiceException(e);
}
}
/**
* 重写用户更新逻辑:
* 1、更新用户
* 2、更新用户和角色的对应关系
* 3、更新用户个人资料信息
*/
public int update(UserEnreplacedy userEnreplacedy) {
try {
if (userMapper.update(userEnreplacedy) == 1) {
if (userMapper.updateUserRole(userEnreplacedy) == 1) {
int result = userMapper.updateUserInfo(userEnreplacedy);
ShiroAuthenticationManager.clearUserAuthByUserId(userEnreplacedy.getId());
return result;
} else {
return 0;
}
} else {
return 0;
}
} catch (Exception e) {
throw new ServiceException(e);
}
}
/**
* 重写用户删除逻辑:
* 1、删除用户和角色的对应关系
* 2、删除用户
*/
public int deleteBatchById(List<Long> userIds) {
try {
int result = userMapper.deleteBatchUserRole(userIds);
if (result == userIds.size()) {
return userMapper.deleteBatchById(userIds);
} else {
return 0;
}
} catch (Exception e) {
throw new ServiceException(e);
}
}
@Override
public int updateOnly(UserEnreplacedy userEnreplacedy) throws ServiceException {
try {
int cnt = userMapper.update(userEnreplacedy);
return cnt;
} catch (Exception e) {
throw new ServiceException(e);
}
}
@Override
public int updatePreplacedword(UserEnreplacedy userEnreplacedy, String preplacedword) throws ServiceException {
try {
int cnt = updateOnly(userEnreplacedy);
// 发送邮件
emailUtil.send126Mail(userEnreplacedy.getAccountName(), "系统密码重置", "您好,您的密码已重置,新密码是:" + preplacedword);
return cnt;
} catch (Exception e) {
throw new ServiceException(e);
}
}
}
16
View Source File : UserDetailsServiceImpl.java
License : Apache License 2.0
Project Creator : u014427391
License : Apache License 2.0
Project Creator : u014427391
/**
* <pre>
*
* </pre>
*
* <pre>
* @author mazq
* 修改记录
* 修改后版本: 修改人: 修改日期: 2020/04/30 15:15 修改内容:
* </pre>
*/
@Slf4j
@Service("userService")
public clreplaced UserDetailsServiceImpl implements UserDetailsService {
@Autowired
UserMapper userRepository;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
User user = userRepository.findByUsername(username);
/*if(user == null){
//log.info("登录用户{},用户名或密码错误!",username);
throw new UsernameNotFoundException("登录用户["+username + "]用户名或密码错误!");
}*/
return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPreplacedword(), getAuthority());
}
private List getAuthority() {
return Arrays.asList(new SimpleGrantedAuthority("ROLE_ADMIN"));
// return Arrays.asList(Collections.emptyList());
}
}
16
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : ShuaiMou
License : Apache License 2.0
Project Creator : ShuaiMou
@Service("userService")
public clreplaced UserServiceImpl implements UserService {
@Resource
private UserMapper userMapper;
@Resource
private RedisUtils redisUtils;
/**
* 功能:验证用户密码和账号是否匹配
*
* @param email 客户端传入到邮箱,也就是登录账户
* @param preplacedword 密码
* @return JsonData 登录成功还是失败
*/
@Override
public JsonData checkLogin(String email, String preplacedword) {
User user = userMapper.findByEmail(email);
// check email
if (null == user) {
throw new BusinessException(StateType.UNAUTHORIZED.getCode(), "the email does not exits");
}
// check preplacedword
String psw = EncriptionUtils.EncoderByMD5(preplacedword);
if (!user.getPreplacedword().equals(psw)) {
throw new BusinessException(StateType.UNAUTHORIZED.getCode(), "wrong preplacedword ");
}
return JsonData.buildSuccess(user);
}
/**
* 功能:完成用户注册,将信息验证并存入数据库
*
* @param user user对象
* @param verificationCode 注册验证码
* @return JsonData注册成功或者失败
*/
@Override
@Transactional(rollbackFor = Exception.clreplaced)
public JsonData register(User user, String verificationCode) throws BusinessException {
User tempUser = userMapper.findByEmail(user.getEmail());
// check user
if (null != tempUser) {
// exits
throw new BusinessException(StateType.UNAUTHORIZED.getCode(), "the email has registered");
} else if (verificationCode == null || !verificationCode.equalsIgnoreCase((String) redisUtils.get(user.getEmail()))) {
throw new BusinessException(StateType.UNAUTHORIZED.getCode(), "验证码不正确,请重试");
} else {
// add user
user.setPreplacedword(EncriptionUtils.EncoderByMD5(user.getPreplacedword()));
user.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
user.setUpdateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
// store in database
return JsonData.buildSuccess(user);
}
}
/**
* 功能:更新用户个人信息
*
* @param user 用户对象
* @return JsonData
*/
@Override
@Transactional(rollbackFor = Exception.clreplaced)
public JsonData updatePersonalInfo(User user) {
userMapper.updateInformation(user);
return JsonData.buildSuccess(userMapper.findByEmail(user.getEmail()));
}
}
16
View Source File : UserServiceAnnotationImpl.java
License : MIT License
Project Creator : PacktPublishing
License : MIT License
Project Creator : PacktPublishing
@Service("userService")
public clreplaced UserServiceAnnotationImpl implements UserService {
Logger logger = LoggerFactory.getLogger(UserServiceAnnotationImpl.clreplaced);
@Autowired
private UserDAO userDAO;
public UserServiceAnnotationImpl() {
logger.debug("SimpleTaskService instantiated");
}
public User findById(int userId) {
return this.userDAO.findById(userId);
}
public User findByUserName(String userName) {
return this.userDAO.findByUserName(userName);
}
public User createNewUser(String name, String userName, String preplacedword) {
User newUser = new User(-1, name, userName, preplacedword);
this.userDAO.createUser(newUser);
logger.debug("New user created successfully: " + newUser);
return newUser;
}
}
See More Examples