getgid getuid

geteuid():返回有效用户的ID。

getuid():返回实际用户的ID。

有效用户ID(EUID)是你最初执行程序时所用的ID   
  表示该ID是程序的所有者   
  真实用户ID(UID)是程序执行过程中采用的ID   
  该ID表明当前运行位置程序的执行者   
  举个例子   
  程序myprogram的所有者为501/anna   
  以501运行该程序此时UID和EUID都是501   
  但是由于中间要访问某些系统资源   
  需要使用root身份   
  此时UID为0而EUID仍是501




相关函数:getegid, setregid, setgid

头文件:#include <unistd.h>    #include <sys/types.h>

定义函数:gid_t getgid(void);

函数说明:getgid()用来取得执行目前进程的组识别码。

返回值:返回组识别码

范例
#include <unistd.h>
#include <sys/types.h>
main()
{
    printf("gid is %d\n", getgid());
}


执行:
gid is 0 //当使用root 身份执行范例程序时

package com.u.api.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.u.api.mapper.GoodsMapper; import com.u.api.mapper.ShopingCartMapper; import com.u.api.model.ShopingCart; import com.u.api.service.ShopingCartService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; @Service public class ShopingCartServiceImpl extends ServiceImpl<ShopingCartMapper, ShopingCart> implements ShopingCartService { @Resource private ShopingCartMapper shopingCartMapper; @Resource private GoodsMapper goodsMapper; @Override public int add(ShopingCart shopingCart) { QueryWrapper<ShopingCart> qw = new QueryWrapper<>(); qw.eq("gid",shopingCart.getGid()); qw.eq("uid",shopingCart.getUid()); ShopingCart shopingCart1 = shopingCartMapper.selectOne(qw); int rs = 0; if(shopingCart1 == null){ shopingCart.setNum(1); rs = shopingCartMapper.insert(shopingCart); }else { UpdateWrapper<ShopingCart> updateWrapper = new UpdateWrapper(); updateWrapper.eq("uid",shopingCart.getUid()); updateWrapper.eq("gid",shopingCart.getGid()); updateWrapper.setSql("num = num + 1"); rs = shopingCartMapper.update(null,updateWrapper); } return rs; } @Override public int del(ShopingCart shopingCart) { QueryWrapper<ShopingCart> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("uid",shopingCart.getUid()); queryWrapper.eq("id",shopingCart.getId()); return shopingCartMapper.delete(queryWrapper); } @Override public List<ShopingCart> getShopingCart(String account) { QueryWrapper<ShopingCart> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("uid",account); List<ShopingCart> shopingCarts = shopingCartMapper.selectList(queryWrapper); return shopingCarts; } }
05-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值