Search in sources :

Example 1 with SysUserBaseInfo

use of tk.ainiyue.danyuan.application.user.userbase.po.SysUserBaseInfo in project danyuan-application by 514840279.

the class SysUserBaseController method save.

@ApiOperation(value = "修改角色信息", notes = "")
@RequestMapping(path = "/save", method = RequestMethod.POST)
@ResponseBody
public String save(@RequestBody SysUserBaseInfo info) {
    logger.info("save", SysUserBaseController.class);
    try {
        SysUserBaseInfo baseInfo = sysUserBaseService.findByName(info.getUserName());
        if (baseInfo == null) {
            info.setUuid(UUID.randomUUID().toString().replaceAll("-", ""));
            encryptPassword(info);
            sysUserBaseService.save(info);
        } else {
            return "用户名已存在";
        }
        return "1";
    } catch (Exception e) {
        return "0";
    }
}
Also used : SysUserBaseInfo(tk.ainiyue.danyuan.application.user.userbase.po.SysUserBaseInfo) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with SysUserBaseInfo

use of tk.ainiyue.danyuan.application.user.userbase.po.SysUserBaseInfo in project danyuan-application by 514840279.

the class SysUserBaseServiceImpl method findAllBySearchText.

/**
 * 方法名 : findAllBySearchText
 * 功 能 : TODO(这里用一句话描述这个方法的作用)
 * 参 数 : @param pageNumber
 * 参 数 : @param pageSize
 * 参 数 : @param info
 * 参 数 : @return
 * 参 考 : @see
 * tk.ainiyue.danyuan.application.user.userbase.service.SysUserBaseService#findAllBySearchText(int,
 * int, tk.ainiyue.danyuan.application.user.userbase.po.SysUserBaseInfo)
 * 作 者 : Administrator
 */
@Override
public Page<SysUserBaseInfo> findAllBySearchText(int pageNumber, int pageSize, SysUserBaseInfo info) {
    // logger.info(tableUuid, SysColumnServiceImpl.class);
    // Page<SysColumnInfo> list = sysColumnDao.findAllByTableUuid(tableUuid);
    Example<SysUserBaseInfo> example = Example.of(info);
    Sort sort = new Sort(new Order(Direction.ASC, "createTime"));
    PageRequest request = new PageRequest(pageNumber - 1, pageSize, sort);
    Page<SysUserBaseInfo> sourceCodes = sysUserBaseDao.findAll(example, request);
    return sourceCodes;
}
Also used : Order(org.springframework.data.domain.Sort.Order) PageRequest(org.springframework.data.domain.PageRequest) Sort(org.springframework.data.domain.Sort) SysUserBaseInfo(tk.ainiyue.danyuan.application.user.userbase.po.SysUserBaseInfo)

Example 3 with SysUserBaseInfo

use of tk.ainiyue.danyuan.application.user.userbase.po.SysUserBaseInfo in project danyuan-application by 514840279.

the class SysUserBaseServiceImpl method findByName.

/**
 * 方法名 : findByName
 * 功 能 : TODO(这里用一句话描述这个方法的作用)
 * 参 数 : @param userName
 * 参 数 : @return
 * 参 考 : @see
 * tk.ainiyue.danyuan.application.user.userbase.service.SysUserBaseService#findByName(java.lang.String)
 * 作 者 : Administrator
 */
@Override
public SysUserBaseInfo findByName(String userName) {
    SysUserBaseInfo info = new SysUserBaseInfo();
    info.setUserName(userName);
    Example<SysUserBaseInfo> example = Example.of(info);
    SysUserBaseInfo sourceCodes = sysUserBaseDao.findOne(example);
    return sourceCodes;
}
Also used : SysUserBaseInfo(tk.ainiyue.danyuan.application.user.userbase.po.SysUserBaseInfo)

Example 4 with SysUserBaseInfo

use of tk.ainiyue.danyuan.application.user.userbase.po.SysUserBaseInfo in project danyuan-application by 514840279.

the class CustomUserDetailsService method loadUserByUsername.

@Override
public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {
    SysUserBaseInfo user;
    try {
        user = sysUserBaseService.findByName(userName);
    } catch (Exception e) {
        throw new UsernameNotFoundException("user select fail");
    }
    if (user == null) {
        throw new UsernameNotFoundException("no user found");
    } else {
        try {
            List<SysMenuInfo> menu = sysUserBaseService.getRoleByUser(user.getUuid());
            List<GrantedAuthority> gas = new ArrayList<>();
            if (menu != null) {
                for (SysMenuInfo sysMenuInfo : menu) {
                    gas.add(new SimpleGrantedAuthority(sysMenuInfo.getName()));
                }
            }
            // gas.add(new SwitchUserGrantedAuthority("ROLE_USER", new Authentication()));
            UserDetails users = new User(user.getUserName(), user.getPassword(), true, true, true, true, gas);
            return users;
        } catch (Exception e) {
            throw new UsernameNotFoundException("user role select fail");
        }
    }
}
Also used : UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) UserDetails(org.springframework.security.core.userdetails.UserDetails) User(org.springframework.security.core.userdetails.User) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) GrantedAuthority(org.springframework.security.core.GrantedAuthority) SysMenuInfo(tk.ainiyue.danyuan.application.softm.sysmenu.po.SysMenuInfo) ArrayList(java.util.ArrayList) UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) SysUserBaseInfo(tk.ainiyue.danyuan.application.user.userbase.po.SysUserBaseInfo)

Aggregations

SysUserBaseInfo (tk.ainiyue.danyuan.application.user.userbase.po.SysUserBaseInfo)4 ApiOperation (io.swagger.annotations.ApiOperation)1 ArrayList (java.util.ArrayList)1 PageRequest (org.springframework.data.domain.PageRequest)1 Sort (org.springframework.data.domain.Sort)1 Order (org.springframework.data.domain.Sort.Order)1 GrantedAuthority (org.springframework.security.core.GrantedAuthority)1 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)1 User (org.springframework.security.core.userdetails.User)1 UserDetails (org.springframework.security.core.userdetails.UserDetails)1 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 SysMenuInfo (tk.ainiyue.danyuan.application.softm.sysmenu.po.SysMenuInfo)1