Search in sources :

Example 11 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project vip by guangdada.

the class PointServiceImpl method checkPoint.

/**
 * 判断关注微信的积分规则时候已经存在
 * @Title: checkPoint
 * @param merchantId
 * @param pointId
 * @return
 * @date:   2017年9月22日 下午1:54:56
 * @author: chengxg
 */
public boolean checkPoint(Long merchantId, Long pointId) {
    Wrapper<Point> w = new EntityWrapper<Point>();
    w.eq("merchant_id", merchantId);
    w.eq("status", 1);
    w.eq("rule_type", PointType.SUBSCRIBE_WX.getCode());
    if (pointId != null) {
        w.ne("id", pointId);
    }
    int count = pointMapper.selectCount(w);
    return count == 0 ? true : false;
}
Also used : EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Point(com.ikoori.vip.common.persistence.model.Point) Point(com.ikoori.vip.common.persistence.model.Point)

Example 12 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project vip by guangdada.

the class StoreServiceImpl method saveStore.

@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void saveStore(Store store, String pics) {
    if (store.getId() != null) {
        Wrapper<StorePhoto> wrapper = new EntityWrapper<StorePhoto>();
        wrapper.eq("store_id", store.getId());
        storePhotoMapper.delete(wrapper);
        storeMapper.updateById(store);
    } else {
        store.setStoreNo(RandomUtil.generateStoreNum());
        storeMapper.insert(store);
    }
    if (StringUtils.isNotBlank(pics)) {
        JSONArray picA = JSONArray.parseArray(pics);
        if (picA != null) {
            for (int i = 0; i < picA.size(); i++) {
                JSONObject pic = picA.getJSONObject(i);
                Long id = pic.getLong("id");
                StorePhoto storePhoto = new StorePhoto();
                storePhoto.setStoreId(store.getId());
                storePhoto.setPicId(id);
                storePhotoMapper.insert(storePhoto);
            }
        }
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) JSONArray(com.alibaba.fastjson.JSONArray) StorePhoto(com.ikoori.vip.common.persistence.model.StorePhoto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project vip by guangdada.

the class ShareApiImpl method saveShareLog.

/**
 * 保存邀请记录
 *
 * @Title: saveShareLog
 * @param shareUnionid
 *            邀请人unionid
 * @param receiveUnionid
 *            受邀人unionid
 * @param receiveIp
 *            受邀人ip
 * @throws Exception
 * @date: 2017年10月9日 上午9:28:15
 * @author: chengxg
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
@Override
public void saveShareLog(String shareUnionid, String receiveUnionid, String receiveIp) throws Exception {
    log.info("进入saveShareLog>>shareUnionid=" + shareUnionid);
    log.info("进入saveShareLog>>receiveUnionid=" + receiveUnionid);
    log.info("进入saveShareLog>>receiveIp=" + receiveIp);
    // 邀请人不存在, 不处理
    Member shareMem = memberDao.getMemberByUnionid(shareUnionid);
    if (shareMem == null) {
        log.info("邀请人不存在");
        return;
    }
    // 受邀人不是会员 或者已激活不处理
    Member receiveMem = memberDao.getMemberByUnionid(receiveUnionid);
    if (receiveMem == null || receiveMem.isIsActive()) {
        log.info("受邀人不存在");
        return;
    }
    Wrapper<ShareLog> w = new EntityWrapper<ShareLog>();
    w.eq("share_unionid", shareUnionid);
    w.eq("receive_unionid", receiveUnionid);
    int count = shareLogMapper.selectCount(w);
    if (count > 0) {
        log.info("已有邀请记录");
        return;
    }
    ShareLog shareLog = new ShareLog();
    shareLog.setShareUnionid(shareUnionid);
    shareLog.setReceiveUnionid(receiveUnionid);
    shareLog.setReceiveIp(receiveIp);
    shareLog.setReceiveStatus(false);
    shareLogMapper.insert(shareLog);
    log.info("结束saveShareLog");
}
Also used : ShareLog(com.ikoori.vip.common.persistence.model.ShareLog) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Member(com.ikoori.vip.common.persistence.model.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project vip by guangdada.

the class ConstantFactory method getDictsByName.

/**
 * 根据字典名称和字典中的值获取对应的名称
 */
@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 "";
    }
}
Also used : Dict(com.ikoori.vip.common.persistence.model.Dict) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper)

Example 15 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project vip by guangdada.

the class MenuController method edit.

/**
 * 修该菜单
 */
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/edit")
@BussinessLog(value = "修改菜单", key = "name", dict = Dict.MenuDict)
@ResponseBody
public Tip edit(@Valid Menu menu, BindingResult result) {
    if (result.hasErrors()) {
        throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
    }
    // 设置父级菜单编号
    menuSetPcode(menu);
    this.menuMapper.updateById(menu);
    if (!menu.getCode().equals("0") && menu.getIsmenu().intValue() == 1) {
        Wrapper<Menu> wrapper = new EntityWrapper<>();
        wrapper.eq("pcode", menu.getCode());
        List<Menu> submenus = menuMapper.selectList(wrapper);
        Map<String, Boolean> map = new HashMap<String, Boolean>();
        map.put(menu.getUrl() + "/add", false);
        map.put(menu.getUrl() + "/update", false);
        map.put(menu.getUrl() + "/delete", false);
        map.put(menu.getUrl() + "/detail", false);
        map.put(menu.getUrl() + "/list", false);
        map.put(menu.getUrl() + "/" + menu.getCode() + "_add", false);
        map.put(menu.getUrl() + "/" + menu.getCode() + "_update", false);
        for (Menu m : submenus) {
            if (map.get(m.getUrl()) != null) {
                map.put(m.getUrl(), true);
            }
        }
        for (String key : map.keySet()) {
            if (!map.get(key)) {
                Menu subMenu = new Menu();
                if (key.equals(menu.getUrl() + "/add")) {
                    subMenu.setName(menu.getName() + "添加");
                    subMenu.setCode(menu.getCode() + "_add");
                } else if (key.equals(menu.getUrl() + "/update")) {
                    subMenu.setName(menu.getName() + "修改");
                    subMenu.setCode(menu.getCode() + "_update");
                } else if (key.equals(menu.getUrl() + "/delete")) {
                    subMenu.setName(menu.getName() + "删除");
                    subMenu.setCode(menu.getCode() + "_delete");
                } else if (key.equals(menu.getUrl() + "/detail")) {
                    subMenu.setName(menu.getName() + "详情");
                    subMenu.setCode(menu.getCode() + "_detail");
                } else if (key.equals(menu.getUrl() + "/list")) {
                    subMenu.setName(menu.getName() + "查询");
                    subMenu.setCode(menu.getCode() + "_list");
                } else if (key.equals(menu.getUrl() + "/" + menu.getCode() + "_add")) {
                    subMenu.setName(menu.getName() + "跳转添加");
                    subMenu.setCode("to_" + menu.getCode() + "_add");
                } else if (key.equals(menu.getUrl() + "/" + menu.getCode() + "_update")) {
                    subMenu.setName(menu.getName() + "跳转修改");
                    subMenu.setCode("to_" + menu.getCode() + "_update");
                }
                subMenu.setIsmenu(0);
                subMenu.setPcode(menu.getId().toString());
                subMenu.setNum(1);
                subMenu.setUrl(key);
                subMenu.setStatus(1);
                // 判断是否存在该编号
                String existedMenuName = ConstantFactory.me().getMenuNameByCode(subMenu.getCode());
                if (ToolUtil.isNotEmpty(existedMenuName)) {
                    throw new BussinessException(BizExceptionEnum.EXISTED_THE_MENU);
                }
                // 设置父级菜单编号
                menuSetPcode(subMenu);
                subMenu.setStatus(MenuStatus.ENABLE.getCode());
                this.menuMapper.insert(subMenu);
            }
        }
    }
    return SUCCESS_TIP;
}
Also used : HashMap(java.util.HashMap) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Menu(com.ikoori.vip.common.persistence.model.Menu) BussinessException(com.ikoori.vip.common.exception.BussinessException) Permission(com.ikoori.vip.common.annotion.Permission) BussinessLog(com.ikoori.vip.common.annotion.log.BussinessLog) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

EntityWrapper (com.baomidou.mybatisplus.mapper.EntityWrapper)23 News (com.ch999.haha.admin.entity.News)5 Date (java.util.Date)5 Adoption (com.ch999.haha.admin.entity.Adoption)4 AdoptionRequest (com.ch999.haha.admin.entity.AdoptionRequest)4 JSONObject (com.alibaba.fastjson.JSONObject)3 BussinessException (com.ikoori.vip.common.exception.BussinessException)3 Dict (com.ikoori.vip.common.persistence.model.Dict)3 Transactional (org.springframework.transaction.annotation.Transactional)3 JSONArray (com.alibaba.fastjson.JSONArray)2 UserFans (com.ch999.haha.admin.entity.UserFans)2 Permission (com.ikoori.vip.common.annotion.Permission)2 Member (com.ikoori.vip.common.persistence.model.Member)2 Menu (com.ikoori.vip.common.persistence.model.Menu)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 CommentZanBO (com.ch999.haha.admin.document.redis.CommentZanBO)1 UserInfoBO (com.ch999.haha.admin.document.redis.UserInfoBO)1 AdoptionFeedBack (com.ch999.haha.admin.entity.AdoptionFeedBack)1 Phone (com.ch999.haha.admin.entity.Phone)1 UserInfo (com.ch999.haha.admin.entity.UserInfo)1