多语言-座驾/聊天气泡/装扮代码检查处理

This commit is contained in:
liaozetao
2024-04-08 17:12:47 +08:00
committed by khalil
parent fabe81543f
commit cf60bf3328
9 changed files with 104 additions and 112 deletions

View File

@@ -63,7 +63,7 @@ public class ChatBubbleAdminService {
public final static Integer ONE_TIME_SEND_BUBBLE_MAX_NUM = 100;
public Pagination listInfoCardByPage(Integer page, Integer pageSize, String name, Long id, Byte type) {
public Pagination<ChatBubble> listInfoCardByPage(Integer page, Integer pageSize, String name, Long id, Byte type) {
PageHelper.startPage(page, pageSize);
QueryWrapper<ChatBubble> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotBlank(name)) {
@@ -78,7 +78,7 @@ public class ChatBubbleAdminService {
queryWrapper.lambda().orderByDesc(ChatBubble::getId);
List<ChatBubble> bubbleList = chatBubbleService.list(queryWrapper);
PageInfo<ChatBubble> pageInfo = new PageInfo<>(bubbleList);
return new Pagination(pageInfo);
return new Pagination<>(pageInfo);
}
public void saveOrUpdate(ChatBubble chatBubble) {

View File

@@ -50,28 +50,28 @@ public class DressShopAdminService {
@Autowired
private DressShopAdminMapper dressShopAdminMapper;
public List<DressShopVo> getList(Integer pageNum, Integer pageSize, Integer id){
if(pageNum == null){
public List<DressShopVo> getList(Integer pageNum, Integer pageSize, Integer id) {
if (pageNum == null) {
pageNum = Constant.DEFAULT_PAGE;
}
if(pageSize == null){
if (pageSize == null) {
pageSize = Constant.DEFAULT_PAGE_SIZE;
}
PageHelper.startPage(pageNum, pageSize);
QueryWrapper<DressShop> wrapper = new QueryWrapper<>();
if(id != null){
wrapper.lambda().eq(DressShop :: getId, id);
if (id != null) {
wrapper.lambda().eq(DressShop::getId, id);
}
wrapper.lambda().orderByDesc(DressShop :: getDressSeq);
wrapper.lambda().orderByDesc(DressShop::getDressSeq);
List<DressShop> dressShops = dressShopMapper.selectList(wrapper);
Map<Byte, List<Integer>> hashMap = new HashMap<>();
for(DressShop dressShop : dressShops){
for (DressShop dressShop : dressShops) {
Byte dressType = dressShop.getDressType();
Integer ids = dressShop.getId();
// 判断map中是否存在如果存在则添加元素到set中如果不存在则新建set添加到hashMap中
if(hashMap.containsKey(dressType)) {
if (hashMap.containsKey(dressType)) {
hashMap.get(dressType).add(ids);
} else {
List<Integer> list = new ArrayList<>();
@@ -81,17 +81,17 @@ public class DressShopAdminService {
}
List<DressShopVo> list = new LinkedList<>();
hashMap.forEach((k,idList) -> {
if(CollectionUtils.isEmpty(idList)){
return ;
hashMap.forEach((k, idList) -> {
if (CollectionUtils.isEmpty(idList)) {
return;
}
List<DressShopVo> dressShopList = dressShopService.getDressShopList(k, idList);
list.addAll(dressShopList);
});
List<DressShopVo> newList = list.stream().sorted(Comparator.comparing(DressShopVo ::getDressSeq)).collect(Collectors.toList());
for(DressShopVo dressShopVo: newList){
dressShopVo = perfectDressShopVo(dressShopVo);
List<DressShopVo> newList = list.stream().sorted(Comparator.comparing(DressShopVo::getDressSeq)).collect(Collectors.toList());
for (DressShopVo dressShopVo : newList) {
perfectDressShopVo(dressShopVo);
}
return newList;
}
@@ -99,31 +99,31 @@ public class DressShopAdminService {
/**
*
*/
private DressShopVo perfectDressShopVo(DressShopVo dressShopVo){
private DressShopVo perfectDressShopVo(DressShopVo dressShopVo) {
Byte dressType = dressShopVo.getDressType();
Integer dressId = dressShopVo.getDressId();
Integer buyNum = 0;
Integer userDonateNum = 0;
List<DressShopRecordVo> recordNumList = new LinkedList<>();
if(DressShopTypeEnum.HEADWEAR.getDressType().equals(dressType)){
if (DressShopTypeEnum.HEADWEAR.getDressType().equals(dressType)) {
recordNumList = dressShopAdminMapper.getHeadwearRecordNum(dressId);
} else if(DressShopTypeEnum.CAR.getDressType().equals(dressType)){
} else if (DressShopTypeEnum.CAR.getDressType().equals(dressType)) {
recordNumList = dressShopAdminMapper.getCardRecordNum(dressId);
} else if(DressShopTypeEnum.NAMEPLATE.getDressType().equals(dressType)){
recordNumList= dressShopAdminMapper.getNameplateRecordNum(dressId);
} else if(DressShopTypeEnum.INFO_CARD.getDressType().equals(dressType)){
} else if (DressShopTypeEnum.NAMEPLATE.getDressType().equals(dressType)) {
recordNumList = dressShopAdminMapper.getNameplateRecordNum(dressId);
} else if (DressShopTypeEnum.INFO_CARD.getDressType().equals(dressType)) {
recordNumList = dressShopAdminMapper.getInfoCardRecordNum(dressId);
} else if(DressShopTypeEnum.CHAT_BUBBLE.getDressType().equals(dressType)){
} else if (DressShopTypeEnum.CHAT_BUBBLE.getDressType().equals(dressType)) {
recordNumList = dressShopAdminMapper.getChatBubbleRecordNum(dressId);
}
// 获取列表并判断是否有对应的数量
if(CollectionUtils.isNotEmpty(recordNumList) && recordNumList.size() > 0){
for(DressShopRecordVo recordVo: recordNumList){
if (CollectionUtils.isNotEmpty(recordNumList) && recordNumList.size() > 0) {
for (DressShopRecordVo recordVo : recordNumList) {
Byte comeFrom = recordVo.getComeFrom();
if(comeFrom.equals(Constant.DressComeFrom.BUY) || Constant.UserInfoCardComeFrom.BUY.equals(comeFrom)){
if (comeFrom.equals(Constant.DressComeFrom.BUY) || Constant.UserInfoCardComeFrom.BUY.equals(comeFrom)) {
buyNum = recordVo.getNum();
}else if(comeFrom.equals(Constant.DressComeFrom.USER_DONATE) || Constant.UserInfoCardComeFrom.USER_DONATE.equals(comeFrom)){
} else if (comeFrom.equals(Constant.DressComeFrom.USER_DONATE) || Constant.UserInfoCardComeFrom.USER_DONATE.equals(comeFrom)) {
userDonateNum = recordVo.getNum();
}
}
@@ -136,20 +136,20 @@ public class DressShopAdminService {
public Integer getCount(Integer id) {
QueryWrapper<DressShop> wrapper = new QueryWrapper<>();
if(id != null){
wrapper.lambda().eq(DressShop :: getId, id);
if (id != null) {
wrapper.lambda().eq(DressShop::getId, id);
}
return dressShopMapper.selectCount(wrapper);
}
public DressShop getById(Integer id){
return dressShopMapper.selectById(id);
public DressShop getById(Integer id) {
return dressShopMapper.selectById(id);
}
public void delById(Integer id) {
DressShop dressShop = dressShopMapper.selectById(id);
if(dressShop == null){
if (dressShop == null) {
throw new ServiceException("查询不到对应装扮");
}
dressShopMapper.deleteById(id);
@@ -157,39 +157,39 @@ public class DressShopAdminService {
public void saveOrUpdate(DressShop newDressShop) {
Integer dressId = newDressShop.getDressId();
if(! checkDressId(newDressShop.getDressType(),dressId)){
if (!checkDressId(newDressShop.getDressType(), dressId)) {
log.error("checkDressId error dressType:{} dressId:{}", newDressShop.getDressType(), dressId);
throw new ServiceException("查找不到对应的装扮id");
}
DressShop dressShop = dressShopMapper.selectById(newDressShop.getId());
DressShop lastDressShop;
if(dressShop == null){
if (dressShop == null) {
checkDressShopSeq(dressShop, newDressShop.getDressSeq());
lastDressShop = buildNewDressShop(dressShop, newDressShop);
dressShopMapper.insert(lastDressShop);
}else{
} else {
checkDressShopSeq(dressShop, newDressShop.getDressSeq());
lastDressShop = buildNewDressShop(dressShop, newDressShop);
dressShopMapper.updateById(lastDressShop);
}
}
private void checkDressShopSeq(DressShop dressShop, Integer newDressShopSeq){
private void checkDressShopSeq(DressShop dressShop, Integer newDressShopSeq) {
QueryWrapper<DressShop> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(DressShop :: getDressSeq, newDressShopSeq);
wrapper.lambda().eq(DressShop::getDressSeq, newDressShopSeq);
DressShop newDressShop = dressShopMapper.selectOne(wrapper);
if(dressShop == null && newDressShop != null){
if (dressShop == null && newDressShop != null) {
throw new ServiceException("排序不能重复");
}else{
if(newDressShop != null && ! dressShop.getDressSeq().equals(newDressShop.getDressSeq())){
} else {
if (newDressShop != null && !dressShop.getDressSeq().equals(newDressShop.getDressSeq())) {
throw new ServiceException("排序不能重复");
}
}
}
private DressShop buildNewDressShop(DressShop dressShop, DressShop newDressShop){
private DressShop buildNewDressShop(DressShop dressShop, DressShop newDressShop) {
Date date = new Date();
if(dressShop == null){
if (dressShop == null) {
dressShop = new DressShop();
dressShop.setCreateTime(date);
}
@@ -203,34 +203,34 @@ public class DressShopAdminService {
return dressShop;
}
private Boolean checkDressId(Byte dressType,Integer dressId){
private Boolean checkDressId(Byte dressType, Integer dressId) {
Boolean checkStatus = true;
if(DressShopTypeEnum.NAMEPLATE.getDressType().equals(dressType)){
if (DressShopTypeEnum.NAMEPLATE.getDressType().equals(dressType)) {
Nameplate nameplate = nameplateMapper.selectById(dressId);
if(nameplate == null) {
if (nameplate == null) {
checkStatus = false;
}
} else if(DressShopTypeEnum.HEADWEAR.getDressType().equals(dressType)){
} else if (DressShopTypeEnum.HEADWEAR.getDressType().equals(dressType)) {
Headwear headwear = headwearService.getHeadwear(dressId);
if(headwear == null){
if (headwear == null) {
checkStatus = false;
}
} else if(DressShopTypeEnum.CAR.getDressType().equals(dressType)){
} else if (DressShopTypeEnum.CAR.getDressType().equals(dressType)) {
CarGoods carGoods = carGoodsService.getCarGoods(dressId);
if(carGoods == null) {
if (carGoods == null) {
checkStatus = false;
}
} else if(DressShopTypeEnum.INFO_CARD.getDressType().equals(dressType)){
} else if (DressShopTypeEnum.INFO_CARD.getDressType().equals(dressType)) {
InfoCard infoCard = infoCardService.getInfoCardById(dressId.longValue());
if(infoCard == null){
if (infoCard == null) {
checkStatus = false;
}
} else if(DressShopTypeEnum.CHAT_BUBBLE.getDressType().equals(dressType)){
} else if (DressShopTypeEnum.CHAT_BUBBLE.getDressType().equals(dressType)) {
ChatBubble chatBubble = chatBubbleService.getChatBubbleById(dressId.longValue());
if(chatBubble == null){
if (chatBubble == null) {
checkStatus = false;
}
} else{
} else {
throw new ServiceException("查找不到对应的装扮类型");
}
return checkStatus;

View File

@@ -1,6 +1,7 @@
package com.accompany.admin.controller.car;
import cn.hutool.core.util.StrUtil;
import com.accompany.admin.base.Pagination;
import com.accompany.common.result.BusiResult;
import com.accompany.common.status.BusiStatus;
import com.accompany.common.tencent.cos.TencentCosUploadService;
@@ -10,10 +11,7 @@ import com.accompany.admin.controller.BaseController;
import com.accompany.business.model.CarGoods;
import com.accompany.business.service.car.CarGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@@ -34,47 +32,43 @@ public class CarGoodsAdminController extends BaseController {
@Autowired
private TencentCosUploadService uploadService;
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public void getCarGoods(Integer id) {
@GetMapping(value = "/{id}")
public JSONObject getCarGoods(Integer id) {
CarGoods carGoods = this.carGoodsService.getCarGoods(id);
JSONObject jsonObject = new JSONObject();
if (carGoods != null) {
jsonObject.put("entity", carGoods);
}
writeJson(jsonObject.toJSONString());
return jsonObject;
}
@RequestMapping(value = "", method = RequestMethod.GET)
public void getCarGoodsList(Integer page, Integer pageSize,
@RequestParam(required = false, defaultValue = "2") Byte enable,
String carGoodsName,
Byte carGoodsType) {
@GetMapping(value = "")
public Pagination<CarGoods> getCarGoodsList(Integer page, Integer pageSize,
@RequestParam(required = false, defaultValue = "2") Byte enable,
String carGoodsName,
Byte carGoodsType) {
logger.info("getCarGoodsList({}, {}, {})", page, pageSize, enable);
if (enable != null && enable.equals(ALL_CARS)){
if (enable != null && enable.equals(ALL_CARS)) {
enable = null;
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("total", this.carGoodsService.countCarGoods(enable, carGoodsName, carGoodsType));
jsonObject.put("rows", this.carGoodsService.getCarGoodsList(page, pageSize, enable,null, carGoodsName, carGoodsType));
writeJson(jsonObject.toJSONString());
Pagination<CarGoods> pagination = new Pagination<>();
pagination.setTotal(carGoodsService.countCarGoods(enable, carGoodsName, carGoodsType));
pagination.setRows(carGoodsService.getCarGoodsList(page, pageSize, enable, null, carGoodsName, carGoodsType));
return pagination;
}
@RequestMapping(value = "", method = RequestMethod.POST)
public void saveCarGoods(CarGoods carGoods) {
try{
if(carGoods.getId() == null){
@PostMapping(value = "")
public BusiResult<Void> saveCarGoods(CarGoods carGoods) {
try {
if (carGoods.getId() == null) {
this.carGoodsService.addCarGoods(carGoods);
}else{
} else {
this.carGoodsService.updateCarGoods(carGoods);
}
writeJson(true, "保存成功");
}catch(Exception e){
return BusiResult.success("保存成功", null);
} catch (Exception e) {
logger.error(e.getMessage());
writeJson(false, e.getMessage());
return BusiResult.fail(e.getMessage());
}
}
@@ -110,14 +104,14 @@ public class CarGoodsAdminController extends BaseController {
writeJson(jsonObject.toJSONString());
}
@RequestMapping(value = "/total/list",method = RequestMethod.GET)
public BusiResult getTotalCarGoodsList(){
@RequestMapping(value = "/total/list", method = RequestMethod.GET)
public BusiResult getTotalCarGoodsList() {
BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS);
try{
try {
List<CarGoods> list = this.carGoodsService.getTotalCarGoodsList();
busiResult.setData(list);
return busiResult;
}catch (Exception e){
} catch (Exception e) {
return new BusiResult(BusiStatus.BUSIERROR);
}
}

View File

@@ -31,14 +31,14 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequestMapping(value = "/admin/chatbubble")
public class ChatBubbleAdminController extends BaseController {
public class ChatBubbleAdminController extends BaseController {
@Autowired
private ChatBubbleAdminService chatBubbleAdminService;
@GetMapping(value = "/listByPage")
public Pagination listInfoCardByPage(Integer page, Integer pageSize, String name, Long id, Byte type) {
public Pagination<ChatBubble> listInfoCardByPage(Integer page, Integer pageSize, String name, Long id, Byte type) {
return chatBubbleAdminService.listInfoCardByPage(page, pageSize, name, id, type);
}
@@ -55,7 +55,7 @@ public class ChatBubbleAdminController extends BaseController {
@GetMapping(value = "/listRecordByPage")
public Pagination listRecordByPage(Integer page, Integer pageSize, Long erbanNo, Long bubbleId) {
return chatBubbleAdminService.listRecordByPage(page, pageSize, erbanNo, bubbleId);
return chatBubbleAdminService.listRecordByPage(page, pageSize, erbanNo, bubbleId);
}
@GetMapping(value = "/recoveryChatBubble")

View File

@@ -25,30 +25,30 @@ public class DressShopAdminController extends BaseController {
@ApiOperation("装扮商城")
@GetMapping(value = "/list")
@ResponseBody
public BusiResult getList(Integer pageNum, Integer pageSize, Integer id){
public BusiResult<JSONObject> getList(Integer pageNum, Integer pageSize, Integer id) {
JSONObject jsonObject = new JSONObject();
List<DressShopVo> list = dressShopAdminService.getList(pageNum, pageSize, id);
jsonObject.put("total", dressShopAdminService.getCount(id));
jsonObject.put("rows", list);
return new BusiResult(jsonObject);
return new BusiResult<>(jsonObject);
}
@GetMapping(value = "/getById")
@ResponseBody
public BusiResult getById(Integer id){
public BusiResult getById(Integer id) {
return new BusiResult(dressShopAdminService.getById(id));
}
@GetMapping(value = "/delById")
@ResponseBody
public BusiResult delById(Integer id){
public BusiResult delById(Integer id) {
dressShopAdminService.delById(id);
return new BusiResult(BusiStatus.SUCCESS);
}
@PostMapping(value = "/saveOrUpdate")
@ResponseBody
public BusiResult saveOrUpdate(DressShop dressShop){
public BusiResult saveOrUpdate(DressShop dressShop) {
dressShopAdminService.saveOrUpdate(dressShop);
return new BusiResult(BusiStatus.SUCCESS);
}

View File

@@ -29,17 +29,17 @@ public class MessageSourceAdminSerialize extends JsonSerializer<String> implemen
@SneakyThrows
@Override
public void serialize(String str, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
if (StringUtils.isEmpty(str)){
if (StringUtils.isEmpty(str)) {
jsonGenerator.writeNull();
return;
}
MessageSource messageSource = SpringContextHolder.getBean(MessageSource.class);
String i18nId = className + "." + (StringUtils.isNoneBlank(fieldName)? getFieldNameValue(jsonGenerator.getCurrentValue()): str);
String i18nId = className + "." + (StringUtils.isNoneBlank(fieldName) ? getFieldNameValue(jsonGenerator.getCurrentValue()) : str);
Map<String, String> i18nMap = new HashMap<>();
for (Locale locale: WebLocaleConfig.partitionLocales){
for (Locale locale : WebLocaleConfig.partitionLocales) {
String message = messageSource.getMessage(i18nId, null, str, locale);
i18nMap.put(locale.getLanguage(), message);
}
@@ -58,7 +58,7 @@ public class MessageSourceAdminSerialize extends JsonSerializer<String> implemen
@Override
public JsonSerializer<?> createContextual(SerializerProvider serializerProvider, BeanProperty beanProperty) {
I18nAdmin annotation = beanProperty.getAnnotation(I18nAdmin.class);
if (null != annotation && StringUtils.isNoneBlank(annotation.className())){
if (null != annotation && StringUtils.isNoneBlank(annotation.className())) {
MessageSourceAdminSerialize serialize = new MessageSourceAdminSerialize();
serialize.setClassName(annotation.className());
serialize.setFieldName(annotation.fieldName());

View File

@@ -1,8 +1,6 @@
package com.accompany.business.model;
import com.accompany.common.annotation.ReplaceAppDomain;
import com.accompany.core.serialize.MessageSourceAdminSerialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.util.Date;

View File

@@ -12,7 +12,7 @@ public class UserCarGoodsVo {
private Integer nobleId;
@I18nAdmin(className = "CarGoods")
@I18nAdmin(className = "CarGoods", fieldName = "name")
private String name;
@ReplaceAppDomain

View File

@@ -79,14 +79,14 @@ public class CarGoodsService extends BaseService {
return this.carGoodsMapper.selectByExample(example);
}
public List<UserCarGoodsVo> getUserCarGoodsList(Integer page, Integer pageSize, Long uid,Boolean goldSale){
public List<UserCarGoodsVo> getUserCarGoodsList(Integer page, Integer pageSize, Long uid, Boolean goldSale) {
List<UserCarGoodsVo> userCarGoodsVoList = Lists.newArrayList();
List<CarGoods> carGoodsList = this.getCarGoodsList(page, pageSize, Constant.CarGoodsEnable.ENABLE,goldSale, null, null);
if (carGoodsList == null || carGoodsList.isEmpty()){
List<CarGoods> carGoodsList = this.getCarGoodsList(page, pageSize, Constant.CarGoodsEnable.ENABLE, goldSale, null, null);
if (carGoodsList == null || carGoodsList.isEmpty()) {
return userCarGoodsVoList;
}
for (CarGoods carGoods: carGoodsList){
for (CarGoods carGoods : carGoodsList) {
UserCarGoodsVo userCarGoodsVo = new UserCarGoodsVo();
userCarGoodsVo.setId(carGoods.getId());
userCarGoodsVo.setCreateTime(carGoods.getCreateTime());
@@ -105,7 +105,7 @@ public class CarGoodsService extends BaseService {
userCarGoodsVo.setOtherViewType(carGoods.getOtherViewType());
// 是否限定
if(carGoods.getIsNobleLimit() || carGoods.getIsMonsterLimit() || carGoods.getIsWeekStarLimit() || carGoods.getIsActivityLimit()) {
if (carGoods.getIsNobleLimit() || carGoods.getIsMonsterLimit() || carGoods.getIsWeekStarLimit() || carGoods.getIsActivityLimit()) {
userCarGoodsVo.setIsLimit(true);
} else {
userCarGoodsVo.setIsLimit(false);
@@ -120,11 +120,11 @@ public class CarGoodsService extends BaseService {
userCarGoodsVo.setRadishPrice(carGoods.getRadishPrice());
userCarGoodsVo.setRadishRenewPrice(carGoods.getRadishRenewPrice());
userCarGoodsVo.setRadishOriginalPrice(carGoods.getRadishOriginalPrice());
if (uid != null){
if (uid != null) {
CarCarport carport = carportService.getUserCarport(uid, carGoods.getId());
if (carport != null){
if (carport != null) {
userCarGoodsVo.setStatus(carport.getStatus());
userCarGoodsVo.setExpireDate(DateTimeUtil.compareDay(carport.getExpireTime(),new Date()));
userCarGoodsVo.setExpireDate(DateTimeUtil.compareDay(carport.getExpireTime(), new Date()));
}
}
@@ -254,10 +254,10 @@ public class CarGoodsService extends BaseService {
}
}
public List<CarGoods> getTotalCarGoodsList(){
public List<CarGoods> getTotalCarGoodsList() {
CarGoodsExample example = new CarGoodsExample();
List<CarGoods> list = carGoodsMapper.selectByExample(example);
if(CollectionUtils.isEmpty(list)){
if (CollectionUtils.isEmpty(list)) {
return Lists.newArrayList();
}
return list;