Browse Source

用户注册/修改密码

suochencheng 7 years ago
parent
commit
53af510cfa

+ 3 - 0
src/main/java/com/izouma/awesomeadmin/dao/UserInfoMapper.java

@@ -35,5 +35,8 @@ public interface UserInfoMapper {
     List<String> findDepartLeader(String userId);
     List<String> findDepartLeader(String userId);
 
 
     List<String> findUserByRoleName(String roleName);
     List<String> findUserByRoleName(String roleName);
+
+    int updatePassword(UserInfo record);
+
 }
 }
 
 

+ 179 - 4
src/main/java/com/izouma/awesomeadmin/dao/UserInfoMapper.xml

@@ -21,6 +21,15 @@
         <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
         <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
         <result column="money_coin" property="moneyCoin" jdbcType="DECIMAL"/>
         <result column="money_coin" property="moneyCoin" jdbcType="DECIMAL"/>
         <result column="money_point" property="moneyPoint" jdbcType="DECIMAL"/>
         <result column="money_point" property="moneyPoint" jdbcType="DECIMAL"/>
+        <result column="contacter" property="contacter" jdbcType="VARCHAR"/>
+        <result column="contact_phone" property="contactPhone" jdbcType="VARCHAR"/>
+        <result column="company_name" property="companyName" jdbcType="VARCHAR"/>
+        <result column="company_type" property="companyType" jdbcType="VARCHAR"/>
+        <result column="admin_flag" property="adminFlag" jdbcType="CHAR"/>
+        <result column="cash_pledge" property="cashPledge" jdbcType="INTEGER"/>
+        <result column="approve_flag" property="approveFlag" jdbcType="CHAR"/>
+        <result column="store_flag" property="storeFlag" jdbcType="CHAR"/>
+        <result column="company_flag" property="companyFlag" jdbcType="CHAR"/>
         <association property="departId" javaType="string" column="id"
         <association property="departId" javaType="string" column="id"
                      select="com.izouma.awesomeadmin.dao.DepartInfoMapper.getUserDepartId"/>
                      select="com.izouma.awesomeadmin.dao.DepartInfoMapper.getUserDepartId"/>
         <association property="roleId" javaType="string" column="id"
         <association property="roleId" javaType="string" column="id"
@@ -28,7 +37,9 @@
     </resultMap>
     </resultMap>
     <sql id="Base_Column_List">
     <sql id="Base_Column_List">
         id, username, nickname, icon, birthday, sex, open_id, union_id, phone, mail,
         id, username, nickname, icon, birthday, sex, open_id, union_id, phone, mail,
-        country, province, city, district, create_time, del_flag, money_coin, money_point
+        country, province, city, district, create_time, del_flag, money_coin, money_point,
+        contacter, contact_phone, company_name, company_type, admin_flag, cash_pledge,
+        approve_flag, store_flag, company_flag
     </sql>
     </sql>
     <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
     <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
         select
         select
@@ -105,6 +116,33 @@
             <if test="moneyPoint != null">
             <if test="moneyPoint != null">
                 money_point,
                 money_point,
             </if>
             </if>
+            <if test="contacter != null">
+                contacter,
+            </if>
+            <if test="contactPhone != null">
+                contact_phone,
+            </if>
+            <if test="companyName != null">
+                company_name,
+            </if>
+            <if test="companyType != null">
+                company_type,
+            </if>
+            <if test="adminFlag != null">
+                admin_flag,
+            </if>
+            <if test="cashPledge != null">
+                cash_pledge,
+            </if>
+            <if test="approveFlag != null">
+                approve_flag,
+            </if>
+            <if test="storeFlag != null">
+                store_flag,
+            </if>
+            <if test="companyFlag != null">
+                company_flag,
+            </if>
         </trim>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">
             <if test="id != null">
@@ -167,6 +205,33 @@
             <if test="moneyPoint != null">
             <if test="moneyPoint != null">
                 #{moneyPoint},
                 #{moneyPoint},
             </if>
             </if>
+            <if test="contacter != null">
+                #{contacter},
+            </if>
+            <if test="contactPhone != null">
+                #{contactPhone},
+            </if>
+            <if test="companyName != null">
+                #{companyName},
+            </if>
+            <if test="companyType != null">
+                #{companyType},
+            </if>
+            <if test="adminFlag != null">
+                #{adminFlag},
+            </if>
+            <if test="cashPledge != null">
+                #{cashPledge},
+            </if>
+            <if test="approveFlag != null">
+                #{approveFlag},
+            </if>
+            <if test="storeFlag != null">
+                #{storeFlag},
+            </if>
+            <if test="companyFlag != null">
+                #{companyFlag},
+            </if>
         </trim>
         </trim>
     </insert>
     </insert>
     <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.UserInfo">
     <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.UserInfo">
@@ -224,10 +289,37 @@
                 del_flag = #{delFlag,jdbcType=CHAR},
                 del_flag = #{delFlag,jdbcType=CHAR},
             </if>
             </if>
             <if test="moneyCoin != null">
             <if test="moneyCoin != null">
-                money_coin = #{moneyCoin,jdbcType=CHAR},
+                money_coin = #{moneyCoin},
             </if>
             </if>
             <if test="moneyPoint != null">
             <if test="moneyPoint != null">
-                money_point = #{moneyPoint,jdbcType=CHAR},
+                money_point = #{moneyPoint},
+            </if>
+            <if test="contacter != null">
+                contacter = #{contacter},
+            </if>
+            <if test="contactPhone != null">
+                contact_phone = #{contactPhone},
+            </if>
+            <if test="companyName != null">
+                company_name = #{companyName},
+            </if>
+            <if test="companyType != null">
+                company_type = #{companyType},
+            </if>
+            <if test="adminFlag != null">
+                admin_flag = #{adminFlag},
+            </if>
+            <if test="cashPledge != null">
+                cash_pledge = #{cashPledge},
+            </if>
+            <if test="approveFlag != null">
+                approve_flag = #{approveFlag},
+            </if>
+            <if test="storeFlag != null">
+                store_flag = #{storeFlag},
+            </if>
+            <if test="companyFlag != null">
+                company_flag = #{companyFlag},
             </if>
             </if>
         </set>
         </set>
         where id = #{id,jdbcType=INTEGER}
         where id = #{id,jdbcType=INTEGER}
@@ -293,6 +385,34 @@
             <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
             <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
                 and del_flag = #{record.delFlag}
                 and del_flag = #{record.delFlag}
             </if>
             </if>
+            <if test="record.contacter != null and !&quot;&quot;.equals(record.contacter)">
+                and contacter = #{record.contacter}
+            </if>
+            <if test="record.contactPhone != null and !&quot;&quot;.equals(record.contactPhone)">
+                and contact_phone = #{record.contactPhone}
+            </if>
+            <if test="record.companyName != null and !&quot;&quot;.equals(record.companyName)">
+                and company_name = #{record.companyName}
+            </if>
+            <if test="record.companyType != null and !&quot;&quot;.equals(record.companyType)">
+                and company_type = #{record.companyType}
+            </if>
+            <if test="record.adminFlag != null and !&quot;&quot;.equals(record.adminFlag)">
+                and admin_flag = #{record.adminFlag}
+            </if>
+            <if test="record.cashPledge != null and !&quot;&quot;.equals(record.cashPledge)">
+                and cash_pledge = #{record.cashPledge}
+            </if>
+            <if test="record.approveFlag != null and !&quot;&quot;.equals(record.approveFlag)">
+                and approve_flag = #{record.approveFlag}
+            </if>
+            <if test="record.storeFlag != null and !&quot;&quot;.equals(record.storeFlag)">
+                and store_flag = #{record.storeFlag}
+            </if>
+            <if test="record.companyFlag != null and !&quot;&quot;.equals(record.companyFlag)">
+                and company_flag = #{record.companyFlag}
+            </if>
+
         </where>
         </where>
         order by id desc
         order by id desc
     </select>
     </select>
@@ -356,6 +476,35 @@
             <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
             <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                 and del_flag = #{delFlag}
                 and del_flag = #{delFlag}
             </if>
             </if>
+
+            <if test="contacter != null and !&quot;&quot;.equals(contacter)">
+                and contacter = #{contacter}
+            </if>
+            <if test="contactPhone != null and !&quot;&quot;.equals(contactPhone)">
+                and contact_phone = #{contactPhone}
+            </if>
+            <if test="companyName != null and !&quot;&quot;.equals(companyName)">
+                and company_name = #{companyName}
+            </if>
+            <if test="companyType != null and !&quot;&quot;.equals(companyType)">
+                and company_type = #{companyType}
+            </if>
+            <if test="adminFlag != null and !&quot;&quot;.equals(adminFlag)">
+                and admin_flag = #{adminFlag}
+            </if>
+            <if test="cashPledge != null and !&quot;&quot;.equals(cashPledge)">
+                and cash_pledge = #{cashPledge}
+            </if>
+            <if test="approveFlag != null and !&quot;&quot;.equals(approveFlag)">
+                and approve_flag = #{approveFlag}
+            </if>
+            <if test="storeFlag != null and !&quot;&quot;.equals(storeFlag)">
+                and store_flag = #{storeFlag}
+            </if>
+            <if test="companyFlag != null and !&quot;&quot;.equals(companyFlag)">
+                and company_flag = #{companyFlag}
+            </if>
+
         </where>
         </where>
         order by id desc
         order by id desc
     </select>
     </select>
@@ -426,7 +575,7 @@
         SELECT
         SELECT
         <include refid="Base_Column_List"/>
         <include refid="Base_Column_List"/>
         from sys_user
         from sys_user
-        WHERE username = #{username} AND password = #{password} AND del_flag = 'N'
+        WHERE (username = #{username} or phone = #{username} ) AND password = #{password} AND del_flag = 'N'
     </select>
     </select>
     <select id="findDepartLeader" resultType="java.lang.String">
     <select id="findDepartLeader" resultType="java.lang.String">
         SELECT *
         SELECT *
@@ -450,5 +599,31 @@
             AND id = #{id}
             AND id = #{id}
         </where>
         </where>
     </update>
     </update>
+
+    <update id="updatePassword" parameterType="com.izouma.awesomeadmin.model.UserInfo">
+        update sys_user
+        <set>
+            <if test="password != null">
+                password = #{password,jdbcType=VARCHAR},
+            </if>
+        </set>
+        <where>
+            and del_flag = 'N'
+            <if test="id != null and !&quot;&quot;.equals(id)">
+                and id = #{id}
+            </if>
+            <if test="username != null and !&quot;&quot;.equals(username)">
+                and username = #{username}
+            </if>
+            <if test="phone != null and !&quot;&quot;.equals(phone)">
+                and phone = #{phone}
+            </if>
+            <if test="mail != null and !&quot;&quot;.equals(mail)">
+                and mail = #{mail}
+            </if>
+        </where>
+
+    </update>
+
 </mapper>
 </mapper>
 
 

+ 90 - 0
src/main/java/com/izouma/awesomeadmin/model/UserInfo.java

@@ -55,6 +55,24 @@ public class UserInfo {
 
 
     private Double moneyPoint;
     private Double moneyPoint;
 
 
+    private String contacter;
+
+    private String contactPhone;
+
+    private String companyName;
+
+    private String companyType;
+
+    private String adminFlag;
+
+    private Integer cashPledge;
+
+    private String approveFlag;
+
+    private String storeFlag;
+
+    private String companyFlag;
+
     public String getDepartId() {
     public String getDepartId() {
         return departId;
         return departId;
     }
     }
@@ -222,5 +240,77 @@ public class UserInfo {
     public void setMoneyPoint(Double moneyPoint) {
     public void setMoneyPoint(Double moneyPoint) {
         this.moneyPoint = moneyPoint;
         this.moneyPoint = moneyPoint;
     }
     }
+
+    public String getContacter() {
+        return contacter;
+    }
+
+    public void setContacter(String contacter) {
+        this.contacter = contacter;
+    }
+
+    public String getContactPhone() {
+        return contactPhone;
+    }
+
+    public void setContactPhone(String contactPhone) {
+        this.contactPhone = contactPhone;
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public String getCompanyType() {
+        return companyType;
+    }
+
+    public void setCompanyType(String companyType) {
+        this.companyType = companyType;
+    }
+
+    public String getAdminFlag() {
+        return adminFlag;
+    }
+
+    public void setAdminFlag(String adminFlag) {
+        this.adminFlag = adminFlag;
+    }
+
+    public Integer getCashPledge() {
+        return cashPledge;
+    }
+
+    public void setCashPledge(Integer cashPledge) {
+        this.cashPledge = cashPledge;
+    }
+
+    public String getApproveFlag() {
+        return approveFlag;
+    }
+
+    public void setApproveFlag(String approveFlag) {
+        this.approveFlag = approveFlag;
+    }
+
+    public String getStoreFlag() {
+        return storeFlag;
+    }
+
+    public void setStoreFlag(String storeFlag) {
+        this.storeFlag = storeFlag;
+    }
+
+    public String getCompanyFlag() {
+        return companyFlag;
+    }
+
+    public void setCompanyFlag(String companyFlag) {
+        this.companyFlag = companyFlag;
+    }
 }
 }
 
 

+ 1 - 0
src/main/java/com/izouma/awesomeadmin/service/UserInfoService.java

@@ -38,5 +38,6 @@ public interface UserInfoService {
 
 
     UserInfo loginWechat(String code) throws UserInfoServiceImpl.LoginException;
     UserInfo loginWechat(String code) throws UserInfoServiceImpl.LoginException;
 
 
+    boolean updatePassword(UserInfo userInfo);
 }
 }
 
 

+ 27 - 6
src/main/java/com/izouma/awesomeadmin/service/impl/UserInfoServiceImpl.java

@@ -41,19 +41,19 @@ import java.util.*;
 @Service
 @Service
 public class UserInfoServiceImpl implements UserInfoService {
 public class UserInfoServiceImpl implements UserInfoService {
 
 
-    private static Logger    logger    = Logger.getLogger(UserInfoServiceImpl.class);
-    private        RongCloud rongCloud = RongCloud.getInstance(PropertiesFileLoader.getProperties("rongyunappkey"), PropertiesFileLoader.getProperties("rongyunappsecret"));
+    private static Logger logger = Logger.getLogger(UserInfoServiceImpl.class);
+    private RongCloud rongCloud = RongCloud.getInstance(PropertiesFileLoader.getProperties("rongyunappkey"), PropertiesFileLoader.getProperties("rongyunappsecret"));
 
 
     @Autowired
     @Autowired
-    private UserInfoMapper    userInfoMapper;
+    private UserInfoMapper userInfoMapper;
     @Autowired
     @Autowired
-    private SysRoleMapper     sysRoleMapper;
+    private SysRoleMapper sysRoleMapper;
     @Autowired
     @Autowired
-    private DepartInfoMapper  departInfoMapper;
+    private DepartInfoMapper departInfoMapper;
     @Autowired
     @Autowired
     private SysAppTokenMapper sysAppTokenMapper;
     private SysAppTokenMapper sysAppTokenMapper;
     @Autowired
     @Autowired
-    private OSSFileService    ossFileService;
+    private OSSFileService ossFileService;
 
 
     @Override
     @Override
     public List<UserInfo> getUserInfoList(UserInfo record) {
     public List<UserInfo> getUserInfoList(UserInfo record) {
@@ -184,6 +184,27 @@ public class UserInfoServiceImpl implements UserInfoService {
         return false;
         return false;
     }
     }
 
 
+    @Override
+    public boolean updatePassword(UserInfo record) {
+
+        logger.info("updatePassword");
+        try {
+            if (StringUtils.isNotEmpty(record.getPassword())) {
+                record.setPassword(MD5Util.getMD5(record.getPassword()));
+            }
+
+            int updates = userInfoMapper.updatePassword(record);
+
+            if (updates > 0) {
+                return true;
+            }
+        } catch (Exception e) {
+            logger.error("updatePassword", e);
+        }
+
+        return false;
+    }
+
     @Override
     @Override
     public UserInfo login(String username, String password) {
     public UserInfo login(String username, String password) {
         logger.info("login");
         logger.info("login");

+ 54 - 0
src/main/java/com/izouma/awesomeadmin/web/UserInfoController.java

@@ -16,6 +16,7 @@ import com.izouma.awesomeadmin.service.SysMenuService;
 import com.izouma.awesomeadmin.shiro.PhoneCodeToken;
 import com.izouma.awesomeadmin.shiro.PhoneCodeToken;
 import com.izouma.awesomeadmin.util.CookieUtil;
 import com.izouma.awesomeadmin.util.CookieUtil;
 import com.izouma.awesomeadmin.util.ExportExcelUtil;
 import com.izouma.awesomeadmin.util.ExportExcelUtil;
+import com.izouma.awesomeadmin.util.MD5Util;
 import org.activiti.engine.IdentityService;
 import org.activiti.engine.IdentityService;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.SecurityUtils;
@@ -190,5 +191,58 @@ public class UserInfoController {
         ExportExcelUtil.ExportWithResponse(sheetName, titleName, fileName,
         ExportExcelUtil.ExportWithResponse(sheetName, titleName, fileName,
                 columnNumber, columnWidth, columnName, dataList, response);
                 columnNumber, columnWidth, columnName, dataList, response);
     }
     }
+
+
+    @RequestMapping(value = "/updatePassword", method = RequestMethod.POST)
+    @ResponseBody
+    public Result updatePassword(UserInfo userInfo) {
+
+        boolean isSuccess;
+
+        isSuccess = userInfoService.updatePassword(userInfo);
+
+        if (isSuccess) {
+            return new Result(true, "更新成功");
+        } else {
+            return new Result(false, "更新失败");
+        }
+    }
+
+
+    @RequestMapping(value = "/register", method = RequestMethod.POST)
+    @ResponseBody
+    public Result register(UserInfo userInfo) {
+
+        boolean isSuccess;
+        UserInfo data = new UserInfo();
+        data.setUsername(userInfo.getUsername());
+
+        data = userInfoService.getUserInfo(data);
+        if (data != null) {
+            return new Result(true, "用户名已存在");
+        }
+
+        UserInfo data2 = new UserInfo();
+        data2.setPhone(userInfo.getPhone());
+
+        data2 = userInfoService.getUserInfo(data2);
+        if (data2 != null) {
+            return new Result(true, "手机号已存在");
+        }
+
+
+        userInfo.setNickname(userInfo.getUsername());
+        userInfo.setIcon("https://microball.oss-cn-hangzhou.aliyuncs.com/huanbaojia/icon_morentouxiang.png");
+
+        isSuccess = userInfoService.createUserInfo(userInfo);
+
+        if (isSuccess) {
+            return new Result(true, "注册成功");
+        } else {
+            return new Result(false, "注册失败");
+        }
+    }
+
+
 }
 }