Commit c73498fa by xiaolang850403

日常提交

parent 77aad3c2
...@@ -15,7 +15,11 @@ public enum CodeEnum { ...@@ -15,7 +15,11 @@ public enum CodeEnum {
LOGIN_SUCCESS(20001,"登录成功!"), LOGIN_SUCCESS(20001,"登录成功!"),
LOGIN_ERROR(20002,"用户名或密码错误!"), LOGIN_ERROR(20002,"用户名或密码错误!"),
ISEXITE_ERROR(20003,"账号已经存在!"), ISEXITE_ERROR(20003,"账号已经存在!"),
LOGINOUT_SUCCESS(20004,"成功!"); ISEXITE_NOT_ERROR(20005,"账号不存在!"),
LOGINOUT_SUCCESS(20004,"成功!"),
ISEXITE_MOBILE(20006,"手机号已经存在!"),
FORMAT_MOBILE(20007,"手机号格式不正确!")
;
......
...@@ -4,6 +4,8 @@ import javax.servlet.http.HttpServletRequest; ...@@ -4,6 +4,8 @@ import javax.servlet.http.HttpServletRequest;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/* /*
* @author xiaol * @author xiaol
...@@ -53,4 +55,65 @@ public class Common { ...@@ -53,4 +55,65 @@ public class Common {
return Arrays.toString(arr); return Arrays.toString(arr);
} }
/**
* @param phone 字符串类型的手机号
* 传入手机号,判断后返回
* true为手机号,false相反
* */
public static boolean isPhone(String phone) {
String regex = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\\d{8}$";
if (phone.length() != 11) {
return false;
} else {
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(phone);
return m.matches();
}
}
/**
* 发送短信
* 成功返回TRUE,失败返回错误码
* @param mobile 手机号码 多手机号用逗号分隔如
* @param msg 短信内容
* @return mixed
*/
public static boolean send_msg(String mobile,String msg) {
Map<String, Object> map=new HashMap<String, Object>();
map.put("account","tbnn30");
map.put("pswd","JT2k8yx8");
map.put("mobile",mobile);
map.put("msg",msg);
String data = http_build_query(map);
//$return = file_get_contents("http://send.18sms.com/msg/HttpBatchSendSM?"+data);
//$status = explode(',', $return)[1];
//return $status == 0 ? true : $status;
return true;
}
/**
* Java实现PHP中的http_build_query()效果
* @param array
* key=value形式的二位数组
* @return
*/
public static String http_build_query(Map<String,Object> array) {
String reString = null;
//遍历数组形成akey=avalue&bkey=bvalue&ckey=cvalue形式的的字符串
Iterator it = array.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Object> entry = (Map.Entry) it.next();
String key = entry.getKey();
Object value = entry.getValue();
reString += key + "=" + value + "&";
}
reString = reString.substring(0, reString.length() - 1);
//将得到的字符串进行处理得到目标格式的字符串
reString = java.net.URLEncoder.encode(reString);
reString = reString.replace("%3D", "=").replace("%26", "&");
return reString;
}
} }
package com.asset.common;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Util {
private MD5Util() {
}
public static String getEncryption(String originString)throws UnsupportedEncodingException {
String result = "";
if (originString != null) {
try {
// 指定加密的方式为MD5
MessageDigest md = MessageDigest.getInstance("MD5");
// 进行加密运算
byte bytes[] = md.digest(originString.getBytes("ISO8859-1"));
for (int i = 0; i < bytes.length; i++) {
// 将整数转换成十六进制形式的字符串 这里与0xff进行与运算的原因是保证转换结果为32位
String str = Integer.toHexString(bytes[i] & 0xFF);
if (str.length() == 1) {
str += "F";
}
result += str;
}
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
return result;
}
public static String getSession(HttpServletRequest request){
HttpSession session = request.getSession();
String username = (String) session.getAttribute("username");
return username;
}
}
...@@ -2,15 +2,22 @@ package com.asset.controller; ...@@ -2,15 +2,22 @@ package com.asset.controller;
import com.asset.common.*; import com.asset.common.*;
import com.asset.domain.User; import com.asset.domain.User;
import com.asset.domain.system.Certificate;
import com.asset.mapper.UserMapper; import com.asset.mapper.UserMapper;
import com.asset.service.UserService; import com.asset.service.UserService;
import com.asset.service.system.CertificateService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.nio.file.spi.FileSystemProvider;
/* /*
* @author xiaol * @author xiaol
...@@ -22,19 +29,187 @@ public class UserController { ...@@ -22,19 +29,187 @@ public class UserController {
@Autowired @Autowired
UserService userService; UserService userService;
@Autowired
CertificateService certificateService;
@RequestMapping("/register") @RequestMapping("/register")
public Result register(@Validated(value={Insert.class}) @RequestBody User user, BindingResult result){ public Result register(@Validated(value={Insert.class}) @RequestBody User user, BindingResult result) throws UnsupportedEncodingException {
if(userService.insertUser(user)){ if (result.hasErrors()) {
return ResultUtil.Validated(result);
}
user.setCreate_at(Common.getTime());
String pass = MD5Util.getEncryption(user.getPassword());
user.setPassword(pass);
userService.insertUser(user);
System.out.println(user);
System.out.println("*****************");
System.out.println(user.getId());
if(user.getId() != null){
//组合写入凭证表的数据
if(user.getExpert() != null){ //专家凭证
if(user.getExpert().contains(",")){
try {
certificateService.insertAllCycle(user.getExpert(),user.getId(),1);
}catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR);
}
}else{
try {
certificateService.insertCycle(user.getExpert(),user.getId(),1);
}catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR);
}
}
}
if(user.getRecom() != null){ //推荐凭证
if(user.getRecom().contains(",")){
try {
certificateService.insertAllCycle(user.getRecom(),user.getId(),2);
}catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR);
}
}else{
try {
certificateService.insertCycle(user.getExpert(),user.getId(),2);
}catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR);
}
}
}
if(user.getOther() != null){ //其他凭证
if(user.getOther().contains(",")){
try {
certificateService.insertAllCycle(user.getOther(),user.getId(),0);
}catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR);
}
}else{
try {
certificateService.insertCycle(user.getExpert(),user.getId(),0);
}catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR);
}
}
}
return ResultUtil.success(CodeEnum.SUCCESS); return ResultUtil.success(CodeEnum.SUCCESS);
}else{ }else{
return ResultUtil.success(CodeEnum.ERROR); return ResultUtil.success(CodeEnum.ERROR);
} }
} }
@GetMapping("/checkMobile")
public Result checkMobile(String mobile) {
if(! Common.isPhone(mobile)){
return ResultUtil.success(CodeEnum.FORMAT_MOBILE);
}
User admin1 = userService.getUserByMobile(mobile);
if(admin1 != null){
return ResultUtil.success(CodeEnum.ISEXITE_MOBILE);
}
return ResultUtil.success(CodeEnum.SUCCESS);
}
@GetMapping("/sendMobileCode")
public Result sendMobileCode(String mobile) {
if(! Common.isPhone(mobile)){
return ResultUtil.success(CodeEnum.FORMAT_MOBILE);
}
return ResultUtil.success(CodeEnum.SUCCESS);
}
@RequestMapping("/login") @RequestMapping("/login")
public Result login(@Validated(value={Login.class}) @RequestBody User user, BindingResult result){ public Result login(@Validated(value={Login.class}) @RequestBody User user, BindingResult result, HttpSession session) throws UnsupportedEncodingException {
if (result.hasErrors()) {
return ResultUtil.Validated(result);
}
String mobile= user.getMobile();
String password= user.getPassword();
User admin1 = userService.getUserByMobile(mobile);
if(admin1 == null){ //判断账号是否存在
return ResultUtil.error(CodeEnum.ISEXITE_NOT_ERROR);
}else {
String pass = MD5Util.getEncryption(password);
String passwordold = admin1.getPassword();
if (!passwordold.equals(pass)){
return ResultUtil.error(CodeEnum.LOGIN_ERROR);
}
}
session.setAttribute("mobile",mobile);
return ResultUtil.success(CodeEnum.SUCCESS);
}
@GetMapping("/getUserById")
public Result getUserById(int id) {
User user = userService.getUserById(id);
if(user != null){
return ResultUtil.success(CodeEnum.SUCCESS,user);
}
return ResultUtil.success(CodeEnum.ERROR);
}
@RequestMapping("/getUpdateUser")
public Result getUpdateUser(@Validated(value={Update.class}) @RequestBody User user, BindingResult result) {
if (result.hasErrors()) {
return ResultUtil.Validated(result);
}
userService.updateUser(user);
System.out.println(user);
System.out.println("*****************");
System.out.println(user.getId());
if(user.getId() != null){
//删除凭证的旧数据
certificateService.deleteCertificateByUserId(user.getId());
//组合写入凭证表的数据
if(user.getExpert() != null){ //专家凭证
if(user.getExpert().contains(",")){
try {
certificateService.insertAllCycle(user.getExpert(),user.getId(),1);
}catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR);
}
}else{
try {
certificateService.insertCycle(user.getExpert(),user.getId(),1);
}catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR);
}
}
}
if(user.getRecom() != null){ //推荐凭证
if(user.getRecom().contains(",")){
try {
certificateService.insertAllCycle(user.getRecom(),user.getId(),2);
}catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR);
}
}else{
try {
certificateService.insertCycle(user.getExpert(),user.getId(),2);
}catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR);
}
}
}
if(user.getOther() != null){ //其他凭证
if(user.getOther().contains(",")){
try {
certificateService.insertAllCycle(user.getOther(),user.getId(),0);
}catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR);
}
}else{
try {
certificateService.insertCycle(user.getExpert(),user.getId(),0);
}catch (Exception e){
return ResultUtil.success(CodeEnum.ERROR);
}
}
}
return ResultUtil.success(CodeEnum.SUCCESS); return ResultUtil.success(CodeEnum.SUCCESS);
}else{
return ResultUtil.success(CodeEnum.ERROR);
}
} }
} }
package com.asset.controller.system; package com.asset.controller.system;
import com.asset.common.CodeEnum;
import com.asset.common.Common;
import com.asset.common.Result;
import com.asset.common.ResultUtil;
import com.asset.domain.User;
import com.asset.domain.system.Area;
import com.asset.service.system.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping(value = "/area")
public class AreaController { public class AreaController {
@Autowired
AreaService areaService;
@GetMapping("/getAreaList")
public Result getAreaList(int pid) {
List<Area> list = areaService.getAreaByPid(pid);
return ResultUtil.success(CodeEnum.SUCCESS,list);
}
} }
package com.asset.controller.system; package com.asset.controller.system;
import com.asset.common.CodeEnum;
import com.asset.common.Result;
import com.asset.common.ResultUtil;
import com.asset.domain.system.Discipline;
import com.asset.service.system.DisciplineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/* /*
* @author xiaol * @author xiaol
* @date 2020/02/29 * @date 2020/03/03
*/ */
@RestController @RestController
@RequestMapping(value = "/discipline")
public class DisciplineController { public class DisciplineController {
@Autowired
DisciplineService disciplineService;
@GetMapping("/getDisciplineList")
public Result getDisciplineList() {
List<Discipline> list = disciplineService.disciplineList();
return ResultUtil.success(CodeEnum.SUCCESS,list);
}
} }
package com.asset.controller.system;
import com.asset.common.CodeEnum;
import com.asset.common.Result;
import com.asset.common.ResultUtil;
import com.asset.domain.system.Job;
import com.asset.domain.system.School;
import com.asset.service.system.JobService;
import com.asset.service.system.SchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping(value = "/job")
public class JobController {
@Autowired
JobService jobService;
@GetMapping("/getJobList")
public Result getJobList() {
List<Job> list = jobService.jobList();
return ResultUtil.success(CodeEnum.SUCCESS,list);
}
}
package com.asset.controller.system;
import com.asset.common.CodeEnum;
import com.asset.common.Result;
import com.asset.common.ResultUtil;
import com.asset.domain.system.School;
import com.asset.service.system.SchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping(value = "/school")
public class SchoolController {
@Autowired
SchoolService schoolService;
@GetMapping("/getSchoolList")
public Result getSchoolList() {
List<School> list = schoolService.schoolList();
return ResultUtil.success(CodeEnum.SUCCESS,list);
}
}
...@@ -4,6 +4,7 @@ import com.asset.common.Insert; ...@@ -4,6 +4,7 @@ import com.asset.common.Insert;
import com.asset.common.Login; import com.asset.common.Login;
import com.asset.common.Special; import com.asset.common.Special;
import com.asset.common.Update; import com.asset.common.Update;
import com.asset.domain.system.Certificate;
import lombok.Data; import lombok.Data;
import javax.persistence.Id; import javax.persistence.Id;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
...@@ -18,11 +19,12 @@ import java.util.List; ...@@ -18,11 +19,12 @@ import java.util.List;
@Data @Data
public class User { public class User {
@Id @Id
@NotEmpty(message = "{id.NotEmpty}", groups = {Update.class})
private Integer id; private Integer id;
/** /**
* 账号 * 姓名
*/ */
@NotEmpty(message = "{name.NotEmpty}", groups = {Insert.class,Login.class}) @NotEmpty(message = "{name.NotEmpty}", groups = {Insert.class})
private String name; private String name;
/** /**
* 密码 * 密码
...@@ -32,11 +34,10 @@ public class User { ...@@ -32,11 +34,10 @@ public class User {
@Size(min=6,max=20,message="{password.size}",groups = {Insert.class,Special.class,Login.class}) @Size(min=6,max=20,message="{password.size}",groups = {Insert.class,Special.class,Login.class})
private String password; private String password;
private String title;
private String sex; private String sex;
private Long mobile; @NotEmpty(message = "{mobile.NotEmpty}", groups = {Login.class})
private String mobile;
private String email; private String email;
...@@ -70,4 +71,12 @@ public class User { ...@@ -70,4 +71,12 @@ public class User {
private String expert_type; private String expert_type;
private String expert_type_value; private String expert_type_value;
private String expert; //专家凭证
private String recom; //推荐凭证
private String other; //其他凭证
private List<Certificate> certificate;
} }
...@@ -9,11 +9,11 @@ public interface UserMapper { ...@@ -9,11 +9,11 @@ public interface UserMapper {
public User getUserById(Integer id); public User getUserById(Integer id);
public User getUserByName(String name); public User getUserByMobile(String mobile);
List<User> getUserList(Map param); List<User> getUserList(Map param);
public boolean insertUser(User user); public int insertUser(User user);
public boolean deleteUserById(Integer id); public boolean deleteUserById(Integer id);
......
package com.asset.mapper.system;
import com.asset.domain.system.Area;
import com.github.pagehelper.Page;
import java.util.List;
public interface AreaMapper {
public List<Area> getAreaByPid(Integer pid);
Page<Area> areaList();
}
...@@ -4,6 +4,7 @@ import com.asset.domain.system.Certificate; ...@@ -4,6 +4,7 @@ import com.asset.domain.system.Certificate;
import com.asset.domain.system.Discipline; import com.asset.domain.system.Discipline;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import java.util.List;
import java.util.Map; import java.util.Map;
public interface CertificateMapper { public interface CertificateMapper {
...@@ -18,5 +19,9 @@ public interface CertificateMapper { ...@@ -18,5 +19,9 @@ public interface CertificateMapper {
public boolean deleteCertificateById(Integer id); public boolean deleteCertificateById(Integer id);
public boolean deleteCertificateByUserId(Integer user_id);
public boolean updateCertificate(Certificate certificate); public boolean updateCertificate(Certificate certificate);
public boolean insertAllCertificate(List<Certificate> certificates);
} }
package com.asset.mapper.system; package com.asset.mapper.system;
import com.asset.domain.system.Discipline; import com.asset.domain.system.Discipline;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import java.util.Map;
public interface DisciplineMapper { public interface DisciplineMapper {
public Discipline getDisciplineById(Integer id); public Discipline getDisciplineByid(Integer id);
Page<Discipline> disciplineList(Map param); Page<Discipline> disciplineList();
} }
package com.asset.mapper.system;
import com.asset.domain.system.Job;
import com.github.pagehelper.Page;
public interface JobMapper {
public Job getJobByid(Integer id);
Page<Job> jobList();
}
package com.asset.mapper.system;
import com.asset.domain.system.School;
import com.github.pagehelper.Page;
public interface SchoolMapper {
public School getSchoolByid(Integer id);
Page<School> schoolList();
}
...@@ -24,8 +24,8 @@ public class UserService implements UserMapper { ...@@ -24,8 +24,8 @@ public class UserService implements UserMapper {
} }
@Override @Override
public User getUserByName(String name) { public User getUserByMobile(String mobile) {
return userMapper.getUserByName(name); return userMapper.getUserByMobile(mobile);
} }
@Override @Override
...@@ -35,11 +35,8 @@ public class UserService implements UserMapper { ...@@ -35,11 +35,8 @@ public class UserService implements UserMapper {
} }
@Override @Override
public boolean insertUser(User user) { public int insertUser(User user) {
user.setCreate_at(Common.getTime()); return userMapper.insertUser(user);
userMapper.insertUser(user);
return true;
} }
@Override @Override
......
package com.asset.service.system;
import com.asset.domain.system.Area;
import com.asset.mapper.system.AreaMapper;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/*
* @author xiaol
* @date 2020/03/03
*/
@Service("AreaService")
public class AreaService implements AreaMapper {
@Autowired
AreaMapper areaMapper;
@Override
public List<Area> getAreaByPid(Integer pid) {
return areaMapper.getAreaByPid(pid);
}
@Override
public Page<Area> areaList() {
return areaMapper.areaList();
}
}
package com.asset.service.system; package com.asset.service.system;
import com.asset.common.Common;
import com.asset.domain.system.Certificate; import com.asset.domain.system.Certificate;
import com.asset.mapper.system.CertificateMapper; import com.asset.mapper.system.CertificateMapper;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/* /*
* @author xiaol * @author xiaol
* @date 2020/03/02 * @date 2020/03/02
...@@ -42,7 +46,41 @@ public class CertificateService implements CertificateMapper { ...@@ -42,7 +46,41 @@ public class CertificateService implements CertificateMapper {
} }
@Override @Override
public boolean deleteCertificateByUserId(Integer user_id) {
return certificateMapper.deleteCertificateByUserId(user_id);
}
@Override
public boolean updateCertificate(Certificate certificate) { public boolean updateCertificate(Certificate certificate) {
return certificateMapper.updateCertificate(certificate); return certificateMapper.updateCertificate(certificate);
} }
@Override
public boolean insertAllCertificate(List<Certificate> certificates) {
return certificateMapper.insertAllCertificate(certificates);
}
//循环批量写入数据库
public boolean insertAllCycle(String expert, Integer user_id,Integer type){
String[] arr = expert.split(",");
List<Certificate> list = new ArrayList<Certificate>();
for (int i=0;i<arr.length;i++){
Certificate certificate = new Certificate();
certificate.setUser_id(user_id);
certificate.setImage(arr[i]);
certificate.setType(type);
certificate.setCreate_at(Common.getTime());
list.add(certificate);
}
return insertAllCertificate(list);
}
public boolean insertCycle(String expert, Integer user_id,Integer type){
Certificate certificate = new Certificate();
certificate.setUser_id(user_id);
certificate.setImage(expert);
certificate.setType(type);
certificate.setCreate_at(Common.getTime());
return insertCertificate(certificate);
}
} }
package com.asset.service.system;
import com.asset.domain.system.Discipline;
import com.asset.domain.system.School;
import com.asset.mapper.system.DisciplineMapper;
import com.asset.mapper.system.SchoolMapper;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/*
* @author xiaol
* @date 2020/03/03
*/
@Service("DisciplineService")
public class DisciplineService implements DisciplineMapper {
@Autowired
DisciplineMapper disciplineMapper;
@Override
public Discipline getDisciplineByid(Integer id) {
return disciplineMapper.getDisciplineByid(id);
}
@Override
public Page<Discipline> disciplineList() {
return disciplineMapper.disciplineList();
}
}
package com.asset.service.system;
import com.asset.domain.system.Job;
import com.asset.domain.system.School;
import com.asset.mapper.system.JobMapper;
import com.asset.mapper.system.SchoolMapper;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/*
* @author xiaol
* @date 2020/03/03
*/
@Service("JobService")
public class JobService implements JobMapper {
@Autowired
JobMapper jobMapper;
@Override
public Job getJobByid(Integer id) {
return jobMapper.getJobByid(id);
}
@Override
public Page<Job> jobList() {
return jobMapper.jobList();
}
}
package com.asset.service.system;
import com.asset.domain.system.Area;
import com.asset.domain.system.School;
import com.asset.mapper.system.AreaMapper;
import com.asset.mapper.system.SchoolMapper;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/*
* @author xiaol
* @date 2020/03/03
*/
@Service("SchoolService")
public class SchoolService implements SchoolMapper {
@Autowired
SchoolMapper schoolMapper;
@Override
public School getSchoolByid(Integer id) {
return schoolMapper.getSchoolByid(id);
}
@Override
public Page<School> schoolList() {
return schoolMapper.schoolList();
}
}
...@@ -3,6 +3,8 @@ username.NotEmpty=账号不能为空 ...@@ -3,6 +3,8 @@ username.NotEmpty=账号不能为空
password.NotEmpty=密码不能为空 password.NotEmpty=密码不能为空
password.Pattern=密码必须是数字或字母 password.Pattern=密码必须是数字或字母
password.size=密码由6到20位数组或字母组成 password.size=密码由6到20位数组或字母组成
mobile.NotEmpty=手机号不能为空
id.NotEmpty=账号ID不能为空
#角色 #角色
role.NotEmpty=角色名不能为空 role.NotEmpty=角色名不能为空
#菜单 #菜单
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.asset.mapper.system.AreaMapper">
<resultMap id="BaseResultMap" type="com.asset.domain.system.Area">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="pid" jdbcType="VARCHAR" property="pid"/>
</resultMap>
<select id="getAreaByPid" parameterType="Map" resultMap="BaseResultMap">
select * from ex_area where pid = #{pid}
</select>
<select id="areaList" parameterType="Map" resultMap="BaseResultMap">
select * from ex_area
</select>
</mapper>
\ No newline at end of file
...@@ -27,11 +27,22 @@ ...@@ -27,11 +27,22 @@
</insert> </insert>
<delete id="deleteCertificateById" > <delete id="deleteCertificateById" >
delete from ex_user where id=#{id} delete from ex_certificate where id=#{id}
</delete>
<delete id="deleteCertificateByUserId" >
delete from ex_certificate where user_id = #{user_id}
</delete> </delete>
<update id="updateCertificate" parameterType="com.asset.domain.system.Certificate"> <update id="updateCertificate" parameterType="com.asset.domain.system.Certificate">
update ex_user set name=#{name},sex=#{sex},mobile=#{mobile},email=#{email},title=#{title} where id=#{id} update ex_certificate set name=#{name},sex=#{sex},mobile=#{mobile},email=#{email},title=#{title} where id=#{id}
</update> </update>
<insert id="insertAllCertificate" parameterType="com.asset.domain.system.Certificate">
insert into ex_certificate(user_id,type,image,create_at) value
<foreach collection='list' item='item' separator=','>
(#{item.user_id},#{item.type},#{item.image},#{item.create_at})
</foreach>
</insert>
</mapper> </mapper>
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<id column="id" jdbcType="INTEGER" property="id"/> <id column="id" jdbcType="INTEGER" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/> <result column="name" jdbcType="VARCHAR" property="name"/>
</resultMap> </resultMap>
<select id="getDisciplineById" resultType="com.asset.domain.system.Discipline"> <select id="getDisciplineByid" resultMap="BaseResultMap">
select * from ex_discipline where id = #{id} select * from ex_discipline where id = #{id}
</select> </select>
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.asset.mapper.system.JobMapper">
<resultMap id="BaseResultMap" type="com.asset.domain.system.Job">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
</resultMap>
<select id="getJobByid" resultMap="BaseResultMap">
select * from ex_job where id = #{id}
</select>
<select id="jobList" parameterType="Map" resultMap="BaseResultMap">
select * from ex_job
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.asset.mapper.system.SchoolMapper">
<resultMap id="BaseResultMap" type="com.asset.domain.system.School">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
</resultMap>
<select id="getSchoolByid" resultMap="BaseResultMap">
select * from ex_school where id = #{id}
</select>
<select id="schoolList" parameterType="Map" resultMap="BaseResultMap">
select * from ex_school
</select>
</mapper>
\ No newline at end of file
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
<id column="id" jdbcType="INTEGER" property="id"/> <id column="id" jdbcType="INTEGER" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/> <result column="name" jdbcType="VARCHAR" property="name"/>
<result column="password" jdbcType="VARCHAR" property="password"/> <result column="password" jdbcType="VARCHAR" property="password"/>
<result column="title" jdbcType="VARCHAR" property="title"/>
<result column="idcard" jdbcType="VARCHAR" property="idcard"/> <result column="idcard" jdbcType="VARCHAR" property="idcard"/>
<result column="card_front" jdbcType="VARCHAR" property="card_front"/> <result column="card_front" jdbcType="VARCHAR" property="card_front"/>
<result column="email" jdbcType="VARCHAR" property="email"/> <result column="email" jdbcType="VARCHAR" property="email"/>
...@@ -20,22 +19,24 @@ ...@@ -20,22 +19,24 @@
<result column="employer" jdbcType="VARCHAR" property="employer"/> <result column="employer" jdbcType="VARCHAR" property="employer"/>
<result column="state" jdbcType="VARCHAR" property="state"/> <result column="state" jdbcType="VARCHAR" property="state"/>
<result column="create_at" jdbcType="VARCHAR" property="create_at"/> <result column="create_at" jdbcType="VARCHAR" property="create_at"/>
<!--关联凭证关联表-->
<association property="certificate" column="id" select="com.asset.mapper.system.CertificateMapper.getCertificateByUserId" />
</resultMap> </resultMap>
<select id="getUserById" resultMap="BaseResultMap"> <select id="getUserById" resultMap="BaseResultMap">
select * from ex_user where id=#{id} select * from ex_user where id=#{id}
</select> </select>
<select id="getUserByName" resultMap="BaseResultMap"> <select id="getUserByMobile" resultMap="BaseResultMap">
select * from ex_user where name = #{name} select * from ex_user where mobile = #{mobile}
</select> </select>
<select id="getUserList" resultMap="BaseResultMap"> <select id="getUserList" resultMap="BaseResultMap">
select * from ex_user select * from ex_user
</select> </select>
<insert id="insertUser" parameterType="com.asset.domain.User"> <insert id="insertUser" useGeneratedKeys="true" keyProperty="id">
insert into ex_user(name,password,title,province,card_front,email,sex,card_obverse,mobile,school_id,discipline_id,job_id,employer,create_at,city,county,address,is_expert) insert into ex_user(name,password,province,card_front,email,sex,card_obverse,mobile,school_id,discipline_id,job_id,employer,create_at,city,county,address,is_expert,expert_type,expert_type_value)
value (#{name},#{password},#{title},#{province},#{card_front},#{email},#{sex},#{card_obverse},#{mobile},#{school_id},#{discipline_id},#{job_id},#{employer},#{create_at},#{city},#{county},#{address},#{is_expert}) value (#{name},#{password},#{province},#{card_front},#{email},#{sex},#{card_obverse},#{mobile},#{school_id},#{discipline_id},#{job_id},#{employer},#{create_at},#{city},#{county},#{address},#{is_expert},#{expert_type},#{expert_type_value})
</insert> </insert>
<delete id="deleteUserById" > <delete id="deleteUserById" >
...@@ -43,7 +44,9 @@ ...@@ -43,7 +44,9 @@
</delete> </delete>
<update id="updateUser" parameterType="com.asset.domain.User"> <update id="updateUser" parameterType="com.asset.domain.User">
update ex_user set name=#{name},sex=#{sex},mobile=#{mobile},email=#{email},title=#{title} where id=#{id} update ex_user set name=#{name},sex=#{sex},mobile=#{mobile},email=#{email},province=#{province},card_front=#{card_front},card_obverse=#{card_obverse},school_id=#{school_id},
discipline_id=#{discipline_id},job_id=#{job_id},employer=#{employer},city=#{city},county=#{county},address=#{address},is_expert=#{is_expert},expert_type=#{expert_type},expert_type_value=#{expert_type_value},
where id=#{id}
</update> </update>
<update id="updatePassword" parameterType="com.asset.domain.User"> <update id="updatePassword" parameterType="com.asset.domain.User">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment