Search in sources :

Example 66 with Merchant

use of com.ikoori.vip.common.persistence.model.Merchant in project vip by guangdada.

the class UploadController method upload.

private JSONObject upload(MultipartFile picture, PicType picType) {
    JSONObject obj = new JSONObject();
    String pictureName = UUID.randomUUID().toString() + ".jpg";
    try {
        Long userId = Long.valueOf(ShiroKit.getUser().getId());
        String fileSavePath = gunsProperties.getFileUploadPath() + pictureName;
        picture.transferTo(new File(fileSavePath));
        Picture pic = new Picture();
        if (ShiroKit.hasRole(Const.MERCHANT_NAME)) {
            Merchant merchant = merchantService.getMerchantUserId(userId);
            pic.setMerchantId(merchant.getId());
        }
        pic.setPictypeId(picType.getCode());
        pic.setRealName(picture.getOriginalFilename());
        pic.setAbsUrl(gunsProperties.getImageUrl() + "/" + pictureName);
        pic.setName(pictureName);
        pictureMapper.insert(pic);
        obj.put("pictureName", pic.getAbsUrl());
        obj.put("pictureId", pic.getId());
    } catch (Exception e) {
        throw new BussinessException(BizExceptionEnum.UPLOAD_ERROR);
    }
    return obj;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Merchant(com.ikoori.vip.common.persistence.model.Merchant) Picture(com.ikoori.vip.common.persistence.model.Picture) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) BussinessException(com.ikoori.vip.common.exception.BussinessException) BussinessException(com.ikoori.vip.common.exception.BussinessException)

Aggregations

Merchant (com.ikoori.vip.common.persistence.model.Merchant)66 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)59 Permission (com.ikoori.vip.common.annotion.Permission)55 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)35 HashMap (java.util.HashMap)29 Map (java.util.Map)20 Store (com.ikoori.vip.common.persistence.model.Store)12 Card (com.ikoori.vip.common.persistence.model.Card)11 BussinessException (com.ikoori.vip.common.exception.BussinessException)8 Coupon (com.ikoori.vip.common.persistence.model.Coupon)7 MemberCard (com.ikoori.vip.common.persistence.model.MemberCard)7 LinkedHashMap (java.util.LinkedHashMap)4 JSONObject (com.alibaba.fastjson.JSONObject)3 Ticket (com.ikoori.vip.common.persistence.model.Ticket)3 User (com.ikoori.vip.common.persistence.model.User)3 Transactional (org.springframework.transaction.annotation.Transactional)3 Member (com.ikoori.vip.common.persistence.model.Member)2 Picture (com.ikoori.vip.common.persistence.model.Picture)2 StoreCoupon (com.ikoori.vip.common.persistence.model.StoreCoupon)2 CouponCodeWarpper (com.ikoori.vip.server.modular.biz.warpper.CouponCodeWarpper)2