1、*Mapper.java继承泛型错误修改
2、行政区实体中增加编号属性
3、行政区级别枚举去掉组
4、实现系统启动后初始化数据库数据监听器
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ£æ¥å
ç´ æ¯å¦åå¨ |
| | | * @param doc doc对象 |
| | | * @param elementName å
ç´ åç§° |
| | | * @return è¿åç»æ è¿åç»æ |
| | | */ |
| | | public Element getElement(Document doc, String elementName){ |
| | | if(doc == null){ |
| | | return null ; |
| | | } |
| | | if(elementName == null){ |
| | | return null ; |
| | | } |
| | | elementName = elementName.trim() ; |
| | | if(elementName.equals("")){ |
| | | return null ; |
| | | } |
| | | return this.get_element(doc, elementName) ; |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥å
ç´ æ¯å¦åå¨ |
| | | * @param doc doc对象 |
| | |
| | | elementName = elementName.trim() ; |
| | | if(elementName.equals("")){ |
| | | return false ; |
| | | } |
| | | Element e = this.getElement(doc, elementName) ; |
| | | } |
| | | Element e = this.get_element(doc, elementName) ; |
| | | return e != null; |
| | | } |
| | | |
| | |
| | | * @throws Exception æåºå¼å¸¸ |
| | | */ |
| | | public String getSetAttrTxt(Document doc, String elementName, String attrName, String attPropertyNameFix, Boolean canBlank, String setValue) throws Exception{ |
| | | Element e = this.checkAndGetElement(doc, elementName); |
| | | Element e = this.check_and_get_element(doc, elementName); |
| | | return this.getSetAttrTxt(e, attrName, attPropertyNameFix, canBlank, setValue) ; |
| | | } |
| | | |
| | |
| | | * @throws Exception æåºå¼å¸¸ |
| | | */ |
| | | public Integer getSetAttrPlusInt(Document doc, String elementName, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{ |
| | | Element e = this.checkAndGetElement(doc, elementName); |
| | | Element e = this.check_and_get_element(doc, elementName); |
| | | return this.getSetAttrPlusInt(e, attrName, attPropertyNameFix, min, max, setValue) ; |
| | | } |
| | | |
| | |
| | | * @throws Exception æåºå¼å¸¸ |
| | | */ |
| | | public Integer getSetAttrInt(Document doc, String elementName, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{ |
| | | Element e = this.checkAndGetElement(doc, elementName); |
| | | Element e = this.check_and_get_element(doc, elementName); |
| | | return this.getSetAttrInt(e, attrName, attPropertyNameFix, min, max, setValue) ; |
| | | } |
| | | |
| | |
| | | * @throws Exception æåºå¼å¸¸ |
| | | */ |
| | | public Double getSetAttrPlusDouble(Document doc, String elementName, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{ |
| | | Element e = this.checkAndGetElement(doc, elementName); |
| | | Element e = this.check_and_get_element(doc, elementName); |
| | | return this.getSetAttrPlusDouble(e, attrName, attPropertyNameFix, min, max, setValue) ; |
| | | } |
| | | |
| | |
| | | * @throws Exception æåºå¼å¸¸ |
| | | */ |
| | | public Double getSetAttrDouble(Document doc, String elementName, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{ |
| | | Element e = this.checkAndGetElement(doc, elementName); |
| | | Element e = this.check_and_get_element(doc, elementName); |
| | | return this.getSetAttrDouble(e, attrName, attPropertyNameFix, min, max, setValue) ; |
| | | } |
| | | |
| | |
| | | * @param elementName å
ç´ åç§° å
ç´ åï¼å½¢å¦"config.base.test" |
| | | * @return è¿åç»æ |
| | | */ |
| | | private Element getElement(Document doc, String elementName){ |
| | | private Element get_element(Document doc, String elementName){ |
| | | Element e = null ; |
| | | Element root ; |
| | | String nm ; |
| | |
| | | if(eNames.length == 1){ |
| | | e = root ; |
| | | }else{ |
| | | e = this.getNextElement(root, eNames, 1) ; |
| | | e = this.get_next_element(root, eNames, 1) ; |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param index æ°ç»ä¸æ |
| | | * @return è¿åç»æ |
| | | */ |
| | | private Element getNextElement(Element base, String[] eNames, int index){ |
| | | private Element get_next_element(Element base, String[] eNames, int index){ |
| | | Element e = null ; |
| | | String nm ; |
| | | List<Element> list = base.getChildren() ; |
| | |
| | | if(eNames.length == index + 1){ |
| | | e = el ; |
| | | }else{ |
| | | e = this.getNextElement(el, eNames, index + 1) ; |
| | | e = this.get_next_element(el, eNames, index + 1) ; |
| | | } |
| | | break ; |
| | | } |
| | |
| | | * @return è¿åç»æ |
| | | * @throws Exception æåºå¼å¸¸ |
| | | */ |
| | | private Element checkAndGetElement(Document doc, String elementName)throws Exception{ |
| | | private Element check_and_get_element(Document doc, String elementName)throws Exception{ |
| | | if(doc == null){ |
| | | throw new Exception("é
ç½®æä»¶çDOM对象为空!"); |
| | | } |
| | |
| | | if(elementName.equals("")){ |
| | | throw new Exception("å
ç´ å为空!"); |
| | | } |
| | | Element e = this.getElement(doc, elementName) ; |
| | | Element e = this.get_element(doc, elementName) ; |
| | | if(e == null){ |
| | | throw new Exception("æªå¾å°å称为" + elementName + "çå
ç´ !"); |
| | | } |
| | |
| | | import java.util.Map; |
| | | |
| | | @Mapper |
| | | public interface BaBlockMapper extends BaseMapper<BaPrivilege> { |
| | | public interface BaBlockMapper extends BaseMapper<BaBlock> { |
| | | /** |
| | | * delete by primary key |
| | | * @param id primaryKey |
| | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | public interface BaDistrictMapper extends BaseMapper<BaPrivilege> { |
| | | public interface BaDistrictMapper extends BaseMapper<BaDistrict> { |
| | | |
| | | /** |
| | | * select by primary key |
| | | * @param id primary key |
| | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | @Mapper |
| | | public interface BaRolePrivilegeMapper extends BaseMapper<BaRolePrivilegeMapper> { |
| | | public interface BaRolePrivilegeMapper extends BaseMapper<BaRolePrivilege> { |
| | | |
| | | /** |
| | | * insert record to table |
| | |
| | | public String name; |
| | | |
| | | /** |
| | | * è¡æ¿åºç¼å· |
| | | */ |
| | | @Schema(description = "è¡æ¿åºç¼å·", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotEmpty(message = "è¡æ¿åºç¼å·ä¸è½ä¸ºç©º") //ä¸è½ä¸ºç©ºä¹ä¸è½ä¸ºnull |
| | | @Max(message = "è¡æ¿åºç¼å·ä¸å¤§äº99", value = 99) |
| | | @Min(message = "è¡æ¿åºç¼å·ä¸å°äº0",value = 0) |
| | | public String num; |
| | | |
| | | /** |
| | | * è¡æ¿åºçº§å« |
| | | */ |
| | | @Schema(description = "è¡æ¿åºçº§å«", requiredMode = Schema.RequiredMode.REQUIRED) |
| | |
| | | City((byte)1, "å¸"), |
| | | County((byte)2, "å¿"), |
| | | Town((byte)3, "é"), |
| | | Village((byte)4, "æ"), |
| | | Group((byte)5, "ç»"); |
| | | Village((byte)4, "æ") ; |
| | | |
| | | @EnumValue |
| | | public Byte code ; |
| | |
| | | public String getName() { |
| | | return this.name ; |
| | | } |
| | | |
| | | public static DistrictLevel get(Byte code){ |
| | | if(code.byteValue() == City.code.byteValue()){ |
| | | return City ; |
| | | }else if(code.byteValue() == County.code.byteValue()){ |
| | | return County ; |
| | | }else if(code.byteValue() == Town.code.byteValue()){ |
| | | return Town ; |
| | | }else if(code.byteValue() == Village.code.byteValue()){ |
| | | return Village ; |
| | | } |
| | | return null ; |
| | | } |
| | | } |
| | |
| | | rObj = DistrictLevel.Town ; |
| | | }else if(sourceObj == DistrictLevel.Village.code){ |
| | | rObj = DistrictLevel.Village ; |
| | | }else if(sourceObj == DistrictLevel.Group.code){ |
| | | rObj = DistrictLevel.Group ; |
| | | } |
| | | return rObj ; |
| | | } |
| | |
| | | maxPoolPreparedStatementPerConnectionSize: 20 |
| | | #屿§ç±»åæ¯å符串ï¼éè¿å«åçæ¹å¼é
ç½®æ©å±æä»¶ï¼å¸¸ç¨çæä»¶æï¼ |
| | | #çæ§ç»è®¡ç¨çfilter:statï¼æ¥å¿ç¨çfilter:log4jï¼é²å¾¡sql注å
¥çfilter:wall |
| | | #å¼ç¨filter:statï¼è§https://blog.csdn.net/K_520_W/article/details/132382812 |
| | | filters: stat,wall,config |
| | | webStatFilter: |
| | | # æ·»å è¿æ»¤è§å |
| | |
| | | </trim> |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | <!--@mbg.generated--> |
| | | delete from ba_block |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <delete id="deleteLogicById" parameterType="java.lang.Long"> |
| | | <!--@mbg.generated--> |
| | | update ba_block set deleted = 1 |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoBa.BaBlock"> |
| | | <!--@mbg.generated--> |
| | | insert into ba_block (id, `name`, `header`, phone, area, color, deleted) |
| | |
| | | deleted = #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | <!--@mbg.generated--> |
| | | delete from ba_block |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <delete id="deleteLogicById" parameterType="java.lang.Long"> |
| | | <!--@mbg.generated--> |
| | | update ba_block set deleted = 1 |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | |
| | | </mapper> |
| | |
| | | <id column="id" jdbcType="BIGINT" property="id" /> |
| | | <id column="supperId" jdbcType="BIGINT" property="supperId" /> |
| | | <result column="name" jdbcType="VARCHAR" property="name" /> |
| | | <result column="num" jdbcType="TINYINT" property="num" /> |
| | | <result property="level" column="level" typeHandler="com.dy.common.mybatis.envm.EnumCodeTypeHandler" javaType="com.dy.pipIrrGlobal.util.DistrictLevel"/> |
| | | <result property="deleted" column="deleted" typeHandler="com.dy.common.mybatis.envm.EnumCodeTypeHandler" javaType="com.dy.common.mybatis.envm.Deleted"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, supperId, `name`, `level`, deleted |
| | | id, supperId, `name`, num, `level`, deleted |
| | | </sql> |
| | | |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | | select |
| | |
| | | from ba_district |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <select id="selectByLevel" parameterType="java.lang.Byte" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | | select |
| | |
| | | from ba_district |
| | | where level = #{level,jdbcType=TINYINT} |
| | | </select> |
| | | |
| | | <select id="selectBySupperId" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | | select |
| | |
| | | from ba_district |
| | | where supperId = #{supperId,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoBa.BaDistrict"> |
| | | <!--@mbg.generated--> |
| | | insert into ba_district (id, supperId, `name`, `level`, deleted) |
| | | insert into ba_district (id, supperId, `name`, num, `level`, deleted) |
| | | values (#{id,jdbcType=BIGINT}, |
| | | #{supperId,jdbcType=BIGINT}, |
| | | #{name,jdbcType=VARCHAR}, |
| | | #{num,jdbcType=TINYINT}, |
| | | #{level,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT}, |
| | | #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT} |
| | | ) |
| | | </insert> |
| | | |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaDistrict"> |
| | | <!--@mbg.generated--> |
| | | insert into ba_district |
| | |
| | | </if> |
| | | <if test="name != null"> |
| | | `name`, |
| | | </if> |
| | | <if test="num != null"> |
| | | num, |
| | | </if> |
| | | <if test="level != null"> |
| | | `level`, |
| | |
| | | <if test="name != null"> |
| | | #{name,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="num != null"> |
| | | #{num,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="level != null"> |
| | | #{level,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT}, |
| | | </if> |
| | |
| | | <set> |
| | | <if test="name != null"> |
| | | `name` = #{name,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="num != null"> |
| | | num = #{num,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="supperId != null"> |
| | | supperId = #{supperId,jdbcType=BIGINT}, |
| | |
| | | update ba_district |
| | | set supperId = #{supperId,jdbcType=BIGINT}, |
| | | `name` = #{name,jdbcType=VARCHAR}, |
| | | num = #{num,jdbcType=TINYINT}, |
| | | `level` = #{level,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT}, |
| | | deleted = #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT} |
| | | where id = #{id,jdbcType=BIGINT} |
| | |
| | | package com.dy.pipIrrBase.config; |
| | | |
| | | import com.dy.common.webListener.GenerateIdSetSuffixListener; |
| | | import com.dy.pipIrrBase.util.InitListener; |
| | | import jakarta.servlet.ServletContextListener; |
| | | import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; |
| | | import org.springframework.context.annotation.Bean; |
| | |
| | | */ |
| | | //private static final int order_config = 0 ; |
| | | private static final int order_idSetSuffix = 1 ; |
| | | //private static final int order_init = 2 ; |
| | | |
| | | /* |
| | | * è§£æåç§***.configé
ç½®çConfigListenerï¼ææ¶ä¸éç¨æ¤ç§é
ç½®æ¹å¼ |
| | |
| | | */ |
| | | |
| | | /** |
| | | * å
鍿ä¾listenerï¼è¯¥listenerå¨ç³»ç»å¯å¨æ¶ï¼æ ¹æ®é
置设置ID产çå¨çåç¼ |
| | | * å
鍿ä¾listenerï¼è¯¥listenerå¨ç³»ç»å¯å¨æ¶ï¼æ ¹æ®é
ç½® 设置ID产çå¨çåç¼ |
| | | * @return 注åBean |
| | | */ |
| | | @Bean |
| | | public ServletListenerRegistrationBean<? extends ServletContextListener> reqSsoListener() { |
| | | public ServletListenerRegistrationBean<? extends ServletContextListener> regSsoListener() { |
| | | ServletListenerRegistrationBean<GenerateIdSetSuffixListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); |
| | | listenerRegistrationBean.setListener(new GenerateIdSetSuffixListener()); |
| | | listenerRegistrationBean.setOrder(order_idSetSuffix); |
| | | return listenerRegistrationBean; |
| | | } |
| | | |
| | | // /** |
| | | // * å
鍿ä¾listenerï¼è¯¥listenerå¨ç³»ç»å¯å¨æ¶ï¼åå§åæ°æ®åºæ°æ® |
| | | // * @return 注åBean |
| | | // */ |
| | | // @Bean |
| | | // public ServletListenerRegistrationBean<? extends ServletContextListener> regInitListener() { |
| | | // ServletListenerRegistrationBean<InitListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); |
| | | // listenerRegistrationBean.setListener(new InitListener()); |
| | | // listenerRegistrationBean.setOrder(order_init); |
| | | // return listenerRegistrationBean; |
| | | // } |
| | | } |
| | |
| | | }) |
| | | @GetMapping(path = "allLevel") |
| | | public BaseResponse<List<DistrictLevel>> allDistrictLevels(){ |
| | | List<DistrictLevel> list = Arrays.asList(DistrictLevel.City, DistrictLevel.County, DistrictLevel.Town, DistrictLevel.Village, DistrictLevel.Group) ; |
| | | List<DistrictLevel> list = Arrays.asList(DistrictLevel.City, DistrictLevel.County, DistrictLevel.Town, DistrictLevel.Village) ; |
| | | return BaseResponseUtils.buildSuccess(list); |
| | | } |
| | | |
| | |
| | | @Length(message = "è¡æ¿åºåç§°å°äº{max}å", min = 1, max = 25) |
| | | public String name ; |
| | | |
| | | @Schema(description = "è¡æ¿åºç¼å·", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotEmpty(message = "è¡æ¿åºç¼å·ä¸è½ä¸ºç©º") //ä¸è½ä¸ºç©ºä¹ä¸è½ä¸ºnull |
| | | @Length(message = "è¡æ¿åºç¼å·æ¯ä¸ä½æä¸¤ä½æ°", min = 1, max = 2) |
| | | public String num ; |
| | | |
| | | @Schema(description = "è¡æ¿åºçº§å«", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "è¡æ¿åºçº§å«ä¸è½ä¸ºç©º") //ä¸è½ä¸ºç©ºä¹ä¸è½ä¸ºnull |
| | | @Max(message = "è¡æ¿åºçº§å«ä¸æ£ç¡®", value = 10) |
| | |
| | | @Mapping(target = "id", source = "supperId") |
| | | @Mapping(target = "supperId", source = "supperId") |
| | | @Mapping(target = "name", source = "name") |
| | | @Mapping(target = "num", source = "num") |
| | | @Mapping(target = "level", source = "level", qualifiedByName = "districtLevelByteToObj") |
| | | @Mapping(target = "deleted", source = "deleted", qualifiedByName = "deletedByteToObj") |
| | | @Mapping(target = "subDistricts", ignore = true) |
New file |
| | |
| | | package com.dy.pipIrrBase.util; |
| | | |
| | | import com.dy.common.multiDataSource.DataSourceContext; |
| | | import com.dy.common.mybatis.envm.Deleted; |
| | | import com.dy.common.mybatis.envm.Disabled; |
| | | import com.dy.common.util.ConfigXml; |
| | | import com.dy.common.util.MD5; |
| | | import com.dy.common.webListener.ConfigListener; |
| | | import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper; |
| | | import com.dy.pipIrrGlobal.daoBa.BaUserMapper; |
| | | import com.dy.pipIrrGlobal.pojoBa.BaDistrict; |
| | | import com.dy.pipIrrGlobal.pojoBa.BaUser; |
| | | import com.dy.pipIrrGlobal.util.DistrictLevel; |
| | | import org.jdom2.Document; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.context.event.ApplicationReadyEvent; |
| | | import org.springframework.context.ApplicationListener; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.net.URL; |
| | | |
| | | /** |
| | | * çå¬å¨ï¼å®ç°åè½ï¼å¨ç³»ç»å¯å¨æ¶åå§åï¼åæ°æ®åºä¸æå
¥æ°æ® |
| | | * æ¬çå¬å¨ä¸è½éç¨ServletContextListeneræ¹å¼ï¼å 为Servletä¸ä¸æContextå建å |
| | | * Spring容å¨å¹¶æ²¡æå建å®ï¼èæ¬ç±»ä¸ç¨çäºSpring容å¨ä¸çBeanï¼å³distriDao, userDaoã |
| | | * æä»¥éç¨äºSpringäºä»¶çå¬å¨æ¥å®ç° |
| | | */ |
| | | @Component |
| | | public class InitListener implements ApplicationListener<ApplicationReadyEvent> { |
| | | |
| | | private BaDistrictMapper distriDao ; |
| | | private BaUserMapper userDao ; |
| | | |
| | | @Autowired |
| | | public void setDistriDao(BaDistrictMapper distriDao){ |
| | | this.distriDao = distriDao ; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setUserDao(BaUserMapper userDao){ |
| | | this.userDao = userDao ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * SpringBoot容å¨å·²ç»åå¤å¥½äº |
| | | * @param event äºä»¶ |
| | | */ |
| | | @Override |
| | | public void onApplicationEvent(@NonNull ApplicationReadyEvent event) { |
| | | try { |
| | | //ç1ç§ï¼çå¾
com.alibaba.druid.pool.DruidDataSourceå®å§å宿 |
| | | Thread.sleep(1000L); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | }finally { |
| | | this.init(event); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å®å§å |
| | | */ |
| | | @SuppressWarnings("unused ") |
| | | private void init(ApplicationReadyEvent event){ |
| | | try { |
| | | URL configFileURL = ConfigListener.class.getResource("/init-config.xml" ); |
| | | ConfigXml configXml = new ConfigXml() ; |
| | | Document doc = configXml.createDom(configFileURL) ; |
| | | this.doInit(configXml, doc); |
| | | } catch (Exception e) { |
| | | System.out.println("ç³»ç»å¯å¨æ¶ï¼åå§åé
ç½®åºé !"); |
| | | System.out.println(e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | private void doInit(ConfigXml configXml, Document doc) throws Exception{ |
| | | if(configXml != null && doc != null){ |
| | | for(int num = 1; num <= 10000; num++){ |
| | | if(configXml.existElement(doc, "config.orgs.org" + num)){ |
| | | String orgTag = configXml.getSetAttrTxt(doc, "config.orgs.org" + num,"name", null, false, null) ; |
| | | //è®¾ç½®æ°æ®æº |
| | | DataSourceContext.set(orgTag); |
| | | if(!this.existDistricts()){ |
| | | if(configXml.existElement(doc, "config.orgs.org" + num + ".districts.city")){ |
| | | String distriName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.city","name", null, false, null) ; |
| | | String distriNum = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.city","num", null, false, null) ; |
| | | Integer distriLevel = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".districts.city","level", null, 1, 99,null) ; |
| | | Long supperId = this.saveDistrict(null, distriName, distriNum, distriLevel); |
| | | if(supperId != null && configXml.existElement(doc, "config.orgs.org" + num + ".districts.city.country")){ |
| | | distriName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.city.country","name", null, false, null) ; |
| | | distriNum = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.city.country","num", null, false, null) ; |
| | | distriLevel = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".districts.city.country","level", null, 1, 99,null) ; |
| | | this.saveDistrict(supperId, distriName, distriNum, distriLevel); |
| | | } |
| | | } |
| | | } |
| | | if(!this.existUsers()){ |
| | | if(configXml.existElement(doc, "config.orgs.org" + num + ".user")){ |
| | | String name = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".user","name", null, false, null) ; |
| | | String phone = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".user","phone", null, false, null) ; |
| | | String password = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".user","password", null, false, null) ; |
| | | Integer supperAdmin = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".user","supperAdmin", null, 0, 1,null) ; |
| | | this.saveUser(orgTag, name, phone, password, supperAdmin); |
| | | } |
| | | } |
| | | }else{ |
| | | break ; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ°æ®åºä¸æ¯å¦åå¨è¡æ¿åºåæ°æ® |
| | | * @return åå¨å¦ |
| | | */ |
| | | private boolean existDistricts(){ |
| | | Long total = this.distriDao.selectCount(null) ; |
| | | return (total != null && total > 0) ; |
| | | } |
| | | |
| | | /** |
| | | * æ°æ®åºä¸æ¯å¦åå¨è¡æ¿åºåæ°æ® |
| | | * @return åå¨å¦ |
| | | */ |
| | | private boolean existUsers(){ |
| | | Long total = this.userDao.selectCount(null) ; |
| | | return (total != null && total > 0) ; |
| | | } |
| | | |
| | | /** |
| | | * æ°æ®åºä¸ä¿åè¡æ¿åºåå®ä½ |
| | | * @param supperId ä¸çº§ID |
| | | * @param name åç§° |
| | | * @param num ç¼å· |
| | | * @param level çº§å« |
| | | * @return id |
| | | */ |
| | | private Long saveDistrict(Long supperId, String name, String num, Integer level){ |
| | | if((name != null && !name.trim().equals("")) && |
| | | (num != null && !num.trim().equals("")) && |
| | | level != null){ |
| | | BaDistrict po = new BaDistrict() ; |
| | | po.supperId = supperId ; |
| | | po.name = name ; |
| | | po.num = num ; |
| | | po.level = DistrictLevel.get(level.byteValue()) ; |
| | | po.deleted = Deleted.NO ; |
| | | this.distriDao.insert(po) ; |
| | | return po.getId() ; |
| | | }else{ |
| | | return null ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ä¿åç¨æ· |
| | | * @param orgTag æºææ ç¾ |
| | | * @param name åç§° |
| | | * @param phone ææºå· |
| | | * @param password å¯ç |
| | | * @param supperAdmin æ¯å¦ä¸ºè¶
级管çåï¼1æ¯ï¼0å¦ï¼ |
| | | */ |
| | | private void saveUser(String orgTag, String name, String phone, String password, Integer supperAdmin) throws Exception{ |
| | | if((name != null && !name.trim().equals("")) && |
| | | (phone != null && !phone.trim().equals("")) && |
| | | (password != null && !password.trim().equals("")) && |
| | | supperAdmin != null){ |
| | | BaUser po = new BaUser() ; |
| | | po.name = name ; |
| | | po.phone = phone ; |
| | | po.password = MD5.encrypt(password) ;//è¿è¡å å¯ç ; |
| | | po.orgTag = orgTag ; |
| | | po.supperAdmin = supperAdmin.byteValue() ; |
| | | po.disabled = Disabled.NO ; |
| | | po.deleted = Deleted.NO ; |
| | | this.userDao.insert(po) ; |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <config> |
| | | <orgs> |
| | | <!-- å¤ä¸ªç»ç»ï¼ç¨ç¼å·åºåï¼ç¼å·ä»1å¼å§ --> |
| | | <org1 name="ym"> |
| | | <districts> |
| | | <city name="æ¥éå½æèªæ²»å·" num="23" level="1"> |
| | | <country name="å
è°å¿" num="28" level="2" /> |
| | | </city> |
| | | </districts> |
| | | <user name="è¶
级管çå" phone="admin" password="admin" supperAdmin="1" /> |
| | | </org1> |
| | | </orgs> |
| | | </config> |