Search in sources :

Example 41 with XmallException

use of cn.exrick.common.exception.XmallException in project xmall by Exrick.

the class ContentServiceImpl method updateContent.

@Override
public int updateContent(TbContent tbContent) {
    TbContent old = getContentById(tbContent.getId());
    if (tbContent.getImage().isEmpty()) {
        tbContent.setImage(old.getImage());
    }
    tbContent.setCreated(old.getCreated());
    tbContent.setUpdated(new Date());
    if (tbContentMapper.updateByPrimaryKey(tbContent) != 1) {
        throw new XmallException("更新内容失败");
    }
    // 同步缓存
    deleteHomeRedis();
    return 1;
}
Also used : XmallException(cn.exrick.common.exception.XmallException) Date(java.util.Date)

Example 42 with XmallException

use of cn.exrick.common.exception.XmallException in project xmall by Exrick.

the class ThanksServiceImpl method getThanksListByPage.

@Override
public DataTablesResult getThanksListByPage(int page, int size) {
    DataTablesResult result = new DataTablesResult();
    TbThanksExample example = new TbThanksExample();
    if (page <= 0) {
        page = 1;
    }
    PageHelper.startPage(page, size);
    List<TbThanks> list = tbThanksMapper.selectByExample(example);
    if (list == null) {
        throw new XmallException("获取捐赠列表失败");
    }
    PageInfo<TbThanks> pageInfo = new PageInfo<>(list);
    for (TbThanks tbThanks : list) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date = null;
        try {
            date = dateFormat.format(tbThanks.getDate());
        } catch (Exception e) {
            e.printStackTrace();
        }
        tbThanks.setTime(date);
        tbThanks.setEmail(null);
    }
    result.setSuccess(true);
    result.setRecordsTotal((int) pageInfo.getTotal());
    result.setData(list);
    return result;
}
Also used : PageInfo(com.github.pagehelper.PageInfo) TbThanks(cn.exrick.manager.pojo.TbThanks) DataTablesResult(cn.exrick.common.pojo.DataTablesResult) TbThanksExample(cn.exrick.manager.pojo.TbThanksExample) XmallException(cn.exrick.common.exception.XmallException) SimpleDateFormat(java.text.SimpleDateFormat) XmallException(cn.exrick.common.exception.XmallException) ParseException(java.text.ParseException)

Example 43 with XmallException

use of cn.exrick.common.exception.XmallException in project xmall by Exrick.

the class ThanksServiceImpl method updateThanks.

@Override
public int updateThanks(TbThanks tbThanks) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date = null;
    try {
        date = format.parse(tbThanks.getTime());
    } catch (ParseException e) {
        e.printStackTrace();
    }
    tbThanks.setDate(date);
    if (tbThanksMapper.updateByPrimaryKey(tbThanks) != 1) {
        throw new XmallException("更新捐赠失败");
    }
    return 1;
}
Also used : ParseException(java.text.ParseException) XmallException(cn.exrick.common.exception.XmallException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 44 with XmallException

use of cn.exrick.common.exception.XmallException in project xmall by Exrick.

the class ThanksServiceImpl method addThanks.

@Override
public int addThanks(TbThanks tbThanks) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date = null;
    try {
        date = format.parse(tbThanks.getTime());
    } catch (ParseException e) {
        e.printStackTrace();
    }
    tbThanks.setDate(date);
    if (tbThanksMapper.insert(tbThanks) != 1) {
        throw new XmallException("添加捐赠失败");
    }
    return 1;
}
Also used : ParseException(java.text.ParseException) XmallException(cn.exrick.common.exception.XmallException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 45 with XmallException

use of cn.exrick.common.exception.XmallException in project xmall by Exrick.

the class UserServiceImpl method getRoleList.

@Override
public DataTablesResult getRoleList() {
    DataTablesResult result = new DataTablesResult();
    List<RoleDto> list = new ArrayList<>();
    TbRoleExample example = new TbRoleExample();
    List<TbRole> list1 = tbRoleMapper.selectByExample(example);
    if (list1 == null) {
        throw new XmallException("获取角色列表失败");
    }
    for (TbRole tbRole : list1) {
        RoleDto roleDto = new RoleDto();
        roleDto.setId(tbRole.getId());
        roleDto.setName(tbRole.getName());
        roleDto.setDescription(tbRole.getDescription());
        List<String> permissions = tbUserMapper.getPermsByRoleId(tbRole.getId());
        String names = "";
        if (permissions.size() > 1) {
            names += permissions.get(0);
            for (int i = 1; i < permissions.size(); i++) {
                names += "|" + permissions.get(i);
            }
        } else if (permissions.size() == 1) {
            names += permissions.get(0);
        }
        roleDto.setPermissions(names);
        list.add(roleDto);
    }
    result.setData(list);
    return result;
}
Also used : RoleDto(cn.exrick.manager.dto.RoleDto) DataTablesResult(cn.exrick.common.pojo.DataTablesResult) XmallException(cn.exrick.common.exception.XmallException)

Aggregations

XmallException (cn.exrick.common.exception.XmallException)47 Date (java.util.Date)22 TbMember (cn.exrick.manager.pojo.TbMember)12 DataTablesResult (cn.exrick.common.pojo.DataTablesResult)11 TbMemberExample (cn.exrick.manager.pojo.TbMemberExample)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Gson (com.google.gson.Gson)4 TbItem (cn.exrick.manager.pojo.TbItem)3 TbThanksExample (cn.exrick.manager.pojo.TbThanksExample)3 PageInfo (com.github.pagehelper.PageInfo)3 ParseException (java.text.ParseException)3 ArrayList (java.util.ArrayList)3 CartProduct (cn.exrick.manager.dto.front.CartProduct)2 SearchItem (cn.exrick.manager.dto.front.SearchItem)2 TbContentCategory (cn.exrick.manager.pojo.TbContentCategory)2 TbItemCat (cn.exrick.manager.pojo.TbItemCat)2 TbItemDesc (cn.exrick.manager.pojo.TbItemDesc)2 TbThanks (cn.exrick.manager.pojo.TbThanks)2 TransportClient (org.elasticsearch.client.transport.TransportClient)2 Settings (org.elasticsearch.common.settings.Settings)2