Search in sources :

Example 1 with Picture

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

the class UserMgrController method upload.

/**
 * 上传图片(上传到项目的webapp/static/img)
 */
@RequestMapping(method = RequestMethod.POST, path = "/upload")
@ResponseBody
public JSONObject upload(@RequestPart("file") MultipartFile picture) {
    JSONObject obj = new JSONObject();
    String pictureName = UUID.randomUUID().toString() + ".jpg";
    try {
        String fileSavePath = gunsProperties.getFileUploadPath();
        picture.transferTo(new File(fileSavePath + pictureName));
        Picture pic = new Picture();
        pic.setPictypeId(PicType.LOGO.getCode());
        pic.setRealName(picture.getOriginalFilename());
        pic.setUrl(fileSavePath + pictureName);
        pic.setName(pictureName);
        Integer picId = pictureMapper.insert(pic);
        obj.put("pictureName", pictureName);
        obj.put("pictureId", picId);
    } catch (Exception e) {
        throw new BussinessException(BizExceptionEnum.UPLOAD_ERROR);
    }
    return obj;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Picture(com.ikoori.vip.common.persistence.model.Picture) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) NoPermissionException(javax.naming.NoPermissionException) BussinessException(com.ikoori.vip.common.exception.BussinessException) BussinessException(com.ikoori.vip.common.exception.BussinessException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with Picture

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

the class PictureController method pictureUpdate.

/**
 * 跳转到修改图片
 */
@Permission
@RequestMapping("/picture_update/{pictureId}")
public String pictureUpdate(@PathVariable Long pictureId, Model model) {
    Picture picture = pictureService.selectById(pictureId);
    model.addAttribute(picture);
    return PREFIX + "picture_edit.html";
}
Also used : Picture(com.ikoori.vip.common.persistence.model.Picture) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Picture

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

the class PictureController method list.

/**
 * 获取图片列表
 */
@Permission
@RequestMapping(value = "/list")
@ResponseBody
public Object list(String condition) {
    Page<Picture> page = new PageFactory<Picture>().defaultPage();
    Long userId = Long.valueOf(ShiroKit.getUser().getId());
    Merchant merchant = merchantService.getMerchantUserId(userId);
    List<Map<String, Object>> result = pictureService.getPictureList(page, condition, page.getOrderByField(), page.isAsc(), merchant.getId());
    page.setRecords((List<Picture>) new PictureWarpper(result).warp());
    return super.packForBT(page);
}
Also used : Merchant(com.ikoori.vip.common.persistence.model.Merchant) Picture(com.ikoori.vip.common.persistence.model.Picture) PictureWarpper(com.ikoori.vip.server.modular.biz.warpper.PictureWarpper) Map(java.util.Map) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with Picture

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

the class StoreApiImpl method getStoreDetail.

/**
 * <p>Title: getStoreDetail</p>
 * <p>Description: 会员门店详情</p>
 * @param storeId 门店id
 * @return
 * @see com.ikoori.vip.api.service.StoreApi#getStoreDetail(java.lang.Long)
 */
@Override
public JSONObject getStoreDetail(Long storeId) {
    log.info("进入getStoreDetail>>storeId=" + storeId);
    Store store = storeDao.getStoreDetail(storeId);
    JSONObject obj = new JSONObject();
    List<Picture> pictures = storePhotoDao.selectStorePhoto(storeId);
    obj.put("id", store.getId());
    obj.put("name", store.getName());
    obj.put("address", store.getAddress());
    obj.put("latitude", store.getLatitude());
    obj.put("longitude", store.getLongitude());
    obj.put("servicePhone", store.getServicePhone());
    obj.put("openTime", store.getOpenTime());
    obj.put("closeTime", store.getCloseTime());
    obj.put("pictures", pictures);
    log.info("结束getStoreDetail");
    return obj;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Picture(com.ikoori.vip.common.persistence.model.Picture) Store(com.ikoori.vip.common.persistence.model.Store)

Example 5 with Picture

use of com.ikoori.vip.common.persistence.model.Picture 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

Picture (com.ikoori.vip.common.persistence.model.Picture)5 JSONObject (com.alibaba.fastjson.JSONObject)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 Permission (com.ikoori.vip.common.annotion.Permission)2 BussinessException (com.ikoori.vip.common.exception.BussinessException)2 Merchant (com.ikoori.vip.common.persistence.model.Merchant)2 File (java.io.File)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 MultipartFile (org.springframework.web.multipart.MultipartFile)2 Store (com.ikoori.vip.common.persistence.model.Store)1 PictureWarpper (com.ikoori.vip.server.modular.biz.warpper.PictureWarpper)1 Map (java.util.Map)1 NoPermissionException (javax.naming.NoPermissionException)1