com.baomidou.mybatisplus.mapper.EntityWrapper Java Examples

The following examples show how to use com.baomidou.mybatisplus.mapper.EntityWrapper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: unimall   Author: iotechn   File: AddressServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateAddress(Long addressId, String province, String city, String county, String address, Integer defaultAddress, Long userId, String phone, String consignee) throws ServiceException {
    AddressDO addressDO = new AddressDO(province, city, county, address, defaultAddress, userId, phone, consignee);
    Date now = new Date();
    if (defaultAddress != 0) {
        defaultAddress = 1;
        List<AddressDO> addressDOS = addressMapper.selectList(new EntityWrapper<AddressDO>().eq("user_id", userId).eq("default_address", 1));
        if (addressDOS.size() != 0) {
            AddressDO preDefault = addressDOS.get(0);
            preDefault.setDefaultAddress(0);
            addressMapper.updateById(preDefault);
        }
    }
    addressDO.setDefaultAddress(defaultAddress);
    addressDO.setGmtUpdate(now);
    return addressMapper.update(addressDO, new EntityWrapper<AddressDO>()
            .eq("id", addressId)
            .eq("user_id", userId)) > 0;

}
 
Example #2
Source Project: mysiteforme   Author: wangl1989   File: UserConteroller.java    License: Apache License 2.0 6 votes vote down vote up
@RequiresPermissions("sys:user:list")
@PostMapping("list")
@ResponseBody
public LayerData<User> list(@RequestParam(value = "page",defaultValue = "1")Integer page,
                            @RequestParam(value = "limit",defaultValue = "10")Integer limit,
                            ServletRequest request){
    Map map = WebUtils.getParametersStartingWith(request, "s_");
    LayerData<User> userLayerData = new LayerData<>();
    EntityWrapper<User> userEntityWrapper = new EntityWrapper<>();
    if(!map.isEmpty()){
        String keys = (String) map.get("key");
        if(StringUtils.isNotBlank(keys)) {
            userEntityWrapper.like("login_name", keys).or().like("tel", keys).or().like("email", keys);
        }
    }
    Page<User> userPage = userService.selectPage(new Page<>(page,limit),userEntityWrapper);
    userLayerData.setCount(userPage.getTotal());
    userLayerData.setData(userPage.getRecords());
    return  userLayerData;
}
 
Example #3
Source Project: Ffast-Java   Author: ZhiYiDai   File: DictTypeServiceImpl.java    License: MIT License 6 votes vote down vote up
@Override
protected ServiceResult createBefore(DictType m) {
    ServiceResult result = new ServiceResult();
    EntityWrapper ew = new EntityWrapper<DictType>();
    ew.eq("identity", m.getIdentity());
    if (selectCount(ew) > 0) {
        result.setMessage("标识重复,请重新输入");
        return result;
    }
    EntityWrapper ew1 = new EntityWrapper<DictType>();
    ew1.eq("name", m.getName());
    if (selectCount(ew1) > 0) {
        result.setMessage("分类名重复,请重新输入");
        return result;
    }
    return null;
}
 
Example #4
Source Project: Ffast-Java   Author: ZhiYiDai   File: RoleResServiceImpl.java    License: MIT License 6 votes vote down vote up
@Cacheable(value = "sys", key = "'roleRes_resIds_'+#roleId")
@Override
public List<Long> getRoleResIds(Long roleId) {
    RoleRes m = new RoleRes();
    m.setRoleId(roleId);
    EntityWrapper ew = new EntityWrapper<RoleRes>(m);
    ew.setSqlSelect("res_id");
    List<RoleRes> roleResList = selectList(ew);
    List<Long> resIds = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(roleResList)) {
        for (RoleRes roleRes : roleResList) {
            resIds.add(roleRes.getResId());
        }
    }
    return resIds;
}
 
Example #5
Source Project: unimall   Author: iotechn   File: AdminGroupShopGoodsServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(rollbackFor = Exception.class)
public String deleteGroupShopSpu(Long adminId, Long id) throws ServiceException {

    GroupShopDO groupShopDO = groupShopMapper.selectById(id);
    if (groupShopDO == null) {
        throw new AdminServiceException(ExceptionDefinition.SPU_NO_EXITS_OR_ONLY_SPU);
    }

    if (groupShopDO.getStatus() > 0) {
        throw new AdminServiceException(ExceptionDefinition.GROUP_SHOP_ALREAD_ATCIVE);
    }

    if (groupShopMapper.deleteById(id) <= 0) {
        throw new AdminServiceException(ExceptionDefinition.GROUP_SHOP_SPU_DELETE_SQL_QUERY_ERROR);
    }
    if (groupShopSkuMapper.delete((new EntityWrapper<GroupShopSkuDO>().eq("group_shop_id", id))) <= 0) {
        throw new AdminServiceException(ExceptionDefinition.GROUP_SHOP_SKU_DELETE_SQL_QUERY_ERROR);
    }

    cacheComponent.delPrefixKey(GROUP_SHOP_CACHE);
    return "ok";
}
 
Example #6
Source Project: unimall   Author: iotechn   File: AdminFreightTemplateServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public List<FreightTemplateDTO> getAllFreightTemplate(Long adminId) throws ServiceException {
    List<FreightTemplateDO> freightTemplateDOList = freightTemplateMapper.selectList(null); //查出主表所有数据
    List<FreightTemplateDTO> freightTemplateDTOList = new ArrayList<>();
    if (freightTemplateDOList == null || freightTemplateDOList.size() == 0) { //如果主表没有记录
        return freightTemplateDTOList;
    }
    for (FreightTemplateDO freightTemplateDO : freightTemplateDOList) {  //查出副表中,主表每条数据对应的数据
        FreightTemplateDTO freightTemplateDTO = new FreightTemplateDTO();
        List<FreightTemplateCarriageDO> freightTemplateCarriageDOList = freightTemplateCarriageMapper.selectList(new EntityWrapper<FreightTemplateCarriageDO>()
                .eq("template_id", freightTemplateDO.getId()));
        freightTemplateDTO.setFreightTemplateDO(freightTemplateDO);
        freightTemplateDTO.setFreightTemplateCarriageDOList(freightTemplateCarriageDOList);
        freightTemplateDTOList.add(freightTemplateDTO);
    }
    return freightTemplateDTOList;
}
 
Example #7
Source Project: app-version   Author: xtTech   File: ChannelServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public ServiceResult findByChannelCode(String channelCode) {
    Channel channel = new Channel();
    channel.setChannelCode(channelCode);
    channel.setAppId(ThreadLocalUtils.USER_THREAD_LOCAL.get().getAppId());
    EntityWrapper<Channel> wrapper = new EntityWrapper<>(channel);
    wrapper.last("limit 0,1");
    List<Channel> channels = channelMapper.selectList(wrapper);

    if (!channels.isEmpty()) {
        Channel channel1 = channels.get(0);
        if (!channel1.getAppId().equals(ThreadLocalUtils.USER_THREAD_LOCAL.get().getAppId())) {
            return ServiceResultConstants.RESOURCE_NOT_BELONG_APP;
        }
        return ServiceResult.ok(channel1);
    } else {
        return ServiceResultConstants.CHANNEL_NOT_EXISTS;
    }
}
 
Example #8
Source Project: WebStack-Guns   Author: jsnjfz   File: MenuServiceImpl.java    License: MIT License 6 votes vote down vote up
@Override
@Transactional
public void delMenuContainSubMenus(Long menuId) {

    Menu menu = menuMapper.selectById(menuId);

    //删除当前菜单
    delMenu(menuId);

    //删除所有子菜单
    Wrapper<Menu> wrapper = new EntityWrapper<>();
    wrapper = wrapper.like("pcodes", "%[" + menu.getCode() + "]%");
    List<Menu> menus = menuMapper.selectList(wrapper);
    for (Menu temp : menus) {
        delMenu(temp.getId());
    }
}
 
Example #9
Source Project: cola-cloud   Author: leecho   File: MessageServiceImpl.java    License: MIT License 6 votes vote down vote up
@Override
public List<Message> selectList(Message message, Long userId) {
    EntityWrapper<Message> wrapper = this.newEntityWrapper();

    if (userId != null) {
        wrapper.eq("sys_user_id", userId);
    }
    if (message != null) {
        if (message.getDeleteFlag() != null) {
            wrapper.eq("delete_flag", "N");
        } else {
            wrapper.eq("delete_flag", message.getDeleteFlag());
        }
        if (message.getReadFlag() != null) {
            wrapper.eq("read_flag", "N");
        } else {
            wrapper.eq("read_flag", message.getReadFlag());
        }
    }
    return super.selectList(wrapper);
}
 
Example #10
Source Project: unimall   Author: iotechn   File: AdminUserServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean addUser(Long adminId, UserDO user) throws ServiceException {
    if (user == null){
        throw new AdminServiceException(ExceptionDefinition.USER_INFORMATION_MISSING);
    }
    if(user.getPhone() == null){
        throw new AdminServiceException(ExceptionDefinition.USER_INFORMATION_MISSING);
    }
    if(userMapper.selectCount(new EntityWrapper<UserDO>().eq("phone",user.getPhone())) > 0){
        throw new AdminServiceException(ExceptionDefinition.USER_PHONE_ALREADY_EXIST);
    }
    Date now = new Date();
    user.setId(null);
    user.setPassword(Md5Crypt.md5Crypt(user.getPassword().getBytes(), "$1$" + user.getPhone().substring(0,7)));
    user.setGmtCreate(now);
    user.setGmtUpdate(now);
    return userMapper.insert(user) > 0;
}
 
Example #11
Source Project: watchdog-framework   Author: watchdog-framework   File: SysRoleResourceServiceImpl.java    License: MIT License 6 votes vote down vote up
@Override
public List<SysResource> findAllResourceByRoleId(String rid) {
    List<SysRoleResource> rps = this.selectList(new EntityWrapper<SysRoleResource>().eq("rid",rid));
    if(rps!=null){
        List<String> pids = new ArrayList<>();
        rps.forEach(v->pids.add(v.getPid()));
        if(pids.size()==0){
            return null;
        }
        return resourceService.selectList(new EntityWrapper<SysResource>()
                .in("id", pids)
                .orderBy("sort",true)
        );
    }
    return null;
}
 
Example #12
Source Project: MeetingFilm   Author: daydreamdev   File: ConstantFactory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 根据字典名称和字典中的值获取对应的名称
 */
@Override
public String getDictsByName(String name, Integer val) {
    Dict temp = new Dict();
    temp.setName(name);
    Dict dict = dictMapper.selectOne(temp);
    if (dict == null) {
        return "";
    } else {
        Wrapper<Dict> wrapper = new EntityWrapper<>();
        wrapper = wrapper.eq("pid", dict.getId());
        List<Dict> dicts = dictMapper.selectList(wrapper);
        for (Dict item : dicts) {
            if (item.getNum() != null && item.getNum().equals(val)) {
                return item.getName();
            }
        }
        return "";
    }
}
 
Example #13
Source Project: cola-cloud   Author: leecho   File: DatabaseCachableClientDetailsService.java    License: MIT License 6 votes vote down vote up
@Transactional(rollbackFor = Exception.class)
@CachePut(value = OAUTH_CLINET_DETAILS_CACHE, key = "#clientDetails.clientId")
public ClientDetails updateCachedClientDetail(ClientDetails clientDetails) throws NoSuchClientException {
    Optional<Client> clientOptional = Optional.of(this.clientService.findOneByColumn("client_id", clientDetails.getClientId()));
    clientOptional.orElseThrow(() -> new NoSuchClientException("Client ID not found"));

    Client client = Client.builder()
            .clientId(clientDetails.getClientId())
            .clientSecret(clientDetails.getClientSecret())
            .accessTokenValiditySeconds(clientDetails.getAccessTokenValiditySeconds())
            .refreshTokenValiditySeconds(clientDetails.getRefreshTokenValiditySeconds()).build();
    client.setId(clientOptional.get().getId());

    client.setGrantType(clientDetails.getAuthorizedGrantTypes().stream().collect(Collectors.joining(",")));
    client.setRedirectUri(clientDetails.getRegisteredRedirectUri().stream().collect(Collectors.joining(",")));
    clientService.insert(client);

    EntityWrapper<Scope> wrapper = new EntityWrapper<>();
    wrapper.eq("client_id", clientOptional.get().getId());
    scopeService.delete(wrapper);

    List<Scope> clientScopes = clientDetails.getScope().stream().map(scope ->
            Scope.builder().clientId(client.getId()).autoApprove(false).scope(scope).build()).collect(Collectors.toList());
    this.scopeService.insertBatch(clientScopes);
    return clientDetails;
}
 
Example #14
Source Project: unimall   Author: iotechn   File: OrderServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(rollbackFor = Exception.class)
public String refund(String orderNo, Long userId) throws ServiceException {
    OrderDO orderDO = orderBizService.checkOrderExist(orderNo, userId);
    if (PayChannelType.OFFLINE.getCode().equals(orderDO.getPayChannel())) {
        throw new AppServiceException(ExceptionDefinition.ORDER_PAY_CHANNEL_NOT_SUPPORT_REFUND);
    }
    if (OrderStatusType.refundable(orderDO.getStatus())) {
        OrderDO updateOrderDO = new OrderDO();
        updateOrderDO.setStatus(OrderStatusType.REFUNDING.getCode());
        orderBizService.changeOrderStatus(orderNo, orderDO.getStatus() , updateOrderDO);
        GlobalExecutor.execute(() -> {
            OrderDTO orderDTO = new OrderDTO();
            BeanUtils.copyProperties(orderDO, orderDTO);
            List<OrderSkuDO> orderSkuList = orderSkuMapper.selectList(new EntityWrapper<OrderSkuDO>().eq("order_no", orderDO.getOrderNo()));
            orderDTO.setSkuList(orderSkuList);
            adminNotifyBizService.refundOrder(orderDTO);
        });
        return "ok";
    }
    throw new AppServiceException(ExceptionDefinition.ORDER_STATUS_NOT_SUPPORT_REFUND);
}
 
Example #15
Source Project: cola-cloud   Author: leecho   File: SysLogController.java    License: MIT License 6 votes vote down vote up
/**
 * 查找系统日志
 */
@GetMapping(value = "/list")
@ApiOperation("查找系统日志")
public Result<Page<List<SysLog>>> list(Integer type, String name, Date startDate, Date endDate) {
    EntityWrapper wrapper = new EntityWrapper<>();
    wrapper.like("name", name);
    if (type != null) {
        wrapper.eq("type", type);
    }
    if (startDate != null) {
        wrapper.andNew("create_time >= {0}", startDate);
    }
    //
    if (endDate != null) {
        wrapper.andNew("create_time <= {0}", endDate);
    }
    wrapper.orderBy("id");
    return this.success(sysLogService.selectPage(this.getPagination(), wrapper));
}
 
Example #16
Source Project: MeetingFilm   Author: daydreamdev   File: DefaultOrderServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Page<OrderVO> getOrderByUserId(Integer userId, Page<OrderVO> page) {
    Page<OrderVO> result = new Page<>();
    if (userId == null) {
        log.error("订单查询业务失败,用户编号未传入");
        return null;
    } else {
        List<OrderVO> ordersByUserId = moocOrderTMapper.getOrdersByUserId(userId, page);
        if (ordersByUserId == null && ordersByUserId.size() == 0) {
            result.setTotal(0);
            result.setRecords(new ArrayList<>());
            return result;
        } else {
            // 获取订单总数
            EntityWrapper<MoocOrderT> entityWrapper = new EntityWrapper<>();
            entityWrapper.eq("order_user", userId);
            Integer counts = moocOrderTMapper.selectCount(entityWrapper);
            // 将结果放入Page
            result.setTotal(counts);
            result.setRecords(ordersByUserId);

            return result;
        }
    }
}
 
Example #17
Source Project: pig   Author: magicgis   File: SysUserServiceImpl.java    License: MIT License 6 votes vote down vote up
@Override
@CacheEvict(value = "user_details", key = "#userDto.username")
public Boolean updateUser(UserDTO userDto) {
    SysUser sysUser = new SysUser();
    BeanUtils.copyProperties(userDto, sysUser);
    sysUser.setUpdateTime(new Date());
    this.updateById(sysUser);

    SysUserRole condition = new SysUserRole();
    condition.setUserId(userDto.getUserId());
    sysUserRoleService.delete(new EntityWrapper<>(condition));
    userDto.getRole().forEach(roleId -> {
        SysUserRole userRole = new SysUserRole();
        userRole.setUserId(sysUser.getUserId());
        userRole.setRoleId(roleId);
        userRole.insert();
    });
    return Boolean.TRUE;
}
 
Example #18
Source Project: unimall   Author: iotechn   File: AdminRecommendServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean addRecommend(Long adminId, Long spuId, Integer recommendType) throws ServiceException {

    if (!(spuMapper.selectCount(new EntityWrapper<SpuDO>().eq("id", spuId)) > 0)) {
        throw new AdminServiceException(ExceptionDefinition.RECOMMEND_SPU_NO_HAS);
    }

    if (recommendMapper.selectCount(new EntityWrapper<RecommendDO>()
            .eq("spu_id", spuId)
            .eq("recommend_type", recommendType)) > 0) {
        throw new AdminServiceException(ExceptionDefinition.RECOMMEND_ALREADY_HAS);
    }
    RecommendDO recommendDO = new RecommendDO(spuId, recommendType);
    Date now = new Date();
    recommendDO.setGmtCreate(now);
    recommendDO.setGmtUpdate(now);
    if (!(recommendMapper.insert(recommendDO) > 0)) {
        throw new AdminServiceException(ExceptionDefinition.RECOMMEND_SQL_ADD_FAILED);
    }
    cacheComponent.delPrefixKey(RECOMMEND_NAME+recommendType);
    return true;
}
 
Example #19
Source Project: unimall   Author: iotechn   File: AdminGoodsServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(rollbackFor = Exception.class)
public String delete(Long spuId, Long adminId) throws ServiceException {
    if (spuMapper.deleteById(spuId) <= 0) {
        throw new AdminServiceException(ExceptionDefinition.GOODS_NOT_EXIST);
    }
    cartMapper.delete(new EntityWrapper<CartDO>().in("sku_id", skuMapper.getSkuIds(spuId)));
    skuMapper.delete(new EntityWrapper<SkuDO>().eq("spu_id", spuId));
    imgMapper.delete(new EntityWrapper<ImgDO>().eq("biz_id", spuId).eq("biz_type", BizType.GOODS.getCode()));
    spuAttributeMapper.delete(new EntityWrapper<SpuAttributeDO>().eq("spu_id", spuId));
    goodsBizService.clearGoodsCache(spuId);
    pluginUpdateInvoke(spuId);

    cacheComponent.delPrefixKey(GoodsBizService.CA_SPU_PAGE_PREFIX);
    return "ok";
}
 
Example #20
Source Project: MeetingFilm   Author: daydreamdev   File: MenuServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void delMenuContainSubMenus(Long menuId) {

    Menu menu = menuMapper.selectById(menuId);

    //删除当前菜单
    delMenu(menuId);

    //删除所有子菜单
    Wrapper<Menu> wrapper = new EntityWrapper<>();
    wrapper = wrapper.like("pcodes", "%[" + menu.getCode() + "]%");
    List<Menu> menus = menuMapper.selectList(wrapper);
    for (Menu temp : menus) {
        delMenu(temp.getId());
    }
}
 
Example #21
Source Project: unimall   Author: iotechn   File: AppraiseBizService.java    License: Apache License 2.0 6 votes vote down vote up
public Page<AppraiseResponseDTO> getSpuAllAppraise(Long spuId, Integer pageNo, Integer pageSize) throws ServiceException {
    String cacheKey = CA_APPRAISE_KEY + spuId + "_" + pageNo + "_" + pageSize;
    Page obj = cacheComponent.getObj(cacheKey, Page.class);
    if (obj != null) {
        return obj;
    }
    Integer count = appraiseMapper.selectCount(new EntityWrapper<AppraiseDO>().eq("spu_id", spuId));
    Integer offset = pageSize * (pageNo - 1);
    List<AppraiseResponseDTO> appraiseResponseDTOS = appraiseMapper.selectSpuAllAppraise(spuId, offset, pageSize);
    for (AppraiseResponseDTO appraiseResponseDTO : appraiseResponseDTOS) {
        appraiseResponseDTO.setImgList(imgMapper.getImgs(BizType.COMMENT.getCode(), appraiseResponseDTO.getId()));
    }
    Page<AppraiseResponseDTO> page = new Page<>(appraiseResponseDTOS, pageNo, pageSize, count);
    cacheComponent.putObj(cacheKey, page, Const.CACHE_ONE_DAY);
    return page;
}
 
Example #22
Source Project: mysiteforme   Author: wangl1989   File: QiniuFileUtil.java    License: Apache License 2.0 5 votes vote down vote up
/***
 * 普通上传图片
 * @param file
 * @return
 * @throws QiniuException
 * @throws IOException
 */
public static String upload(MultipartFile file) throws IOException, NoSuchAlgorithmException {
	Zone z = Zone.zone0();
	Configuration config = new Configuration(z);
	String fileName = "", extName = "", filePath = "";
	if (null != file && !file.isEmpty()) {
		extName = file.getOriginalFilename().substring(
				file.getOriginalFilename().lastIndexOf("."));
		fileName = UUID.randomUUID() + extName;
		UploadManager uploadManager = new UploadManager(config);
		Auth auth = Auth.create(qiniuAccess, qiniuKey);
		String token = auth.uploadToken(bucketName);
		byte[] data = file.getBytes();
		QETag tag = new QETag();
		String hash = tag.calcETag(file);
		Rescource rescource = new Rescource();
		EntityWrapper<RestResponse> wrapper = new EntityWrapper<>();
		wrapper.eq("hash",hash);
		rescource = rescource.selectOne(wrapper);
		if( rescource!= null){
			return rescource.getWebUrl();
		}
		Response r = uploadManager.put(data, fileName, token);
		if (r.isOK()) {
			filePath = path + fileName;
			rescource = new Rescource();
			rescource.setFileName(fileName);
			rescource.setFileSize(new java.text.DecimalFormat("#.##").format(file.getSize()/1024)+"kb");
			rescource.setHash(hash);
			rescource.setFileType(StringUtils.isBlank(extName)?"unknown":extName);
			rescource.setWebUrl(filePath);
			rescource.setSource("qiniu");
			rescource.insert();
		}
	}
	return filePath;
}
 
Example #23
Source Project: mysiteforme   Author: wangl1989   File: QuartzTaskController.java    License: Apache License 2.0 5 votes vote down vote up
@RequiresPermissions("quartz:task:list")
@PostMapping("list")
@ResponseBody
public LayerData<QuartzTask> list(@RequestParam(value = "page",defaultValue = "1")Integer page,
                                  @RequestParam(value = "limit",defaultValue = "10")Integer limit,
                                  ServletRequest request){
    Map map = WebUtils.getParametersStartingWith(request, "s_");
    LayerData<QuartzTask> layerData = new LayerData<>();
    EntityWrapper<QuartzTask> wrapper = new EntityWrapper<>();
    wrapper.eq("del_flag",false);
    if(!map.isEmpty()){
        String name = (String) map.get("name");
        if(StringUtils.isNotBlank(name)) {
            wrapper.like("name",name);
        }else{
            map.remove("name");
        }

        String status = (String) map.get("status");
        if(StringUtils.isNotBlank(status)) {
            wrapper.eq("status",status);
        }else{
            map.remove("status");
        }

    }
    Page<QuartzTask> pageData = quartzTaskService.queryList(wrapper,new Page<>(page,limit));
    layerData.setData(pageData.getRecords());
    layerData.setCount(pageData.getTotal());
    return layerData;
}
 
Example #24
Source Project: app-version   Author: xtTech   File: AdminController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 列出所有应用
 *
 * @return 应用列表
 */
@ApiOperation(
        value = "列出所有应用(可分页,查询)",
        notes = "应用列表"
)
@ApiImplicitParams({
        @ApiImplicitParam(paramType = "header", dataType = "string", name = "Authorization", value = "用户凭证", required = true),
        @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1"),
        @ApiImplicitParam(name = "pageSize", value = "每页显示数据条数", defaultValue = "10"),
        @ApiImplicitParam(name = "appName", value = "应用名称"),
        @ApiImplicitParam(name = "isAll", value = "是否查询全部应用(包括已软删的),1是0否"),
})
@GetMapping("/app/list")
public ServiceResult listApp(@RequestParam(required = false, defaultValue = "1") int page,
                             @RequestParam(required = false, defaultValue = "10") int pageSize,
                             @RequestParam(required = false, defaultValue = "") String appName,
                             @RequestParam(required = false, defaultValue = "false") Boolean isAll) {
    EntityWrapper<App> wrapper = new EntityWrapper<>();
    if (StringUtils.isNotBlank(appName)) {
        wrapper.andNew().like("app_name", "%" + appName + "%");
    }
    //是否查询全部的数据(已删和未删的)
    if (!isAll) {
        wrapper.and().eq("del_flag", 0);
    }
    return adminService.listApp(page, pageSize, wrapper);
}
 
Example #25
Source Project: easyweb-shiro   Author: uxawseny   File: UserServiceImpl.java    License: MIT License 5 votes vote down vote up
@Transactional(rollbackFor = Exception.class)
@Override
public boolean update(User user) {
    user.setUsername(null);
    boolean rs = userMapper.updateById(user) > 0;
    if (rs) {
        userRoleMapper.delete(new EntityWrapper().eq("user_id", user.getUserId()));
        List<Integer> roleIds = getRoleIds(user.getRoles());
        if (userRoleMapper.insertBatch(user.getUserId(), roleIds) < roleIds.size()) {
            throw new BusinessException("修改失败,请重试");
        }
    }
    return rs;
}
 
Example #26
Source Project: mysiteforme   Author: wangl1989   File: BlogChannelServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public BlogChannel getChannelByHref(String href) {
    EntityWrapper<BlogChannel> wrapper = new EntityWrapper<>();
    wrapper.eq("del_flag",false);
    wrapper.eq("href",href);
    BlogChannel c  = selectOne(wrapper);
    return c;
}
 
Example #27
Source Project: MI-S   Author: MIYAOW   File: AdminArticleController.java    License: MIT License 5 votes vote down vote up
/**
 * 更新文章可用状态
 *
 * @param id
 * @param status
 * @return
 */
@RequestMapping("/updateStatue")
@ResponseBody
public BaseResult updateStatue(String id, int status) {

    EntityWrapper<Article> ew = new EntityWrapper<>();
    Article article = new Article();
    article.setArticleId(id);
    article.setStatus(status);
    ew.setEntity(article);
    iArticleService.updateById(article);
    return new BaseResult(null, ReturnCode.SUCCESS);
}
 
Example #28
Source Project: MI-S   Author: MIYAOW   File: AdminTagController.java    License: MIT License 5 votes vote down vote up
/**
 * 分页加载标签
 * @param pages 分页对象
 * @param param  搜索条件
 * @param model
 * @return
 */
@RequestMapping("/list")
public String selectPage(Page pages, String param, Model model) {
    Page<Tag> page;
    EntityWrapper<Tag> ex = new EntityWrapper<>();
    if (StringUtils.checkValNotNull(param)) {
        ex.where("tag_name like concat('%',{0},'%')", param);
    }
    ex.orderBy("sort", true);
    ex.orderBy("create_time", true);
    page = iTagService.selectPage(new Page(pages.getCurrent(), pages.getSize()), ex);
    model.addAttribute("page", page);
    return "admin/tag/tagTable";
}
 
Example #29
Source Project: app-version   Author: xtTech   File: UserServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ServiceResult register(String phone, String password) {
    if (StringUtilsExt.hasEmpty(password, phone)) {
        return ServiceResultConstants.NEED_PARAMS;
    }
    EntityWrapper<User> userEntityWrapper = new EntityWrapper<>();
    userEntityWrapper.eq("phone", phone);
    Integer integer = userMapper.selectCount(userEntityWrapper);
    if (integer > 0) {
        return ServiceResultConstants.USER_EXISTS;
    }
    Integer count = userMapper.selectCount(new EntityWrapper<>());
    User user = new User();
    if (count > 0) {
        user.setIsAdmin(0);
    } else {
        user.setIsAdmin(1);
    }
    user.setUserId($.field.createUUID());
    user.setFirstLoginTime(new Date());
    user.setPhone(phone);
    user.setNickName(phone);
    try {
        String md5 = $.security.digest.digest(password + phone, ALGORITHM); // 加盐算法
        user.setPassword(md5);
        Integer insert = userMapper.insert(user);
        if (insert > 0) {
            return ServiceResult.ok(null);
        } else {
            return ServiceResultConstants.DB_ERROR;
        }
    } catch (NoSuchAlgorithmException e) {
        logger.error("密码加密出错", e);
        return ServiceResultConstants.ERROR_500;
    }
}
 
Example #30
Source Project: pig   Author: magicgis   File: SysUserServiceImpl.java    License: MIT License 5 votes vote down vote up
/**
 * 获取当前用户的子部门信息
 *
 * @param userVO 用户信息
 * @return 子部门列表
 */
private List<Integer> getChildDepts(UserVO userVO) {
    UserVO userVo = findUserByUsername(userVO.getUsername());
    Integer deptId = userVo.getDeptId();

    //获取当前部门的子部门
    SysDeptRelation deptRelation = new SysDeptRelation();
    deptRelation.setAncestor(deptId);
    List<SysDeptRelation> deptRelationList = sysDeptRelationService.selectList(new EntityWrapper<>(deptRelation));
    List<Integer> deptIds = new ArrayList<>();
    for (SysDeptRelation sysDeptRelation : deptRelationList) {
        deptIds.add(sysDeptRelation.getDescendant());
    }
    return deptIds;
}