添加app图标管理功能

master
yangkai 6 years ago
parent de55f0b10c
commit 0b70366c7e

@ -0,0 +1,15 @@
package au.com.royalpay.payment.manage.support.cms.core;
import com.alibaba.fastjson.JSONObject;
public interface AppStyleService {
JSONObject listAppStyleGroup(int page, int limit);
JSONObject getAppStyleByStyleId(String style_id);
void switchGroupByStyleId(String style_id);
void addAppStyle(String style_id, JSONObject appStyleGroup);
void updateAppStyleByStyleId(String style_id, String originStyleId, JSONObject appStyleGroup);
}

@ -0,0 +1,101 @@
package au.com.royalpay.payment.manage.support.cms.core.Impl;
import au.com.royalpay.payment.manage.support.cms.core.AppStyleService;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMethod;
import java.io.IOException;
import java.net.URISyntaxException;
@Service
public class AppStyleServiceImpl implements AppStyleService {
@Value("http://127.0.0.1:9533")
private String cmsHost;
private Logger logger = LoggerFactory.getLogger(getClass());
@Override
public JSONObject listAppStyleGroup(int page, int limit) {
String url = concatUrl("/app/style_group");
HttpRequestGenerator gen = new HttpRequestGenerator(url, RequestMethod.GET).addQueryString("page", page + "").addQueryString("limit", limit + "");
try {
HttpRequestResult res = gen.execute();
if (res.isSuccess()) {
return res.getResponseContentJSONObj();
}
} catch (URISyntaxException | IOException e) {
logger.error(e.getMessage(), e);
}
throw new ServerErrorException("Failed to request CMS");
}
@Override
public JSONObject getAppStyleByStyleId(String style_id) {
String url = concatUrl("/app/style_group/" + style_id);
HttpRequestGenerator gen = new HttpRequestGenerator(url, RequestMethod.GET);
try {
HttpRequestResult res = gen.execute();
if (res.isSuccess()) {
return res.getResponseContentJSONObj();
}
} catch (URISyntaxException | IOException e) {
logger.error(e.getMessage(), e);
}
throw new ServerErrorException("Failed to request CMS");
}
@Override
public void switchGroupByStyleId(String style_id) {
String url = concatUrl("/app/style_group/" + style_id);
try {
HttpRequestResult res = new HttpRequestGenerator(url, RequestMethod.PUT).execute();
if (res.isSuccess()) {
return;
}
} catch (URISyntaxException e) {
logger.error(e.getMessage(), e);
}
throw new ServerErrorException("Failed to request CMS");
}
@Override
public void addAppStyle(String style_id, JSONObject appStyleGroup) {
String url = concatUrl("/app/style_group");
try {
HttpRequestResult gen = new HttpRequestGenerator(url, RequestMethod.POST).addQueryString("style_id", style_id).setJSONEntity(appStyleGroup).execute();
if (gen.isSuccess()) {
return;
}
} catch (URISyntaxException e) {
logger.error(e.getMessage(), e);
}
throw new ServerErrorException("Failed to request CMS");
}
@Override
public void updateAppStyleByStyleId(String style_id, String originStyleId, JSONObject appStyleGroup) {
String url = concatUrl("/app/style_group/" + style_id + "/style");
try {
HttpRequestResult gen = new HttpRequestGenerator(url, RequestMethod.PUT).addQueryString("originStyleId", originStyleId).setJSONEntity(appStyleGroup).execute();
if (gen.isSuccess()) {
return;
}
} catch (URISyntaxException e) {
logger.error(e.getMessage(), e);
}
throw new ServerErrorException("Failed to request CMS");
}
private String concatUrl(String uri) {
String host = cmsHost.endsWith("/") ? cmsHost.substring(0, cmsHost.length() - 1) : cmsHost;
uri = uri.startsWith("/") ? uri.substring(1) : uri;
return host + "/" + uri;
}
}

@ -0,0 +1,42 @@
package au.com.royalpay.payment.manage.support.cms.web;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.support.cms.core.AppStyleService;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RestController
@ManagerMapping(value = "/app/cms/app_style", role = {ManagerRole.SITE_MANAGER})
public class AppStyleController {
@Resource
private AppStyleService appStyleService;
@RequestMapping(value = "/style_group", method = RequestMethod.GET)
public JSONObject listAppStyleGroup(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit) {
return appStyleService.listAppStyleGroup(page, limit);
}
@RequestMapping(value = "/style_group/{style_id}", method = RequestMethod.GET)
public JSONObject getAppStyleByStyleId(@PathVariable String style_id) {
return appStyleService.getAppStyleByStyleId(style_id);
}
@RequestMapping(value = "/style_group/{style_id}", method = RequestMethod.PUT)
public void switchGroupByStyleId(@PathVariable String style_id) {
appStyleService.switchGroupByStyleId(style_id);
}
@RequestMapping(value = "/style_group", method = RequestMethod.POST)
public void addOneGroupAppStyle(@RequestParam String style_id, @RequestBody JSONObject appStyleGroup) {
appStyleService.addAppStyle(style_id, appStyleGroup);
}
@RequestMapping(value = "/style_group/{style_id}/style", method = RequestMethod.PUT)
public void updateAppStyleByStyleId(@PathVariable String style_id,@RequestParam String originStyleId, @RequestBody JSONObject appStyleGroup) {
appStyleService.updateAppStyleByStyleId(style_id, originStyleId, appStyleGroup);
}
}

@ -4,6 +4,67 @@
define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angular) {
'use strict';
var app = angular.module('cms', ['ui.router','ng.uditor']);
var style = [
{
"style_key":"settlement",
"style_value":""
},
{
"style_key":"home_select",
"style_value":""
},
{
"style_key":"activity_gray",
"style_value":""
},
{
"style_key":"activity_select",
"style_value":""
},
{
"style_key":"mess_gray",
"style_value":""
},
{
"style_key":"mess_select",
"style_value":""
},
{
"style_key":"my_select",
"style_value":""
},
{
"style_key":"transaction",
"style_value":""
},
{
"style_key":"statistics",
"style_value":""
},
{
"style_key":"marketing_account",
"style_value":""
},
{
"style_key":"usergroup",
"style_value":""
},
{
"style_key":"coupon",
"style_value":""
},
{
"style_key":"rpbill",
"style_value":""
},
{
"style_key":"invoice_assistant",
"style_value":""
},
{
"style_key":"home_gray",
"style_value":""
}];
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('cms', {
url: '/cms',
@ -38,7 +99,41 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu
}).state('cms.phone_top_up', {
url: '/phone_top_up',
controller: 'CmsPhonetopupCtrl',
templateUrl: '/static/cms/templates/phone_top_up.html'
templateUrl: '/static/cms/templates/phone_top_up.html',
}).state('cms.app_style',{
url: '/app_style',
controller: 'cmsAppStyleListCtrl',
templateUrl: '/static/cms/templates/app_style.html',
}).state('cms.app_style.app_style_preview',{
url: '/{style_id}/preview',
controller: 'cmsAppStylePreviewCtrl',
templateUrl: '/static/cms/templates/app_style_preview.html',
resolve: {
appStyles: ['$http', '$stateParams', function ($http, $stateParams) {
return $http.get('/app/cms/app_style/style_group/' + $stateParams.style_id);
}]
}
}).state('cms.app_style.app_style_save',{
url: '/save',
controller: 'cmsAppStyleSaveCtrl',
templateUrl: '/static/cms/templates/app_style_config.html',
resolve: {
style: function () {
return angular.copy(style);
}
}
}).state('cms.app_style.app_style_edit',{
url: '/{style_id}/edit',
controller: 'cmsAppStyleEditCtrl',
templateUrl: '/static/cms/templates/app_style_config.html',
resolve: {
appStyles: ['$http', '$stateParams', function ($http, $stateParams) {
return $http.get('/app/cms/app_style/style_group/' + $stateParams.style_id);
}],
style: function () {
return angular.copy(style);
}
}
})
}]);
app.controller('cmsRootCtrl', ['$scope', function ($scope) {
@ -140,6 +235,142 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu
$scope.article = article.data;
}]);
app.controller('cmsAppStyleListCtrl', ['$scope', '$http', '$uibModal', function ($scope, $http, $uibModal) {
$scope.pagination = {};
$scope.appStyleGroupList = function (page) {
var params = $scope.queryParams || {};
params.page = page || $scope.pagination.page || 1;
$http.get('/app/cms/app_style/style_group', {params: params}).then(function (resp) {
$scope.appStyleGroups = resp.data.data;
$scope.pagination = resp.data.pagination;
})
};
$scope.appStyleGroupList(1);
}]);
app.controller('cmsAppStylePreviewCtrl', ['$scope', '$http', 'appStyles', function ($scope, $http, appStyles) {
$scope.appStyles = appStyles.data.data;
}]);
app.controller('cmsAppStyleEditCtrl', ['$scope', '$http', '$state','commonDialog', 'appStyles', 'style', function ($scope, $http, $state, commonDialog, appStyles, style) {
$scope.ctrl = {sending: false, flag: false, originStyleId: angular.copy(appStyles.data.data[0].style_id)};
$scope.entity={};
$scope.style = angular.copy(style);
$scope.entity.appStyle = angular.copy(appStyles.data.data);
$scope.params = {style_id: angular.copy(appStyles.data.data[0].style_id)};
$scope.appStyleList = function() {
var styleKeyStr = "";
$scope.entity.appStyle.forEach(function(item){
styleKeyStr += item.style_key + ",";
});
$scope.style.forEach(function(item){
if (styleKeyStr.indexOf(item.style_key) < 0) {
$scope.entity.appStyle.push({"style_key": item.style_key,"style_value":""});
}
})
};
$scope.appStyleList();
$scope.addSpecOption = function() {
$scope.entity.appStyle.push({});
};
// 删除规格选项
$scope.delSpecOption = function(index) {
$scope.entity.appStyle.splice(index, 1);
};
$scope.saveOneGroupAppStyle = function() {
if ($scope.params.style_id == "" || $scope.params.style_id == null) {
$scope.errmsg = "title不能为空";
return;
}
var item = "";
for (var i=0;i<$scope.entity.appStyle.length;i++) {
item = $scope.entity.appStyle[i];
if (item.style_value == "" || item.style_value == null) {
$scope.errmsg = "value不能为空";
return;
}
if (item.style_value.substr(0,4).toLowerCase() != "http" &&
item.style_value.substr(0,5).toLowerCase() != "https") {
$scope.errmsg = "value必须以http或者https开头";
return;
}
}
$scope.ctrl.sending = true;
$http.put('/app/cms/app_style/style_group/' + $scope.params.style_id + '/style?originStyleId=' + $scope.ctrl.originStyleId, $scope.entity).then(function(){
$scope.ctrl.sending = false;
$state.go('cms.app_style.app_style_preview',{style_id: $scope.params.style_id});
}, function (resp) {
$scope.ctrl.sending = false;
$scope.errmsg = resp.data.message;
})
}
$scope.toggleAppStyleIsValid = function(styleId) {
if (styleId) {
commonDialog.confirm({
title: '确认操作',
content: '当前操作将发布title为' +styleId +"的app图标是否确认"
}).then(function () {
$http.put('/app/cms/app_style/style_group/' + styleId).then(function () {
$state.reload();
})
})
}
}
}]);
app.controller('cmsAppStyleSaveCtrl', ['$scope', '$http', '$state', 'style', function ($scope, $http, $state, style) {
$scope.ctrl = {sending: false, flag: true};
$scope.entity={};
$scope.entity.appStyle = angular.copy(style);
$scope.params = {style_id: ""};
$scope.addSpecOption = function() {
$scope.entity.appStyle.push({});
};
// 删除规格选项
$scope.delSpecOption = function(index) {
console.log(index)
$scope.entity.appStyle.splice(index, 1);
};
$scope.saveOneGroupAppStyle = function() {
if ($scope.params.style_id == "" || $scope.params.style_id == null) {
$scope.errmsg = "title不能为空";
return;
}
var item = "";
for (var i=0;i<$scope.entity.appStyle.length;i++) {
item = $scope.entity.appStyle[i];
if (item.style_value == "" || item.style_value == null) {
$scope.errmsg = "value不能为空";
return;
}
if (item.style_value.substr(0,4).toLowerCase() != "http" &&
item.style_value.substr(0,5).toLowerCase() != "https") {
$scope.errmsg = "value必须以http或者https开头";
return;
}
}
$scope.ctrl.sending = true;
$http.post('/app/cms/app_style/style_group?style_id=' + $scope.params.style_id, $scope.entity).then(function(){
$scope.ctrl.sending = false;
$state.go('cms.app_style.app_style_preview', {style_id: $scope.params.style_id});
}, function (resp) {
$scope.ctrl.sending = false;
$scope.errmsg = resp.data.message;
})
};
$scope.checkStyleValue = function () {
}
}]);
app.filter('topUpType', function () {
return function (status) {
switch (status + '') {

@ -0,0 +1,65 @@
<div ui-view>
<section class="content-header">
<h1>APP_STYLE</h1>
<ol class="breadcrumb">
<li><a ui-sref="cms">网站管理</a></li>
<li>app图标</li>
</ol>
</section>
<section class="content" >
<div class="box box-warning">
<div class="box-body">
<div class="form-inline">
<div class="form-group">
<a class="btn btn-success" ui-sref=".app_style_save">
<i class="fa fa-plus"></i> New App Style
</a>
</div>
</div>
</div>
</div>
<div class="box box-default">
<div class="box-body table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Title</th>
<th>Published</th>
<th>Operation</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="appStyleGroup in appStyleGroups" class="ng-scope">
<td><a role="button" ui-sref=".app_style_preview({style_id:appStyleGroup.style_id})" ng-bind="appStyleGroup.style_id"></a></td>
<td>
<a title="Toggle publish status">
<i class="fa" ng-class="{'fa-check text-success':appStyleGroup.is_valid,'fa-remove text-danger':!appStyleGroup.is_valid}"></i>
</a>
</td>
<td>
<a role="button" ui-sref=".app_style_edit({style_id:appStyleGroup.style_id})" title="edit"><i class="fa fa-edit"></i></a>
<a role="button" ui-sref=".app_style_preview({style_id:appStyleGroup.style_id})" title="preview"><i class="fa fa-eye"></i></a>
</td>
</tr>
</tbody>
</table>
</div>
<div class="box-footer">
<uib-pagination class="pagination"
total-items="pagination.totalCount"
boundary-links="true"
ng-model="pagination.page"
items-per-page="pagination.limit"
max-size="10"
ng-change="appStyleGroupList()"
previous-text="&lsaquo;"
next-text="&rsaquo;"
first-text="&laquo;"
last-text="&raquo;"></uib-pagination>
<div class="row">
<div class="col-xs-12">Total Records:{{pagination.totalCount}};Total Pages:{{pagination.totalPages}}</div>
</div>
</div>
</div>
</section>
</div>

@ -0,0 +1,67 @@
<div ui-view xmlns="http://www.w3.org/1999/html">
<section class="content-header">
<h1>APP_STYLE</h1>
<ol class="breadcrumb">
<li><a ui-sref="cms">网站管理</a></li>
<li><a ui-sref="cms.app_style">app图标</a></li>
<li class="active" ng-bind="!ctrl.flag?'Edit Article':'New Article'"></li>
</ol>
</section>
<section class="content" >
<div class="box box-warning">
<div class="box-body">
<div class="form-inline">
<div class="form-group">
<div class="form-group">
<label class="control-label" for="short-name-search">title</label>
<input type="text" class="form-control" id="short-name-search" name="style_id"
ng-model="params.style_id" required>
<div class="checkbox-inline">
<label><input role="button" type="radio" ng-value="true" ng-model="entity.appStyle[0].is_valid" ng-change="toggleAppStyleIsValid(params.style_id)"> Published</label>
</div>
</div>
<!--<div class="form-group">-->
<!--<button class="btn btn-success" type="button" ng-click="addSpecOption()">-->
<!--<i class="fa fa-plus"></i> New App Style-->
<!--</button>-->
<!--</div>-->
</div>
</div>
</div>
</div>
<div class="box box-default">
<div class="alert alert-danger" ng-if="errmsg" ng-bind="errmsg"></div>
<div class="box-body table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Key</th>
<th>Value</th>
<!--<th class=>Operation</th>-->
</tr>
</thead>
<tbody>
<tr ng-repeat="appStyle in entity.appStyle">
<td>
<input class="form-control" ng-model="appStyle.style_key" placeholder="Key" disabled>
</td>
<td>
<input class="form-control" name="style_value" ng-model="appStyle.style_value" placeholder="Value">
</td>
<!--<td>-->
<!--<button type="button" ng-click="delSpecOption($index)"-->
<!--class="btn btn-default" title="删除">-->
<!--<i class="fa fa-trash-o"></i> 删除-->
<!--</button>-->
<!--</td>-->
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button class="btn btn-success" type="button" ng-click="saveOneGroupAppStyle(style_form)" ng-disabled="ctrl.sending">Submit</button>
<a role="button" class="btn btn-danger" ui-sref="^" ui-sref-opts="{reload:true}">Cancel</a>
</div>
</div>
</section>
</div>

@ -0,0 +1,46 @@
<div ui-view>
<section class="content-header">
<h1>APP_STYLE</h1>
<ol class="breadcrumb">
<li><a ui-sref="cms">网站管理</a></li>
<li><a ui-sref="cms.app_style">app图标</a></li>
<li class="active">app图标详情</li>
</ol>
</section>
<section class="content" >
<div class="box box-warning">
<div class="box-body">
<div class="form-inline">
<div class="form-group">
<a class="btn btn-success" ui-sref="cms.app_style.app_style_save">
<i class="fa fa-plus"></i> New App Style
</a>
<a class="btn btn-primary" ui-sref="cms.app_style.app_style_edit({style_id:appStyles[0].style_id})">
<i class="fa fa-edit"></i> Edit App Style
</a>
</div>
</div>
</div>
</div>
<div class="box box-default">
<div class="box-body table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Title</th>
<th>Style_Key</th>
<th>Style_Value</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="appStyle in appStyles">
<td ng-bind="appStyle.style_id"></td>
<td ng-bind="appStyle.style_key"></td>
<td style="width: 50%;" ng-bind="appStyle.style_value"></td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
</div>

@ -26,6 +26,9 @@
<div class="btn-group">
<a class="btn btn-default" ui-sref=".category({catId:'app_ad'})">App广告页</a>
</div>
<div class="btn-group">
<a class="btn btn-default" ui-sref=".app_style">App图标</a>
</div>
<div class="btn-group">
<a class="btn btn-default" ui-sref=".phone_top_up">话费充值</a>
</div>

@ -67,7 +67,7 @@
<td>{{client.bank_account_no}}</td>
<td>{{client.contact_person}}</td>
<td>{{client.contact_phone}}</td>
<td>{{client.last_update_date}}</td>
<td>{{client.creation_date}}</td>
<td>{{client.remark}}</td>
<td>
<a role="button" class="text-bold text-danger"

Loading…
Cancel
Save