…'),0!==t&&e.push(''+(a.last||a.pages)+" ")),e.join("")}(),next:function(){return a.next?''+a.next+" ":""}(),count:'共 '+a.count+" 条 ",limit:function(){var e=[''];return layui.each(a.limits,function(t,n){e.push('"+n+" 条/页 ")}),e.join("")+" "}(),refresh:['',' '," "].join(""),skip:function(){return['到第',' ','页确定 '," "].join("")}()};return['',function(){var e=[];return layui.each(a.layout,function(a,t){i[t]&&e.push(i[t])}),e.join("")}(),"
"].join("")},u.prototype.jump=function(e,a){if(e){var t=this,i=t.config,r=e.children,u=e[n]("button")[0],l=e[n]("input")[0],p=e[n]("select")[0],c=function(){var e=0|l.value.replace(/\s|\D/g,"");e&&(i.curr=e,t.render())};if(a)return c();for(var o=0,y=r.length;oi.pages||(i.curr=e,t.render())});p&&s.on(p,"change",function(){var e=this.value;i.curr*e>i.count&&(i.curr=Math.ceil(i.count/e)),i.limit=e,t.render()}),u&&s.on(u,"click",function(){c()})}},u.prototype.skip=function(e){if(e){var a=this,t=e[n]("input")[0];t&&s.on(t,"keyup",function(t){var n=this.value,i=t.keyCode;/^(37|38|39|40)$/.test(i)||(/\D/.test(n)&&(this.value=n.replace(/\D/,"")),13===i&&a.jump(e,!0))})}},u.prototype.render=function(e){var n=this,i=n.config,r=n.type(),u=n.view();2===r?i.elem&&(i.elem.innerHTML=u):3===r?i.elem.html(u):a[t](i.elem)&&(a[t](i.elem).innerHTML=u),i.jump&&i.jump(i,e);var s=a[t]("layui-laypage-"+i.index);n.jump(s),i.hash&&!e&&(location.hash="!"+i.hash+"="+i.curr),n.skip(s)};var s={render:function(e){var a=new u(e);return a.index},index:layui.laypage?layui.laypage.index+1e4:0,on:function(e,a,t){return e.attachEvent?e.attachEvent("on"+a,function(a){a.target=a.srcElement,t.call(e,a)}):e.addEventListener(a,t,!1),this}};e(i,s)});
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/layui/lay/modules/laytpl.js:
--------------------------------------------------------------------------------
1 | /** layui-v2.5.4 MIT License By https://www.layui.com */
2 | ;layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},c={exp:function(e){return new RegExp(e,"g")},query:function(e,c,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return n((c||"")+r.open+o+r.close+(t||""))},escape:function(e){return String(e||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(e,r){var c="Laytpl Error:";return"object"==typeof console&&console.error(c+e+"\n"+(r||"")),c+e}},n=c.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=n("^"+r.open+"#",""),l=n(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(n(r.open+"#"),r.open+"# ").replace(n(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(n(r.open+"!(.+?)!"+r.close),function(e){return e=e.replace(n("^"+r.open+"!"),"").replace(n("!"+r.close),"").replace(n(r.open+"|"+r.close),function(e){return e.replace(/(.)/g,"\\$1")})}).replace(/(?="|')/g,"\\").replace(c.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(c.query(1),function(e){var c='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(n(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),c='"+_escape_('),c+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,c.escape)}catch(u){return delete o.cache,c.error(u,p)}},t.pt.render=function(e,r){var n,t=this;return e?(n=t.cache?t.cache(e,c.escape):t.parse(t.tpl,e),r?void r(n):n):c.error("no data")};var o=function(e){return"string"!=typeof e?c.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var c in e)r[c]=e[c]},o.v="1.2.0",e("laytpl",o)});
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/layui/lay/modules/rate.js:
--------------------------------------------------------------------------------
1 | /** layui-v2.5.4 MIT License By https://www.layui.com */
2 | ;layui.define("jquery",function(e){"use strict";var a=layui.jquery,i={config:{},index:layui.rate?layui.rate.index+1e4:0,set:function(e){var i=this;return i.config=a.extend({},i.config,e),i},on:function(e,a){return layui.onevent.call(this,n,e,a)}},l=function(){var e=this,a=e.config;return{setvalue:function(a){e.setvalue.call(e,a)},config:a}},n="rate",t="layui-rate",o="layui-icon-rate",s="layui-icon-rate-solid",u="layui-icon-rate-half",r="layui-icon-rate-solid layui-icon-rate-half",c="layui-icon-rate-solid layui-icon-rate",f="layui-icon-rate layui-icon-rate-half",v=function(e){var l=this;l.index=++i.index,l.config=a.extend({},l.config,i.config,e),l.render()};v.prototype.config={length:5,text:!1,readonly:!1,half:!1,value:0,theme:""},v.prototype.render=function(){var e=this,i=e.config,l=i.theme?'style="color: '+i.theme+';"':"";i.elem=a(i.elem),parseInt(i.value)!==i.value&&(i.half||(i.value=Math.ceil(i.value)-i.value<.5?Math.ceil(i.value):Math.floor(i.value)));for(var n='",u=1;u<=i.length;u++){var r=' ";i.half&&parseInt(i.value)!==i.value&&u==Math.ceil(i.value)?n=n+' ":n+=r}n+=" "+(i.text?''+i.value+"星":"")+" ";var c=i.elem,f=c.next("."+t);f[0]&&f.remove(),e.elemTemp=a(n),i.span=e.elemTemp.next("span"),i.setText&&i.setText(i.value),c.html(e.elemTemp),c.addClass("layui-inline"),i.readonly||e.action()},v.prototype.setvalue=function(e){var a=this,i=a.config;i.value=e,a.render()},v.prototype.action=function(){var e=this,i=e.config,l=e.elemTemp,n=l.find("i").width();l.children("li").each(function(e){var t=e+1,v=a(this);v.on("click",function(e){if(i.value=t,i.half){var o=e.pageX-a(this).offset().left;o<=n/2&&(i.value=i.value-.5)}i.text&&l.next("span").text(i.value+"星"),i.choose&&i.choose(i.value),i.setText&&i.setText(i.value)}),v.on("mousemove",function(e){if(l.find("i").each(function(){a(this).addClass(o).removeClass(r)}),l.find("i:lt("+t+")").each(function(){a(this).addClass(s).removeClass(f)}),i.half){var c=e.pageX-a(this).offset().left;c<=n/2&&v.children("i").addClass(u).removeClass(s)}}),v.on("mouseleave",function(){l.find("i").each(function(){a(this).addClass(o).removeClass(r)}),l.find("i:lt("+Math.floor(i.value)+")").each(function(){a(this).addClass(s).removeClass(f)}),i.half&&parseInt(i.value)!==i.value&&l.children("li:eq("+Math.floor(i.value)+")").children("i").addClass(u).removeClass(c)})})},v.prototype.events=function(){var e=this;e.config},i.render=function(e){var a=new v(e);return l.call(a)},e(n,i)});
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/layui/lay/modules/util.js:
--------------------------------------------------------------------------------
1 | /** layui-v2.5.4 MIT License By https://www.layui.com */
2 | ;layui.define("jquery",function(t){"use strict";var e=layui.$,i={fixbar:function(t){var i,n,a="layui-fixbar",o="layui-fixbar-top",r=e(document),l=e("body");t=e.extend({showHeight:200},t),t.bar1=t.bar1===!0?"":t.bar1,t.bar2=t.bar2===!0?"":t.bar2,t.bgcolor=t.bgcolor?"background-color:"+t.bgcolor:"";var c=[t.bar1,t.bar2,""],g=e(['',t.bar1?''+c[0]+" ":"",t.bar2?''+c[1]+" ":"",''+c[2]+" "," "].join("")),s=g.find("."+o),u=function(){var e=r.scrollTop();e>=t.showHeight?i||(s.show(),i=1):i&&(s.hide(),i=0)};e("."+a)[0]||("object"==typeof t.css&&g.css(t.css),l.append(g),u(),g.find("li").on("click",function(){var i=e(this),n=i.attr("lay-type");"top"===n&&e("html,body").animate({scrollTop:0},200),t.click&&t.click.call(this,n)}),r.on("scroll",function(){clearTimeout(n),n=setTimeout(function(){u()},100)}))},countdown:function(t,e,i){var n=this,a="function"==typeof e,o=new Date(t).getTime(),r=new Date(!e||a?(new Date).getTime():e).getTime(),l=o-r,c=[Math.floor(l/864e5),Math.floor(l/36e5)%24,Math.floor(l/6e4)%60,Math.floor(l/1e3)%60];a&&(i=e);var g=setTimeout(function(){n.countdown(t,r+1e3,i)},1e3);return i&&i(l>0?c:[0,0,0,0],e,g),l<=0&&clearTimeout(g),g},timeAgo:function(t,e){var i=this,n=[[],[]],a=(new Date).getTime()-new Date(t).getTime();return a>6912e5?(a=new Date(t),n[0][0]=i.digit(a.getFullYear(),4),n[0][1]=i.digit(a.getMonth()+1),n[0][2]=i.digit(a.getDate()),e||(n[1][0]=i.digit(a.getHours()),n[1][1]=i.digit(a.getMinutes()),n[1][2]=i.digit(a.getSeconds())),n[0].join("-")+" "+n[1].join(":")):a>=864e5?(a/1e3/60/60/24|0)+"天前":a>=36e5?(a/1e3/60/60|0)+"小时前":a>=12e4?(a/1e3/60|0)+"分钟前":a<0?"未来":"刚刚"},digit:function(t,e){var i="";t=String(t),e=e||2;for(var n=t.length;n /g,">").replace(/'/g,"'").replace(/"/g,""")},event:function(t,n,a){n=i.event[t]=e.extend(!0,i.event[t],n)||{},e("body").on(a||"click","*["+t+"]",function(){var i=e(this),a=i.attr(t);n[a]&&n[a].call(this,i)})}};!function(t,e,i){"$:nomunge";function n(){a=e[l](function(){o.each(function(){var e=t(this),i=e.width(),n=e.height(),a=t.data(this,g);(i!==a.w||n!==a.h)&&e.trigger(c,[a.w=i,a.h=n])}),n()},r[s])}var a,o=t([]),r=t.resize=t.extend(t.resize,{}),l="setTimeout",c="resize",g=c+"-special-event",s="delay",u="throttleWindow";r[s]=250,r[u]=!0,t.event.special[c]={setup:function(){if(!r[u]&&this[l])return!1;var e=t(this);o=o.add(e),t.data(this,g,{w:e.width(),h:e.height()}),1===o.length&&n()},teardown:function(){if(!r[u]&&this[l])return!1;var e=t(this);o=o.not(e),e.removeData(g),o.length||clearTimeout(a)},add:function(e){function n(e,n,o){var r=t(this),l=t.data(this,g)||{};l.w=n!==i?n:r.width(),l.h=o!==i?o:r.height(),a.apply(this,arguments)}if(!r[u]&&this[l])return!1;var a;return t.isFunction(e)?(a=e,n):(a=e.handler,void(e.handler=n))}}}(e,window),t("util",i)});
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/lib/bootstrap/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bootstrap",
3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
4 | "keywords": [
5 | "css",
6 | "js",
7 | "less",
8 | "mobile-first",
9 | "responsive",
10 | "front-end",
11 | "framework",
12 | "web"
13 | ],
14 | "homepage": "http://getbootstrap.com",
15 | "license": "MIT",
16 | "moduleType": "globals",
17 | "main": [
18 | "less/bootstrap.less",
19 | "dist/js/bootstrap.js"
20 | ],
21 | "ignore": [
22 | "/.*",
23 | "_config.yml",
24 | "CNAME",
25 | "composer.json",
26 | "CONTRIBUTING.md",
27 | "docs",
28 | "js/tests",
29 | "test-infra"
30 | ],
31 | "dependencies": {
32 | "jquery": "1.9.1 - 3"
33 | },
34 | "version": "3.3.7",
35 | "_release": "3.3.7",
36 | "_resolution": {
37 | "type": "version",
38 | "tag": "v3.3.7",
39 | "commit": "0b9c4a4007c44201dce9a6cc1a38407005c26c86"
40 | },
41 | "_source": "https://github.com/twbs/bootstrap.git",
42 | "_target": "v3.3.7",
43 | "_originalSource": "bootstrap",
44 | "_direct": true
45 | }
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/lib/bootstrap/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2011-2016 Twitter, Inc.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaoMaPrincess/.NetCoreWebApi/266dcd560162e1db7a5d7d7b1e4379ba83625a6d/CoreWebApi/Core.Msi/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaoMaPrincess/.NetCoreWebApi/266dcd560162e1db7a5d7d7b1e4379ba83625a6d/CoreWebApi/Core.Msi/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaoMaPrincess/.NetCoreWebApi/266dcd560162e1db7a5d7d7b1e4379ba83625a6d/CoreWebApi/Core.Msi/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaoMaPrincess/.NetCoreWebApi/266dcd560162e1db7a5d7d7b1e4379ba83625a6d/CoreWebApi/Core.Msi/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/lib/bootstrap/dist/js/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/lib/jquery-validation-unobtrusive/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-validation-unobtrusive",
3 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive",
4 | "version": "3.2.9",
5 | "_release": "3.2.9",
6 | "_resolution": {
7 | "type": "version",
8 | "tag": "v3.2.9",
9 | "commit": "a91f5401898e125f10771c5f5f0909d8c4c82396"
10 | },
11 | "_source": "https://github.com/aspnet/jquery-validation-unobtrusive.git",
12 | "_target": "^3.2.9",
13 | "_originalSource": "jquery-validation-unobtrusive",
14 | "_direct": true
15 | }
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) .NET Foundation. All rights reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 | these files except in compliance with the License. You may obtain a copy of the
5 | License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software distributed
10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the
12 | specific language governing permissions and limitations under the License.
13 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/lib/jquery-validation/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-validation",
3 | "homepage": "https://jqueryvalidation.org/",
4 | "repository": {
5 | "type": "git",
6 | "url": "git://github.com/jquery-validation/jquery-validation.git"
7 | },
8 | "authors": [
9 | "Jörn Zaefferer "
10 | ],
11 | "description": "Form validation made easy",
12 | "main": "dist/jquery.validate.js",
13 | "keywords": [
14 | "forms",
15 | "validation",
16 | "validate"
17 | ],
18 | "license": "MIT",
19 | "ignore": [
20 | "**/.*",
21 | "node_modules",
22 | "bower_components",
23 | "test",
24 | "demo",
25 | "lib"
26 | ],
27 | "dependencies": {
28 | "jquery": ">= 1.7.2"
29 | },
30 | "version": "1.17.0",
31 | "_release": "1.17.0",
32 | "_resolution": {
33 | "type": "version",
34 | "tag": "1.17.0",
35 | "commit": "fc9b12d3bfaa2d0c04605855b896edb2934c0772"
36 | },
37 | "_source": "https://github.com/jzaefferer/jquery-validation.git",
38 | "_target": "^1.17.0",
39 | "_originalSource": "jquery-validation",
40 | "_direct": true
41 | }
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/lib/jquery-validation/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | =====================
3 |
4 | Copyright Jörn Zaefferer
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/lib/jquery/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery",
3 | "main": "dist/jquery.js",
4 | "license": "MIT",
5 | "ignore": [
6 | "package.json"
7 | ],
8 | "keywords": [
9 | "jquery",
10 | "javascript",
11 | "browser",
12 | "library"
13 | ],
14 | "homepage": "https://github.com/jquery/jquery-dist",
15 | "version": "3.3.1",
16 | "_release": "3.3.1",
17 | "_resolution": {
18 | "type": "version",
19 | "tag": "3.3.1",
20 | "commit": "9e8ec3d10fad04748176144f108d7355662ae75e"
21 | },
22 | "_source": "https://github.com/jquery/jquery-dist.git",
23 | "_target": "^3.3.1",
24 | "_originalSource": "jquery",
25 | "_direct": true
26 | }
--------------------------------------------------------------------------------
/CoreWebApi/Core.Msi/wwwroot/lib/jquery/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright JS Foundation and other contributors, https://js.foundation/
2 |
3 | This software consists of voluntary contributions made by many
4 | individuals. For exact contribution history, see the revision history
5 | available at https://github.com/jquery/jquery
6 |
7 | The following license applies to all parts of this software except as
8 | documented below:
9 |
10 | ====
11 |
12 | Permission is hereby granted, free of charge, to any person obtaining
13 | a copy of this software and associated documentation files (the
14 | "Software"), to deal in the Software without restriction, including
15 | without limitation the rights to use, copy, modify, merge, publish,
16 | distribute, sublicense, and/or sell copies of the Software, and to
17 | permit persons to whom the Software is furnished to do so, subject to
18 | the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be
21 | included in all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 |
31 | ====
32 |
33 | All files located in the node_modules and external directories are
34 | externally maintained libraries used by this software which have their
35 | own licenses; we recommend you read them, as their terms may differ from
36 | the terms above.
37 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Repository/AdvertisementRepository.cs:
--------------------------------------------------------------------------------
1 | using Core.IRepository;
2 | using Core.IRepository.BASE;
3 | using Core.Model.Models;
4 | using Core.Repository.BASE;
5 | using Core.Repository.Sugar;
6 | using SqlSugar;
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq.Expressions;
10 | using System.Text;
11 |
12 | namespace Core.Repository
13 | {
14 | public class AdvertisementRepository : BaseRepository, IAdvertisementRepository
15 | {
16 | //private DbContext context;
17 | //private SqlSugarClient db;
18 | //private SimpleClient entityDB;
19 |
20 | //internal SqlSugarClient Db
21 | //{
22 | // get { return db; }
23 | // private set { db = value; }
24 | //}
25 | //public DbContext Context
26 | //{
27 | // get { return context; }
28 | // set { context = value; }
29 | //}
30 |
31 | /////
32 | ///// 构造函数获取Sqlsugar实例
33 | /////
34 | //public AdvertisementRepository()
35 | //{
36 | // DbContext.Init(BaseDBConfig.ConnectionString);
37 | // context = DbContext.GetDbContext();
38 | // db = context.Db;
39 | // entityDB = context.GetEntityDB(db);
40 | //}
41 |
42 | //public int Add(Advertisement model)
43 | //{
44 | // var i= db.Insertable(model).ExecuteReturnIdentity();
45 | // return i;
46 | //}
47 |
48 | //public bool Delete(Advertisement model)
49 | //{
50 | // var i= db.Deleteable(model).ExecuteCommand();
51 | // return i > 0;
52 | //}
53 |
54 | //public List Query(Expression> whereExpression)
55 | //{
56 | // return entityDB.GetList(whereExpression);
57 | //}
58 |
59 | ///
60 | /// 求和方法实现
61 | ///
62 | ///
63 | ///
64 | ///
65 | public int Sum(int i, int j)
66 | {
67 | return i + j;
68 | }
69 |
70 | //public bool Update(Advertisement model)
71 | //{
72 | // //以主键为条件
73 | // var i= db.Updateable(model).ExecuteCommand();
74 | // return i > 0;
75 | //}
76 |
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Repository/BlogArticleRepository.cs:
--------------------------------------------------------------------------------
1 | using Core.Common.Dapper;
2 | using Core.IRepository;
3 | using Core.Model.Models;
4 | using Core.Repository.BASE;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 |
11 | namespace Core.Repository
12 | {
13 | public class BlogArticleRepository : BaseRepository, IBlogArticleRepository
14 | {
15 | private readonly DbContext db;
16 | public BlogArticleRepository(DbContext _db)
17 | {
18 | db = _db;
19 | }
20 | public BlogArticle GetBlog()
21 | {
22 | string sql = "SELECT * FROM systemuser";
23 | var list = DbContext.QueryFirstOrDefault(sql);
24 |
25 | return list; //new BlogArticle() { btitle="1" };//
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Repository/Core.Repository.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 |
6 |
7 |
8 | ..\Core.Msi\bin\Debug\
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Repository/Mis/HomeRepository.cs:
--------------------------------------------------------------------------------
1 | using Core.Common.EFCore;
2 | using Core.IRepository.Mis;
3 | using Core.Model.Models;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Linq;
9 | using Core.Model.ViewModels;
10 |
11 | namespace Core.Repository.Mis
12 | {
13 | public class HomeRepository : IHomeRepository
14 | {
15 | private readonly IEFContext _context;
16 | public HomeRepository(IEFContext context)
17 | {
18 | _context = context;
19 | }
20 |
21 | public Task> GetActionList(Guid userID, Guid menuID)
22 | {
23 | throw new NotImplementedException();
24 | }
25 |
26 | ///
27 | /// 根据用户ID获取对应的菜单列表
28 | ///
29 | /// userID
30 | ///
31 | public async Task> GetMenuList(Guid userID)
32 | {
33 | if (userID == null)
34 | {
35 | return null;
36 | }
37 | var query = from a in _context.Set()
38 | join b in _context.Set()
39 | on a.RoleID equals b.RoleID
40 | join c in _context.Set()
41 | on b.PrivilegeID equals c.ID
42 | where a.UserID == userID && b.PrivilegeType == Model.PrivilegeTypeEnum.菜单 && c.ShowOnMenu == true
43 | select new SystemMenu
44 | {
45 | ID = c.ID,
46 | MenuName = c.MenuName,
47 | Url = c.Url,
48 | ParentID = c.ParentID,
49 | DisplayOrder = c.DisplayOrder
50 | };
51 | var folder = _context.Set().Where(x => x.FolderOnly == true && x.ShowOnMenu == true);
52 | List menuList = new List();
53 | if (folder.Count() > 0)
54 | {
55 | await Task.Run(() =>
56 | {
57 | foreach (var item in folder)
58 | {
59 | var childList = query.Where(x => x.ParentID == item.ID);
60 | if (childList.Count() > 0)
61 | {
62 | MenuInfo menu = new MenuInfo();
63 | menu.ModuleName = item.MenuName;
64 | menu.SystemMenus = childList.OrderBy(x => x.DisplayOrder).ToList();
65 | menuList.Add(menu);
66 | }
67 | }
68 | });
69 | }
70 |
71 | return menuList;
72 |
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Repository/Mis/LoginRepository.cs:
--------------------------------------------------------------------------------
1 | using Core.Common.EFCore;
2 | using Core.IRepository.Mis;
3 | using Core.Model.Models;
4 | using Core.Model.ViewModels;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 | using System.Linq;
9 | using Core.Model;
10 | using Core.Common;
11 | using Core.Common.Helper;
12 |
13 | namespace Core.Repository.Mis
14 | {
15 | ///
16 | /// 登录数据层实现
17 | ///
18 | public class LoginRepository : ILoginRepository
19 | {
20 | private readonly IEFContext _context;
21 | public LoginRepository(IEFContext context)
22 | {
23 | _context = context;
24 | }
25 | /////
26 | ///// 获取用户信息
27 | /////
28 | /////
29 | /////
30 | /////
31 | public ResponseMessage GetUserInfo(string itCode, string password)
32 | {
33 | var response = new ResponseMessage();
34 | if (string.IsNullOrWhiteSpace(itCode))
35 | {
36 | response.Message = "请输入用户名";
37 | response.IsSuccess = false;
38 | return response;
39 | }
40 | if (string.IsNullOrWhiteSpace(password))
41 | {
42 | response.Message = "请输入密码";
43 | response.IsSuccess = false;
44 | return response;
45 | }
46 |
47 | password = MD5Helper.GetMD5String(password);
48 | var code = (from a in _context.Set()
49 | where a.ITCode == itCode
50 | select new
51 | {
52 | ID = a.ID
53 | }).FirstOrDefault();
54 | if (code == null)
55 | {
56 | response.Message = "用户名不存在";
57 | response.IsSuccess = false;
58 | return response;
59 | }
60 | var pwd = (from a in _context.Set()
61 | where a.ITCode == itCode && a.Password == password
62 | select new
63 | {
64 | ID = a.ID
65 | }).FirstOrDefault();
66 | if (pwd == null)
67 | {
68 | response.Message = "密码错误,请重新输入";
69 | response.IsSuccess = false;
70 | return response;
71 | }
72 |
73 | var data = (from a in _context.Set()
74 | join b in _context.Set()
75 | on a.ID equals b.UserID
76 | where a.ID == pwd.ID
77 | select new
78 | {
79 | ID = a.ID,
80 | UserName = a.Name,
81 | RoleID = b.RoleID
82 | }).FirstOrDefault();
83 | if (data != null)
84 | {
85 | response.Message = "登录成功,欢迎来到CloudBlog管理平台";
86 | response.IsSuccess = true;
87 |
88 | response.Data = new UserInfoVM();
89 | response.Data.ID = data.ID;
90 | response.Data.Name = data.UserName;
91 | // 写入session
92 | return response;
93 | }
94 | else
95 | {
96 | response.Message = "当前用户未分配角色,请联系管理员";
97 | response.IsSuccess = false;
98 | return response;
99 | }
100 |
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Repository/Mis/SystemUserRepository.cs:
--------------------------------------------------------------------------------
1 | using Core.Common.EFCore;
2 | using Core.IRepository.Mis;
3 | using Core.Model.Models;
4 | using Core.Model.ViewModels;
5 | using Microsoft.EntityFrameworkCore;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Linq;
11 | using Core.Model;
12 | using Core.Model.SearchModels;
13 |
14 | namespace Core.Repository.Mis
15 | {
16 | public class SystemUserRepository : ISystemUserRepository
17 | {
18 | private readonly IEFContext _context;
19 | public SystemUserRepository(IEFContext context)
20 | {
21 | _context = context;
22 | }
23 | ///
24 | /// 用户列表
25 | ///
26 | /// 搜索字段
27 | ///
28 | public async Task> GetUserList(UserSearch search)
29 | {
30 |
31 | var query = from a in _context.Set()
32 | select new UserInfoVM
33 | {
34 | ID = a.ID,
35 | ITCode = a.ITCode,
36 | Name = a.Name,
37 | Email = a.Email,
38 | Sex = a.Sex,
39 | IsValid = a.IsValid,
40 | CreateTime = a.CreateTime
41 | };
42 | var userRole = from a in _context.Set()
43 | join b in _context.Set()
44 | on a.RoleID equals b.ID
45 | select new
46 | {
47 | ID = a.UserID,
48 | RoleName = b.RoleName
49 | };
50 |
51 | if (!string.IsNullOrEmpty(search.ITCode))
52 | {
53 | query = query.Where(x => x.ITCode.Contains(search.ITCode));// search.ITCode.Contains(x.ITCode));
54 | }
55 | if (!string.IsNullOrEmpty(search.Name))
56 | {
57 | query = query.Where(x => x.ITCode.Contains(search.ITCode));
58 | }
59 | await query.ForEachAsync(x =>
60 | {
61 | if (userRole.Where(a => a.ID == x.ID).FirstOrDefault() != null)
62 | {
63 | x.RoleName = userRole.Where(a => a.ID == x.ID).Select(a => a.RoleName).ToList();
64 | }
65 | });
66 | var list = await query.Skip((search.Page-1) * search.
67 | Limit).Take(search.Limit).ToListAsync();
68 | TableModel data = new TableModel()
69 | {
70 | Data = list,
71 | Count = query.Count(),
72 | Code=0
73 | };
74 | return data;
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Repository/Sugar/BaseDBConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Core.Repository.Sugar
6 | {
7 | public class BaseDBConfig
8 | {
9 | ///
10 | /// 连接字符串
11 | ///
12 | // public static string ConnectionString { get; set; }
13 | public static string ConnectionString = "server=.;uid=sa;pwd=sasa;database=CoreWebApiDb";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Repository/UserRepository.cs:
--------------------------------------------------------------------------------
1 | using Core.Common.Dapper;
2 | using Core.Common.Helper;
3 | using Core.IRepository;
4 | using Core.Model.ViewModels;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Core.Repository
11 | {
12 | ///
13 | /// 用户数据层实现
14 | ///
15 | public class UserRepository : IUserRepository
16 | {
17 | private readonly DbContext _db;
18 | public UserRepository(DbContext db)
19 | {
20 | _db = db;
21 | }
22 | public async Task UserRegister(LoginVM loginVM)
23 | {
24 | LoginResult loginResult = new LoginResult();
25 | loginVM.PasswordMD5 = MD5Helper.GetMD5String(loginVM.Password);
26 | string sql = @"INSERT INTO systemuser ( ID, CreateTime, Creator, ITCode, PASSWORD, Email, NAME, Sex,IsValid )
27 | VALUES (UUID(), NOW(), 'sys', @ITCode, @PasswordMD5, @Email, @Name, 0, 1)";
28 | //DbContext.ExecuteScalarAsync()
29 | await DbContext.ExecuteAsync(sql, loginVM);
30 | loginResult.Reason = "成功";
31 | return loginResult;
32 |
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Services/AdvertisementServices.cs:
--------------------------------------------------------------------------------
1 | using Core.IRepository;
2 | using Core.IServices;
3 | using Core.Model.Models;
4 | using Core.Services.BASE;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq.Expressions;
8 | using System.Text;
9 |
10 | namespace Core.Services
11 | {
12 | public class AdvertisementServices : BaseServices, IAdvertisementServices
13 | {
14 | IAdvertisementRepository dal;
15 | // 构造函数注入
16 | public AdvertisementServices(IAdvertisementRepository dal)
17 | {
18 | this.dal = dal;
19 | base.baseDal = dal;
20 | }
21 | public int Sum(int i, int j)
22 | {
23 | return dal.Sum(i, j);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Services/BlogArticleServices.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Core.IRepository;
3 | using Core.IServices;
4 | using Core.Model.Models;
5 | using Core.Model.ViewModels;
6 | using Core.Services.BASE;
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Text;
11 | using System.Threading.Tasks;
12 |
13 | namespace Core.Services
14 | {
15 | public class BlogArticleServices : BaseServices, IBlogArticleServices
16 | {
17 | private readonly IBlogArticleRepository dal;
18 |
19 | private readonly IMapper _mapper;
20 |
21 | public BlogArticleServices(IBlogArticleRepository dal,IMapper mapper)
22 | {
23 | this.dal = dal;
24 | base.baseDal = dal;
25 | _mapper = mapper;
26 | }
27 |
28 | ///
29 | /// 获取详情
30 | ///
31 | ///
32 | ///
33 | public async Task getBlogDetails(int id)
34 | {
35 | var bloglist = await dal.Query(a => a.bID > 0, a => a.bID);
36 | var idmin = bloglist.FirstOrDefault() != null ? bloglist.FirstOrDefault().bID : 0;
37 | var idmax = bloglist.LastOrDefault() != null ? bloglist.LastOrDefault().bID : 1;
38 | var idminshow = id;
39 | var idmaxshow = id;
40 |
41 | BlogArticle blogArticle = new BlogArticle();
42 |
43 | blogArticle = (await dal.Query(a => a.bID == idminshow)).FirstOrDefault();
44 |
45 | BlogArticle prevblog = new BlogArticle();
46 |
47 |
48 | while (idminshow > idmin)
49 | {
50 | idminshow--;
51 | prevblog = (await dal.Query(a => a.bID == idminshow)).FirstOrDefault();
52 | if (prevblog != null)
53 | {
54 | break;
55 | }
56 | }
57 |
58 | BlogArticle nextblog = new BlogArticle();
59 | while (idmaxshow < idmax)
60 | {
61 | idmaxshow++;
62 | nextblog = (await dal.Query(a => a.bID == idmaxshow)).FirstOrDefault();
63 | if (nextblog != null)
64 | {
65 | break;
66 | }
67 | }
68 |
69 |
70 | blogArticle.btraffic += 1;
71 | await dal.Update(blogArticle, new List { "btraffic" });
72 |
73 | BlogViewModel models = _mapper.Map(blogArticle);
74 | //BlogViewModel models = new BlogViewModel()
75 | //{
76 | // bsubmitter = blogArticle.bsubmitter,
77 | // btitle = blogArticle.btitle,
78 | // bcategory = blogArticle.bcategory,
79 | // bcontent = blogArticle.bcontent,
80 | // btraffic = blogArticle.btraffic,
81 | // bcommentNum = blogArticle.bcommentNum,
82 | // bUpdateTime = blogArticle.bUpdateTime,
83 | // bCreateTime = blogArticle.bCreateTime,
84 | // bRemark = blogArticle.bRemark,
85 | //};
86 |
87 | if (nextblog != null)
88 | {
89 | models.next = nextblog.btitle;
90 | models.nextID = nextblog.bID;
91 | }
92 |
93 | if (prevblog != null)
94 | {
95 | models.previous = prevblog.btitle;
96 | models.previousID = prevblog.bID;
97 | }
98 | return models;
99 | }
100 |
101 | [Common.Attributes.Caching(AbsoluteExpiration = 10)] //添加缓存特性
102 | public async Task> GetBlogs()
103 | {
104 | var blogList = await dal.Query(a=>a.bID>0,a=>a.bID);
105 | return blogList;
106 | }
107 |
108 | public BlogArticle GetBlog()
109 | {
110 | return dal.GetBlog();
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Services/Core.Services.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 |
6 |
7 |
8 | ..\Core.Msi\bin\Debug\
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Services/Mis/HomeServices.cs:
--------------------------------------------------------------------------------
1 | using Core.IRepository.Mis;
2 | using Core.IServices.Mis;
3 | using Core.Model.Models;
4 | using Core.Model.ViewModels;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Core.Services.Mis
11 | {
12 | public class HomeServices : IHomeServices
13 | {
14 | private readonly IHomeRepository _homeRepository;
15 | public HomeServices(IHomeRepository homeRepository)
16 | {
17 | _homeRepository = homeRepository;
18 | }
19 |
20 | public Task> GetActionList(Guid userID, Guid menuID)
21 | {
22 | throw new NotImplementedException();
23 | }
24 |
25 | public async Task> GetMenuList(Guid userID)
26 | {
27 | return await _homeRepository.GetMenuList(userID);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Services/Mis/LoginServices.cs:
--------------------------------------------------------------------------------
1 | using Core.IRepository.Mis;
2 | using Core.IServices.Mis;
3 | using Core.Model;
4 | using Core.Model.ViewModels;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 |
9 | namespace Core.Services.Mis
10 | {
11 | public class LoginServices : ILoginServices
12 | {
13 | private readonly ILoginRepository _loginRepository;
14 | public LoginServices(ILoginRepository loginRepository)
15 | {
16 | _loginRepository = loginRepository;
17 | }
18 | public ResponseMessage GetUserInfo(string itCode, string password)
19 | {
20 | return _loginRepository.GetUserInfo(itCode, password);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/CoreWebApi/Core.Services/Mis/SystemUserServices.cs:
--------------------------------------------------------------------------------
1 | using Core.IRepository.Mis;
2 | using Core.IServices.Mis;
3 | using Core.Model;
4 | using Core.Model.Models;
5 | using Core.Model.SearchModels;
6 | using Core.Model.ViewModels;
7 | using System;
8 | using System.Collections.Generic;
9 | using System.IO;
10 | using System.Linq;
11 | using System.Text;
12 | using System.Threading.Tasks;
13 |
14 | namespace Core.Services.Mis
15 | {
16 | public class SystemUserServices : ISystemUserServices
17 | {
18 |
19 | private readonly ISystemUserRepository _userRepository;
20 | public SystemUserServices(ISystemUserRepository userRepository)
21 | {
22 | _userRepository = userRepository;
23 | }
24 | public async Task> GetUserList(UserSearch search)
25 | {
26 | return await _userRepository.GetUserList(search);
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/CoreWebApi/Core.Services/UserServices.cs:
--------------------------------------------------------------------------------
1 | using Core.IRepository;
2 | using Core.IServices;
3 | using Core.Model.ViewModels;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Core.Services
10 | {
11 | ///
12 | /// 用户业务层实现
13 | ///
14 | public class UserServices : IUserServices
15 | {
16 | private readonly IUserRepository userRepository;
17 | public UserServices(IUserRepository _userRepository)
18 | {
19 | userRepository = _userRepository;
20 | }
21 | ///
22 | /// 用户注册
23 | ///
24 | ///
25 | ///
26 | public async Task UserRegister(LoginVM loginVM)
27 | {
28 | return await userRepository.UserRegister(loginVM);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreDBConsole/CoreDBConsole.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreDBConsole/Program.cs:
--------------------------------------------------------------------------------
1 | using Core.Common.EFCore;
2 | using Core.Common.Helper;
3 | using Core.Model;
4 | using Microsoft.Extensions.Options;
5 | using System;
6 | using System.Net;
7 | using System.Net.Mail;
8 | using System.Text;
9 |
10 | namespace CoreDBConsole
11 | {
12 | class Program
13 | {
14 |
15 | static void Main(string[] args)
16 | {
17 |
18 | MailMessage mailMsg = new MailMessage();//实例化对象
19 | mailMsg.From = new MailAddress("923974733@qq.com", "季某人");//源邮件地址和发件人
20 | mailMsg.To.Add(new MailAddress("xiaomaprincess@gmail.com"));//收件人地址
21 | mailMsg.Subject = "邮件发送测试";//发送邮件的标题
22 | StringBuilder sb = new StringBuilder();
23 | sb.Append("测试测试测试测试");
24 | sb.Append("嘿嘿");
25 | mailMsg.Body = sb.ToString();//发送邮件的内容
26 | //指定smtp服务地址(根据发件人邮箱指定对应SMTP服务器地址)
27 | SmtpClient client = new SmtpClient();//格式:smtp.126.com smtp.164.com
28 | // 服务器名称
29 | client.Host = "smtp.qq.com";
30 | //端口
31 | client.Port = 587;
32 | //启用加密
33 | client.EnableSsl = true;
34 | //通过用户名和密码验证发件人身份
35 | client.Credentials = new NetworkCredential("923974733@qq.com", "xxxxxxxxxx");
36 | //发送邮件
37 | try
38 | {
39 | client.Send(mailMsg);
40 | }
41 | catch (SmtpException ex)
42 | {
43 |
44 | }
45 | Console.WriteLine("邮件已发送,请注意查收!");
46 | Console.ReadKey();
47 |
48 | //string connectionString = @"Server=localhost;Database=coreweb;User=root;Password=Princess;";
49 | //EFContext context = new EFContext(connectionString, DBTypeEnum.Mysql);
50 | //context.Database.EnsureCreated();
51 | //Console.WriteLine("数据库已初始化完毕,请查看!");
52 |
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27703.2047
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreWebApi", "CoreWebApi\CoreWebApi.csproj", "{C1AD1388-B576-4FA7-84CA-D39F9BEE6866}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Model", "Core.Model\Core.Model.csproj", "{E1E8C3EE-3769-4844-8163-E4B0A8B6B427}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.IRepository", "Core.IRepository\Core.IRepository.csproj", "{E8E44F38-BE8E-4F2D-ADD4-DFBA8CF74546}"
11 | EndProject
12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Repository", "Core.Repository\Core.Repository.csproj", "{3B8B3ACE-E41F-4A07-AA9C-EE04F2857016}"
13 | EndProject
14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.IServices", "Core.IServices\Core.IServices.csproj", "{D41A2D10-ECFE-4615-851D-AD2A3CF5209B}"
15 | EndProject
16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Services", "Core.Services\Core.Services.csproj", "{6D968205-C23E-4042-9DF5-A2EAD4462029}"
17 | EndProject
18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Common", "Core.Common\Core.Common.csproj", "{97E07083-E52E-4DF0-835E-88604A2D33AE}"
19 | EndProject
20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreDBConsole", "CoreDBConsole\CoreDBConsole.csproj", "{62736B64-C99D-4CA6-921E-F0E1A5049CA7}"
21 | EndProject
22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.Msi", "Core.Msi\Core.Msi.csproj", "{66A989B2-3FDC-4F2D-B644-89B7D43907F6}"
23 | EndProject
24 | Global
25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
26 | Debug|Any CPU = Debug|Any CPU
27 | Release|Any CPU = Release|Any CPU
28 | EndGlobalSection
29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
30 | {C1AD1388-B576-4FA7-84CA-D39F9BEE6866}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {C1AD1388-B576-4FA7-84CA-D39F9BEE6866}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {C1AD1388-B576-4FA7-84CA-D39F9BEE6866}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {C1AD1388-B576-4FA7-84CA-D39F9BEE6866}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {E1E8C3EE-3769-4844-8163-E4B0A8B6B427}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {E1E8C3EE-3769-4844-8163-E4B0A8B6B427}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {E1E8C3EE-3769-4844-8163-E4B0A8B6B427}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {E1E8C3EE-3769-4844-8163-E4B0A8B6B427}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {E8E44F38-BE8E-4F2D-ADD4-DFBA8CF74546}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {E8E44F38-BE8E-4F2D-ADD4-DFBA8CF74546}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {E8E44F38-BE8E-4F2D-ADD4-DFBA8CF74546}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {E8E44F38-BE8E-4F2D-ADD4-DFBA8CF74546}.Release|Any CPU.Build.0 = Release|Any CPU
42 | {3B8B3ACE-E41F-4A07-AA9C-EE04F2857016}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43 | {3B8B3ACE-E41F-4A07-AA9C-EE04F2857016}.Debug|Any CPU.Build.0 = Debug|Any CPU
44 | {3B8B3ACE-E41F-4A07-AA9C-EE04F2857016}.Release|Any CPU.ActiveCfg = Release|Any CPU
45 | {3B8B3ACE-E41F-4A07-AA9C-EE04F2857016}.Release|Any CPU.Build.0 = Release|Any CPU
46 | {D41A2D10-ECFE-4615-851D-AD2A3CF5209B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47 | {D41A2D10-ECFE-4615-851D-AD2A3CF5209B}.Debug|Any CPU.Build.0 = Debug|Any CPU
48 | {D41A2D10-ECFE-4615-851D-AD2A3CF5209B}.Release|Any CPU.ActiveCfg = Release|Any CPU
49 | {D41A2D10-ECFE-4615-851D-AD2A3CF5209B}.Release|Any CPU.Build.0 = Release|Any CPU
50 | {6D968205-C23E-4042-9DF5-A2EAD4462029}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51 | {6D968205-C23E-4042-9DF5-A2EAD4462029}.Debug|Any CPU.Build.0 = Debug|Any CPU
52 | {6D968205-C23E-4042-9DF5-A2EAD4462029}.Release|Any CPU.ActiveCfg = Release|Any CPU
53 | {6D968205-C23E-4042-9DF5-A2EAD4462029}.Release|Any CPU.Build.0 = Release|Any CPU
54 | {97E07083-E52E-4DF0-835E-88604A2D33AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55 | {97E07083-E52E-4DF0-835E-88604A2D33AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
56 | {97E07083-E52E-4DF0-835E-88604A2D33AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
57 | {97E07083-E52E-4DF0-835E-88604A2D33AE}.Release|Any CPU.Build.0 = Release|Any CPU
58 | {62736B64-C99D-4CA6-921E-F0E1A5049CA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
59 | {62736B64-C99D-4CA6-921E-F0E1A5049CA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
60 | {62736B64-C99D-4CA6-921E-F0E1A5049CA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
61 | {62736B64-C99D-4CA6-921E-F0E1A5049CA7}.Release|Any CPU.Build.0 = Release|Any CPU
62 | {66A989B2-3FDC-4F2D-B644-89B7D43907F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63 | {66A989B2-3FDC-4F2D-B644-89B7D43907F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
64 | {66A989B2-3FDC-4F2D-B644-89B7D43907F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
65 | {66A989B2-3FDC-4F2D-B644-89B7D43907F6}.Release|Any CPU.Build.0 = Release|Any CPU
66 | EndGlobalSection
67 | GlobalSection(SolutionProperties) = preSolution
68 | HideSolutionNode = FALSE
69 | EndGlobalSection
70 | GlobalSection(ExtensibilityGlobals) = postSolution
71 | SolutionGuid = {5E261F9A-6E6A-48D9-BC4D-DA56DC8007B9}
72 | EndGlobalSection
73 | EndGlobal
74 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/AOP/CoreCacheAOP.cs:
--------------------------------------------------------------------------------
1 | using Castle.DynamicProxy;
2 | using Core.Common.Attributes;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 |
8 | namespace CoreWebApi.AOP
9 | {
10 | ///
11 | /// AOP 缓存
12 | ///
13 | public class CoreCacheAOP : IInterceptor
14 | {
15 | private ICaching _cache;
16 | public CoreCacheAOP(ICaching cache)
17 | {
18 | _cache = cache;
19 | }
20 | ///
21 | /// 拦截方法
22 | ///
23 | ///
24 | public void Intercept(IInvocation invocation)
25 | {
26 |
27 | var method = invocation.MethodInvocationTarget ?? invocation.Method;
28 | // 对当前方法的特性验证
29 | if (method.GetCustomAttributes(true).FirstOrDefault(x => x.GetType() == typeof(CachingAttribute)) is CachingAttribute qCachingAttribute)
30 | {
31 | // 获取自定缓存键
32 | var cacheKey = CustomCacheKey(invocation);
33 |
34 | var cacheValue = _cache.Get(cacheKey);
35 | if (cacheValue != null)
36 | {
37 | // 获取当前的缓存值,并作为返回值返回
38 | invocation.ReturnValue = cacheValue;
39 | return;
40 | }
41 | // 继续执行当前请求
42 | invocation.Proceed();
43 |
44 | // 存入缓存
45 | if (string.IsNullOrWhiteSpace(cacheKey))
46 | {
47 | _cache.Set(cacheKey, invocation.ReturnValue);
48 | }
49 | }
50 | else
51 | {
52 | invocation.Proceed();
53 | }
54 |
55 |
56 | }
57 |
58 | ///
59 | /// 自定义缓存键
60 | ///
61 | ///
62 | ///
63 | private string CustomCacheKey(IInvocation invocation)
64 | {
65 | var typeName = invocation.TargetType.Name;
66 | var methodName = invocation.Method.Name;
67 | var methodArguments = invocation.Arguments.Select(GetArgumentValue).Take(3).ToList();
68 | string key = $"{typeName}:{methodName}:";
69 | foreach (var item in methodArguments)
70 | {
71 | key += $"{ item}";
72 | }
73 |
74 | return key.TrimEnd(':');
75 | }
76 |
77 | ///
78 | /// object 转 stirng
79 | ///
80 | ///
81 | ///
82 | private string GetArgumentValue(object arg)
83 | {
84 | if (arg is int || arg is long || arg is string)
85 | {
86 | return arg.ToString();
87 | }
88 | if (arg is DateTime)
89 | {
90 | return ((DateTime)arg).ToString("yyyy-MM-DD HH:mm:ss");
91 | }
92 | return "";
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/AOP/CoreLogAOP.cs:
--------------------------------------------------------------------------------
1 | using Castle.DynamicProxy;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 |
8 | namespace CoreWebApi.AOP
9 | {
10 | ///
11 | /// 拦截器
12 | ///
13 | public class CoreLogAOP : IInterceptor
14 | {
15 | ///
16 | /// 实现IInterceptor方法
17 | ///
18 | /// 包含被拦截方法的信息
19 | public void Intercept(IInvocation invocation)
20 | {
21 | var dataIntercept=$"{DateTime.Now.ToString("yyyyMMDDHHmmss")}"+$"当前执行方法:{invocation.Method.Name}"+$"参数是:{string.Join(",",invocation.Arguments.Select(a=>(a??"")).ToString().ToArray())} \r\n";
22 |
23 | // 执行后,继续执行当前方法
24 | invocation.Proceed();
25 | dataIntercept += ($"方法执行完毕,返回结果:{invocation.ReturnValue}");
26 |
27 | #region 输出到当前项目日志
28 | var path = Directory.GetCurrentDirectory() + @"\Log";
29 | if (!Directory.Exists(path))
30 | {
31 | Directory.CreateDirectory(path);
32 | }
33 | string fileName = path + $@"\InterceptLog-{DateTime.Now.ToString("yyyy-MM-dd HHmmss")}.log";
34 | StreamWriter sw = File.AppendText(fileName);
35 | sw.WriteLine(dataIntercept);
36 | sw.Close();
37 | #endregion
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/AOP/ICachingProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 |
6 | namespace CoreWebApi.AOP
7 | {
8 | ///
9 | /// 缓存接口
10 | ///
11 | public interface ICaching
12 | {
13 | ///
14 | /// 取数据
15 | ///
16 | ///
17 | ///
18 | object Get(string cacheKey);
19 | ///
20 | /// 存数据
21 | ///
22 | ///
23 | ///
24 | void Set(string cacheLey, object cacheValue);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/AOP/MemoryCaching.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Caching.Memory;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 |
7 | namespace CoreWebApi.AOP
8 | {
9 | ///
10 | /// 实例化缓存接口
11 | ///
12 | public class MemoryCaching : ICaching
13 | {
14 |
15 | private IMemoryCache _cache;
16 |
17 | public MemoryCaching(IMemoryCache cache)
18 | {
19 | _cache = cache;
20 | }
21 |
22 | public object Get(string cacheKey)
23 | {
24 | return _cache.Get(cacheKey);
25 | }
26 |
27 | public void Set(string cacheLey, object cacheValue)
28 | {
29 | // 设置过期时间
30 | _cache.Set(cacheLey, cacheValue, TimeSpan.FromSeconds(7200));
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/AuthHelper/OverWrite/JwtHelper.cs:
--------------------------------------------------------------------------------
1 | using Core.Model;
2 | using Microsoft.IdentityModel.Tokens;
3 | using System;
4 | using System.IdentityModel.Tokens.Jwt;
5 | using System.Security.Claims;
6 | using System.Text;
7 |
8 | namespace CoreWebApi.AuthHelper.OverWrite
9 | {
10 | public class JwtHelper
11 | {
12 | public static string secretKey { get; set; } = "sdfsdfsrty45634kkhllghtdgdfss345t678fs";
13 |
14 | ///
15 | /// 颁发JWT字符串
16 | ///
17 | ///
18 | ///
19 | public static string IssueJWT(TokenModelJWT tokenModel)
20 | {
21 | var dateTime = DateTime.UtcNow;
22 | //var claims = new Claim[]
23 | //{
24 | // new Claim(JwtRegisteredClaimNames.Jti,tokenModel.Uid.ToString()),//Id
25 | // new Claim("Role", tokenModel.Role),//角色
26 | // new Claim(JwtRegisteredClaimNames.Iat,dateTime.ToString(),ClaimValueTypes.Integer64)
27 | //};
28 |
29 | var claims = new Claim[]
30 | {
31 | // Claim的默认配置
32 | new Claim(JwtRegisteredClaimNames.Jti,Guid.NewGuid().ToString()),
33 | new Claim(JwtRegisteredClaimNames.Iat, $"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}"),
34 | new Claim(JwtRegisteredClaimNames.Nbf,$"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}") ,
35 | // 设置JWT过期时间 100秒
36 | new Claim(JwtRegisteredClaimNames.Exp,$"{new DateTimeOffset(DateTime.Now.AddSeconds(100)).ToUnixTimeSeconds()}"),
37 | new Claim(JwtRegisteredClaimNames.Iss,"Blog.Core"),
38 | new Claim(JwtRegisteredClaimNames.Aud,"wr"),
39 | // 使用官方UseAuthentication授权要验证的Role
40 | new Claim(ClaimTypes.Role,tokenModel.Role)
41 | };
42 | //秘钥
43 | var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey));
44 | var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
45 |
46 | var jwt = new JwtSecurityToken(
47 | issuer: "Blog.Core",
48 | claims: claims, //声明集合
49 | expires: dateTime.AddHours(2),
50 | signingCredentials: creds);
51 |
52 | var jwtHandler = new JwtSecurityTokenHandler();
53 | var encodedJwt = jwtHandler.WriteToken(jwt);
54 |
55 | return encodedJwt;
56 | }
57 |
58 |
59 | ///
60 | /// 解析
61 | ///
62 | ///
63 | ///
64 | public static TokenModelJWT SerializeJWT(string jwtStr)
65 | {
66 | var jwtHandler = new JwtSecurityTokenHandler();
67 | JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(jwtStr);
68 | object role = new object(); ;
69 | try
70 | {
71 | jwtToken.Payload.TryGetValue("Role", out role);
72 | }
73 | catch (Exception e)
74 | {
75 | Console.WriteLine(e);
76 | throw;
77 | }
78 | var tm = new TokenModelJWT
79 | {
80 | Uid = (jwtToken.Id).ObjToInt(),
81 | Role = role != null ? role.ObjToString() : "",
82 | };
83 | return tm;
84 | }
85 | }
86 |
87 | public class TokenModelJWT
88 | {
89 | ///
90 | /// Id
91 | ///
92 | public long Uid { get; set; }
93 | ///
94 | /// 角色
95 | ///
96 | public string Role { get; set; }
97 | ///
98 | /// 职能
99 | ///
100 | public string Work { get; set; }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/AuthHelper/OverWrite/JwtTokenAuth.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.Http;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Security.Claims;
7 | using System.Threading.Tasks;
8 |
9 | namespace CoreWebApi.AuthHelper.OverWrite
10 | {
11 | public class JwtTokenAuth
12 | {
13 |
14 | private readonly RequestDelegate _next;
15 |
16 | public JwtTokenAuth(RequestDelegate next)
17 | {
18 | _next = next;
19 | }
20 | ///
21 | /// 处理http请求
22 | ///
23 | /// http请求上下文
24 | ///
25 | public Task Invoke(HttpContext httpContext)
26 | {
27 | // 检测是否包含'Authorization'请求头
28 | if (!httpContext.Request.Headers.ContainsKey("Authorization"))
29 | {
30 | return _next(httpContext);
31 | }
32 |
33 | // 获取token 并去除Bearer
34 | var tokenHeader = httpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ","");
35 |
36 | TokenModelJWT tm = JwtHelper.SerializeJWT(tokenHeader); // 序列化token,获取授权
37 |
38 | // 授权 可以是多个角色
39 | var claimList = new List();
40 | var claim = new Claim(ClaimTypes.Role, tm.Role);
41 | claimList.Add(claim);
42 | var identity = new ClaimsIdentity(claimList);
43 | var principal = new ClaimsPrincipal(identity);
44 | httpContext.User = principal;
45 |
46 | return _next(httpContext);
47 | }
48 | }
49 |
50 | //public static class RequestCultureMiddlewareExtensions
51 | //{
52 | // public static IApplicationBuilder UseRequestCulture(
53 | // this IApplicationBuilder builder)
54 | // {
55 | // return builder.UseMiddleware();
56 | // }
57 | //}
58 | }
59 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/AutoMapper/CustomProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Core.Model.Models;
3 | using Core.Model.ViewModels;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Threading.Tasks;
8 |
9 | namespace CoreWebApi.AutoMapper
10 | {
11 | ///
12 | /// 自动映射
13 | ///
14 | public class CustomProfile: Profile
15 | {
16 | public CustomProfile()
17 | {
18 | CreateMap();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/Controllers/LoginController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using CoreWebApi.AuthHelper.OverWrite;
6 | using Microsoft.AspNetCore.Authorization;
7 | using Microsoft.AspNetCore.Cors;
8 | using Microsoft.AspNetCore.Mvc;
9 |
10 | namespace CoreWebApi.Controllers
11 | {
12 | [Route("api/[controller]/[action]")]
13 | [ApiController]
14 | [Produces("application/json")]
15 | [EnableCors("LimitRequests")]
16 | public class LoginController : Controller
17 | {
18 | ///
19 | /// 获取token
20 | ///
21 | /// 用户id
22 | /// 角色
23 | ///
24 | [HttpGet]
25 | public JsonResult GetJWTStr(long id , string sub)
26 | {
27 | //这里就是用户登陆以后,通过数据库去调取数据,分配权限的操作
28 | TokenModelJWT tokenModel = new TokenModelJWT();
29 | tokenModel.Uid = id;
30 | tokenModel.Role = sub;
31 |
32 | // 获取token
33 | string jwtStr = JwtHelper.IssueJWT(tokenModel);
34 | return Json(jwtStr);
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/Controllers/TodoItemController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using CoreWebApi.Models;
6 | using Microsoft.AspNetCore.Authorization;
7 | using Microsoft.AspNetCore.Http;
8 | using Microsoft.AspNetCore.Mvc;
9 |
10 | namespace CoreWebApi.Controllers
11 | {
12 | ///
13 | /// Todo控制器
14 | ///
15 | [Produces("application/json")]
16 | [Route("api/[controller]/[action]")]
17 | [ApiController]
18 | [Authorize(Roles ="Admin,Client")]
19 | [Authorize(Policy ="SystemOrAdmin")]
20 | public class TodoItemController : ControllerBase
21 | {
22 | ///
23 | /// 获取待办事项列表
24 | ///
25 | ///
26 | [HttpGet]
27 | [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
28 | public List GetAll()
29 | {
30 | var ss = new List();
31 | return ss;
32 | }
33 | ///
34 | /// 根据ID获取特定数据
35 | ///
36 | /// 主键ID
37 | ///
38 | [HttpGet("{id}", Name = "GetTodo")]
39 | [ProducesResponseType(200)]
40 | public a GetById(long id)
41 | {
42 | var result = new a();
43 | return result;
44 | }
45 | ///
46 | /// FromBody 特性从情报体中获取参数,2.1版本之后不用添加
47 | ///
48 | ///
49 | ///
50 | [HttpPost]
51 | [ProducesResponseType(typeof(TodoItem), 201)]// 数据注释,告诉客户端返回类型
52 | public IActionResult Create([FromBody]TodoItem item)
53 | {
54 | if (item == null)
55 | {
56 | return BadRequest();
57 | }
58 | // 添加成功后跳转到名为GetById的route
59 | return CreatedAtRoute("GetTodo", new { id = item.Id }, item);
60 | }
61 | ///
62 | /// Put请求:更新数据
63 | ///
64 | ///
65 | ///
66 | ///
67 | [HttpPut("{id}")]
68 | public IActionResult Update(long id, [FromBody] TodoItem item)
69 | {
70 | if (item == null || item.Id != id)
71 | {
72 | return BadRequest();
73 | }
74 | return NoContent();
75 | }
76 | ///
77 | /// Delete
78 | ///
79 | ///
80 | ///
81 | [HttpDelete("{id}")]
82 | public IActionResult Delete(long id)
83 | {
84 | return NoContent();
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/Controllers/UserController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Core.IServices;
6 | using Core.Model.ViewModels;
7 | using Microsoft.AspNetCore.Http;
8 | using Microsoft.AspNetCore.Mvc;
9 |
10 | namespace CoreWebApi.Controllers
11 | {
12 | [Produces("application/json")]
13 | [Route("api/v1/[controller]/[action]")]
14 | [ApiController]
15 | public class UserController : ControllerBase
16 | {
17 | private readonly IUserServices userServices;
18 | public UserController(IUserServices _userServices)
19 | {
20 | userServices = _userServices;
21 | }
22 |
23 | ///
24 | /// 用户注册
25 | ///
26 | ///
27 | ///
28 | [HttpPost]
29 | public async Task UserRegister(LoginVM loginVM)
30 | {
31 | return await userServices.UserRegister(loginVM);
32 | //return await new Task(new LoginResult{Reason="1"});
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 | using CoreWebApi.Models;
7 | using Microsoft.AspNetCore.Http;
8 | using Microsoft.AspNetCore.Authorization;
9 |
10 | namespace CoreWebApi.Controllers
11 | {
12 | ///
13 | /// value控制器
14 | ///
15 | [Route("api/[controller]/[action]")]
16 | [ApiController]
17 | [Produces("application/json")]
18 | [Authorize]
19 | public class ValuesController : ControllerBase
20 | {
21 | // GET api/values
22 | [HttpGet]
23 | [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
24 | public ActionResult> Get()
25 | {
26 | return new string[] { "value1", "value2" };
27 | }
28 |
29 | ///
30 | /// Get请求
31 | ///
32 | ///
33 | ///
34 | // GET api/values/5
35 | [HttpGet("{id}")]
36 | [ProducesResponseType(201)]
37 | public ActionResult Get(int id)
38 | {
39 | return "value";
40 | }
41 |
42 | // POST api/values
43 | [HttpPost]
44 | [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
45 | public void Post([FromBody] string value)
46 | {
47 | }
48 |
49 | // PUT api/values/5
50 | [HttpPut("{id}")]
51 | [ProducesResponseType(201)]
52 | public void Put(int id, [FromBody] string value)
53 | {
54 | }
55 |
56 | // DELETE api/values/5
57 | [HttpDelete("{id}")]
58 | [ProducesResponseType(201)]
59 | public void Delete(int id)
60 | {
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/CoreWebApi.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 | true
6 | 1701;1702;1705;1591;1703
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | Always
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/Filter/GlobalExceptionFilter.cs:
--------------------------------------------------------------------------------
1 | using CoreWebApi.Log;
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.AspNetCore.Http;
4 | using Microsoft.AspNetCore.Mvc;
5 | using Microsoft.AspNetCore.Mvc.Filters;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Linq;
9 | using System.Threading.Tasks;
10 |
11 | namespace CoreWebApi.Filter
12 | {
13 | ///
14 | /// 全局异常错误日志
15 | ///
16 | public class GlobalExceptionFilter : IExceptionFilter
17 | {
18 | private readonly IHostingEnvironment _env;
19 | private readonly ILoggerHelper _loggerHelper;
20 | public GlobalExceptionFilter(IHostingEnvironment env, ILoggerHelper loggerHelper)
21 | {
22 | _env = env;
23 | _loggerHelper = loggerHelper;
24 | }
25 | public void OnException(ExceptionContext context)
26 | {
27 | var json = new JsonErrorResponse();
28 | // 错误信息
29 | json.Message = context.Exception.Message;
30 | if (_env.IsDevelopment())
31 | {
32 | // 开发环境,记录堆栈信息
33 | json.DevelopmentMessage = context.Exception.StackTrace;
34 | }
35 | // 使用log4net记录错误日志
36 | context.Result = new InternalServerErrorObjectResult(json);
37 | _loggerHelper.Error(json.Message, WriteLog(json.Message, context.Exception));
38 | }
39 |
40 | ///
41 | /// 自定义返回格式
42 | ///
43 | ///
44 | ///
45 | ///
46 | private string WriteLog(string throwMsg,Exception ex)
47 | {
48 | return string.Format("【自定义错误】:{0} \r\n【异常类型】:{1} \r\n【异常信息】:{2} \r\n【堆栈调用】:{3}", new object[] { throwMsg,
49 | ex.GetType().Name, ex.Message, ex.StackTrace });
50 | }
51 | }
52 |
53 | public class InternalServerErrorObjectResult : ObjectResult
54 | {
55 | public InternalServerErrorObjectResult(object value) : base(value)
56 | {
57 | StatusCode = StatusCodes.Status500InternalServerError;
58 | }
59 | }
60 |
61 | ///
62 | /// 返回错误信息
63 | ///
64 | public class JsonErrorResponse
65 | {
66 | ///
67 | /// 生产环境消息
68 | ///
69 | public string Message { get; set; }
70 |
71 | ///
72 | /// 开发环境消息
73 | ///
74 | public string DevelopmentMessage { get; set; }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/Models/TodeItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 |
6 | namespace CoreWebApi.Models
7 | {
8 | public class TodoItem
9 | {
10 | ///
11 | /// 主键
12 | ///
13 | public long Id { get; set; }
14 | ///
15 | /// 待办事项描述
16 | ///
17 | public string Name { get; set; }
18 | ///
19 | /// 是否完成
20 | ///
21 | public bool IsComplete { get; set; }
22 | }
23 | public struct a
24 | {
25 | ///
26 | /// awawaw
27 | ///
28 | public string wwwwwww { get; set; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/Nlog.config:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.Extensions.Configuration;
9 | using Microsoft.Extensions.Logging;
10 | using NLog.Web;
11 |
12 | namespace CoreWebApi
13 | {
14 | public class Program
15 | {
16 | public static void Main(string[] args)
17 | {
18 | CreateWebHostBuilder(args).Build().Run();
19 | }
20 |
21 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
22 | WebHost.CreateDefaultBuilder(args)
23 | .UseNLog()
24 | .UseStartup();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:64402",
8 | "sslPort": 44391
9 | }
10 | },
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "swagger",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "CoreWebApi": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "swagger",
24 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
25 | "environmentVariables": {
26 | "ASPNETCORE_ENVIRONMENT": "Development"
27 | }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/SwaggerHelper/CustomApiVersion.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 |
6 | namespace CoreWebApi.SwaggerHelper
7 | {
8 | ///
9 | /// 自定义接口版本
10 | ///
11 | public class CustomApiVersion
12 | {
13 | public enum ApiVersions
14 | {
15 | ///
16 | /// v1版本
17 | ///
18 | v1=1,
19 | ///
20 | /// v2版本
21 | ///
22 | v2=2,
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/SwaggerHelper/CustomRouteAttribute.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.AspNetCore.Mvc.ApiExplorer;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using static CoreWebApi.SwaggerHelper.CustomApiVersion;
8 |
9 | namespace CoreWebApi.SwaggerHelper
10 | {
11 | ///
12 | /// 自定义路由 /api/{version}/[controler]/[action]
13 | ///
14 | public class CustomRouteAttribute : RouteAttribute, IApiDescriptionGroupNameProvider
15 | {
16 | ///
17 | /// 分组名称,用来实现实现IApiDescriptionGroupNameProvider
18 | ///
19 | public string GroupName { get; set; }
20 |
21 | ///
22 | /// 自定义路由构造函数,继承基类路由
23 | ///
24 | ///
25 | public CustomRouteAttribute(string actionName = "[action]"):base("/api/{version}/[controller]/"+actionName)
26 | {
27 |
28 | }
29 |
30 | ///
31 | /// 自定义路由构造函数,继承基类路由
32 | ///
33 | /// 方法名
34 | /// 版本
35 | public CustomRouteAttribute(ApiVersions version, string actionName = "[action]") : base($"/api/{version.ToString()}/[controller]/{actionName}")
36 | {
37 | GroupName = version.ToString();
38 | }
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Debug",
5 | "System": "Information",
6 | "Microsoft": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/appsettings.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaoMaPrincess/.NetCoreWebApi/266dcd560162e1db7a5d7d7b1e4379ba83625a6d/CoreWebApi/CoreWebApi/appsettings.json
--------------------------------------------------------------------------------
/CoreWebApi/CoreWebApi/log4net.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # .NetCoreWebApi
2 | **一个基于.NETCore的后端接口项目。目前的设想是做个人博客网站使用。前端打算用Vue全家桶(目前还未开始)。**
3 |
4 | 此外还有一个单层项目:
5 |
6 | https://github.com/xiaoMaPrincess/Asp.NetCore-WebApi
7 |
8 | ------
9 |
10 | ### 计划引入的功能:
11 |
12 | **Swagger:**
13 |
14 | SwaggerUI **√**
15 |
16 | 身份认证与授权 **√**
17 |
18 | Api多版本控制 **√**
19 |
20 | **ORM:**
21 |
22 | Dapper **√**
23 |
24 | EFCore **√**
25 |
26 | **关系型数据库:**
27 |
28 | Mysql **√**
29 |
30 | SqlServer **√**
31 |
32 | **Nosql数据库:**
33 |
34 | Redis **√**
35 |
36 | MonogoDB **√**
37 |
38 | **依赖注入:**
39 |
40 | AutoFac **√**
41 |
42 | .NetCore自带容器 **√**
43 |
44 | **作业调度:**
45 |
46 | Quartz.NET
47 |
48 | **日志记录:**
49 |
50 | Nlog **√**
51 |
52 | **对象自动映射:**
53 |
54 | AutoMapper **√**
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------