The following issues were found
litemall-core/src/main/java/org/linlinjava/litemall/core/util/ResponseUtil.java
16 issues
Line: 42
* 具体见litemall-wx-api模块的WxResponseCode。
* </ul>
*/
public class ResponseUtil {
public static Object ok() {
Map<String, Object> obj = new HashMap<String, Object>();
obj.put("errno", 0);
obj.put("errmsg", "成功");
return obj;
Reported by PMD.
Line: 42
* 具体见litemall-wx-api模块的WxResponseCode。
* </ul>
*/
public class ResponseUtil {
public static Object ok() {
Map<String, Object> obj = new HashMap<String, Object>();
obj.put("errno", 0);
obj.put("errmsg", "成功");
return obj;
Reported by PMD.
Line: 45
public class ResponseUtil {
public static Object ok() {
Map<String, Object> obj = new HashMap<String, Object>();
obj.put("errno", 0);
obj.put("errmsg", "成功");
return obj;
}
public static Object ok(Object data) {
Reported by PMD.
Line: 46
public static Object ok() {
Map<String, Object> obj = new HashMap<String, Object>();
obj.put("errno", 0);
obj.put("errmsg", "成功");
return obj;
}
public static Object ok(Object data) {
Map<String, Object> obj = new HashMap<String, Object>();
Reported by PMD.
Line: 64
if (list instanceof Page) {
Page page = (Page) list;
data.put("total", page.getTotal());
data.put("page", page.getPageNum());
data.put("limit", page.getPageSize());
data.put("pages", page.getPages());
} else {
data.put("total", list.size());
Reported by PMD.
Line: 64
if (list instanceof Page) {
Page page = (Page) list;
data.put("total", page.getTotal());
data.put("page", page.getPageNum());
data.put("limit", page.getPageSize());
data.put("pages", page.getPages());
} else {
data.put("total", list.size());
Reported by PMD.
Line: 65
if (list instanceof Page) {
Page page = (Page) list;
data.put("total", page.getTotal());
data.put("page", page.getPageNum());
data.put("limit", page.getPageSize());
data.put("pages", page.getPages());
} else {
data.put("total", list.size());
data.put("page", 1);
Reported by PMD.
Line: 65
if (list instanceof Page) {
Page page = (Page) list;
data.put("total", page.getTotal());
data.put("page", page.getPageNum());
data.put("limit", page.getPageSize());
data.put("pages", page.getPages());
} else {
data.put("total", list.size());
data.put("page", 1);
Reported by PMD.
Line: 66
Page page = (Page) list;
data.put("total", page.getTotal());
data.put("page", page.getPageNum());
data.put("limit", page.getPageSize());
data.put("pages", page.getPages());
} else {
data.put("total", list.size());
data.put("page", 1);
data.put("limit", list.size());
Reported by PMD.
Line: 66
Page page = (Page) list;
data.put("total", page.getTotal());
data.put("page", page.getPageNum());
data.put("limit", page.getPageSize());
data.put("pages", page.getPages());
} else {
data.put("total", list.size());
data.put("page", 1);
data.put("limit", list.size());
Reported by PMD.
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCollectService.java
16 issues
Line: 17
@Service
public class LitemallCollectService {
@Resource
private LitemallCollectMapper collectMapper;
public int count(int uid, byte type, Integer gid) {
LitemallCollectExample example = new LitemallCollectExample();
example.or().andUserIdEqualTo(uid).andTypeEqualTo(type).andValueIdEqualTo(gid).andDeletedEqualTo(false);
return (int) collectMapper.countByExample(example);
Reported by PMD.
Line: 21
public int count(int uid, byte type, Integer gid) {
LitemallCollectExample example = new LitemallCollectExample();
example.or().andUserIdEqualTo(uid).andTypeEqualTo(type).andValueIdEqualTo(gid).andDeletedEqualTo(false);
return (int) collectMapper.countByExample(example);
}
public List<LitemallCollect> queryByType(Integer userId, Byte type, Integer page, Integer limit, String sort, String order) {
LitemallCollectExample example = new LitemallCollectExample();
Reported by PMD.
Line: 21
public int count(int uid, byte type, Integer gid) {
LitemallCollectExample example = new LitemallCollectExample();
example.or().andUserIdEqualTo(uid).andTypeEqualTo(type).andValueIdEqualTo(gid).andDeletedEqualTo(false);
return (int) collectMapper.countByExample(example);
}
public List<LitemallCollect> queryByType(Integer userId, Byte type, Integer page, Integer limit, String sort, String order) {
LitemallCollectExample example = new LitemallCollectExample();
Reported by PMD.
Line: 21
public int count(int uid, byte type, Integer gid) {
LitemallCollectExample example = new LitemallCollectExample();
example.or().andUserIdEqualTo(uid).andTypeEqualTo(type).andValueIdEqualTo(gid).andDeletedEqualTo(false);
return (int) collectMapper.countByExample(example);
}
public List<LitemallCollect> queryByType(Integer userId, Byte type, Integer page, Integer limit, String sort, String order) {
LitemallCollectExample example = new LitemallCollectExample();
Reported by PMD.
Line: 21
public int count(int uid, byte type, Integer gid) {
LitemallCollectExample example = new LitemallCollectExample();
example.or().andUserIdEqualTo(uid).andTypeEqualTo(type).andValueIdEqualTo(gid).andDeletedEqualTo(false);
return (int) collectMapper.countByExample(example);
}
public List<LitemallCollect> queryByType(Integer userId, Byte type, Integer page, Integer limit, String sort, String order) {
LitemallCollectExample example = new LitemallCollectExample();
Reported by PMD.
Line: 32
if (type != null) {
criteria.andTypeEqualTo(type);
}
criteria.andUserIdEqualTo(userId);
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
Reported by PMD.
Line: 33
criteria.andTypeEqualTo(type);
}
criteria.andUserIdEqualTo(userId);
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
Reported by PMD.
Line: 45
public int countByType(Integer userId, Byte type) {
LitemallCollectExample example = new LitemallCollectExample();
example.or().andUserIdEqualTo(userId).andTypeEqualTo(type).andDeletedEqualTo(false);
return (int) collectMapper.countByExample(example);
}
public LitemallCollect queryByTypeAndValue(Integer userId, Byte type, Integer valueId) {
LitemallCollectExample example = new LitemallCollectExample();
Reported by PMD.
Line: 45
public int countByType(Integer userId, Byte type) {
LitemallCollectExample example = new LitemallCollectExample();
example.or().andUserIdEqualTo(userId).andTypeEqualTo(type).andDeletedEqualTo(false);
return (int) collectMapper.countByExample(example);
}
public LitemallCollect queryByTypeAndValue(Integer userId, Byte type, Integer valueId) {
LitemallCollectExample example = new LitemallCollectExample();
Reported by PMD.
Line: 45
public int countByType(Integer userId, Byte type) {
LitemallCollectExample example = new LitemallCollectExample();
example.or().andUserIdEqualTo(userId).andTypeEqualTo(type).andDeletedEqualTo(false);
return (int) collectMapper.countByExample(example);
}
public LitemallCollect queryByTypeAndValue(Integer userId, Byte type, Integer valueId) {
LitemallCollectExample example = new LitemallCollectExample();
Reported by PMD.
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCouponUserService.java
16 issues
Line: 16
import java.util.List;
@Service
public class LitemallCouponUserService {
@Resource
private LitemallCouponUserMapper couponUserMapper;
public Integer countCoupon(Integer couponId) {
LitemallCouponUserExample example = new LitemallCouponUserExample();
Reported by PMD.
Line: 18
@Service
public class LitemallCouponUserService {
@Resource
private LitemallCouponUserMapper couponUserMapper;
public Integer countCoupon(Integer couponId) {
LitemallCouponUserExample example = new LitemallCouponUserExample();
example.or().andCouponIdEqualTo(couponId).andDeletedEqualTo(false);
return (int)couponUserMapper.countByExample(example);
Reported by PMD.
Line: 22
public Integer countCoupon(Integer couponId) {
LitemallCouponUserExample example = new LitemallCouponUserExample();
example.or().andCouponIdEqualTo(couponId).andDeletedEqualTo(false);
return (int)couponUserMapper.countByExample(example);
}
public Integer countUserAndCoupon(Integer userId, Integer couponId) {
LitemallCouponUserExample example = new LitemallCouponUserExample();
Reported by PMD.
Line: 22
public Integer countCoupon(Integer couponId) {
LitemallCouponUserExample example = new LitemallCouponUserExample();
example.or().andCouponIdEqualTo(couponId).andDeletedEqualTo(false);
return (int)couponUserMapper.countByExample(example);
}
public Integer countUserAndCoupon(Integer userId, Integer couponId) {
LitemallCouponUserExample example = new LitemallCouponUserExample();
Reported by PMD.
Line: 28
public Integer countUserAndCoupon(Integer userId, Integer couponId) {
LitemallCouponUserExample example = new LitemallCouponUserExample();
example.or().andUserIdEqualTo(userId).andCouponIdEqualTo(couponId).andDeletedEqualTo(false);
return (int)couponUserMapper.countByExample(example);
}
public void add(LitemallCouponUser couponUser) {
couponUser.setAddTime(LocalDateTime.now());
Reported by PMD.
Line: 28
public Integer countUserAndCoupon(Integer userId, Integer couponId) {
LitemallCouponUserExample example = new LitemallCouponUserExample();
example.or().andUserIdEqualTo(userId).andCouponIdEqualTo(couponId).andDeletedEqualTo(false);
return (int)couponUserMapper.countByExample(example);
}
public void add(LitemallCouponUser couponUser) {
couponUser.setAddTime(LocalDateTime.now());
Reported by PMD.
Line: 28
public Integer countUserAndCoupon(Integer userId, Integer couponId) {
LitemallCouponUserExample example = new LitemallCouponUserExample();
example.or().andUserIdEqualTo(userId).andCouponIdEqualTo(couponId).andDeletedEqualTo(false);
return (int)couponUserMapper.countByExample(example);
}
public void add(LitemallCouponUser couponUser) {
couponUser.setAddTime(LocalDateTime.now());
Reported by PMD.
Line: 50
if (status != null) {
criteria.andStatusEqualTo(status);
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
Reported by PMD.
Line: 73
public LitemallCouponUser queryOne(Integer userId, Integer couponId) {
List<LitemallCouponUser> couponUserList = queryList(userId, couponId, CouponUserConstant.STATUS_USABLE, 1, 1, "add_time", "desc");
if(couponUserList.size() == 0){
return null;
}
return couponUserList.get(0);
}
Reported by PMD.
Line: 73
public LitemallCouponUser queryOne(Integer userId, Integer couponId) {
List<LitemallCouponUser> couponUserList = queryList(userId, couponId, CouponUserConstant.STATUS_USABLE, 1, 1, "add_time", "desc");
if(couponUserList.size() == 0){
return null;
}
return couponUserList.get(0);
}
Reported by PMD.
litemall-core/src/test/java/org/linlinjava/litemall/core/QiniuStorageTest.java
15 issues
Line: 32
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
qiniuStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = qiniuStorage.loadAsResource("litemall.png");
String url = qiniuStorage.generateUrl("litemall.png");
logger.info("test file " + test);
logger.info("store file " + resource.getURI());
logger.info("generate url " + url);
Reported by PMD.
Line: 35
qiniuStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = qiniuStorage.loadAsResource("litemall.png");
String url = qiniuStorage.generateUrl("litemall.png");
logger.info("test file " + test);
logger.info("store file " + resource.getURI());
logger.info("generate url " + url);
}
}
Reported by PMD.
Line: 36
Resource resource = qiniuStorage.loadAsResource("litemall.png");
String url = qiniuStorage.generateUrl("litemall.png");
logger.info("test file " + test);
logger.info("store file " + resource.getURI());
logger.info("generate url " + url);
}
}
Reported by PMD.
Line: 37
String url = qiniuStorage.generateUrl("litemall.png");
logger.info("test file " + test);
logger.info("store file " + resource.getURI());
logger.info("generate url " + url);
}
}
Reported by PMD.
Line: 24
@SpringBootTest
public class QiniuStorageTest {
private final Log logger = LogFactory.getLog(QiniuStorageTest.class);
@Autowired
private QiniuStorage qiniuStorage;
@Test
public void test() throws IOException {
Reported by PMD.
Line: 24
@SpringBootTest
public class QiniuStorageTest {
private final Log logger = LogFactory.getLog(QiniuStorageTest.class);
@Autowired
private QiniuStorage qiniuStorage;
@Test
public void test() throws IOException {
Reported by PMD.
Line: 26
private final Log logger = LogFactory.getLog(QiniuStorageTest.class);
@Autowired
private QiniuStorage qiniuStorage;
@Test
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
Reported by PMD.
Line: 29
private QiniuStorage qiniuStorage;
@Test
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
qiniuStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = qiniuStorage.loadAsResource("litemall.png");
String url = qiniuStorage.generateUrl("litemall.png");
Reported by PMD.
Line: 30
@Test
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
qiniuStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = qiniuStorage.loadAsResource("litemall.png");
String url = qiniuStorage.generateUrl("litemall.png");
logger.info("test file " + test);
Reported by PMD.
Line: 30
@Test
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
qiniuStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = qiniuStorage.loadAsResource("litemall.png");
String url = qiniuStorage.generateUrl("litemall.png");
logger.info("test file " + test);
Reported by PMD.
litemall-core/src/test/java/org/linlinjava/litemall/core/LocalStorageTest.java
15 issues
Line: 32
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
localStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = localStorage.loadAsResource("litemall.png");
String url = localStorage.generateUrl("litemall.png");
logger.info("test file " + test);
logger.info("store file " + resource.getURI());
logger.info("generate url " + url);
Reported by PMD.
Line: 35
localStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = localStorage.loadAsResource("litemall.png");
String url = localStorage.generateUrl("litemall.png");
logger.info("test file " + test);
logger.info("store file " + resource.getURI());
logger.info("generate url " + url);
}
}
Reported by PMD.
Line: 36
Resource resource = localStorage.loadAsResource("litemall.png");
String url = localStorage.generateUrl("litemall.png");
logger.info("test file " + test);
logger.info("store file " + resource.getURI());
logger.info("generate url " + url);
}
}
Reported by PMD.
Line: 37
String url = localStorage.generateUrl("litemall.png");
logger.info("test file " + test);
logger.info("store file " + resource.getURI());
logger.info("generate url " + url);
}
}
Reported by PMD.
Line: 24
@SpringBootTest
public class LocalStorageTest {
private final Log logger = LogFactory.getLog(LocalStorageTest.class);
@Autowired
private LocalStorage localStorage;
@Test
public void test() throws IOException {
Reported by PMD.
Line: 24
@SpringBootTest
public class LocalStorageTest {
private final Log logger = LogFactory.getLog(LocalStorageTest.class);
@Autowired
private LocalStorage localStorage;
@Test
public void test() throws IOException {
Reported by PMD.
Line: 26
private final Log logger = LogFactory.getLog(LocalStorageTest.class);
@Autowired
private LocalStorage localStorage;
@Test
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
Reported by PMD.
Line: 29
private LocalStorage localStorage;
@Test
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
localStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = localStorage.loadAsResource("litemall.png");
String url = localStorage.generateUrl("litemall.png");
Reported by PMD.
Line: 30
@Test
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
localStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = localStorage.loadAsResource("litemall.png");
String url = localStorage.generateUrl("litemall.png");
logger.info("test file " + test);
Reported by PMD.
Line: 30
@Test
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
localStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = localStorage.loadAsResource("litemall.png");
String url = localStorage.generateUrl("litemall.png");
logger.info("test file " + test);
Reported by PMD.
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxFootprintController.java
15 issues
Line: 30
@RequestMapping("/wx/footprint")
@Validated
public class WxFootprintController {
private final Log logger = LogFactory.getLog(WxFootprintController.class);
@Autowired
private LitemallFootprintService footprintService;
@Autowired
private LitemallGoodsService goodsService;
Reported by PMD.
Line: 30
@RequestMapping("/wx/footprint")
@Validated
public class WxFootprintController {
private final Log logger = LogFactory.getLog(WxFootprintController.class);
@Autowired
private LitemallFootprintService footprintService;
@Autowired
private LitemallGoodsService goodsService;
Reported by PMD.
Line: 33
private final Log logger = LogFactory.getLog(WxFootprintController.class);
@Autowired
private LitemallFootprintService footprintService;
@Autowired
private LitemallGoodsService goodsService;
/**
* 删除用户足迹
Reported by PMD.
Line: 35
@Autowired
private LitemallFootprintService footprintService;
@Autowired
private LitemallGoodsService goodsService;
/**
* 删除用户足迹
*
* @param userId 用户ID
Reported by PMD.
Line: 62
if (footprint == null) {
return ResponseUtil.badArgumentValue();
}
if (!footprint.getUserId().equals(userId)) {
return ResponseUtil.badArgumentValue();
}
footprintService.deleteById(footprintId);
return ResponseUtil.ok();
Reported by PMD.
Line: 62
if (footprint == null) {
return ResponseUtil.badArgumentValue();
}
if (!footprint.getUserId().equals(userId)) {
return ResponseUtil.badArgumentValue();
}
footprintService.deleteById(footprintId);
return ResponseUtil.ok();
Reported by PMD.
Line: 87
List<LitemallFootprint> footprintList = footprintService.queryByAddTime(userId, page, limit);
List<Object> footprintVoList = new ArrayList<>(footprintList.size());
for (LitemallFootprint footprint : footprintList) {
Map<String, Object> c = new HashMap<String, Object>();
c.put("id", footprint.getId());
c.put("goodsId", footprint.getGoodsId());
c.put("addTime", footprint.getAddTime());
Reported by PMD.
Line: 89
List<Object> footprintVoList = new ArrayList<>(footprintList.size());
for (LitemallFootprint footprint : footprintList) {
Map<String, Object> c = new HashMap<String, Object>();
c.put("id", footprint.getId());
c.put("goodsId", footprint.getGoodsId());
c.put("addTime", footprint.getAddTime());
LitemallGoods goods = goodsService.findById(footprint.getGoodsId());
Reported by PMD.
Line: 95
c.put("addTime", footprint.getAddTime());
LitemallGoods goods = goodsService.findById(footprint.getGoodsId());
c.put("name", goods.getName());
c.put("brief", goods.getBrief());
c.put("picUrl", goods.getPicUrl());
c.put("retailPrice", goods.getRetailPrice());
footprintVoList.add(c);
Reported by PMD.
Line: 96
LitemallGoods goods = goodsService.findById(footprint.getGoodsId());
c.put("name", goods.getName());
c.put("brief", goods.getBrief());
c.put("picUrl", goods.getPicUrl());
c.put("retailPrice", goods.getRetailPrice());
footprintVoList.add(c);
}
Reported by PMD.
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCollectController.java
15 issues
Line: 40
@RequestMapping("/wx/collect")
@Validated
public class WxCollectController {
private final Log logger = LogFactory.getLog(WxCollectController.class);
@Autowired
private LitemallCollectService collectService;
@Autowired
private LitemallGoodsService goodsService;
Reported by PMD.
Line: 40
@RequestMapping("/wx/collect")
@Validated
public class WxCollectController {
private final Log logger = LogFactory.getLog(WxCollectController.class);
@Autowired
private LitemallCollectService collectService;
@Autowired
private LitemallGoodsService goodsService;
Reported by PMD.
Line: 43
private final Log logger = LogFactory.getLog(WxCollectController.class);
@Autowired
private LitemallCollectService collectService;
@Autowired
private LitemallGoodsService goodsService;
@Autowired
private LitemallTopicService topicService;
Reported by PMD.
Line: 45
@Autowired
private LitemallCollectService collectService;
@Autowired
private LitemallGoodsService goodsService;
@Autowired
private LitemallTopicService topicService;
/**
* 用户收藏列表
Reported by PMD.
Line: 47
@Autowired
private LitemallGoodsService goodsService;
@Autowired
private LitemallTopicService topicService;
/**
* 用户收藏列表
*
* @param userId 用户ID
Reported by PMD.
Line: 71
List<LitemallCollect> collectList = collectService.queryByType(userId, type, page, limit, sort, order);
List<Object> collects = new ArrayList<>(collectList.size());
for (LitemallCollect collect : collectList) {
Map<String, Object> c = new HashMap<String, Object>();
c.put("id", collect.getId());
c.put("type", collect.getType());
c.put("valueId", collect.getValueId());
Reported by PMD.
Line: 73
List<Object> collects = new ArrayList<>(collectList.size());
for (LitemallCollect collect : collectList) {
Map<String, Object> c = new HashMap<String, Object>();
c.put("id", collect.getId());
c.put("type", collect.getType());
c.put("valueId", collect.getValueId());
if (type == (byte)0){
//查询商品信息
Reported by PMD.
Line: 80
if (type == (byte)0){
//查询商品信息
LitemallGoods goods = goodsService.findById(collect.getValueId());
c.put("name", goods.getName());
c.put("brief", goods.getBrief());
c.put("picUrl", goods.getPicUrl());
c.put("retailPrice", goods.getRetailPrice());
} else {
//查询专题信息
Reported by PMD.
Line: 81
//查询商品信息
LitemallGoods goods = goodsService.findById(collect.getValueId());
c.put("name", goods.getName());
c.put("brief", goods.getBrief());
c.put("picUrl", goods.getPicUrl());
c.put("retailPrice", goods.getRetailPrice());
} else {
//查询专题信息
LitemallTopic topic = topicService.findById(collect.getValueId());
Reported by PMD.
Line: 82
LitemallGoods goods = goodsService.findById(collect.getValueId());
c.put("name", goods.getName());
c.put("brief", goods.getBrief());
c.put("picUrl", goods.getPicUrl());
c.put("retailPrice", goods.getRetailPrice());
} else {
//查询专题信息
LitemallTopic topic = topicService.findById(collect.getValueId());
c.put("title", topic.getTitle());
Reported by PMD.
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallPermissionService.java
14 issues
Line: 21
@Service
public class LitemallPermissionService {
@Resource
private LitemallPermissionMapper permissionMapper;
public Set<String> queryByRoleIds(Integer[] roleIds) {
Set<String> permissions = new HashSet<String>();
if(roleIds.length == 0){
return permissions;
Reported by PMD.
Line: 30
}
LitemallPermissionExample example = new LitemallPermissionExample();
example.or().andRoleIdIn(Arrays.asList(roleIds)).andDeletedEqualTo(false);
List<LitemallPermission> permissionList = permissionMapper.selectByExample(example);
for(LitemallPermission permission : permissionList){
permissions.add(permission.getPermission());
}
Reported by PMD.
Line: 30
}
LitemallPermissionExample example = new LitemallPermissionExample();
example.or().andRoleIdIn(Arrays.asList(roleIds)).andDeletedEqualTo(false);
List<LitemallPermission> permissionList = permissionMapper.selectByExample(example);
for(LitemallPermission permission : permissionList){
permissions.add(permission.getPermission());
}
Reported by PMD.
Line: 48
}
LitemallPermissionExample example = new LitemallPermissionExample();
example.or().andRoleIdEqualTo(roleId).andDeletedEqualTo(false);
List<LitemallPermission> permissionList = permissionMapper.selectByExample(example);
for(LitemallPermission permission : permissionList){
permissions.add(permission.getPermission());
}
Reported by PMD.
Line: 48
}
LitemallPermissionExample example = new LitemallPermissionExample();
example.or().andRoleIdEqualTo(roleId).andDeletedEqualTo(false);
List<LitemallPermission> permissionList = permissionMapper.selectByExample(example);
for(LitemallPermission permission : permissionList){
permissions.add(permission.getPermission());
}
Reported by PMD.
Line: 64
}
LitemallPermissionExample example = new LitemallPermissionExample();
example.or().andRoleIdEqualTo(roleId).andPermissionEqualTo("*").andDeletedEqualTo(false);
return permissionMapper.countByExample(example) != 0;
}
public void deleteByRoleId(Integer roleId) {
LitemallPermissionExample example = new LitemallPermissionExample();
Reported by PMD.
Line: 64
}
LitemallPermissionExample example = new LitemallPermissionExample();
example.or().andRoleIdEqualTo(roleId).andPermissionEqualTo("*").andDeletedEqualTo(false);
return permissionMapper.countByExample(example) != 0;
}
public void deleteByRoleId(Integer roleId) {
LitemallPermissionExample example = new LitemallPermissionExample();
Reported by PMD.
Line: 64
}
LitemallPermissionExample example = new LitemallPermissionExample();
example.or().andRoleIdEqualTo(roleId).andPermissionEqualTo("*").andDeletedEqualTo(false);
return permissionMapper.countByExample(example) != 0;
}
public void deleteByRoleId(Integer roleId) {
LitemallPermissionExample example = new LitemallPermissionExample();
Reported by PMD.
Line: 70
public void deleteByRoleId(Integer roleId) {
LitemallPermissionExample example = new LitemallPermissionExample();
example.or().andRoleIdEqualTo(roleId).andDeletedEqualTo(false);
permissionMapper.logicalDeleteByExample(example);
}
public void add(LitemallPermission litemallPermission) {
litemallPermission.setAddTime(LocalDateTime.now());
Reported by PMD.
Line: 70
public void deleteByRoleId(Integer roleId) {
LitemallPermissionExample example = new LitemallPermissionExample();
example.or().andRoleIdEqualTo(roleId).andDeletedEqualTo(false);
permissionMapper.logicalDeleteByExample(example);
}
public void add(LitemallPermission litemallPermission) {
litemallPermission.setAddTime(LocalDateTime.now());
Reported by PMD.
litemall-core/src/test/java/org/linlinjava/litemall/core/AliyunStorageTest.java
14 issues
Line: 31
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
aliyunStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = aliyunStorage.loadAsResource("litemall.png");
String url = aliyunStorage.generateUrl("litemall.png");
logger.info("test file " + test);
logger.info("store file " + resource.getURI());
logger.info("generate url " + url);
Reported by PMD.
Line: 34
aliyunStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = aliyunStorage.loadAsResource("litemall.png");
String url = aliyunStorage.generateUrl("litemall.png");
logger.info("test file " + test);
logger.info("store file " + resource.getURI());
logger.info("generate url " + url);
}
}
Reported by PMD.
Line: 35
Resource resource = aliyunStorage.loadAsResource("litemall.png");
String url = aliyunStorage.generateUrl("litemall.png");
logger.info("test file " + test);
logger.info("store file " + resource.getURI());
logger.info("generate url " + url);
}
}
Reported by PMD.
Line: 36
String url = aliyunStorage.generateUrl("litemall.png");
logger.info("test file " + test);
logger.info("store file " + resource.getURI());
logger.info("generate url " + url);
}
}
Reported by PMD.
Line: 23
@SpringBootTest
public class AliyunStorageTest {
private final Log logger = LogFactory.getLog(AliyunStorageTest.class);
@Autowired
private AliyunStorage aliyunStorage;
@Test
public void test() throws IOException {
Reported by PMD.
Line: 23
@SpringBootTest
public class AliyunStorageTest {
private final Log logger = LogFactory.getLog(AliyunStorageTest.class);
@Autowired
private AliyunStorage aliyunStorage;
@Test
public void test() throws IOException {
Reported by PMD.
Line: 25
private final Log logger = LogFactory.getLog(AliyunStorageTest.class);
@Autowired
private AliyunStorage aliyunStorage;
@Test
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
Reported by PMD.
Line: 28
private AliyunStorage aliyunStorage;
@Test
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
aliyunStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = aliyunStorage.loadAsResource("litemall.png");
String url = aliyunStorage.generateUrl("litemall.png");
Reported by PMD.
Line: 29
@Test
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
aliyunStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = aliyunStorage.loadAsResource("litemall.png");
String url = aliyunStorage.generateUrl("litemall.png");
logger.info("test file " + test);
Reported by PMD.
Line: 29
@Test
public void test() throws IOException {
String test = getClass().getClassLoader().getResource("litemall.png").getFile();
File testFile = new File(test);
aliyunStorage.store(new FileInputStream(test), testFile.length(), "image/png", "litemall.png");
Resource resource = aliyunStorage.loadAsResource("litemall.png");
String url = aliyunStorage.generateUrl("litemall.png");
logger.info("test file " + test);
Reported by PMD.
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdminController.java
14 issues
Line: 31
@RequestMapping("/admin/admin")
@Validated
public class AdminAdminController {
private final Log logger = LogFactory.getLog(AdminAdminController.class);
@Autowired
private LitemallAdminService adminService;
@Autowired
private LogHelper logHelper;
Reported by PMD.
Line: 31
@RequestMapping("/admin/admin")
@Validated
public class AdminAdminController {
private final Log logger = LogFactory.getLog(AdminAdminController.class);
@Autowired
private LitemallAdminService adminService;
@Autowired
private LogHelper logHelper;
Reported by PMD.
Line: 34
private final Log logger = LogFactory.getLog(AdminAdminController.class);
@Autowired
private LitemallAdminService adminService;
@Autowired
private LogHelper logHelper;
@RequiresPermissions("admin:admin:list")
@RequiresPermissionsDesc(menu = {"系统管理", "管理员管理"}, button = "查询")
Reported by PMD.
Line: 36
@Autowired
private LitemallAdminService adminService;
@Autowired
private LogHelper logHelper;
@RequiresPermissions("admin:admin:list")
@RequiresPermissionsDesc(menu = {"系统管理", "管理员管理"}, button = "查询")
@GetMapping("/list")
public Object list(String username,
Reported by PMD.
Line: 39
private LogHelper logHelper;
@RequiresPermissions("admin:admin:list")
@RequiresPermissionsDesc(menu = {"系统管理", "管理员管理"}, button = "查询")
@GetMapping("/list")
public Object list(String username,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
Reported by PMD.
Line: 39
private LogHelper logHelper;
@RequiresPermissions("admin:admin:list")
@RequiresPermissionsDesc(menu = {"系统管理", "管理员管理"}, button = "查询")
@GetMapping("/list")
public Object list(String username,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
Reported by PMD.
Line: 59
return ResponseUtil.fail(ADMIN_INVALID_NAME, "管理员名称不符合规定");
}
String password = admin.getPassword();
if (StringUtils.isEmpty(password) || password.length() < 6) {
return ResponseUtil.fail(ADMIN_INVALID_PASSWORD, "管理员密码长度不能小于6");
}
return null;
}
Reported by PMD.
Line: 76
String username = admin.getUsername();
List<LitemallAdmin> adminList = adminService.findAdmin(username);
if (adminList.size() > 0) {
return ResponseUtil.fail(ADMIN_NAME_EXIST, "管理员已经存在");
}
String rawPassword = admin.getPassword();
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
Reported by PMD.
Line: 76
String username = admin.getUsername();
List<LitemallAdmin> adminList = adminService.findAdmin(username);
if (adminList.size() > 0) {
return ResponseUtil.fail(ADMIN_NAME_EXIST, "管理员已经存在");
}
String rawPassword = admin.getPassword();
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
Reported by PMD.
Line: 133
// 管理员不能删除自身账号
Subject currentUser = SecurityUtils.getSubject();
LitemallAdmin currentAdmin = (LitemallAdmin) currentUser.getPrincipal();
if (currentAdmin.getId().equals(anotherAdminId)) {
return ResponseUtil.fail(ADMIN_DELETE_NOT_ALLOWED, "管理员不能删除自己账号");
}
adminService.deleteById(anotherAdminId);
Reported by PMD.