diff --git a/JSD-7843配置使用文档.docx b/JSD-7843配置使用文档.docx new file mode 100644 index 0000000..7e51ed4 Binary files /dev/null and b/JSD-7843配置使用文档.docx differ diff --git a/README.md b/README.md index 378062a..6d36c54 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ # open-JSD-7843 -JSD-7843 开源材料 \ No newline at end of file +jsd-7843 开源材料\ +免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ +仅作为开发者学习参考使用!禁止用于任何商业用途!\ +为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。 \ No newline at end of file diff --git a/jsd-7843-需求确认书.docx b/jsd-7843-需求确认书.docx new file mode 100644 index 0000000..2c68663 Binary files /dev/null and b/jsd-7843-需求确认书.docx differ diff --git a/lib/finekit-10.0.jar b/lib/finekit-10.0.jar new file mode 100644 index 0000000..f4482fc Binary files /dev/null and b/lib/finekit-10.0.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..9b60ed6 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,25 @@ + + + com.fr.plugin.j7843.sso.auth + + yes + 1.1 + 10.0 + 2018-07-31 + mqh + + + com.fr.plugin.j7843.sso + + com.fanruan.api + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/j7843/sso/LifeCycleMonitorImpl.java b/src/main/java/com/fr/plugin/j7843/sso/LifeCycleMonitorImpl.java new file mode 100644 index 0000000..b596ade --- /dev/null +++ b/src/main/java/com/fr/plugin/j7843/sso/LifeCycleMonitorImpl.java @@ -0,0 +1,33 @@ + /* + * Copyright (C), 2018-2021 + * Project: starter + * FileName: OneAccessLifeCycleMonitor + * Author: Louis + * Date: 2021/3/30 15:10 + */ + package com.fr.plugin.j7843.sso; + + import com.fr.plugin.context.PluginContext; +import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; + + /** + *
+ * + * + * @author Louis + * @since 1.0.0 + */ + public class LifeCycleMonitorImpl extends AbstractPluginLifecycleMonitor { + public LifeCycleMonitorImpl() { + } + + @Override + public void afterRun(PluginContext pluginContext) { +// SsoConfig.getInstance(); + } + + @Override + public void beforeStop(PluginContext pluginContext) { + + } + } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/j7843/sso/LocaleFinder.java b/src/main/java/com/fr/plugin/j7843/sso/LocaleFinder.java new file mode 100644 index 0000000..5cfe371 --- /dev/null +++ b/src/main/java/com/fr/plugin/j7843/sso/LocaleFinder.java @@ -0,0 +1,37 @@ + /* + * Copyright (C), 2018-2020 + * Project: starter + * FileName: LocaleFinder + * Author: Louis + * Date: 2020/8/31 22:19 + */ + package com.fr.plugin.j7843.sso; + + import com.fr.intelli.record.Focus; +import com.fr.intelli.record.Original; +import com.fr.record.analyzer.EnableMetrics; +import com.fr.stable.fun.impl.AbstractLocaleFinder; + +import static com.fr.plugin.j7843.sso.config.SsoConfig.PLUGIN_ID; + + /** + *
+ * + * + * @author Louis + * @since 1.0.0 + */ + @EnableMetrics + public class LocaleFinder extends AbstractLocaleFinder { + + @Override + @Focus(id = PLUGIN_ID, text = "Plugin-J7843-Sso", source = Original.PLUGIN) + public String find() { + return "com/fr/plugin/j7843/sso/locale/lang"; + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/j7843/sso/ProcessDBAccess.java b/src/main/java/com/fr/plugin/j7843/sso/ProcessDBAccess.java new file mode 100644 index 0000000..053274a --- /dev/null +++ b/src/main/java/com/fr/plugin/j7843/sso/ProcessDBAccess.java @@ -0,0 +1,66 @@ + /* + * Copyright (C), 2018-2020 + * Project: starter + * FileName: RoleGroupDBAccess + * Author: Louis + * Date: 2020/6/4 11:48 + */ + package com.fr.plugin.j7843.sso; + + import com.fr.plugin.db.AbstractDBAccessProvider; + import com.fr.plugin.j7843.sso.dao.CstDataDao; + import com.fr.plugin.j7843.sso.dao.CstStatusDao; + import com.fr.plugin.j7843.sso.entity.CstDataEntity; + import com.fr.plugin.j7843.sso.entity.CstStatusEntity; + import com.fr.stable.db.accessor.DBAccessor; + import com.fr.stable.db.dao.BaseDAO; + import com.fr.stable.db.dao.DAOProvider; + + /** + * 〈Function Description〉
+ * 〈ProcessDBAccess〉 + * + * @author Louis + * @since 1.0.0 + */ + public class ProcessDBAccess extends AbstractDBAccessProvider { + private static DBAccessor accessor; + + public ProcessDBAccess() { + } + + public static DBAccessor getAccessor() { + return accessor; + } + + @Override + public DAOProvider[] registerDAO() { + return new DAOProvider[]{ + new DAOProvider() { + @Override + public Class getEntityClass() { + return CstDataEntity.class; + } + @Override + public Class getDAOClass() { + return CstDataDao.class; + } + }, + new DAOProvider() { + @Override + public Class getEntityClass() { + return CstStatusEntity.class; + } + @Override + public Class getDAOClass() { + return CstStatusDao.class; + } + } + }; + } + + @Override + public void onDBAvailable(DBAccessor dbAccessor) { + accessor = dbAccessor; + } + } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/j7843/sso/bean/CstDataBean.java b/src/main/java/com/fr/plugin/j7843/sso/bean/CstDataBean.java new file mode 100644 index 0000000..b41994c --- /dev/null +++ b/src/main/java/com/fr/plugin/j7843/sso/bean/CstDataBean.java @@ -0,0 +1,128 @@ + /* + * Copyright (C), 2018-2021 + * Project: starter + * FileName: CstBean + * Author: Louis + * Date: 2021/5/17 22:01 + */ + package com.fr.plugin.j7843.sso.bean; + + import com.fr.third.fasterxml.jackson.annotation.JsonInclude; + import com.fr.third.fasterxml.jackson.annotation.JsonProperty; + + /** + *
+ * + * + * @author Louis + * @since 1.0.0 + */ + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + public class CstDataBean { + private String id; + private String pcode; + private String cityCo; + private String projName; + private String telphone; + private String time; + @JsonProperty("fy_code") + private String fyCode; + @JsonProperty("fy_name") + private String fyName; + private int price; + @JsonProperty("rg_time") + private String rgTime; + @JsonProperty("qy_time") + private String qyTime; + + public CstDataBean() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getPcode() { + return pcode; + } + + public void setPcode(String pcode) { + this.pcode = pcode; + } + + public String getTelphone() { + return telphone; + } + + public void setTelphone(String telphone) { + this.telphone = telphone; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public String getProjName() { + return projName; + } + + public void setProjName(String projName) { + this.projName = projName; + } + + public String getCityCo() { + return cityCo; + } + + public void setCityCo(String cityCo) { + this.cityCo = cityCo; + } + + public String getFyCode() { + return fyCode; + } + + public void setFyCode(String fyCode) { + this.fyCode = fyCode; + } + + public String getFyName() { + return fyName; + } + + public void setFyName(String fyName) { + this.fyName = fyName; + } + + public int getPrice() { + return price; + } + + public void setPrice(int price) { + this.price = price; + } + + public String getRgTime() { + return rgTime; + } + + public void setRgTime(String rgTime) { + this.rgTime = rgTime; + } + + public String getQyTime() { + return qyTime; + } + + public void setQyTime(String qyTime) { + this.qyTime = qyTime; + } + } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/j7843/sso/bean/DataResponse.java b/src/main/java/com/fr/plugin/j7843/sso/bean/DataResponse.java new file mode 100644 index 0000000..ba9d92e --- /dev/null +++ b/src/main/java/com/fr/plugin/j7843/sso/bean/DataResponse.java @@ -0,0 +1,104 @@ + /* + * Copyright (C), 2018-2021 + * Project: starter + * FileName: DataResponse + * Author: Louis + * Date: 2021/3/19 11:46 + */ + package com.fr.plugin.j7843.sso.bean; + + import com.fr.third.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serializable; +import java.util.List; + + /** + *
+ * + * + * @author Louis + * @since 1.0.0 + */ + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + public class DataResponse implements Serializable { + private static final long serialVersionUID = -6470353731188369521L; + private String code; + private String message; + private List data; + + public DataResponse() { + } + + public DataResponse code(String code) { + this.code = code; + return this; + } + + public DataResponse message(String message) { + this.message = message; + return this; + } + + public DataResponse data(List data) { + this.setData(data); + return this; + } + + private static DataResponse create() { + return new DataResponse(); + } + + /** + * 操作结果 + * + * @return + */ + public static DataResponse success() { + return create().code("0").message("success"); + } + + /** + * 操作结果 + * + * @param data + * @return + */ + public static DataResponse operation(List data) { + return create().code("0").message("success").data(data); + } + + /** + * 报错结果 + * + * @param code + * @param message + * @return + */ + public static DataResponse error(String code, String message) { + return create().code(code).message(message); + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/j7843/sso/config/SsoConfig.java b/src/main/java/com/fr/plugin/j7843/sso/config/SsoConfig.java new file mode 100644 index 0000000..b4b1045 --- /dev/null +++ b/src/main/java/com/fr/plugin/j7843/sso/config/SsoConfig.java @@ -0,0 +1,57 @@ + /* + * Copyright (C), 2018-2021 + * Project: starter + * FileName: OneAccessConfig + * Author: Louis + * Date: 2021/3/30 9:38 + */ + package com.fr.plugin.j7843.sso.config; + + import com.fr.config.ConfigContext; +import com.fr.config.DefaultConfiguration; +import com.fr.config.Visualization; +import com.fr.intelli.record.Focus; +import com.fr.intelli.record.Original; + + /** + *
+ * + * + * @author Louis + * @since 1.0.0 + */ + @Visualization(category = "Plugin-J7843-Sso_Group") + public class SsoConfig extends DefaultConfiguration { + public static final String PLUGIN_ID = "com.fr.plugin.j7843.sso.auth"; + + private static volatile SsoConfig config = null; + + @Focus(id = PLUGIN_ID, text = "Plugin-J7843-Sso", source = Original.PLUGIN) + public static SsoConfig getInstance() { + if (config == null) { + config = ConfigContext.getConfigInstance(SsoConfig.class); + } + return config; + } + +// @Identifier(value = "uriBase", name = "Plugin-J7843-Sso_Config_uriBase", description = "Plugin-J7843-Sso_Config_uriBase_Description", status = Status.SHOW) +// private Conf uriBase = Holders.simple(StringKit.EMPTY); +// @Identifier(value = "privateKey", name = "Plugin-J7843-Sso_Config_privateKey", description = "Plugin-J7843-Sso_Config_privateKey_Description", status = Status.SHOW) +// private Conf privateKey = Holders.simple(StringKit.EMPTY); + +// public String getUriBase() { +// return uriBase.get(); +// } +// +// public void setUriBase(String uriBase) { +// this.uriBase.set(uriBase); +// } +// +// public String getPrivateKey() { +// return privateKey.get(); +// } +// +// public void setPrivateKey(String privateKey) { +// this.privateKey.set(privateKey); +// } + } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/j7843/sso/dao/CstDataDao.java b/src/main/java/com/fr/plugin/j7843/sso/dao/CstDataDao.java new file mode 100644 index 0000000..624cd7c --- /dev/null +++ b/src/main/java/com/fr/plugin/j7843/sso/dao/CstDataDao.java @@ -0,0 +1,49 @@ + /* + * Copyright (C), 2018-2020 + * Project: starter + * FileName: RoleGroupDAO + * Author: Louis + * Date: 2020/6/4 11:44 + */ + package com.fr.plugin.j7843.sso.dao; + + import com.fr.plugin.j7843.sso.ProcessDBAccess; +import com.fr.plugin.j7843.sso.entity.CstDataEntity; +import com.fr.stable.db.action.DBAction; +import com.fr.stable.db.dao.BaseDAO; +import com.fr.stable.db.session.DAOSession; + + /** + * 〈Function Description〉
+ * 〈CstDataDao〉 + * + * @author Louis + * @since 1.0.0 + */ + public class CstDataDao extends BaseDAO { + public CstDataDao(DAOSession daoSession) { + super(daoSession); + } + + protected Class getEntityClass() { + return CstDataEntity.class; + } + + /** + * Save + * + * @param saveCstData + * @throws Exception + */ + public static void save(final CstDataEntity saveCstData) throws Exception { + CstDataEntity cstDataEntity = ProcessDBAccess.getAccessor().runQueryAction(daoContext -> daoContext.getDAO(CstDataDao.class) + .getById(saveCstData.getId())); + if (cstDataEntity != null) { + return; + } + ProcessDBAccess.getAccessor().runDMLAction((DBAction) daoContext -> { + (daoContext.getDAO(CstDataDao.class)).add(saveCstData); + return null; + }); + } + } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/j7843/sso/dao/CstStatusDao.java b/src/main/java/com/fr/plugin/j7843/sso/dao/CstStatusDao.java new file mode 100644 index 0000000..9b3ac94 --- /dev/null +++ b/src/main/java/com/fr/plugin/j7843/sso/dao/CstStatusDao.java @@ -0,0 +1,46 @@ + /* + * Copyright (C), 2018-2020 + * Project: starter + * FileName: RoleGroupMiddleDao + * Author: Louis + * Date: 2020/6/4 14:33 + */ + package com.fr.plugin.j7843.sso.dao; + + import com.fr.plugin.j7843.sso.ProcessDBAccess; + import com.fr.plugin.j7843.sso.entity.CstStatusEntity; + import com.fr.stable.db.dao.BaseDAO; + import com.fr.stable.db.session.DAOSession; + import com.fr.stable.query.QueryFactory; + import com.fr.stable.query.restriction.RestrictionFactory; + + import java.util.List; + + /** + * 〈Function Description〉
+ * 〈CstStatusDao〉 + * + * @author Louis + * @since 1.0.0 + */ + public class CstStatusDao extends BaseDAO { + public CstStatusDao(DAOSession daoSession) { + super(daoSession); + } + protected Class getEntityClass() { + return CstStatusEntity.class; + } + + /** + * 按照手机号查询状态 + * + * @param telphone + * @throws Exception + */ + public static List getStatus(final String pcode, final String telphone) throws Exception { + return ProcessDBAccess.getAccessor().runQueryAction(daoContext -> daoContext.getDAO(CstStatusDao.class) + .find(QueryFactory.create().addRestriction(RestrictionFactory.eq(CstStatusEntity.COLUMN_TELPHONE, telphone)) + .addRestriction(RestrictionFactory.eq(CstStatusEntity.COLUMN_P_CODE, pcode)) + )); + } + } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/j7843/sso/entity/CstDataEntity.java b/src/main/java/com/fr/plugin/j7843/sso/entity/CstDataEntity.java new file mode 100644 index 0000000..b5fb1d8 --- /dev/null +++ b/src/main/java/com/fr/plugin/j7843/sso/entity/CstDataEntity.java @@ -0,0 +1,143 @@ + /* + * Copyright (C), 2018-2020 + * Project: starter + * FileName: RoleGroupEntity + * Author: Louis + * Date: 2020/6/3 16:18 + */ + package com.fr.plugin.j7843.sso.entity; + + import com.fanruan.api.util.StringKit; + import com.fr.plugin.j7843.sso.bean.CstDataBean; + import com.fr.stable.db.entity.BaseEntity; +import com.fr.third.javax.persistence.Column; +import com.fr.third.javax.persistence.Entity; +import com.fr.third.javax.persistence.Table; + + /** + * 〈Function Description〉
+ * 〈CstDataEntity〉 + * + * @author Louis + * @since 1.0.0 + */ + @Entity + @Table(name = "fine_cst_data") + public class CstDataEntity extends BaseEntity { + public static final String COLUMN_P_CODE = "pcode"; + public static final String COLUMN_NAME = "name"; + public static final String COLUMN_TELPHONE = "telphone"; + public static final String COLUMN_TIME = "time"; + public static final String COLUMN_PROJ_NAME = "projName"; + public static final String COLUMN_CITY_CO = "cityCo"; + private static final long serialVersionUID = 6358871812172045109L; + + @Column(name = COLUMN_P_CODE) + private String pcode = StringKit.EMPTY; + @Column(name = COLUMN_NAME) + private String name = StringKit.EMPTY; + @Column(name = COLUMN_TELPHONE) + private String telphone = StringKit.EMPTY; + @Column(name = COLUMN_TIME) + private String time = StringKit.EMPTY; + @Column(name = COLUMN_PROJ_NAME) + private String projName = StringKit.EMPTY; + @Column(name = COLUMN_CITY_CO) + private String cityCo = StringKit.EMPTY; + + public CstDataEntity() { + } + + public CstDataBean createBean(CstDataBean cstData) { + cstData.setId(this.getId()); + cstData.setPcode(this.getPcode()); + cstData.setTelphone(this.getTelphone()); + cstData.setTime(this.getTime()); + cstData.setProjName(this.getProjName()); + cstData.setCityCo(this.getCityCo()); + return cstData; + } + + public CstDataEntity id(String id) { + this.setId(id); + return this; + } + + public CstDataEntity pcode(String pcode) { + this.setPcode(pcode); + return this; + } + + public CstDataEntity name(String name) { + this.setName(name); + return this; + } + + public CstDataEntity telphone(String telphone) { + this.setTelphone(telphone); + return this; + } + + public CstDataEntity time(String time) { + this.setTime(time); + return this; + } + + public CstDataEntity projName(String projName) { + this.setProjName(projName); + return this; + } + + public CstDataEntity cityCo(String cityCo) { + this.setCityCo(cityCo); + return this; + } + + public String getPcode() { + return pcode; + } + + public void setPcode(String pcode) { + this.pcode = pcode; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTelphone() { + return telphone; + } + + public void setTelphone(String telphone) { + this.telphone = telphone; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public String getProjName() { + return projName; + } + + public void setProjName(String projName) { + this.projName = projName; + } + + public String getCityCo() { + return cityCo; + } + + public void setCityCo(String cityCo) { + this.cityCo = cityCo; + } + } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/j7843/sso/entity/CstStatusEntity.java b/src/main/java/com/fr/plugin/j7843/sso/entity/CstStatusEntity.java new file mode 100644 index 0000000..10b3e31 --- /dev/null +++ b/src/main/java/com/fr/plugin/j7843/sso/entity/CstStatusEntity.java @@ -0,0 +1,163 @@ + /* + * Copyright (C), 2018-2020 + * Project: starter + * FileName: RoleGroupMiddleEntity + * Author: Louis + * Date: 2020/6/4 14:14 + */ + package com.fr.plugin.j7843.sso.entity; + + import com.fanruan.api.util.AssistKit; + import com.fanruan.api.util.StringKit; + import com.fr.plugin.j7843.sso.bean.CstDataBean; + import com.fr.stable.db.entity.BaseEntity; + import com.fr.third.javax.persistence.Column; + import com.fr.third.javax.persistence.Entity; + import com.fr.third.javax.persistence.Table; + + /** + * 〈Function Description〉
+ * 〈CstStatusEntity〉 + * + * @author Louis + * @since 1.0.0 + */ + @Entity + @Table(name = "fine_cst_status") + public class CstStatusEntity extends BaseEntity { + public static final String COLUMN_P_CODE = "pcode"; + public static final String COLUMN_FY_CODE = "fy_code"; + public static final String COLUMN_FY_NAME = "fy_name"; + public static final String COLUMN_PRICE = "price"; + public static final String COLUMN_RG_TIME = "rg_time"; + public static final String COLUMN_QY_TIME = "qy_time"; + public static final String COLUMN_TELPHONE = "telphone"; + private static final long serialVersionUID = -7548354093125191283L; + + @Column(name = COLUMN_P_CODE) + private String pcode = StringKit.EMPTY; + @Column(name = COLUMN_FY_CODE) + private String fyCode = StringKit.EMPTY; + @Column(name = COLUMN_FY_NAME) + private String fyName = StringKit.EMPTY; + @Column(name = COLUMN_PRICE) + private int price; + @Column(name = COLUMN_RG_TIME) + private String rgTime = StringKit.EMPTY; + @Column(name = COLUMN_QY_TIME) + private String qyTime = StringKit.EMPTY; + @Column(name = COLUMN_TELPHONE) + private String telphone = StringKit.EMPTY; + + public CstStatusEntity() { + } + + public void createBean(CstDataBean cstDataBean) { + cstDataBean.setFyCode(this.getFyCode()); + cstDataBean.setFyName(this.getFyName()); + cstDataBean.setPrice(this.getPrice()); + cstDataBean.setRgTime(this.getRgTime()); + cstDataBean.setQyTime(this.getQyTime()); + } + + public CstStatusEntity id(String id){ + this.setId(id); + return this; + } + + public CstStatusEntity pcode(String pcode) { + this.setPcode(pcode); + return this; + } + + public CstStatusEntity fyCode(String fyCode) { + this.setFyCode(fyCode); + return this; + } + + public CstStatusEntity fyName(String fyName) { + this.setFyName(fyName); + return this; + } + + public CstStatusEntity price(int price) { + this.setPrice(price); + return this; + } + + public CstStatusEntity rgTime(String rgTime) { + this.setRgTime(rgTime); + return this; + } + + public CstStatusEntity qyTime(String qyTime) { + this.setQyTime(qyTime); + return this; + } + + public CstStatusEntity telphone(String telphone){ + this.setTelphone(telphone); + return this; + } + + public String getTelphone() { + return telphone; + } + + public void setTelphone(String telphone) { + this.telphone = telphone; + } + + public int getPrice() { + return price; + } + + public void setPrice(int price) { + this.price = price; + } + + public String getPcode() { + return pcode; + } + + public void setPcode(String pcode) { + this.pcode = pcode; + } + + public String getFyCode() { + return fyCode; + } + + public void setFyCode(String fyCode) { + this.fyCode = fyCode; + } + + public String getFyName() { + return fyName; + } + + public void setFyName(String fyName) { + this.fyName = fyName; + } + + public String getRgTime() { + return rgTime; + } + + public void setRgTime(String rgTime) { + this.rgTime = rgTime; + } + + public String getQyTime() { + return qyTime; + } + + public void setQyTime(String qyTime) { + this.qyTime = qyTime; + } + + @Override + public String toString() { + return AssistKit.toString(this); + } + } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/j7843/sso/request/ServiceController.java b/src/main/java/com/fr/plugin/j7843/sso/request/ServiceController.java new file mode 100644 index 0000000..af9f2b3 --- /dev/null +++ b/src/main/java/com/fr/plugin/j7843/sso/request/ServiceController.java @@ -0,0 +1,112 @@ + /* + * Copyright (C), 2018-2021 + * Project: starter + * FileName: CallBackController + * Author: Louis + * Date: 2021/3/29 22:36 + */ + package com.fr.plugin.j7843.sso.request; + + import com.fanruan.api.i18n.I18nKit; +import com.fanruan.api.log.LogKit; +import com.fr.decision.webservice.annotation.LoginStatusChecker; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; +import com.fr.plugin.j7843.sso.bean.CstDataBean; +import com.fr.plugin.j7843.sso.bean.DataResponse; +import com.fr.plugin.j7843.sso.config.SsoConfig; +import com.fr.plugin.j7843.sso.dao.CstDataDao; +import com.fr.plugin.j7843.sso.dao.CstStatusDao; +import com.fr.plugin.j7843.sso.entity.CstDataEntity; +import com.fr.plugin.j7843.sso.entity.CstStatusEntity; +import com.fr.third.springframework.stereotype.Controller; +import com.fr.third.springframework.web.bind.annotation.RequestBody; +import com.fr.third.springframework.web.bind.annotation.RequestMapping; +import com.fr.third.springframework.web.bind.annotation.RequestMethod; +import com.fr.third.springframework.web.bind.annotation.ResponseBody; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; + +import static com.fr.plugin.j7843.sso.entity.CstDataEntity.*; + + /** + *
+ * + * + * @author Louis + * @since 1.0.0 + */ + @Controller + @RequestMapping("postCstData") + public class ServiceController { + + private SsoConfig config; + + public ServiceController() { +// this.config = SsoConfig.getInstance(); + } + + @RequestMapping(method = RequestMethod.POST) + @ResponseBody + @LoginStatusChecker(required = false) + public DataResponse doAction(@RequestBody String paramBody, HttpServletRequest req, HttpServletResponse res) { + try { + setHeader(res); + JSONObject params = new JSONObject(paramBody); + return operation(params.getJSONArray("data")); + } catch (Exception e) { + LogKit.error(e.getMessage(), e); + } + return DataResponse.error("500", I18nKit.getLocText("Plugin-J7843-Sso_Error_500")); + } + + /** + * 企业应用业务事件处理 + * + * @param cstArray + * @return + */ + private DataResponse operation(JSONArray cstArray) throws Exception { + List result = new ArrayList<>(); + List cstStatusList; + JSONObject cstObject; + CstDataBean cstDataBean; + for (int i = 0; i < cstArray.size(); i++) { + cstObject = cstArray.getJSONObject(i); + final CstDataEntity cstDataEntity = (new CstDataEntity()).id(cstObject.getString("id")) + .pcode(cstObject.getString(COLUMN_P_CODE)) + .name(cstObject.getString(COLUMN_NAME)) + .telphone(cstObject.getString(COLUMN_TELPHONE)) + .time(cstObject.getString(COLUMN_TIME)) + .projName(cstObject.getString(COLUMN_PROJ_NAME)) + .cityCo(cstObject.getString(COLUMN_CITY_CO)); + CstDataDao.save(cstDataEntity); + cstStatusList = CstStatusDao.getStatus(cstDataEntity.getPcode(), cstDataEntity.getTelphone()); + for (CstStatusEntity cstStatusEntity : cstStatusList) { + if (cstStatusEntity != null) { + cstDataBean = new CstDataBean(); + cstDataEntity.createBean(cstDataBean); + cstStatusEntity.createBean(cstDataBean); + result.add(cstDataBean); + } + } + } + return DataResponse.operation(result); + } + + /** + * 解决跨域访问问题 + * + * @param res + */ + private void setHeader(HttpServletResponse res) { + // 跨域设置header + res.setHeader("Access-Control-Allow-Origin", "*"); + res.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); + res.setHeader("Access-Control-Max-Age", "3600"); + res.setHeader("Access-Control-Allow-Headers", "x-requested-with"); + } + } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/j7843/sso/request/ServiceControllerBridge.java b/src/main/java/com/fr/plugin/j7843/sso/request/ServiceControllerBridge.java new file mode 100644 index 0000000..b5f6f52 --- /dev/null +++ b/src/main/java/com/fr/plugin/j7843/sso/request/ServiceControllerBridge.java @@ -0,0 +1,26 @@ + /* + * Copyright (C), 2018-2021 + * Project: starter + * FileName: UserControllerBridge + * Author: Louis + * Date: 2021/3/29 22:30 + */ + package com.fr.plugin.j7843.sso.request; + + import com.fr.decision.fun.impl.AbstractControllerRegisterProvider; + + /** + *
+ * + * + * @author Louis + * @since 1.0.0 + */ + public class ServiceControllerBridge extends AbstractControllerRegisterProvider { + @Override + public Class[] getControllers() { + return new Class[]{ + ServiceController.class + }; + } + } \ No newline at end of file diff --git a/src/main/resources/com/fr/plugin/j7843/sso/locale/lang.properties b/src/main/resources/com/fr/plugin/j7843/sso/locale/lang.properties new file mode 100644 index 0000000..6b64c02 --- /dev/null +++ b/src/main/resources/com/fr/plugin/j7843/sso/locale/lang.properties @@ -0,0 +1,7 @@ +Plugin-J7843-Sso=Sso Plugin +Plugin-J7843-Sso_Group=Sso Plugin +Plugin-J7843-Sso_Config_uriBase=BaseUri +Plugin-J7843-Sso_Config_uriBase_Description=BaseUri +Plugin-J7843-Sso_Config_privateKey=PrivateKey +Plugin-J7843-Sso_Config_privateKey_Description=PrivateKey +Plugin-J7843-Sso_Error_500=error \ No newline at end of file diff --git a/src/main/resources/com/fr/plugin/j7843/sso/locale/lang_zh_CN.properties b/src/main/resources/com/fr/plugin/j7843/sso/locale/lang_zh_CN.properties new file mode 100644 index 0000000..9177f96 --- /dev/null +++ b/src/main/resources/com/fr/plugin/j7843/sso/locale/lang_zh_CN.properties @@ -0,0 +1,7 @@ +Plugin-J7843-Sso=\u5355\u70B9\u767B\u9646\u63D2\u4EF6 +Plugin-J7843-Sso_Group=\u5355\u70B9\u767B\u9646\u63D2\u4EF6 +Plugin-J7843-Sso_Config_uriBase=\u63A5\u53E3\u5730\u5740 +Plugin-J7843-Sso_Config_uriBase_Description=\u63A5\u53E3\u5730\u5740 +Plugin-J7843-Sso_Config_privateKey=PrivateKey +Plugin-J7843-Sso_Config_privateKey_Description=PrivateKey +Plugin-J7843-Sso_Error_500=error \ No newline at end of file