Commit ff6207f9 authored by 雍欢's avatar 雍欢

1、添加/编辑功能的时候通过easy-search来选择菜单图标;

2、菜单图片改为可以为空
parent 4f599381
package com.huigou.uasp.bmp.opm.application;
import com.huigou.uasp.bmp.opm.domain.model.resource.Icon;
import java.util.List;
public interface IconApplication {
void syncIcons(List<Icon> icons);
}
package com.huigou.uasp.bmp.opm.domain.model.resource;
import com.huigou.data.domain.model.AbstractEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 菜单图标。
*
* @author yonghuan
*/
@Table(name = "sa_opicon")
@Entity
public class Icon extends AbstractEntity {
private String code;
private String html;
public Icon() {
}
public Icon(String code, String html) {
this.code = code;
this.html = html;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getHtml() {
return html;
}
public void setHtml(String html) {
this.html = html;
}
}
package com.huigou.uasp.bmp.opm.repository.org;
import com.huigou.uasp.bmp.opm.domain.model.resource.Icon;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @author yonghuan
*/
public interface IconRepository extends JpaRepository<Icon, String> {
}
package com.huigou.uasp.bmp.opm.impl;
import com.huigou.uasp.bmp.opm.application.IconApplication;
import com.huigou.uasp.bmp.opm.domain.model.resource.Icon;
import com.huigou.uasp.bmp.opm.repository.org.IconRepository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @author yonghuan
*/
public class IconApplicationImpl implements IconApplication {
private IconRepository iconRepository;
public void setIconRepository(IconRepository iconRepository) {
this.iconRepository = iconRepository;
}
@Transactional(rollbackFor = RuntimeException.class)
@Override
public void syncIcons(List<Icon> icons) {
iconRepository.deleteAll();
iconRepository.save(icons);
}
}
package com.huigou.uasp.bmp.opm.proxy;
import com.huigou.uasp.bmp.opm.application.IconApplication;
import com.huigou.uasp.bmp.opm.domain.model.resource.Icon;
import com.huigou.uasp.bmp.opm.impl.IconApplicationImpl;
import com.huigou.uasp.bmp.opm.repository.org.IconRepository;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @author yonghuan
*/
@Service
public class IconApplicationProxy implements IconApplication, InitializingBean {
private IconRepository iconRepository;
private IconApplication iconApplication;
@Autowired
public void setIconRepository(IconRepository iconRepository) {
this.iconRepository = iconRepository;
}
@Override
public void afterPropertiesSet() throws Exception {
IconApplicationImpl impl = new IconApplicationImpl();
impl.setIconRepository(iconRepository);
this.iconApplication = impl;
}
@Transactional(rollbackFor = RuntimeException.class)
@Override
public void syncIcons(List<Icon> icons) {
iconApplication.syncIcons(icons);
}
}
......@@ -350,6 +350,10 @@
<artifactId>query-spring</artifactId>
<version>1.2.7</version>
</dependency>
<dependency>
<groupId>net.sf.cssbox</groupId>
<artifactId>jstyleparser</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
......
package com.huigou.uasp.bmp.opm.controller;
import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.bmp.opm.application.IconApplication;
import com.huigou.uasp.bmp.opm.domain.model.resource.Icon;
import com.huigou.uasp.client.CommonController;
import cz.vutbr.web.css.CSSException;
import cz.vutbr.web.css.CSSFactory;
import cz.vutbr.web.css.RuleSet;
import cz.vutbr.web.css.StyleSheet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
/**
* 图标。
*
* @author yonghuan
*/
@ControllerMapping("icon")
@Controller
public class IconController extends CommonController {
@Autowired
private IconApplication iconApplication;
@Value("${icon.cssFile}")
private String iconCssFile;
/**
* 同步图标
*/
public String syncIcons() throws IOException, CSSException {
String cssFile = getRequest().getRealPath(iconCssFile);
String css = Files.readAllLines(Paths.get(cssFile))
.stream()
.collect(Collectors.joining("\n"));
StyleSheet sheet = CSSFactory.parseString(css, null);
List<Icon> icons = sheet.stream().filter(block -> block instanceof RuleSet)
.map(RuleSet.class::cast)
.filter(rule -> rule.getSelectors().length == 1)
.filter(rule -> rule.size() == 1)
.filter(rule -> "content".equals(rule.get(0).getProperty()))
.map(rule -> rule.getSelectors()[0].get(0).getClassName())
.map(className -> new Icon(className, String.format("<i class='fa %s'></i>", className)))
.collect(Collectors.toList());
iconApplication.syncIcons(icons);
return success();
}
}
package test;
import cz.vutbr.web.css.*;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
public class JstyleparserTest {
@Test
public void test() throws IOException, CSSException {
String css = Files.readAllLines(Paths.get("E:\\work\\topsunit\\IdeaProjects\\huigou\\huigou-xt\\src\\main\\webapp\\themes\\fontawesome\\css\\font-awesome.min.css"))
.stream()
.collect(Collectors.joining("\n"));
StyleSheet sheet = CSSFactory.parseString(css, null);
List<String> icons = sheet.stream().filter(block -> block instanceof RuleSet)
.map(RuleSet.class::cast)
.filter(rule -> rule.getSelectors().length == 1)
.filter(rule -> rule.size() == 1)
.filter(rule -> "content".equals(rule.get(0).getProperty()))
.map(rule -> rule.getSelectors()[0].get(0).getClassName())
.collect(Collectors.toList());
}
}
......@@ -453,7 +453,10 @@
<artifactId>mssql-jdbc</artifactId>
<version>7.4.1.jre8</version>
</dependency>
<dependency>
<groupId>net.sf.cssbox</groupId>
<artifactId>jstyleparser</artifactId>
</dependency>
</dependencies>
<build>
<finalName>huigou-xt</finalName>
......
......@@ -38,6 +38,17 @@ sys.server.ip=127.0.0.1:8080/is/
corpId=wxafae524e350f2298
corpSecret=FwcIKKl8AcVp6xlaXYxfMF0KSTFmyWGP9ZSt0iaCFNf-1GQcLU29ulmk4mVax1QB
email.host=xx
email.username=xx
email.password=xx
\ No newline at end of file
# �Ƿ���ҵ��ڵ㳬ʱ������
bpm.bizTask.timeoutCheck.enabled=true
# BPMҵ��ڵ㳬ʱ����������
bpm.bizTask.timeoutCheck.cron=0/10 * * * * ?
email.host=https://mail.topsunit.com/EWS/Exchange.asmx
email.username=portal@topsunit.com
email.password=20180101
activemq.brokerURL=tcp://127.0.0.1:61616
activemq.userName=admin
activemq.password=admin
icon.cssFile=themes/fontawesome/css/font-awesome.min.css
\ No newline at end of file
......@@ -38,7 +38,7 @@
<c:forEach items="${requestScope.EASY_SEARCH_DATA.headList}" var="obj">
<c:if test="${obj.type!='hidden'}">
<td style='text-align:<c:out value="${obj.align}"/>' title='<c:out value="${data[obj.code]}"/>' width='<c:out value="${obj.width}"/>px'>
<c:out value="${f:format(data[obj.code],obj.type)}" />
<c:out value="${f:format(data[obj.code],obj.type)}" escapeXml="false" />
</td>
</c:if>
<input type='hidden' flag='<c:out value="${obj.type!='hidden'?'1':'0'}"/>' name='<c:out value="${obj.code}"/>'
......
......@@ -11,10 +11,10 @@
<x:inputC name="url" label="Url" readonly="false" maxlength="128" fieldCol="10" wrapper="select" />
<x:hidden name="urlSelector" />
<div class="col-xs-2 col-md-2">
<label class="hg-form-label required" id="code_label">图标&nbsp;:</label>
<label class="hg-form-label" id="code_label">图标&nbsp;:</label>
</div>
<div class="col-xs-8 col-md-8">
<x:input name="icon" label="图标" required="true"/>
<x:input name="icon" label="图标" />
</div>
<div class="col-xs-2 col-md-2">
<span style="padding:10px;font-size:26px;" class="show-icon"></span>
......
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