The following issues were found
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.
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminNoticeController.java
14 issues
Line: 33
@RequestMapping("/admin/notice")
@Validated
public class AdminNoticeController {
private final Log logger = LogFactory.getLog(AdminNoticeController.class);
@Autowired
private LitemallNoticeService noticeService;
@Autowired
private LitemallAdminService adminService;
Reported by PMD.
Line: 33
@RequestMapping("/admin/notice")
@Validated
public class AdminNoticeController {
private final Log logger = LogFactory.getLog(AdminNoticeController.class);
@Autowired
private LitemallNoticeService noticeService;
@Autowired
private LitemallAdminService adminService;
Reported by PMD.
Line: 36
private final Log logger = LogFactory.getLog(AdminNoticeController.class);
@Autowired
private LitemallNoticeService noticeService;
@Autowired
private LitemallAdminService adminService;
@Autowired
private LitemallNoticeAdminService noticeAdminService;
Reported by PMD.
Line: 38
@Autowired
private LitemallNoticeService noticeService;
@Autowired
private LitemallAdminService adminService;
@Autowired
private LitemallNoticeAdminService noticeAdminService;
@RequiresPermissions("admin:notice:list")
@RequiresPermissionsDesc(menu = {"系统管理", "通知管理"}, button = "查询")
Reported by PMD.
Line: 40
@Autowired
private LitemallAdminService adminService;
@Autowired
private LitemallNoticeAdminService noticeAdminService;
@RequiresPermissions("admin:notice:list")
@RequiresPermissionsDesc(menu = {"系统管理", "通知管理"}, button = "查询")
@GetMapping("/list")
public Object list(String title, String content,
Reported by PMD.
Line: 43
private LitemallNoticeAdminService noticeAdminService;
@RequiresPermissions("admin:notice:list")
@RequiresPermissionsDesc(menu = {"系统管理", "通知管理"}, button = "查询")
@GetMapping("/list")
public Object list(String title, String content,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
Reported by PMD.
Line: 45
@RequiresPermissions("admin:notice:list")
@RequiresPermissionsDesc(menu = {"系统管理", "通知管理"}, button = "查询")
@GetMapping("/list")
public Object list(String title, String content,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallNotice> noticeList = noticeService.querySelective(title, content, page, limit, sort, order);
Reported by PMD.
Line: 64
private Integer getAdminId(){
Subject currentUser = SecurityUtils.getSubject();
LitemallAdmin admin = (LitemallAdmin) currentUser.getPrincipal();
return admin.getId();
}
@RequiresPermissions("admin:notice:create")
@RequiresPermissionsDesc(menu = {"推广管理", "通知管理"}, button = "添加")
Reported by PMD.
Line: 65
private Integer getAdminId(){
Subject currentUser = SecurityUtils.getSubject();
LitemallAdmin admin = (LitemallAdmin) currentUser.getPrincipal();
return admin.getId();
}
@RequiresPermissions("admin:notice:create")
@RequiresPermissionsDesc(menu = {"推广管理", "通知管理"}, button = "添加")
@PostMapping("/create")
Reported by PMD.
Line: 69
}
@RequiresPermissions("admin:notice:create")
@RequiresPermissionsDesc(menu = {"推广管理", "通知管理"}, button = "添加")
@PostMapping("/create")
public Object create(@RequestBody LitemallNotice notice) {
Object error = validate(notice);
if (error != null) {
return error;
Reported by PMD.
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminTopicController.java
13 issues
Line: 32
@RequestMapping("/admin/topic")
@Validated
public class AdminTopicController {
private final Log logger = LogFactory.getLog(AdminTopicController.class);
@Autowired
private LitemallTopicService topicService;
@Autowired
private LitemallGoodsService goodsService;
Reported by PMD.
Line: 32
@RequestMapping("/admin/topic")
@Validated
public class AdminTopicController {
private final Log logger = LogFactory.getLog(AdminTopicController.class);
@Autowired
private LitemallTopicService topicService;
@Autowired
private LitemallGoodsService goodsService;
Reported by PMD.
Line: 35
private final Log logger = LogFactory.getLog(AdminTopicController.class);
@Autowired
private LitemallTopicService topicService;
@Autowired
private LitemallGoodsService goodsService;
@RequiresPermissions("admin:topic:list")
@RequiresPermissionsDesc(menu = {"推广管理", "专题管理"}, button = "查询")
Reported by PMD.
Line: 37
@Autowired
private LitemallTopicService topicService;
@Autowired
private LitemallGoodsService goodsService;
@RequiresPermissions("admin:topic:list")
@RequiresPermissionsDesc(menu = {"推广管理", "专题管理"}, button = "查询")
@GetMapping("/list")
public Object list(String title, String subtitle,
Reported by PMD.
Line: 40
private LitemallGoodsService goodsService;
@RequiresPermissions("admin:topic:list")
@RequiresPermissionsDesc(menu = {"推广管理", "专题管理"}, button = "查询")
@GetMapping("/list")
public Object list(String title, String subtitle,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort(accepts = {"id", "add_time", "price"}) @RequestParam(defaultValue = "add_time") String sort,
Reported by PMD.
Line: 40
private LitemallGoodsService goodsService;
@RequiresPermissions("admin:topic:list")
@RequiresPermissionsDesc(menu = {"推广管理", "专题管理"}, button = "查询")
@GetMapping("/list")
public Object list(String title, String subtitle,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort(accepts = {"id", "add_time", "price"}) @RequestParam(defaultValue = "add_time") String sort,
Reported by PMD.
Line: 42
@RequiresPermissions("admin:topic:list")
@RequiresPermissionsDesc(menu = {"推广管理", "专题管理"}, button = "查询")
@GetMapping("/list")
public Object list(String title, String subtitle,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort(accepts = {"id", "add_time", "price"}) @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallTopic> topicList = topicService.querySelective(title, subtitle, page, limit, sort, order);
Reported by PMD.
Line: 84
@GetMapping("/read")
public Object read(@NotNull Integer id) {
LitemallTopic topic = topicService.findById(id);
Integer[] goodsIds = topic.getGoods();
List<LitemallGoods> goodsList = null;
if (goodsIds == null || goodsIds.length == 0) {
goodsList = new ArrayList<>();
} else {
goodsList = goodsService.queryByIds(goodsIds);
Reported by PMD.
Line: 85
public Object read(@NotNull Integer id) {
LitemallTopic topic = topicService.findById(id);
Integer[] goodsIds = topic.getGoods();
List<LitemallGoods> goodsList = null;
if (goodsIds == null || goodsIds.length == 0) {
goodsList = new ArrayList<>();
} else {
goodsList = goodsService.queryByIds(goodsIds);
}
Reported by PMD.
Line: 3
package org.linlinjava.litemall.admin.web;
import io.swagger.models.auth.In;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc;
import org.linlinjava.litemall.core.util.JacksonUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
Reported by PMD.
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/shiro/AdminAuthorizingRealm.java
13 issues
Line: 31
@Autowired
@Lazy
private LitemallAdminService adminService;
@Autowired
@Lazy
private LitemallRoleService roleService;
@Autowired
@Lazy
Reported by PMD.
Line: 34
private LitemallAdminService adminService;
@Autowired
@Lazy
private LitemallRoleService roleService;
@Autowired
@Lazy
private LitemallPermissionService permissionService;
@Override
Reported by PMD.
Line: 37
private LitemallRoleService roleService;
@Autowired
@Lazy
private LitemallPermissionService permissionService;
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
if (principals == null) {
throw new AuthorizationException("PrincipalCollection method argument cannot be null.");
Reported by PMD.
Line: 46
}
LitemallAdmin admin = (LitemallAdmin) getAvailablePrincipal(principals);
Integer[] roleIds = admin.getRoleIds();
Set<String> roles = roleService.queryByIds(roleIds);
Set<String> permissions = permissionService.queryByRoleIds(roleIds);
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
info.setRoles(roles);
info.setStringPermissions(permissions);
Reported by PMD.
Line: 59
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
UsernamePasswordToken upToken = (UsernamePasswordToken) token;
String username = upToken.getUsername();
String password = new String(upToken.getPassword());
if (StringUtils.isEmpty(username)) {
throw new AccountException("用户名不能为空");
}
Reported by PMD.
Line: 60
UsernamePasswordToken upToken = (UsernamePasswordToken) token;
String username = upToken.getUsername();
String password = new String(upToken.getPassword());
if (StringUtils.isEmpty(username)) {
throw new AccountException("用户名不能为空");
}
if (StringUtils.isEmpty(password)) {
Reported by PMD.
Line: 70
}
List<LitemallAdmin> adminList = adminService.findAdmin(username);
Assert.state(adminList.size() < 2, "同一个用户名存在两个账户");
if (adminList.size() == 0) {
throw new UnknownAccountException("找不到用户(" + username + ")的帐号信息");
}
LitemallAdmin admin = adminList.get(0);
Reported by PMD.
Line: 71
List<LitemallAdmin> adminList = adminService.findAdmin(username);
Assert.state(adminList.size() < 2, "同一个用户名存在两个账户");
if (adminList.size() == 0) {
throw new UnknownAccountException("找不到用户(" + username + ")的帐号信息");
}
LitemallAdmin admin = adminList.get(0);
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
Reported by PMD.
Line: 71
List<LitemallAdmin> adminList = adminService.findAdmin(username);
Assert.state(adminList.size() < 2, "同一个用户名存在两个账户");
if (adminList.size() == 0) {
throw new UnknownAccountException("找不到用户(" + username + ")的帐号信息");
}
LitemallAdmin admin = adminList.get(0);
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
Reported by PMD.
Line: 74
if (adminList.size() == 0) {
throw new UnknownAccountException("找不到用户(" + username + ")的帐号信息");
}
LitemallAdmin admin = adminList.get(0);
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
if (!encoder.matches(password, admin.getPassword())) {
throw new UnknownAccountException("找不到用户(" + username + ")的帐号信息");
}
Reported by PMD.
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxSearchController.java
12 issues
Line: 30
@RequestMapping("/wx/search")
@Validated
public class WxSearchController {
private final Log logger = LogFactory.getLog(WxSearchController.class);
@Autowired
private LitemallKeywordService keywordsService;
@Autowired
private LitemallSearchHistoryService searchHistoryService;
Reported by PMD.
Line: 30
@RequestMapping("/wx/search")
@Validated
public class WxSearchController {
private final Log logger = LogFactory.getLog(WxSearchController.class);
@Autowired
private LitemallKeywordService keywordsService;
@Autowired
private LitemallSearchHistoryService searchHistoryService;
Reported by PMD.
Line: 33
private final Log logger = LogFactory.getLog(WxSearchController.class);
@Autowired
private LitemallKeywordService keywordsService;
@Autowired
private LitemallSearchHistoryService searchHistoryService;
/**
* 搜索页面信息
Reported by PMD.
Line: 35
@Autowired
private LitemallKeywordService keywordsService;
@Autowired
private LitemallSearchHistoryService searchHistoryService;
/**
* 搜索页面信息
* <p>
* 如果用户已登录,则给出用户历史搜索记录;
Reported by PMD.
Line: 53
//取出热闹关键词
List<LitemallKeyword> hotKeywordList = keywordsService.queryHots();
List<LitemallSearchHistory> historyList = null;
if (userId != null) {
//取出用户历史关键字
historyList = searchHistoryService.queryByUid(userId);
} else {
historyList = new ArrayList<>(0);
Reported by PMD.
Line: 81
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit) {
List<LitemallKeyword> keywordsList = keywordsService.queryByKeyword(keyword, page, limit);
String[] keys = new String[keywordsList.size()];
int index = 0;
for (LitemallKeyword key : keywordsList) {
keys[index++] = key.getKeyword();
}
return ResponseUtil.ok(keys);
Reported by PMD.
Line: 13
import org.linlinjava.litemall.wx.annotation.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Reported by PMD.
Line: 53
//取出热闹关键词
List<LitemallKeyword> hotKeywordList = keywordsService.queryHots();
List<LitemallSearchHistory> historyList = null;
if (userId != null) {
//取出用户历史关键字
historyList = searchHistoryService.queryByUid(userId);
} else {
historyList = new ArrayList<>(0);
Reported by PMD.
Line: 53
//取出热闹关键词
List<LitemallKeyword> hotKeywordList = keywordsService.queryHots();
List<LitemallSearchHistory> historyList = null;
if (userId != null) {
//取出用户历史关键字
historyList = searchHistoryService.queryByUid(userId);
} else {
historyList = new ArrayList<>(0);
Reported by PMD.
Line: 81
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit) {
List<LitemallKeyword> keywordsList = keywordsService.queryByKeyword(keyword, page, limit);
String[] keys = new String[keywordsList.size()];
int index = 0;
for (LitemallKeyword key : keywordsList) {
keys[index++] = key.getKeyword();
}
return ResponseUtil.ok(keys);
Reported by PMD.
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAddressService.java
12 issues
Line: 17
@Service
public class LitemallAddressService {
@Resource
private LitemallAddressMapper addressMapper;
public List<LitemallAddress> queryByUid(Integer uid) {
LitemallAddressExample example = new LitemallAddressExample();
example.or().andUserIdEqualTo(uid).andDeletedEqualTo(false);
return addressMapper.selectByExample(example);
Reported by PMD.
Line: 21
public List<LitemallAddress> queryByUid(Integer uid) {
LitemallAddressExample example = new LitemallAddressExample();
example.or().andUserIdEqualTo(uid).andDeletedEqualTo(false);
return addressMapper.selectByExample(example);
}
public LitemallAddress query(Integer userId, Integer id) {
LitemallAddressExample example = new LitemallAddressExample();
Reported by PMD.
Line: 21
public List<LitemallAddress> queryByUid(Integer uid) {
LitemallAddressExample example = new LitemallAddressExample();
example.or().andUserIdEqualTo(uid).andDeletedEqualTo(false);
return addressMapper.selectByExample(example);
}
public LitemallAddress query(Integer userId, Integer id) {
LitemallAddressExample example = new LitemallAddressExample();
Reported by PMD.
Line: 27
public LitemallAddress query(Integer userId, Integer id) {
LitemallAddressExample example = new LitemallAddressExample();
example.or().andIdEqualTo(id).andUserIdEqualTo(userId).andDeletedEqualTo(false);
return addressMapper.selectOneByExample(example);
}
public int add(LitemallAddress address) {
address.setAddTime(LocalDateTime.now());
Reported by PMD.
Line: 27
public LitemallAddress query(Integer userId, Integer id) {
LitemallAddressExample example = new LitemallAddressExample();
example.or().andIdEqualTo(id).andUserIdEqualTo(userId).andDeletedEqualTo(false);
return addressMapper.selectOneByExample(example);
}
public int add(LitemallAddress address) {
address.setAddTime(LocalDateTime.now());
Reported by PMD.
Line: 27
public LitemallAddress query(Integer userId, Integer id) {
LitemallAddressExample example = new LitemallAddressExample();
example.or().andIdEqualTo(id).andUserIdEqualTo(userId).andDeletedEqualTo(false);
return addressMapper.selectOneByExample(example);
}
public int add(LitemallAddress address) {
address.setAddTime(LocalDateTime.now());
Reported by PMD.
Line: 48
public LitemallAddress findDefault(Integer userId) {
LitemallAddressExample example = new LitemallAddressExample();
example.or().andUserIdEqualTo(userId).andIsDefaultEqualTo(true).andDeletedEqualTo(false);
return addressMapper.selectOneByExample(example);
}
public void resetDefault(Integer userId) {
LitemallAddress address = new LitemallAddress();
Reported by PMD.
Line: 48
public LitemallAddress findDefault(Integer userId) {
LitemallAddressExample example = new LitemallAddressExample();
example.or().andUserIdEqualTo(userId).andIsDefaultEqualTo(true).andDeletedEqualTo(false);
return addressMapper.selectOneByExample(example);
}
public void resetDefault(Integer userId) {
LitemallAddress address = new LitemallAddress();
Reported by PMD.
Line: 48
public LitemallAddress findDefault(Integer userId) {
LitemallAddressExample example = new LitemallAddressExample();
example.or().andUserIdEqualTo(userId).andIsDefaultEqualTo(true).andDeletedEqualTo(false);
return addressMapper.selectOneByExample(example);
}
public void resetDefault(Integer userId) {
LitemallAddress address = new LitemallAddress();
Reported by PMD.
Line: 57
address.setIsDefault(false);
address.setUpdateTime(LocalDateTime.now());
LitemallAddressExample example = new LitemallAddressExample();
example.or().andUserIdEqualTo(userId).andDeletedEqualTo(false);
addressMapper.updateByExampleSelective(address, example);
}
public List<LitemallAddress> querySelective(Integer userId, String name, Integer page, Integer limit, String sort, String order) {
LitemallAddressExample example = new LitemallAddressExample();
Reported by PMD.
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAddressController.java
12 issues
Line: 26
@RestController
@RequestMapping("/wx/address")
@Validated
public class WxAddressController extends GetRegionService {
private final Log logger = LogFactory.getLog(WxAddressController.class);
@Autowired
private LitemallAddressService addressService;
Reported by PMD.
Line: 26
@RestController
@RequestMapping("/wx/address")
@Validated
public class WxAddressController extends GetRegionService {
private final Log logger = LogFactory.getLog(WxAddressController.class);
@Autowired
private LitemallAddressService addressService;
Reported by PMD.
Line: 27
@RequestMapping("/wx/address")
@Validated
public class WxAddressController extends GetRegionService {
private final Log logger = LogFactory.getLog(WxAddressController.class);
@Autowired
private LitemallAddressService addressService;
@Autowired
Reported by PMD.
Line: 27
@RequestMapping("/wx/address")
@Validated
public class WxAddressController extends GetRegionService {
private final Log logger = LogFactory.getLog(WxAddressController.class);
@Autowired
private LitemallAddressService addressService;
@Autowired
Reported by PMD.
Line: 30
private final Log logger = LogFactory.getLog(WxAddressController.class);
@Autowired
private LitemallAddressService addressService;
@Autowired
private LitemallRegionService regionService;
Reported by PMD.
Line: 33
private LitemallAddressService addressService;
@Autowired
private LitemallRegionService regionService;
/**
* 用户收货地址列表
*
Reported by PMD.
Line: 71
return ResponseUtil.ok(address);
}
private Object validate(LitemallAddress address) {
String name = address.getName();
if (StringUtils.isEmpty(name)) {
return ResponseUtil.badArgument();
}
Reported by PMD.
Line: 71
return ResponseUtil.ok(address);
}
private Object validate(LitemallAddress address) {
String name = address.getName();
if (StringUtils.isEmpty(name)) {
return ResponseUtil.badArgument();
}
Reported by PMD.
Line: 71
return ResponseUtil.ok(address);
}
private Object validate(LitemallAddress address) {
String name = address.getName();
if (StringUtils.isEmpty(name)) {
return ResponseUtil.badArgument();
}
Reported by PMD.
Line: 71
return ResponseUtil.ok(address);
}
private Object validate(LitemallAddress address) {
String name = address.getName();
if (StringUtils.isEmpty(name)) {
return ResponseUtil.badArgument();
}
Reported by PMD.
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallOrderGoodsService.java
12 issues
Line: 15
@Service
public class LitemallOrderGoodsService {
@Resource
private LitemallOrderGoodsMapper orderGoodsMapper;
public int add(LitemallOrderGoods orderGoods) {
orderGoods.setAddTime(LocalDateTime.now());
orderGoods.setUpdateTime(LocalDateTime.now());
return orderGoodsMapper.insertSelective(orderGoods);
Reported by PMD.
Line: 25
public List<LitemallOrderGoods> queryByOid(Integer orderId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
example.or().andOrderIdEqualTo(orderId).andDeletedEqualTo(false);
return orderGoodsMapper.selectByExample(example);
}
public List<LitemallOrderGoods> findByOidAndGid(Integer orderId, Integer goodsId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
Reported by PMD.
Line: 25
public List<LitemallOrderGoods> queryByOid(Integer orderId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
example.or().andOrderIdEqualTo(orderId).andDeletedEqualTo(false);
return orderGoodsMapper.selectByExample(example);
}
public List<LitemallOrderGoods> findByOidAndGid(Integer orderId, Integer goodsId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
Reported by PMD.
Line: 31
public List<LitemallOrderGoods> findByOidAndGid(Integer orderId, Integer goodsId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
example.or().andOrderIdEqualTo(orderId).andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false);
return orderGoodsMapper.selectByExample(example);
}
public LitemallOrderGoods findById(Integer id) {
return orderGoodsMapper.selectByPrimaryKey(id);
Reported by PMD.
Line: 31
public List<LitemallOrderGoods> findByOidAndGid(Integer orderId, Integer goodsId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
example.or().andOrderIdEqualTo(orderId).andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false);
return orderGoodsMapper.selectByExample(example);
}
public LitemallOrderGoods findById(Integer id) {
return orderGoodsMapper.selectByPrimaryKey(id);
Reported by PMD.
Line: 31
public List<LitemallOrderGoods> findByOidAndGid(Integer orderId, Integer goodsId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
example.or().andOrderIdEqualTo(orderId).andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false);
return orderGoodsMapper.selectByExample(example);
}
public LitemallOrderGoods findById(Integer id) {
return orderGoodsMapper.selectByPrimaryKey(id);
Reported by PMD.
Line: 46
public Short getComments(Integer orderId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
example.or().andOrderIdEqualTo(orderId).andDeletedEqualTo(false);
long count = orderGoodsMapper.countByExample(example);
return (short) count;
}
public boolean checkExist(Integer goodsId) {
Reported by PMD.
Line: 46
public Short getComments(Integer orderId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
example.or().andOrderIdEqualTo(orderId).andDeletedEqualTo(false);
long count = orderGoodsMapper.countByExample(example);
return (short) count;
}
public boolean checkExist(Integer goodsId) {
Reported by PMD.
Line: 53
public boolean checkExist(Integer goodsId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
example.or().andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false);
return orderGoodsMapper.countByExample(example) != 0;
}
public void deleteByOrderId(Integer orderId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
Reported by PMD.
Line: 53
public boolean checkExist(Integer goodsId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
example.or().andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false);
return orderGoodsMapper.countByExample(example) != 0;
}
public void deleteByOrderId(Integer orderId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
Reported by PMD.
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/job/OrderJob.java
12 issues
Line: 55
order.setOrderStatus(OrderUtil.STATUS_AUTO_CONFIRM);
order.setConfirmTime(LocalDateTime.now());
if (orderService.updateWithOptimisticLocker(order) == 0) {
logger.info("订单 ID=" + order.getId() + " 数据已经更新,放弃自动确认收货");
} else {
logger.info("订单 ID=" + order.getId() + " 已经超期自动确认收货");
}
}
Reported by PMD.
Line: 57
if (orderService.updateWithOptimisticLocker(order) == 0) {
logger.info("订单 ID=" + order.getId() + " 数据已经更新,放弃自动确认收货");
} else {
logger.info("订单 ID=" + order.getId() + " 已经超期自动确认收货");
}
}
logger.info("系统结束定时任务检查订单是否已经超期自动确认收货");
}
Reported by PMD.
Line: 22
*/
@Component
public class OrderJob {
private final Log logger = LogFactory.getLog(OrderJob.class);
@Autowired
private LitemallOrderGoodsService orderGoodsService;
@Autowired
private LitemallOrderService orderService;
Reported by PMD.
Line: 22
*/
@Component
public class OrderJob {
private final Log logger = LogFactory.getLog(OrderJob.class);
@Autowired
private LitemallOrderGoodsService orderGoodsService;
@Autowired
private LitemallOrderService orderService;
Reported by PMD.
Line: 25
private final Log logger = LogFactory.getLog(OrderJob.class);
@Autowired
private LitemallOrderGoodsService orderGoodsService;
@Autowired
private LitemallOrderService orderService;
@Autowired
private LitemallGoodsProductService productService;
@Autowired
Reported by PMD.
Line: 27
@Autowired
private LitemallOrderGoodsService orderGoodsService;
@Autowired
private LitemallOrderService orderService;
@Autowired
private LitemallGoodsProductService productService;
@Autowired
private LitemallGrouponService grouponService;
@Autowired
Reported by PMD.
Line: 29
@Autowired
private LitemallOrderService orderService;
@Autowired
private LitemallGoodsProductService productService;
@Autowired
private LitemallGrouponService grouponService;
@Autowired
private LitemallGrouponRulesService rulesService;
Reported by PMD.
Line: 31
@Autowired
private LitemallGoodsProductService productService;
@Autowired
private LitemallGrouponService grouponService;
@Autowired
private LitemallGrouponRulesService rulesService;
/**
* 自动确认订单
Reported by PMD.
Line: 33
@Autowired
private LitemallGrouponService grouponService;
@Autowired
private LitemallGrouponRulesService rulesService;
/**
* 自动确认订单
* <p>
* 定时检查订单未确认情况,如果超时 LITEMALL_ORDER_UNCONFIRM 天则自动确认订单
Reported by PMD.
Line: 6
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.core.system.SystemConfig;
import org.linlinjava.litemall.db.domain.*;
import org.linlinjava.litemall.db.service.*;
import org.linlinjava.litemall.db.util.OrderUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
Reported by PMD.
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/job/DbJob.java
11 issues
Line: 21
*/
@Component
public class DbJob {
private final Log logger = LogFactory.getLog(DbJob.class);
@Autowired
private Environment environment;
/*
Reported by PMD.
Line: 21
*/
@Component
public class DbJob {
private final Log logger = LogFactory.getLog(DbJob.class);
@Autowired
private Environment environment;
/*
Reported by PMD.
Line: 24
private final Log logger = LogFactory.getLog(DbJob.class);
@Autowired
private Environment environment;
/*
* 定时时间是每天凌晨5点。
*/
@Scheduled(cron = "0 0 5 * * ?")
Reported by PMD.
Line: 36
String user = environment.getProperty("spring.datasource.druid.username");
String password = environment.getProperty("spring.datasource.druid.password");
String url = environment.getProperty("spring.datasource.druid.url");
int index1 = url.indexOf("3306/");
int index2 = url.indexOf("?");
String db = url.substring(index1+5, index2);
LocalDate localDate = LocalDate.now();
String fileName = localDate.toString() + ".sql";
Reported by PMD.
Line: 37
String password = environment.getProperty("spring.datasource.druid.password");
String url = environment.getProperty("spring.datasource.druid.url");
int index1 = url.indexOf("3306/");
int index2 = url.indexOf("?");
String db = url.substring(index1+5, index2);
LocalDate localDate = LocalDate.now();
String fileName = localDate.toString() + ".sql";
File file = new File("backup", fileName);
Reported by PMD.
Line: 37
String password = environment.getProperty("spring.datasource.druid.password");
String url = environment.getProperty("spring.datasource.druid.url");
int index1 = url.indexOf("3306/");
int index2 = url.indexOf("?");
String db = url.substring(index1+5, index2);
LocalDate localDate = LocalDate.now();
String fileName = localDate.toString() + ".sql";
File file = new File("backup", fileName);
Reported by PMD.
Line: 38
String url = environment.getProperty("spring.datasource.druid.url");
int index1 = url.indexOf("3306/");
int index2 = url.indexOf("?");
String db = url.substring(index1+5, index2);
LocalDate localDate = LocalDate.now();
String fileName = localDate.toString() + ".sql";
File file = new File("backup", fileName);
file.getParentFile().mkdirs();
Reported by PMD.
Line: 41
String db = url.substring(index1+5, index2);
LocalDate localDate = LocalDate.now();
String fileName = localDate.toString() + ".sql";
File file = new File("backup", fileName);
file.getParentFile().mkdirs();
file.createNewFile();
// 备份今天数据库
Reported by PMD.
Line: 43
LocalDate localDate = LocalDate.now();
String fileName = localDate.toString() + ".sql";
File file = new File("backup", fileName);
file.getParentFile().mkdirs();
file.createNewFile();
// 备份今天数据库
DbUtil.backup(file, user, password, db);
// 删除七天前数据库备份文件
Reported by PMD.
Line: 49
// 备份今天数据库
DbUtil.backup(file, user, password, db);
// 删除七天前数据库备份文件
LocalDate before = localDate.minusDays(7);
String fileBeforeName = before.toString()+".sql";
File fileBefore = new File("backup", fileBeforeName);
if (fileBefore.exists()) {
fileBefore.delete();
}
Reported by PMD.