|  |  |  | 
|---|
|  |  |  | import com.github.yulichang.base.MPJBaseMapper; | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.apache.shiro.SecurityUtils; | 
|---|
|  |  |  | import org.checkerframework.checker.units.qual.C; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) | 
|---|
|  |  |  | public Integer create(Category category) { | 
|---|
|  |  |  | if(Objects.isNull(category) | 
|---|
|  |  |  | || Objects.isNull(category.getType()) | 
|---|
|  |  |  | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | LoginUserInfo loginUserInfo = category.getLoginUserInfo(); | 
|---|
|  |  |  | category.setCreateTime(new Date()); | 
|---|
|  |  |  | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | category.setDeleted(Constants.ZERO); | 
|---|
|  |  |  | category.setCreateTime(new Date()); | 
|---|
|  |  |  | category.setCreateUser(loginUserInfo.getId()); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(category.getDetailList())){ | 
|---|
|  |  |  | category.setUpdateTime(new Date()); | 
|---|
|  |  |  | category.setUpdateUser(loginUserInfo.getId()); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(category.getDetailList()) | 
|---|
|  |  |  | && !Constants.equalsInteger(category.getType(),Constants.THREE)){ | 
|---|
|  |  |  | category.setDetail(category.getDetailList().toJSONString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(category.getType(),Constants.ONE)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) | 
|---|
|  |  |  | public void updateById(Category category) { | 
|---|
|  |  |  | if(Objects.isNull(category) | 
|---|
|  |  |  | || Objects.isNull(category.getId()) | 
|---|
|  |  |  | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | LoginUserInfo loginUserInfo = category.getLoginUserInfo(); | 
|---|
|  |  |  | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | category.setUpdateTime(new Date()); | 
|---|
|  |  |  | category.setIsFixed(null); | 
|---|
|  |  |  | category.setUpdateUser(loginUserInfo.getId()); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(category.getDetailList()) | 
|---|
|  |  |  | && !Constants.equalsInteger(category.getType(),Constants.THREE)){ | 
|---|
|  |  |  | category.setDetail(category.getDetailList().toJSONString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | categoryMapper.updateById(category); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void updateStatus(Category category) { | 
|---|
|  |  |  | if(Objects.isNull(category) | 
|---|
|  |  |  | || Objects.isNull(category.getId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | category.setUpdateTime(new Date()); | 
|---|
|  |  |  | category.setIsFixed(null); | 
|---|
|  |  |  | category.setUpdateUser(loginUserInfo.getId()); | 
|---|