Commit bdecafb2 authored by 廖旭伟's avatar 廖旭伟

皮肤管理接口

parent 5fb1dba0
package com.mortals.xhx.common.pdu.skinBase;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
public class SinkBasePdu extends BaseEntityLong {
private static final long serialVersionUID = 1L;
/**
* 所属种类,来源种类
*/
private Long categoryId;
/**
* 产品id
*/
private Long productId;
/**
* 产品名称
*/
@Excel(name = "产品名称")
private String productName;
/**
* css模板合成后文件地址
*/
private String cssFilePath;
/**
* 排序编号
*/
private Integer sortNum;
/**
* 产品皮肤名称,唯一且不为空
*/
private String name;
/**
* 分辨率 (1.1920*1080,2.1080*1920,3.1280*1280)
*/
@Excel(name = "分辨率 ", readConverterExp = "1=1920*1080,2=1080*1920,3=1280*1280")
private String imageResolution;
/**
* 预览图片
*/
@Excel(name = "预览图片")
private String previewImagePath;
public SinkBasePdu(){}
/**
* 获取 所属种类,来源种类
* @return Long
*/
public Long getCategoryId(){
return categoryId;
}
/**
* 设置 所属种类,来源种类
* @param categoryId
*/
public void setCategoryId(Long categoryId){
this.categoryId = categoryId;
}
/**
* 获取 产品id
* @return Long
*/
public Long getProductId(){
return productId;
}
/**
* 设置 产品id
* @param productId
*/
public void setProductId(Long productId){
this.productId = productId;
}
/**
* 获取 产品名称
* @return String
*/
public String getProductName(){
return productName;
}
/**
* 设置 产品名称
* @param productName
*/
public void setProductName(String productName){
this.productName = productName;
}
/**
* 获取 css模板合成后文件地址
* @return String
*/
public String getCssFilePath(){
return cssFilePath;
}
/**
* 设置 css模板合成后文件地址
* @param cssFilePath
*/
public void setCssFilePath(String cssFilePath){
this.cssFilePath = cssFilePath;
}
/**
* 获取 排序编号
* @return Integer
*/
public Integer getSortNum(){
return sortNum;
}
/**
* 设置 排序编号
* @param sortNum
*/
public void setSortNum(Integer sortNum){
this.sortNum = sortNum;
}
/**
* 获取 产品皮肤名称,唯一且不为空
* @return String
*/
public String getName(){
return name;
}
/**
* 设置 产品皮肤名称,唯一且不为空
* @param name
*/
public void setName(String name){
this.name = name;
}
/**
* 获取 分辨率 (1.1920*1080,2.1080*1920,3.1280*1280)
* @return String
*/
public String getImageResolution(){
return imageResolution;
}
/**
* 设置 分辨率 (1.1920*1080,2.1080*1920,3.1280*1280)
* @param imageResolution
*/
public void setImageResolution(String imageResolution){
this.imageResolution = imageResolution;
}
/**
* 获取 预览图片
* @return String
*/
public String getPreviewImagePath(){
return previewImagePath;
}
/**
* 设置 预览图片
* @param previewImagePath
*/
public void setPreviewImagePath(String previewImagePath){
this.previewImagePath = previewImagePath;
}
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof SinkBasePdu) {
SinkBasePdu tmp = (SinkBasePdu) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",categoryId:").append(getCategoryId());
sb.append(",productId:").append(getProductId());
sb.append(",productName:").append(getProductName());
sb.append(",cssFilePath:").append(getCssFilePath());
sb.append(",sortNum:").append(getSortNum());
sb.append(",name:").append(getName());
sb.append(",imageResolution:").append(getImageResolution());
sb.append(",previewImagePath:").append(getPreviewImagePath());
return sb.toString();
}
public void initAttrValue(){
this.categoryId = null;
this.productId = null;
this.productName = "";
this.cssFilePath = "";
this.sortNum = null;
this.name = "";
this.imageResolution = "1";
this.previewImagePath = "";
}
}
package com.mortals.xhx.feign.skinBase;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.skinBase.SinkBasePdu;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@FeignClient(name = "base-manager", path = "/base", fallbackFactory = SinkBaseFeignFallbackFactory.class)
public interface ISinkBaseFeign extends IFeign {
@PostMapping(value = "/skin/base/list")
Rest<RespData<List<SinkBasePdu>>> list(@RequestBody SinkBasePdu sinkBasePdu);
}
@Slf4j
@Component
class SinkBaseFeignFallbackFactory implements FallbackFactory<ISinkBaseFeign> {
@Override
public ISinkBaseFeign create(Throwable throwable) {
return new ISinkBaseFeign(){
@Override
public Rest<RespData<List<SinkBasePdu>>> list(SinkBasePdu sinkBasePdu) {
return Rest.fail("暂时无法获取皮肤列表,请稍后再试!");
}
};
}
}
package com.mortals.xhx.common.code;
import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.common.IBaseEnum;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 应用分类
*/
public enum AppsClassifyEnum implements IBaseEnum {
EDUCATION(1, "教育", SysConstains.STYLE_DEFAULT),
MEDICAL(2, "医疗", SysConstains.STYLE_DEFAULT),
PUBLIC_SERVICE(3, "公共服务", SysConstains.STYLE_DEFAULT);
private int value;
private String desc;
private String style;
AppsClassifyEnum(int value, String desc, String style) {
this.value = value;
this.desc = desc;
this.style = style;
}
@Override
public int getValue() {
return this.value;
}
public String getDesc() {
return desc;
}
public String getStyle()
{
return style;
}
public static AppsClassifyEnum getByValue(int value) {
for (AppsClassifyEnum examStatus : AppsClassifyEnum.values()) {
if (examStatus.getValue() == value) {
return examStatus;
}
}
return null;
}
/**
* 获取Map集合
* @param eItem 不包含项
* @return
*/
public static Map<String,String> getEnumMap(int... eItem) {
Map<String,String> resultMap= new LinkedHashMap<String,String>();
for (AppsClassifyEnum item : AppsClassifyEnum.values()) {
try{
boolean hasE = false;
for (int e : eItem){
if(item.getValue()==e){
hasE = true;
break;
}
}
if(!hasE){
resultMap.put(item.getValue()+"", item.getDesc());
}
}catch(Exception ex){
}
}
return resultMap;
}
}
package com.mortals.xhx.module.apps.web; package com.mortals.xhx.module.apps.web;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.AppsClassifyEnum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -42,6 +44,7 @@ public class AppsInfoController extends BaseCRUDJsonBodyMappingController<AppsIn ...@@ -42,6 +44,7 @@ public class AppsInfoController extends BaseCRUDJsonBodyMappingController<AppsIn
@Override @Override
protected void init(Map<String, Object> model, Context context) { protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "classify", IBaseEnum.getEnumMap(AppsClassifyEnum.class));
super.init(model, context); super.init(model, context);
} }
......
...@@ -19,6 +19,7 @@ import com.mortals.xhx.module.device.service.DeviceService; ...@@ -19,6 +19,7 @@ import com.mortals.xhx.module.device.service.DeviceService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -34,18 +35,23 @@ import java.util.stream.Collectors; ...@@ -34,18 +35,23 @@ import java.util.stream.Collectors;
@Service("deviceService") @Service("deviceService")
@Slf4j @Slf4j
public class DeviceServiceImpl extends AbstractCRUDServiceImpl<DeviceDao, DeviceEntity, Long> implements DeviceService { public class DeviceServiceImpl extends AbstractCRUDServiceImpl<DeviceDao, DeviceEntity, Long> implements DeviceService {
/** 自助终端设备产品id */
@Value("${system.productId:1}")
private Long productId;
@Autowired @Autowired
private IDeviceFeign deviceFeign; private IDeviceFeign deviceFeign;
@Override @Override
public Result<DeviceEntity> find(DeviceEntity entity, PageInfo pageInfo, Context context) throws AppException { public Result<DeviceEntity> find(DeviceEntity entity, PageInfo pageInfo, Context context) throws AppException {
Result<DeviceEntity> result = new Result(); Result<DeviceEntity> result = new Result();
DevicePdu devicePdu = new DevicePdu(); DevicePdu devicePdu = new DevicePdu();
BeanUtils.copyProperties(entity, devicePdu, BeanUtil.getNullPropertyNames(entity)); BeanUtils.copyProperties(entity, devicePdu, BeanUtil.getNullPropertyNames(entity));
String productName = GlobalSysInfo.getParamValue(Constant.PARAMS_PRODUCT_NAME, "数字填单机"); // String productName = GlobalSysInfo.getParamValue(Constant.PARAMS_PRODUCT_NAME, "数字填单机");
devicePdu.setProductName(productName); // devicePdu.setProductName(productName);
devicePdu.setProductId(productId);
Rest<RespData<List<DevicePdu>>> rest = deviceFeign.list(devicePdu); Rest<RespData<List<DevicePdu>>> rest = deviceFeign.list(devicePdu);
if (rest.getCode().equals(YesNoEnum.YES.getValue())) { if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
......
...@@ -11,4 +11,5 @@ import com.mortals.xhx.module.sst.model.SstSkinEntity; ...@@ -11,4 +11,5 @@ import com.mortals.xhx.module.sst.model.SstSkinEntity;
*/ */
public interface SstSkinService extends ICRUDService<SstSkinEntity,Long>{ public interface SstSkinService extends ICRUDService<SstSkinEntity,Long>{
void settingSkin(SstSkinEntity sstSkinEntity,String authorization);
} }
\ No newline at end of file
package com.mortals.xhx.module.sst.service.impl; package com.mortals.xhx.module.sst.service.impl;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.device.DevicePdu;
import com.mortals.xhx.common.pdu.skinBase.SinkBasePdu;
import com.mortals.xhx.feign.device.IDeviceFeign;
import com.mortals.xhx.feign.skinBase.ISinkBaseFeign;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
...@@ -6,6 +18,10 @@ import com.mortals.framework.model.Context; ...@@ -6,6 +18,10 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.sst.dao.SstSkinDao; import com.mortals.xhx.module.sst.dao.SstSkinDao;
import com.mortals.xhx.module.sst.model.SstSkinEntity; import com.mortals.xhx.module.sst.model.SstSkinEntity;
import com.mortals.xhx.module.sst.service.SstSkinService; import com.mortals.xhx.module.sst.service.SstSkinService;
import java.util.ArrayList;
import java.util.List;
/** /**
* SstSkinService * SstSkinService
* 皮肤管理 service实现 * 皮肤管理 service实现
...@@ -15,5 +31,89 @@ import com.mortals.xhx.module.sst.service.SstSkinService; ...@@ -15,5 +31,89 @@ import com.mortals.xhx.module.sst.service.SstSkinService;
*/ */
@Service("sstSkinService") @Service("sstSkinService")
public class SstSkinServiceImpl extends AbstractCRUDServiceImpl<SstSkinDao, SstSkinEntity, Long> implements SstSkinService { public class SstSkinServiceImpl extends AbstractCRUDServiceImpl<SstSkinDao, SstSkinEntity, Long> implements SstSkinService {
/** 自助终端设备产品id */
@Value("${system.productId:1}")
private Long productId;
@Autowired
private ISinkBaseFeign iSinkBaseFeign;
@Autowired
private IDeviceFeign deviceFeign;
@Override
public Result<SstSkinEntity> find(SstSkinEntity entity, PageInfo pageInfo, Context context) throws AppException {
// SstSkinEntity newParams = this.findBefore(entity, pageInfo, context);
// Result<SstSkinEntity> result = this.dao.getList(newParams, pageInfo);
// this.findAfter(entity, pageInfo, context, result.getList());
// return result;
if(entity.getSiteId()==null){
throw new AppException("站点id不能为空");
}
DevicePdu devicePdu = new DevicePdu();
devicePdu.setProductId(productId);
Rest<RespData<List<DevicePdu>>> restDevice = deviceFeign.list(devicePdu);
Long sinkIdUse = 0l;
if(restDevice.getCode().equals(YesNoEnum.YES.getValue())){
if(CollectionUtils.isNotEmpty(restDevice.getData().getData())){
sinkIdUse = restDevice.getData().getData().get(0).getId();
}
}
Result<SstSkinEntity> result = new Result();
SinkBasePdu skinBasePdu = new SinkBasePdu();
skinBasePdu.setProductId(productId);
Rest<RespData<List<SinkBasePdu>>> rest = iSinkBaseFeign.list(skinBasePdu);
if(rest.getCode().equals(YesNoEnum.YES.getValue())){
List<SstSkinEntity> list = new ArrayList<>();
if(CollectionUtils.isNotEmpty(rest.getData().getData())){
for (SinkBasePdu pdu:rest.getData().getData()) {
SstSkinEntity skinEntity = new SstSkinEntity();
skinEntity.setSiteId(entity.getSiteId());
skinEntity.setSkinName(pdu.getName());
skinEntity.setPreviewImagePath(pdu.getPreviewImagePath());
skinEntity.setSkinId(pdu.getId());
if(pdu.getId()==sinkIdUse){
skinEntity.setStatus(1);
}else {
skinEntity.setStatus(0);
}
list.add(skinEntity);
}
}
result.setList(list);
result.setDict(rest.getDict());
}
return result;
}
@Override
public SstSkinEntity update(SstSkinEntity entity, Context context) throws AppException {
return entity;
}
@Override
public SstSkinEntity save(SstSkinEntity entity, Context context) throws AppException {
return entity;
}
@Override
public void settingSkin(SstSkinEntity sstSkinEntity, String authorization) {
if(sstSkinEntity.getSiteId()==null){
throw new AppException("站点id不能为空");
}
DevicePdu devicePdu = new DevicePdu();
devicePdu.setProductId(productId);
Rest<RespData<List<DevicePdu>>> restDevice = deviceFeign.list(devicePdu);
if(restDevice.getCode().equals(YesNoEnum.YES.getValue())){
if(CollectionUtils.isNotEmpty(restDevice.getData().getData())){
for (DevicePdu device:restDevice.getData().getData()){
DevicePdu update = new DevicePdu();
update.setId(device.getId());
update.setSkinId(sstSkinEntity.getSkinId());
deviceFeign.save(update,authorization);
}
}
}
}
} }
\ No newline at end of file
package com.mortals.xhx.module.sst.web; package com.mortals.xhx.module.sst.web;
import com.mortals.framework.annotation.RepeatSubmit;
import com.mortals.framework.service.IUser;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -13,12 +15,10 @@ import com.mortals.xhx.module.sst.model.SstSkinEntity; ...@@ -13,12 +15,10 @@ import com.mortals.xhx.module.sst.model.SstSkinEntity;
import com.mortals.xhx.module.sst.service.SstSkinService; import com.mortals.xhx.module.sst.service.SstSkinService;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*; import static com.mortals.framework.ap.SysConstains.*;
...@@ -45,5 +45,32 @@ public class SstSkinController extends BaseCRUDJsonBodyMappingController<SstSkin ...@@ -45,5 +45,32 @@ public class SstSkinController extends BaseCRUDJsonBodyMappingController<SstSkin
super.init(model, context); super.init(model, context);
} }
@PostMapping({"setting"})
@RepeatSubmit
public String setting(@RequestBody SstSkinEntity entity,@RequestHeader("Authorization") String authorization) {
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "保存" + this.getModuleDesc();
int code=1;
try {
this.service.settingSkin(entity, authorization);
model.put("id", entity.getId());
model.put("entity", entity);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + entity.getId() + "]");
} catch (Exception var7) {
this.doException(this.request, busiDesc, model, var7);
model.put("entity", entity);
this.init(model, context);
code = this.saveException(entity, model, context, var7);
}
this.init(model, context);
JSONObject ret = new JSONObject();
ret.put("code", code);
ret.put("msg", model.remove("message_info"));
ret.put("data", model);
return ret.toJSONString();
}
} }
\ No newline at end of file
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