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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations