Commit 83ff9217 authored by 赵啸非's avatar 赵啸非

添加皮肤同步

parent 0ebee773
package com.mortals.xhx.module.skin.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.skin.model.SkinEntity;
/**
* SkinService
*
* 皮肤 service接口
*
* @author zxfei
* @date 2023-04-03
*/
public interface SkinService extends ICRUDService<SkinEntity,Long>{
* SkinService
* <p>
* 皮肤 service接口
*
* @author zxfei
* @date 2023-04-03
*/
public interface SkinService extends ICRUDService<SkinEntity, Long> {
void syncSkin();
Rest<Void> appUsed(SkinEntity skinEntity, Context context);
}
\ No newline at end of file
......@@ -39,6 +39,20 @@ public class SkinServiceImpl extends AbstractCRUDServiceImpl<SkinDao, SkinEntity
@Autowired
private ISkinBaseFeign skinBaseFeign;
@Override
public Rest<Void> appUsed(SkinEntity skinEntity, Context context) {
//使用 部署
SkinEntity model = new SkinEntity();
model.setUsed(YesNoEnum.NO.getValue());
this.getDao().update(model,new SkinEntity());
//更新当前app
skinEntity.setUsed(YesNoEnum.YES.getValue());
skinEntity.setUpdateTime(new Date());
this.getDao().update(skinEntity);
return Rest.ok("使用应用成功!");
}
@Override
protected void updateBefore(SkinEntity entity, Context context) throws AppException {
super.updateBefore(entity, context);
......
......@@ -7,15 +7,15 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.device.DeviceMsgReqPdu;
import com.mortals.xhx.feign.device.IDeviceMessageFeign;
import com.mortals.xhx.module.skin.model.SkinEntity;
import com.mortals.xhx.module.skin.service.SkinService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
......@@ -62,6 +62,39 @@ public class SkinController extends BaseCRUDJsonBodyMappingController<SkinServic
return super.saveAfter(entity, model, context);
}
/**
*皮肤使用
*/
@PostMapping(value = "used")
public Rest<String> used(@RequestBody SkinEntity entity) {
String busiDesc = this.getModuleDesc() + "皮肤选择使用";
Rest<String> rest = Rest.ok(busiDesc + " 【成功】");
try {
if (ObjectUtils.isEmpty(entity.getId())) {
throw new AppException("皮肤Id不能为空!");
}
SkinEntity skinEntity = this.service.get(entity.getId(), getContext());
if (ObjectUtils.isEmpty(skinEntity)) {
throw new AppException("当前皮肤不存在!skinId:" + entity.getId());
}
if(skinEntity.getUsed()==entity.getUsed()&&skinEntity.getUsed()==YesNoEnum.YES.getValue()){
throw new AppException("当前皮肤不能取消选择!" );
}
if (skinEntity.getUsed() == YesNoEnum.YES.getValue()) {
throw new AppException("当前皮肤使用中!");
}
Rest<Void> usedRest = this.service.appUsed(skinEntity, getContext());
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
log.error("皮肤切换", e);
return Rest.fail(super.convertException(e));
}
return rest;
}
@PostMapping({"refreshSkin"})
@UnAuth
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment